Skip to content

Commit

Permalink
Fix vlan mode precedence to match documentation (#581)
Browse files Browse the repository at this point in the history
* Fix vlan mode attribute precedence to match documentation
* Add 'mode' to no-propagate, otherwise global 'mode' copied into nodes overrides global per-VLAN settings
* Updated test results

Co-authored-by: Jeroen van Bemmel <jeroen.van_bemmel@nokia.com>
  • Loading branch information
jbemmel and jbemmel committed Oct 15, 2022
1 parent e3ce92d commit 76df3c3
Show file tree
Hide file tree
Showing 21 changed files with 4 additions and 77 deletions.
3 changes: 1 addition & 2 deletions netsim/modules/vlan.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,10 @@ def interface_vlan_mode(intf: Box, node: Box, topology: Box) -> str:
vlan = get_from_box(intf,'vlan.access') or get_from_box(intf,'vlan.native')
if not vlan:
return 'irb'

return get_from_box(intf,'vlan.mode') or \
get_from_box(node,f'vlans.{vlan}.mode') or \
get_from_box(topology,f'vlans.{vlan}.mode') or \
get_from_box(node,'vlan.mode') or \
get_from_box(topology,f'vlans.{vlan}.mode') or \
get_from_box(topology,'vlan.mode') or 'irb'

#
Expand Down
6 changes: 3 additions & 3 deletions netsim/topology-defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ bgp:
transform_after: [ vlan ]
next_hop_self: true
attributes:
global: [
global: [
af, as, next_hop_self, rr_cluster_id, rr_list, ebgp_role, as_list, sessions, activate,
advertise_loopback, advertise_roles, community, replace_global_as ]
node: [
Expand Down Expand Up @@ -149,7 +149,7 @@ vrf: # Basic VRF support

vlan: # VLAN support
supported_on: [ eos, iosv, vyos, dellos10, srlinux, none, routeros, nxos, frr, cumulus, sros, routeros7 ]
no_propagate: [ start_vlan_id, start_vni, auto_vni ]
no_propagate: [ start_vlan_id, start_vni, auto_vni, mode ]
vlan_no_propagate: [ id, vni, mode, pool, prefix, evpn ]
start_vlan_id: 1000
start_vni: 100000
Expand Down Expand Up @@ -948,7 +948,7 @@ devices:
external:
image: none
graphite.icon: router

routeros7:
interface_name: ether%d
mgmt_if: ether1
Expand Down
5 changes: 0 additions & 5 deletions tests/topology/expected/bgp-vrf-local-as.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ nodes:
name: r1
vlan:
max_bridge_group: 2
mode: irb
vlans:
blue:
bridge_group: 1
Expand Down Expand Up @@ -425,7 +424,6 @@ nodes:
name: r2
vlan:
max_bridge_group: 3
mode: irb
vlans:
blue:
bridge_group: 2
Expand Down Expand Up @@ -592,7 +590,6 @@ nodes:
name: r3
vlan:
max_bridge_group: 2
mode: irb
vlans:
blue:
bridge_group: 1
Expand Down Expand Up @@ -648,8 +645,6 @@ nodes:
rd: '65000:1'
vrfidx: 100
provider: libvirt
vlan:
mode: irb
vlans:
blue:
id: 1001
Expand Down
5 changes: 0 additions & 5 deletions tests/topology/expected/group-data-vlan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ nodes:
router_id: 10.0.0.1
vlan:
max_bridge_group: 2
mode: irb
vlans:
blue:
bridge_group: 1
Expand Down Expand Up @@ -281,7 +280,6 @@ nodes:
router_id: 10.0.0.2
vlan:
max_bridge_group: 2
mode: irb
vlans:
blue:
bridge_group: 1
Expand Down Expand Up @@ -385,7 +383,6 @@ nodes:
router_id: 10.0.0.3
vlan:
max_bridge_group: 2
mode: irb
vlans:
blue:
bridge_group: 1
Expand Down Expand Up @@ -424,8 +421,6 @@ nodes:
ospf:
area: 0.0.0.0
provider: libvirt
vlan:
mode: irb
vlans:
blue:
host_count: 0
Expand Down
3 changes: 0 additions & 3 deletions tests/topology/expected/rt-vlan-native-routed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ nodes:
name: s1
vlan:
max_bridge_group: 2
mode: irb
vlans:
blue:
bridge_group: 2
Expand All @@ -205,8 +204,6 @@ nodes:
ospf:
area: 0.0.0.0
provider: libvirt
vlan:
mode: irb
vlans:
blue:
host_count: 0
Expand Down
3 changes: 0 additions & 3 deletions tests/topology/expected/rt-vlan-no-gateway.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ nodes:
name: s1
vlan:
max_bridge_group: 1
mode: irb
vlans:
red:
bridge_group: 1
Expand All @@ -164,8 +163,6 @@ nodes:
ipv4: 172.16.0.0/24
vni: 101000
provider: libvirt
vlan:
mode: irb
vlans:
blue:
id: 1001
Expand Down
3 changes: 0 additions & 3 deletions tests/topology/expected/rt-vlan-role-unnumbered.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ nodes:
name: leaf
vlan:
max_bridge_group: 1
mode: irb
vlans:
vxlan:
bridge_group: 1
Expand All @@ -131,8 +130,6 @@ nodes:
ipv6: true
vni: 101000
provider: clab
vlan:
mode: irb
vlans:
vxlan:
host_count: 0
Expand Down
3 changes: 0 additions & 3 deletions tests/topology/expected/vlan-access-neighbors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ nodes:
name: s1
vlan:
max_bridge_group: 1
mode: irb
vlans:
red:
bridge_group: 1
Expand All @@ -225,5 +224,3 @@ nodes:
ipv4: 172.16.0.0/24
vni: 101000
provider: clab
vlan:
mode: irb
2 changes: 0 additions & 2 deletions tests/topology/expected/vlan-access-node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ nodes:
name: s1
vlan:
max_bridge_group: 1
mode: irb
vlans:
red:
bridge_group: 1
Expand Down Expand Up @@ -225,7 +224,6 @@ nodes:
name: s2
vlan:
max_bridge_group: 1
mode: irb
vlans:
blue:
bridge_group: 1
Expand Down
4 changes: 0 additions & 4 deletions tests/topology/expected/vlan-access-single.yml
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ nodes:
router_id: 10.0.0.2
vlan:
max_bridge_group: 1
mode: irb
vlans:
red:
bridge_group: 1
Expand Down Expand Up @@ -290,7 +289,6 @@ nodes:
router_id: 10.0.0.3
vlan:
max_bridge_group: 1
mode: irb
vlans:
red:
bridge_group: 1
Expand All @@ -303,8 +301,6 @@ nodes:
ospf:
area: 0.0.0.0
provider: clab
vlan:
mode: irb
vlans:
red:
host_count: 2
Expand Down
4 changes: 0 additions & 4 deletions tests/topology/expected/vlan-bridge-trunk-router.yml
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,6 @@ nodes:
name: s1
vlan:
max_bridge_group: 2
mode: irb
vlans:
blue:
bridge_group: 2
Expand Down Expand Up @@ -401,7 +400,6 @@ nodes:
name: s2
vlan:
max_bridge_group: 2
mode: irb
vlans:
blue:
bridge_group: 2
Expand Down Expand Up @@ -440,8 +438,6 @@ nodes:
ipv4: 172.16.0.0/24
vni: 101000
provider: libvirt
vlan:
mode: irb
vlans:
blue:
host_count: 1
Expand Down
2 changes: 0 additions & 2 deletions tests/topology/expected/vlan-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ nodes:
name: s1
vlan:
max_bridge_group: 1
mode: bridge
vlans:
red:
bridge_group: 1
Expand Down Expand Up @@ -326,7 +325,6 @@ nodes:
name: s2
vlan:
max_bridge_group: 2
mode: bridge
vlans:
blue:
bridge_group: 2
Expand Down
4 changes: 0 additions & 4 deletions tests/topology/expected/vlan-native-routed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ nodes:
name: r1
vlan:
max_bridge_group: 3
mode: irb
vlans:
blue:
bridge_group: 2
Expand Down Expand Up @@ -261,7 +260,6 @@ nodes:
name: r2
vlan:
max_bridge_group: 3
mode: irb
vlans:
blue:
bridge_group: 2
Expand Down Expand Up @@ -298,8 +296,6 @@ nodes:
ipv4: 172.16.0.0/24
vni: 101000
provider: libvirt
vlan:
mode: irb
vlans:
blue:
host_count: 0
Expand Down
5 changes: 0 additions & 5 deletions tests/topology/expected/vlan-routed-access.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ nodes:
router_id: 10.0.0.1
vlan:
max_bridge_group: 1
mode: irb
vlans:
red:
bridge_group: 1
Expand Down Expand Up @@ -151,7 +150,6 @@ nodes:
router_id: 10.0.0.3
vlan:
max_bridge_group: 1
mode: irb
vlans:
red:
bridge_group: 1
Expand Down Expand Up @@ -222,7 +220,6 @@ nodes:
router_id: 10.0.0.2
vlan:
max_bridge_group: 1
mode: irb
vlans:
red:
bridge_group: 1
Expand All @@ -236,8 +233,6 @@ nodes:
ospf:
area: 0.0.0.0
provider: libvirt
vlan:
mode: irb
vlans:
red:
host_count: 0
Expand Down
6 changes: 0 additions & 6 deletions tests/topology/expected/vlan-routed-vrf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,6 @@ nodes:
name: r1
vlan:
max_bridge_group: 3
mode: irb
vlans:
blue:
bridge_group: 1
Expand Down Expand Up @@ -598,7 +597,6 @@ nodes:
name: r2
vlan:
max_bridge_group: 3
mode: irb
vlans:
blue:
bridge_group: 1
Expand Down Expand Up @@ -803,7 +801,6 @@ nodes:
name: s1
vlan:
max_bridge_group: 3
mode: irb
vlans:
blue:
bridge_group: 2
Expand Down Expand Up @@ -1048,7 +1045,6 @@ nodes:
name: s2
vlan:
max_bridge_group: 3
mode: irb
vlans:
blue:
bridge_group: 1
Expand Down Expand Up @@ -1154,8 +1150,6 @@ nodes:
rd: '65000:1'
vrfidx: 100
provider: clab
vlan:
mode: irb
vlans:
blue:
host_count: 0
Expand Down
3 changes: 0 additions & 3 deletions tests/topology/expected/vlan-routed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ nodes:
name: r1
vlan:
max_bridge_group: 1
mode: irb
vlans:
red:
bridge_group: 1
Expand All @@ -162,8 +161,6 @@ nodes:
ipv4: 172.16.0.0/24
vni: 101000
provider: libvirt
vlan:
mode: irb
vlans:
red:
id: 1000
Expand Down
3 changes: 0 additions & 3 deletions tests/topology/expected/vlan-router-stick.yml
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,6 @@ nodes:
name: s2
vlan:
max_bridge_group: 2
mode: irb
vlans:
blue:
bridge_group: 1
Expand Down Expand Up @@ -538,8 +537,6 @@ nodes:
ospf:
area: 0.0.0.0
provider: libvirt
vlan:
mode: irb
vlans:
blue:
host_count: 0
Expand Down
Loading

0 comments on commit 76df3c3

Please sign in to comment.