@@ -1143,8 +1143,13 @@ def test_zone_with_vrf(self):
11431143 self .cli_set (['vrf' , 'name' , 'VRF-1' , 'table' , '101' ])
11441144 self .cli_set (['vrf' , 'name' , 'VRF-2' , 'table' , '102' ])
11451145 self .cli_set (['interfaces' , 'ethernet' , 'eth0' , 'vrf' , 'VRF-1' ])
1146- self .cli_set (['interfaces' , 'vti' , 'vti1' , 'vrf' , 'VRF-2' ])
1146+ self .cli_set (['interfaces' , 'ethernet' , 'eth0' , 'vif' , '10' , 'vrf' , 'VRF-1' ])
1147+ self .cli_set (['interfaces' , 'ethernet' , 'eth3' , 'vif-s' , '10' , 'vrf' , 'VRF-1' ])
1148+ self .cli_set (['interfaces' , 'ethernet' , 'eth3' , 'vif-s' , '20' , 'vif-c' , '30' , 'vrf' , 'VRF-1' ])
1149+ self .cli_set (['interfaces' , 'vti' , 'vti1' , 'vrf' , 'VRF-1' ])
1150+ self .cli_set (['interfaces' , 'vti' , 'vti2' , 'vrf' , 'VRF-2' ])
11471151
1152+ # commit the config
11481153 self .cli_commit ()
11491154
11501155 nftables_search = [
@@ -1155,8 +1160,10 @@ def test_zone_with_vrf(self):
11551160 ['chain VYOS_ZONE_FORWARD' ],
11561161 ['type filter hook forward priority filter + 1' ],
11571162 ['oifname { "eth1", "eth2" }' , 'counter packets' , 'jump VZONE_ZONE1' ],
1163+ ['oifname { "eth0", "eth0.10", "eth3.10", "eth3.20.30", "vti1" }' , 'counter packets' , 'jump VZONE_ZONE1' ],
11581164 ['oifname "VRF-1"' , 'counter packets' , 'jump VZONE_ZONE1' ],
11591165 ['oifname "vtun66"' , 'counter packets' , 'jump VZONE_ZONE2' ],
1166+ ['oifname "vti2"' , 'counter packets' , 'jump VZONE_ZONE2' ],
11601167 ['oifname "VRF-2"' , 'counter packets' , 'jump VZONE_ZONE2' ],
11611168 ['chain VYOS_ZONE_LOCAL' ],
11621169 ['type filter hook input priority filter + 1' ],
@@ -1190,8 +1197,10 @@ def test_zone_with_vrf(self):
11901197 ['chain VYOS_ZONE_FORWARD' ],
11911198 ['type filter hook forward priority filter + 1' ],
11921199 ['oifname { "eth1", "eth2" }' , 'counter packets' , 'jump VZONE_ZONE1' ],
1200+ ['oifname { "eth0", "eth0.10", "eth3.10", "eth3.20.30", "vti1" }' , 'counter packets' , 'jump VZONE_ZONE1' ],
11931201 ['oifname "VRF-1"' , 'counter packets' , 'jump VZONE_ZONE1' ],
11941202 ['oifname "vtun66"' , 'counter packets' , 'jump VZONE_ZONE2' ],
1203+ ['oifname "vti2"' , 'counter packets' , 'jump VZONE_ZONE2' ],
11951204 ['oifname "VRF-2"' , 'counter packets' , 'jump VZONE_ZONE2' ],
11961205 ['chain VYOS_ZONE_LOCAL' ],
11971206 ['type filter hook input priority filter + 1' ],
@@ -1203,6 +1212,7 @@ def test_zone_with_vrf(self):
12031212 ['counter packets' , 'drop' , 'comment "zone_LOCAL default-action drop"' ],
12041213 ['chain VZONE_LOCAL_OUT' ],
12051214 ['oifname "vtun66"' , 'counter packets' , 'jump NAME6_LOCAL_to_ZONE2_v6' ],
1215+ ['oifname "vti2"' , 'counter packets' , 'jump NAME6_LOCAL_to_ZONE2_v6' ],
12061216 ['oifname "VRF-2"' , 'counter packets' , 'jump NAME6_LOCAL_to_ZONE2_v6' ],
12071217 ['counter packets' , 'drop' , 'comment "zone_LOCAL default-action drop"' ],
12081218 ['chain VZONE_ZONE1' ],
@@ -1218,6 +1228,29 @@ def test_zone_with_vrf(self):
12181228 self .verify_nftables (nftables_search , 'ip vyos_filter' )
12191229 self .verify_nftables (nftables_search_v6 , 'ip6 vyos_filter' )
12201230
1231+ # change memberships in vrf plus delete and add subifs
1232+ self .cli_set (['interfaces' , 'vti' , 'vti1' , 'vrf' , 'VRF-2' ])
1233+ self .cli_delete (['interfaces' , 'ethernet' , 'eth0' , 'vif' , '10' ])
1234+ self .cli_delete (['interfaces' , 'ethernet' , 'eth3' , 'vif-s' , '10' ])
1235+ self .cli_delete (['interfaces' , 'ethernet' , 'eth3' , 'vif-s' , '20' , 'vif-c' , '30' ])
1236+ self .cli_set (['interfaces' , 'ethernet' , 'eth0' , 'vif' , '20' , 'vrf' , 'VRF-1' ])
1237+ self .cli_set (['interfaces' , 'ethernet' , 'eth3' , 'vif-s' , '20' , 'vrf' , 'VRF-1' ])
1238+ self .cli_set (['interfaces' , 'ethernet' , 'eth3' , 'vif-s' , '20' , 'vif-c' , '40' , 'vrf' , 'VRF-1' ])
1239+ self .cli_commit ()
1240+
1241+ # make som verifications to ensure the interface swapped vrf
1242+ nftables_search = [
1243+ ['oifname { "eth0", "eth0.20", "eth3.20", "eth3.20.40" }' , 'counter packets' , 'jump VZONE_ZONE1' ],
1244+ ['oifname { "vti1", "vti2" }' , 'counter packets' , 'jump VZONE_ZONE2' ],
1245+ ]
1246+
1247+ nftables_search_v6 = [
1248+ ['oifname { "eth0", "eth0.20", "eth3.20", "eth3.20.40" }' , 'counter packets' , 'jump VZONE_ZONE1' ],
1249+ ['oifname { "vti1", "vti2" }' , 'counter packets' , 'jump VZONE_ZONE2' ],
1250+ ]
1251+ self .verify_nftables (nftables_search , 'ip vyos_filter' )
1252+ self .verify_nftables (nftables_search_v6 , 'ip6 vyos_filter' )
1253+
12211254 def test_zone_without_member (self ):
12221255 self .cli_set (['firewall' , 'zone' , 'wan' , 'default-action' , 'drop' ])
12231256 error_message = 'Zone "wan" has no interfaces and is not the local zone'
0 commit comments