Skip to content

Commit bf91878

Browse files
committed
fix comments
1 parent 9893f9d commit bf91878

File tree

2 files changed

+21
-41
lines changed

2 files changed

+21
-41
lines changed

cni/network/invoker_cns.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -439,13 +439,10 @@ func configureDefaultAddResult(info *IPResultInfo, addConfig *IPAMAddConfig, add
439439
if len(routes) > 0 {
440440
resRoute = append(resRoute, routes...)
441441
} else { // add default routes if none are provided
442-
// on Swiftv2 windows scenario, skip to add default route on infra vnet;
443-
if !info.skipDefaultRoutes {
444-
resRoute = append(resRoute, network.RouteInfo{
445-
Dst: defaultRouteDstPrefix,
446-
Gw: ncgw,
447-
})
448-
}
442+
resRoute = append(resRoute, network.RouteInfo{
443+
Dst: defaultRouteDstPrefix,
444+
Gw: ncgw,
445+
})
449446
}
450447

451448
// if we have multiple infra ip result infos, we effectively append routes and ip configs to that same interface info each time

cni/network/invoker_cns_test.go

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ func TestCNSIPAMInvoker_Add_Overlay(t *testing.T) {
5252
macAddress := "12:34:56:78:9a:bc"
5353
parsedMacAddress, _ := net.ParseMAC(macAddress)
5454

55-
// parse default route (IP: 0.0.0.0 and mask /0)
56-
_, ipNet, _ := net.ParseCIDR("0.0.0.0/0")
57-
5855
type fields struct {
5956
podName string
6057
podNamespace string
@@ -289,15 +286,8 @@ func TestCNSIPAMInvoker_Add_Overlay(t *testing.T) {
289286
IPAddress: "20.240.1.242",
290287
PrefixLength: 24,
291288
},
292-
NICType: cns.NodeNetworkInterfaceFrontendNIC,
293-
MacAddress: macAddress,
294-
SkipDefaultRoutes: false,
295-
Routes: []cns.Route{
296-
{
297-
IPAddress: "0.0.0.0/0",
298-
GatewayIPAddress: "10.0.0.1",
299-
},
300-
},
289+
NICType: cns.NodeNetworkInterfaceFrontendNIC,
290+
MacAddress: macAddress,
301291
},
302292
},
303293
Response: cns.Response{
@@ -326,7 +316,12 @@ func TestCNSIPAMInvoker_Add_Overlay(t *testing.T) {
326316
Gateway: net.ParseIP("10.0.0.1"),
327317
},
328318
},
329-
Routes: []network.RouteInfo(nil),
319+
Routes: []network.RouteInfo{
320+
{
321+
Dst: network.Ipv4DefaultRouteDstPrefix,
322+
Gw: net.ParseIP("10.0.0.1"),
323+
},
324+
},
330325
NICType: cns.InfraNIC,
331326
SkipDefaultRoutes: true,
332327
HostSubnetPrefix: *parseCIDR("10.0.0.0/24"),
@@ -337,12 +332,7 @@ func TestCNSIPAMInvoker_Add_Overlay(t *testing.T) {
337332
Address: *getCIDRNotationForAddress("20.240.1.242/24"),
338333
},
339334
},
340-
Routes: []network.RouteInfo{
341-
{
342-
Dst: *ipNet,
343-
Gw: net.ParseIP("10.0.0.1"),
344-
},
345-
},
335+
Routes: []network.RouteInfo{},
346336
NICType: cns.NodeNetworkInterfaceFrontendNIC,
347337
MacAddress: parsedMacAddress,
348338
// secondaries don't have a host subnet prefix
@@ -1469,9 +1459,6 @@ func TestCNSIPAMInvoker_Add_SwiftV2(t *testing.T) {
14691459

14701460
pnpID := "PCI\\VEN_15B3&DEV_101C&SUBSYS_000715B3&REV_00\\5&8c5acce&0&0"
14711461

1472-
// parse default route (IP: 0.0.0.0 and mask /0)
1473-
_, ipNet, _ := net.ParseCIDR("0.0.0.0/0")
1474-
14751462
type fields struct {
14761463
podName string
14771464
podNamespace string
@@ -1677,12 +1664,6 @@ func TestCNSIPAMInvoker_Add_SwiftV2(t *testing.T) {
16771664
NICType: cns.NodeNetworkInterfaceFrontendNIC,
16781665
MacAddress: macAddress,
16791666
SkipDefaultRoutes: false,
1680-
Routes: []cns.Route{
1681-
{
1682-
IPAddress: "0.0.0.0/0",
1683-
GatewayIPAddress: "10.0.0.1",
1684-
},
1685-
},
16861667
},
16871668
{
16881669
MacAddress: ibMacAddress,
@@ -1716,7 +1697,12 @@ func TestCNSIPAMInvoker_Add_SwiftV2(t *testing.T) {
17161697
Gateway: net.ParseIP("10.0.0.1"),
17171698
},
17181699
},
1719-
Routes: []network.RouteInfo(nil),
1700+
Routes: []network.RouteInfo{
1701+
{
1702+
Dst: network.Ipv4DefaultRouteDstPrefix,
1703+
Gw: net.ParseIP("10.0.0.1"),
1704+
},
1705+
},
17201706
NICType: cns.InfraNIC,
17211707
SkipDefaultRoutes: true,
17221708
HostSubnetPrefix: *parseCIDR("10.0.0.0/24"),
@@ -1728,18 +1714,14 @@ func TestCNSIPAMInvoker_Add_SwiftV2(t *testing.T) {
17281714
Address: *getCIDRNotationForAddress("20.1.1.10/24"),
17291715
},
17301716
},
1731-
Routes: []network.RouteInfo{{
1732-
Dst: *ipNet,
1733-
Gw: net.ParseIP("10.0.0.1"),
1734-
}},
1717+
Routes: []network.RouteInfo{},
17351718
NICType: cns.NodeNetworkInterfaceFrontendNIC,
17361719
MacAddress: parsedMacAddress,
17371720
},
17381721
ibMacAddress: {
17391722
NICType: cns.BackendNIC,
17401723
MacAddress: ibParsedMacAddress,
17411724
PnPID: pnpID,
1742-
Routes: []network.RouteInfo(nil),
17431725
},
17441726
},
17451727
wantErr: false,
@@ -1762,6 +1744,7 @@ func TestCNSIPAMInvoker_Add_SwiftV2(t *testing.T) {
17621744

17631745
for _, ifInfo := range ipamAddResult.interfaceInfo {
17641746
if ifInfo.NICType == cns.InfraNIC {
1747+
fmt.Printf("want:%+v\nrest:%+v\n", tt.wantDefaultResult, ifInfo)
17651748
require.Equalf(tt.wantDefaultResult, ifInfo, "incorrect ipv4 response")
17661749
}
17671750

0 commit comments

Comments
 (0)