@@ -37,10 +37,6 @@ func init() {
3737 }
3838}
3939
40- // networkAttachCount is the minimum number of networks the PodSandbox
41- // attaches to
42- const networkAttachCount = 2
43-
4440// initPlatform handles linux specific initialization for the CRI service.
4541func (c * criService ) initPlatform () (err error ) {
4642 if userns .RunningInUserNS () {
@@ -69,6 +65,12 @@ func (c *criService) initPlatform() (err error) {
6965 }
7066 }
7167
68+ networkAttachCount := 2
69+
70+ if c .Config ().UseInternalLoopback {
71+ networkAttachCount = 1
72+ }
73+
7274 c .netPlugin = make (map [string ]cni.CNI )
7375 for name , dir := range pluginDirs {
7476 max := c .config .NetworkPluginMaxConfNum
@@ -78,9 +80,10 @@ func (c *criService) initPlatform() (err error) {
7880 }
7981 }
8082 // Pod needs to attach to at least loopback network and a non host network,
81- // hence networkAttachCount is 2. If there are more network configs the
82- // pod will be attached to all the networks but we will only use the ip
83- // of the default network interface as the pod IP.
83+ // hence networkAttachCount is 2 if the CNI plugin is used and
84+ // 1 if the internal mechanism for setting lo to up is used.
85+ // If there are more network configs the pod will be attached to all the networks
86+ // but we will only use the ip of the default network interface as the pod IP.
8487 i , err := cni .New (cni .WithMinNetworkCount (networkAttachCount ),
8588 cni .WithPluginConfDir (dir ),
8689 cni .WithPluginMaxConfNum (max ),
@@ -110,5 +113,9 @@ func (c *criService) initPlatform() (err error) {
110113
111114// cniLoadOptions returns cni load options for the linux.
112115func (c * criService ) cniLoadOptions () []cni.Opt {
116+ if c .config .UseInternalLoopback {
117+ return []cni.Opt {cni .WithDefaultConf }
118+ }
119+
113120 return []cni.Opt {cni .WithLoNetwork , cni .WithDefaultConf }
114121}
0 commit comments