@@ -82,6 +82,11 @@ func (plugin *netPlugin) Stop() {
8282 log .Printf ("[cni-net] Plugin stopped." )
8383}
8484
85+ // GetEndpointID returns a unique endpoint ID based on the CNI args.
86+ func (plugin * netPlugin ) getEndpointID (args * cniSkel.CmdArgs ) string {
87+ return args .ContainerID + "-" + args .IfName
88+ }
89+
8590//
8691// CNI implementation
8792// https://github.com/containernetworking/cni/blob/master/SPEC.md
@@ -104,7 +109,7 @@ func (plugin *netPlugin) Add(args *cniSkel.CmdArgs) error {
104109 var result cniTypes.Result
105110 var resultImpl * cniTypesImpl.Result
106111 networkId := nwCfg .Name
107- endpointId := args . ContainerID
112+ endpointId := plugin . getEndpointID ( args )
108113
109114 // Check whether the network already exists.
110115 nwInfo , err := plugin .nm .GetNetworkInfo (networkId )
@@ -164,9 +169,10 @@ func (plugin *netPlugin) Add(args *cniSkel.CmdArgs) error {
164169
165170 // Initialize endpoint info.
166171 epInfo := & network.EndpointInfo {
167- Id : endpointId ,
168- IfName : args .IfName ,
169- NetNsPath : args .Netns ,
172+ Id : endpointId ,
173+ ContainerID : args .ContainerID ,
174+ NetNsPath : args .Netns ,
175+ IfName : args .IfName ,
170176 }
171177
172178 // Populate addresses and routes.
@@ -178,6 +184,10 @@ func (plugin *netPlugin) Add(args *cniSkel.CmdArgs) error {
178184 }
179185 }
180186
187+ // Populate DNS info.
188+ epInfo .DNSSuffix = resultImpl .DNS .Domain
189+ epInfo .DNSServers = resultImpl .DNS .Nameservers
190+
181191 // Create the endpoint.
182192 log .Printf ("[cni-net] Creating endpoint %+v" , epInfo )
183193 err = plugin .nm .CreateEndpoint (networkId , epInfo )
@@ -214,7 +224,7 @@ func (plugin *netPlugin) Delete(args *cniSkel.CmdArgs) error {
214224
215225 // Initialize values from network config.
216226 networkId := nwCfg .Name
217- endpointId := args . ContainerID
227+ endpointId := plugin . getEndpointID ( args )
218228
219229 // Query the network.
220230 nwInfo , err := plugin .nm .GetNetworkInfo (networkId )
0 commit comments