File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -200,6 +200,20 @@ func (plugin *netPlugin) Add(args *cniSkel.CmdArgs) error {
200200 return plugin .Errorf (errMsg )
201201 }
202202
203+ k8sContainerID := args .ContainerID
204+ if len (k8sContainerID ) == 0 {
205+ errMsg := "Container ID not specified in CNI Args"
206+ log .Printf (errMsg )
207+ return plugin .Errorf (errMsg )
208+ }
209+
210+ k8sIfName := args .IfName
211+ if len (k8sIfName ) == 0 {
212+ errMsg := "Interfacename not specified in CNI Args"
213+ log .Printf (errMsg )
214+ return plugin .Errorf (errMsg )
215+ }
216+
203217 // Parse network configuration from stdin.
204218 nwCfg , err = cni .ParseNetworkConfig (args .StdinData )
205219 if err != nil {
@@ -359,7 +373,9 @@ func (plugin *netPlugin) Add(args *cniSkel.CmdArgs) error {
359373 }
360374 epInfo .Data = make (map [string ]interface {})
361375
362- vethName := fmt .Sprintf ("%s.%s" , k8sNamespace , k8sPodName )
376+ // A runtime must not call ADD twice (without a corresponding DEL) for the same
377+ // (network name, container id, name of the interface inside the container)
378+ vethName := fmt .Sprintf ("%s%s%s" , networkId , k8sContainerID , k8sIfName )
363379 setEndpointOptions (cnsNetworkConfig , epInfo , vethName )
364380
365381 var dns network.DNSInfo
You can’t perform that action at this time.
0 commit comments