@@ -65,21 +65,22 @@ type Net struct {
65
65
// testCase defines the CNI network configuration and the expected
66
66
// bridge addresses for a test case.
67
67
type testCase struct {
68
- cniVersion string // CNI Version
69
- subnet string // Single subnet config: Subnet CIDR
70
- gateway string // Single subnet config: Gateway
71
- ranges []rangeInfo // Ranges list (multiple subnets config)
72
- resolvConf string // host-local resolvConf file path
73
- isGW bool
74
- isLayer2 bool
75
- expGWCIDRs []string // Expected gateway addresses in CIDR form
76
- vlan int
77
- ipMasq bool
78
- macspoofchk bool
79
- AddErr020 string
80
- DelErr020 string
81
- AddErr010 string
82
- DelErr010 string
68
+ cniVersion string // CNI Version
69
+ subnet string // Single subnet config: Subnet CIDR
70
+ gateway string // Single subnet config: Gateway
71
+ ranges []rangeInfo // Ranges list (multiple subnets config)
72
+ resolvConf string // host-local resolvConf file path
73
+ isGW bool
74
+ isLayer2 bool
75
+ expGWCIDRs []string // Expected gateway addresses in CIDR form
76
+ vlan int
77
+ removeDefaultVlan bool
78
+ ipMasq bool
79
+ macspoofchk bool
80
+ AddErr020 string
81
+ DelErr020 string
82
+ AddErr010 string
83
+ DelErr010 string
83
84
84
85
envArgs string // CNI_ARGS
85
86
runtimeConfig struct {
@@ -129,6 +130,9 @@ const (
129
130
vlan = `,
130
131
"vlan": %d`
131
132
133
+ preserveDefaultVlan = `,
134
+ "preserveDefaultVlan": false`
135
+
132
136
netDefault = `,
133
137
"isDefaultGateway": true`
134
138
@@ -191,6 +195,10 @@ func (tc testCase) netConfJSON(dataDir string) string {
191
195
conf := fmt .Sprintf (netConfStr , tc .cniVersion , BRNAME )
192
196
if tc .vlan != 0 {
193
197
conf += fmt .Sprintf (vlan , tc .vlan )
198
+
199
+ if tc .removeDefaultVlan {
200
+ conf += preserveDefaultVlan
201
+ }
194
202
}
195
203
if tc .ipMasq {
196
204
conf += tc .ipMasqConfig ()
@@ -527,6 +535,9 @@ func (tester *testerV10x) cmdAddTest(tc testCase, dataDir string) (types.Result,
527
535
vlans , isExist := interfaceMap [int32 (peerLink .Attrs ().Index )]
528
536
Expect (isExist ).To (BeTrue ())
529
537
Expect (checkVlan (tc .vlan , vlans )).To (BeTrue ())
538
+ if tc .removeDefaultVlan {
539
+ Expect (vlans ).To (HaveLen (1 ))
540
+ }
530
541
}
531
542
532
543
// Check the bridge vlan filtering equals true
@@ -582,6 +593,9 @@ func (tester *testerV10x) cmdAddTest(tc testCase, dataDir string) (types.Result,
582
593
vlans , isExist := interfaceMap [int32 (link .Attrs ().Index )]
583
594
Expect (isExist ).To (BeTrue ())
584
595
Expect (checkVlan (tc .vlan , vlans )).To (BeTrue ())
596
+ if tc .removeDefaultVlan {
597
+ Expect (vlans ).To (HaveLen (1 ))
598
+ }
585
599
}
586
600
587
601
// Check that the bridge has a different mac from the veth
@@ -832,6 +846,9 @@ func (tester *testerV04x) cmdAddTest(tc testCase, dataDir string) (types.Result,
832
846
vlans , isExist := interfaceMap [int32 (peerLink .Attrs ().Index )]
833
847
Expect (isExist ).To (BeTrue ())
834
848
Expect (checkVlan (tc .vlan , vlans )).To (BeTrue ())
849
+ if tc .removeDefaultVlan {
850
+ Expect (vlans ).To (HaveLen (1 ))
851
+ }
835
852
}
836
853
837
854
// Check the bridge vlan filtering equals true
@@ -887,6 +904,9 @@ func (tester *testerV04x) cmdAddTest(tc testCase, dataDir string) (types.Result,
887
904
vlans , isExist := interfaceMap [int32 (link .Attrs ().Index )]
888
905
Expect (isExist ).To (BeTrue ())
889
906
Expect (checkVlan (tc .vlan , vlans )).To (BeTrue ())
907
+ if tc .removeDefaultVlan {
908
+ Expect (vlans ).To (HaveLen (1 ))
909
+ }
890
910
}
891
911
892
912
// Check that the bridge has a different mac from the veth
@@ -1132,6 +1152,9 @@ func (tester *testerV03x) cmdAddTest(tc testCase, dataDir string) (types.Result,
1132
1152
vlans , isExist := interfaceMap [int32 (peerLink .Attrs ().Index )]
1133
1153
Expect (isExist ).To (BeTrue ())
1134
1154
Expect (checkVlan (tc .vlan , vlans )).To (BeTrue ())
1155
+ if tc .removeDefaultVlan {
1156
+ Expect (vlans ).To (HaveLen (1 ))
1157
+ }
1135
1158
}
1136
1159
1137
1160
// Check the bridge vlan filtering equals true
@@ -1187,6 +1210,9 @@ func (tester *testerV03x) cmdAddTest(tc testCase, dataDir string) (types.Result,
1187
1210
vlans , isExist := interfaceMap [int32 (link .Attrs ().Index )]
1188
1211
Expect (isExist ).To (BeTrue ())
1189
1212
Expect (checkVlan (tc .vlan , vlans )).To (BeTrue ())
1213
+ if tc .removeDefaultVlan {
1214
+ Expect (vlans ).To (HaveLen (1 ))
1215
+ }
1190
1216
}
1191
1217
1192
1218
// Check that the bridge has a different mac from the veth
@@ -1358,6 +1384,9 @@ func (tester *testerV01xOr02x) cmdAddTest(tc testCase, dataDir string) (types.Re
1358
1384
vlans , isExist := interfaceMap [int32 (peerLink .Attrs ().Index )]
1359
1385
Expect (isExist ).To (BeTrue ())
1360
1386
Expect (checkVlan (tc .vlan , vlans )).To (BeTrue ())
1387
+ if tc .removeDefaultVlan {
1388
+ Expect (vlans ).To (HaveLen (1 ))
1389
+ }
1361
1390
}
1362
1391
1363
1392
// Check the bridge vlan filtering equals true
@@ -1480,6 +1509,9 @@ func (tester *testerV01xOr02x) cmdAddTest(tc testCase, dataDir string) (types.Re
1480
1509
vlans , isExist := hostNSVlanMap [int32 (peerIndex )]
1481
1510
Expect (isExist ).To (BeTrue ())
1482
1511
Expect (checkVlan (tc .vlan , vlans )).To (BeTrue ())
1512
+ if tc .removeDefaultVlan {
1513
+ Expect (vlans ).To (HaveLen (1 ))
1514
+ }
1483
1515
}
1484
1516
1485
1517
return nil
@@ -1772,6 +1804,18 @@ var _ = Describe("bridge Operations", func() {
1772
1804
cmdAddDelTest (originalNS , targetNS , tc , dataDir )
1773
1805
})
1774
1806
1807
+ It (fmt .Sprintf ("[%s] configures and deconfigures a l2 bridge with vlan id 100 and no default vlan using ADD/DEL" , ver ), func () {
1808
+ tc := testCase {
1809
+ cniVersion : ver ,
1810
+ isLayer2 : true ,
1811
+ vlan : 100 ,
1812
+ removeDefaultVlan : true ,
1813
+ AddErr020 : "cannot convert: no valid IP addresses" ,
1814
+ AddErr010 : "cannot convert: no valid IP addresses" ,
1815
+ }
1816
+ cmdAddDelTest (originalNS , targetNS , tc , dataDir )
1817
+ })
1818
+
1775
1819
for i , tc := range []testCase {
1776
1820
{
1777
1821
// IPv4 only
@@ -1822,6 +1866,11 @@ var _ = Describe("bridge Operations", func() {
1822
1866
tc .cniVersion = ver
1823
1867
cmdAddDelTest (originalNS , targetNS , tc , dataDir )
1824
1868
})
1869
+ It (fmt .Sprintf ("[%s] (%d) configures and deconfigures a bridge, veth with default route and vlanID 100 and no default vlan with ADD/DEL" , ver , i ), func () {
1870
+ tc .cniVersion = ver
1871
+ tc .removeDefaultVlan = true
1872
+ cmdAddDelTest (originalNS , targetNS , tc , dataDir )
1873
+ })
1825
1874
}
1826
1875
1827
1876
for i , tc := range []testCase {
0 commit comments