@@ -15,8 +15,6 @@ import (
1515 "github.com/Azure/azure-container-networking/network"
1616 "github.com/Azure/azure-container-networking/network/networkutils"
1717 cniSkel "github.com/containernetworking/cni/pkg/skel"
18- cniTypes "github.com/containernetworking/cni/pkg/types"
19- cniTypesCurr "github.com/containernetworking/cni/pkg/types/100"
2018 "github.com/pkg/errors"
2119 "go.uber.org/zap"
2220 "go.uber.org/zap/zapcore"
@@ -178,8 +176,8 @@ func (invoker *CNSIPAMInvoker) Add(addConfig IPAMAddConfig) (IPAMAddResult, erro
178176 }
179177 default :
180178 // only count dualstack interface once
181- if addResult .defaultInterfaceInfo .ipResult == nil {
182- addResult .defaultInterfaceInfo .ipResult = & cniTypesCurr. Result {}
179+ if addResult .defaultInterfaceInfo .IPConfigs == nil {
180+ addResult .defaultInterfaceInfo .IPConfigs = make ([] * network. IPConfig , 0 )
183181 if ! info .skipDefaultRoutes {
184182 numInterfacesWithDefaultRoutes ++
185183 }
@@ -331,8 +329,8 @@ func (invoker *CNSIPAMInvoker) Delete(address *net.IPNet, nwCfg *cni.NetworkConf
331329 return nil
332330}
333331
334- func getRoutes (cnsRoutes []cns.Route , skipDefaultRoutes bool ) ([]* cniTypes. Route , error ) {
335- routes := make ([]* cniTypes. Route , 0 )
332+ func getRoutes (cnsRoutes []cns.Route , skipDefaultRoutes bool ) ([]network. RouteInfo , error ) {
333+ routes := make ([]network. RouteInfo , 0 )
336334 for _ , route := range cnsRoutes {
337335 _ , dst , routeErr := net .ParseCIDR (route .IPAddress )
338336 if routeErr != nil {
@@ -345,9 +343,9 @@ func getRoutes(cnsRoutes []cns.Route, skipDefaultRoutes bool) ([]*cniTypes.Route
345343 }
346344
347345 routes = append (routes ,
348- & cniTypes. Route {
346+ network. RouteInfo {
349347 Dst : * dst ,
350- GW : gw ,
348+ Gw : gw ,
351349 })
352350 }
353351
@@ -386,15 +384,15 @@ func configureDefaultAddResult(info *IPResultInfo, addConfig *IPAMAddConfig, add
386384 }
387385
388386 if ip := net .ParseIP (info .podIPAddress ); ip != nil {
389- defaultInterfaceInfo := addResult .defaultInterfaceInfo . ipResult
387+ defaultInterfaceInfo := & addResult .defaultInterfaceInfo
390388 defaultRouteDstPrefix := network .Ipv4DefaultRouteDstPrefix
391389 if ip .To4 () == nil {
392390 defaultRouteDstPrefix = network .Ipv6DefaultRouteDstPrefix
393391 addResult .ipv6Enabled = true
394392 }
395393
396- defaultInterfaceInfo .IPs = append (defaultInterfaceInfo .IPs ,
397- & cniTypesCurr .IPConfig {
394+ defaultInterfaceInfo .IPConfigs = append (defaultInterfaceInfo .IPConfigs ,
395+ & network .IPConfig {
398396 Address : net.IPNet {
399397 IP : ip ,
400398 Mask : ncIPNet .Mask ,
@@ -410,14 +408,13 @@ func configureDefaultAddResult(info *IPResultInfo, addConfig *IPAMAddConfig, add
410408 if len (routes ) > 0 {
411409 defaultInterfaceInfo .Routes = append (defaultInterfaceInfo .Routes , routes ... )
412410 } else { // add default routes if none are provided
413- defaultInterfaceInfo .Routes = append (defaultInterfaceInfo .Routes , & cniTypes. Route {
411+ defaultInterfaceInfo .Routes = append (defaultInterfaceInfo .Routes , network. RouteInfo {
414412 Dst : defaultRouteDstPrefix ,
415- GW : ncgw ,
413+ Gw : ncgw ,
416414 })
417415 }
418416
419- addResult .defaultInterfaceInfo .ipResult = defaultInterfaceInfo
420- addResult .defaultInterfaceInfo .skipDefaultRoutes = info .skipDefaultRoutes
417+ addResult .defaultInterfaceInfo .SkipDefaultRoutes = info .skipDefaultRoutes
421418 }
422419
423420 // get the name of the primary IP address
@@ -427,7 +424,7 @@ func configureDefaultAddResult(info *IPResultInfo, addConfig *IPAMAddConfig, add
427424 }
428425
429426 addResult .hostSubnetPrefix = * hostIPNet
430- addResult .defaultInterfaceInfo .nicType = cns .InfraNIC
427+ addResult .defaultInterfaceInfo .NICType = cns .InfraNIC
431428
432429 // set subnet prefix for host vm
433430 // setHostOptions will execute if IPAM mode is not v4 overlay and not dualStackOverlay mode
@@ -452,28 +449,26 @@ func configureSecondaryAddResult(info *IPResultInfo, addResult *IPAMAddResult, p
452449 return errors .Wrap (err , "Invalid mac address" )
453450 }
454451
455- result := InterfaceInfo {
456- ipResult : & cniTypesCurr.Result {
457- IPs : []* cniTypesCurr.IPConfig {
458- {
459- Address : net.IPNet {
460- IP : ip ,
461- Mask : ipnet .Mask ,
462- },
463- },
464- },
465- },
466- nicType : info .nicType ,
467- macAddress : macAddress ,
468- skipDefaultRoutes : info .skipDefaultRoutes ,
469- }
470-
471452 routes , err := getRoutes (info .routes , info .skipDefaultRoutes )
472453 if err != nil {
473454 return err
474455 }
475456
476- result .ipResult .Routes = append (result .ipResult .Routes , routes ... )
457+ result := network.InterfaceInfo {
458+ IPConfigs : []* network.IPConfig {
459+ {
460+ Address : net.IPNet {
461+ IP : ip ,
462+ Mask : ipnet .Mask ,
463+ },
464+ },
465+ },
466+ Routes : routes ,
467+ NICType : info .nicType ,
468+ MacAddress : macAddress ,
469+ SkipDefaultRoutes : info .skipDefaultRoutes ,
470+ }
471+
477472 addResult .secondaryInterfacesInfo = append (addResult .secondaryInterfacesInfo , result )
478473
479474 return nil
0 commit comments