Skip to content

Commit a1a85d7

Browse files
committed
Prefix On NIC v6 Support
1 parent 98e4976 commit a1a85d7

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

azure-ipam/ipam.go

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -143,17 +143,24 @@ func (p *IPAMPlugin) CmdAdd(args *cniSkel.CmdArgs) error {
143143
cniResult.IPs[i] = ipConfig
144144
}
145145

146-
cniResult.Interfaces = make([]*types100.Interface, 1)
147-
interfaceMap := make(map[string]bool)
148-
cniResult.Interfaces = make([]*types100.Interface, 0, len(resp.PodIPInfo))
146+
cniResult.Interfaces = []*types100.Interface{}
147+
seenInterfaces := map[string]bool{}
148+
149149
for _, podIPInfo := range resp.PodIPInfo {
150-
if _, exists := interfaceMap[podIPInfo.InterfaceName]; !exists {
151-
cniResult.Interfaces = append(cniResult.Interfaces, &types100.Interface{
152-
Name: podIPInfo.InterfaceName, // Populate interface name based on MacAddress
153-
Mac: podIPInfo.MacAddress,
154-
})
155-
interfaceMap[podIPInfo.InterfaceName] = true
150+
if seenInterfaces[podIPInfo.MacAddress] {
151+
continue
152+
}
153+
154+
infMac, err := net.ParseMAC(podIPInfo.MacAddress)
155+
if err != nil {
156+
p.logger.Error("Failed to parse interface MAC address", zap.Error(err), zap.String("macAddress", podIPInfo.MacAddress))
157+
return cniTypes.NewError(cniTypes.ErrUnsupportedField, err.Error(), "failed to parse interface MAC address")
156158
}
159+
160+
cniResult.Interfaces = append(cniResult.Interfaces, &types100.Interface{
161+
Mac: infMac.String(),
162+
})
163+
seenInterfaces[podIPInfo.MacAddress] = true
157164
}
158165

159166
// Get versioned result

cns/restserver/util.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,6 @@ func (service *HTTPRestService) saveNetworkContainerGoalState(req cns.CreateNetw
171171
hostVersion = "-1"
172172
}
173173

174-
hostVersion = req.Version
175-
176174
// Remove the auth token before saving the containerStatus to cns json file
177175
createNetworkContainerRequest := req
178176
createNetworkContainerRequest.AuthorizationToken = ""

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require (
1212
github.com/avast/retry-go/v3 v3.1.1
1313
github.com/avast/retry-go/v4 v4.6.1
1414
github.com/billgraziano/dpapi v0.5.0
15-
github.com/containernetworking/cni v1.2.3
15+
github.com/containernetworking/cni v1.2.2
1616
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
1717
github.com/go-logr/zapr v1.3.0 // indirect
1818
github.com/golang/mock v1.6.0
@@ -25,7 +25,7 @@ require (
2525
github.com/microsoft/ApplicationInsights-Go v0.4.4
2626
github.com/nxadm/tail v1.4.11
2727
github.com/onsi/ginkgo v1.16.5
28-
github.com/onsi/gomega v1.36.0
28+
github.com/onsi/gomega v1.33.1
2929
github.com/patrickmn/go-cache v2.1.0+incompatible
3030
github.com/pkg/errors v0.9.1
3131
github.com/prometheus/client_golang v1.21.1

0 commit comments

Comments
 (0)