@@ -30,7 +30,7 @@ func TestConfigure(t *testing.T) {
30
30
31
31
ns1 := netns .NewNetNS (t )
32
32
ns1 .Do (func () error {
33
- ip , ri := getFakes (t , true )
33
+ ip , ri := getFakes (t , true , false )
34
34
masterMAC := ri .MasterIfMAC
35
35
ifaceCleanup := createDummyDevice (t , masterMAC )
36
36
defer ifaceCleanup ()
@@ -41,7 +41,22 @@ func TestConfigure(t *testing.T) {
41
41
42
42
ns2 := netns .NewNetNS (t )
43
43
ns2 .Do (func () error {
44
- ip , ri := getFakes (t , false )
44
+ ip , ri := getFakes (t , false , false )
45
+ masterMAC := ri .MasterIfMAC
46
+ ifaceCleanup := createDummyDevice (t , masterMAC )
47
+ defer ifaceCleanup ()
48
+
49
+ runConfigureThenDelete (t , ri , ip , 1500 )
50
+ return nil
51
+ })
52
+ }
53
+
54
+ func TestConfigureZeros (t * testing.T ) {
55
+ setupLinuxRoutingSuite (t )
56
+
57
+ ns1 := netns .NewNetNS (t )
58
+ ns1 .Do (func () error {
59
+ ip , ri := getFakes (t , true , true )
45
60
masterMAC := ri .MasterIfMAC
46
61
ifaceCleanup := createDummyDevice (t , masterMAC )
47
62
defer ifaceCleanup ()
@@ -54,7 +69,7 @@ func TestConfigure(t *testing.T) {
54
69
func TestConfigureRouteWithIncompatibleIP (t * testing.T ) {
55
70
setupLinuxRoutingSuite (t )
56
71
57
- _ , ri := getFakes (t , true )
72
+ _ , ri := getFakes (t , true , false )
58
73
ipv6 := netip .MustParseAddr ("fd00::2" ).AsSlice ()
59
74
err := ri .Configure (ipv6 , 1500 , false , false )
60
75
require .Error (t , err )
@@ -73,7 +88,7 @@ func TestDeleteRouteWithIncompatibleIP(t *testing.T) {
73
88
func TestDelete (t * testing.T ) {
74
89
setupLinuxRoutingSuite (t )
75
90
76
- fakeIP , fakeRoutingInfo := getFakes (t , true )
91
+ fakeIP , fakeRoutingInfo := getFakes (t , true , false )
77
92
masterMAC := fakeRoutingInfo .MasterIfMAC
78
93
79
94
tests := []struct {
@@ -235,7 +250,8 @@ func createDummyDevice(t *testing.T, macAddr mac.MAC) func() {
235
250
236
251
// getFakes returns a fake IP simulating an Endpoint IP and RoutingInfo as test harnesses.
237
252
// To create routing info with a list of CIDRs which the interface has access to, set withCIDR parameter to true
238
- func getFakes (t * testing.T , withCIDR bool ) (netip.Addr , RoutingInfo ) {
253
+ // If withZeroCIDR is also set to true, the function will use the "0.0.0.0/0" CIDR block instead of other CIDR blocks.
254
+ func getFakes (t * testing.T , withCIDR bool , withZeroCIDR bool ) (netip.Addr , RoutingInfo ) {
239
255
fakeGateway := netip .MustParseAddr ("192.168.2.1" )
240
256
fakeSubnet1CIDR := netip .MustParsePrefix ("192.168.0.0/16" )
241
257
fakeSubnet2CIDR := netip .MustParsePrefix ("192.170.0.0/16" )
@@ -245,9 +261,13 @@ func getFakes(t *testing.T, withCIDR bool) (netip.Addr, RoutingInfo) {
245
261
246
262
var fakeRoutingInfo * RoutingInfo
247
263
if withCIDR {
264
+ cidrs := []string {fakeSubnet1CIDR .String (), fakeSubnet2CIDR .String ()}
265
+ if withZeroCIDR {
266
+ cidrs = []string {"0.0.0.0/0" }
267
+ }
248
268
fakeRoutingInfo , err = parse (
249
269
fakeGateway .String (),
250
- [] string { fakeSubnet1CIDR . String (), fakeSubnet2CIDR . String ()} ,
270
+ cidrs ,
251
271
fakeMAC .String (),
252
272
"1" ,
253
273
ipamOption .IPAMENI ,
0 commit comments