From ac62e62d0b62a97a33de3daf3013e15a0b374db1 Mon Sep 17 00:00:00 2001 From: Ivan Pepelnjak Date: Fri, 3 Jan 2025 10:58:50 +0100 Subject: [PATCH] Cleanup 'unnumbered' references (fixes #1697) --- netsim/modules/_routing.py | 2 +- netsim/modules/isis.py | 9 +++------ netsim/modules/ospf.py | 4 +--- tests/errors/isis-capability.log | 1 + tests/errors/isis-capability.yml | 7 ++++--- 5 files changed, 10 insertions(+), 13 deletions(-) diff --git a/netsim/modules/_routing.py b/netsim/modules/_routing.py index 439731901..849c50a3c 100644 --- a/netsim/modules/_routing.py +++ b/netsim/modules/_routing.py @@ -281,7 +281,7 @@ def build_vrf_interface_list(node: Box, proto: str, topology: Box) -> None: def remove_unaddressed_intf(node: Box, proto: str) -> None: for intf in node.interfaces: if proto in intf: - if not any(af in intf for af in ('ipv4','ipv6','unnumbered')): # Do we have at least some addressing on the interface? + if not any(af in intf for af in ('ipv4','ipv6')): # Do we have at least some addressing on the interface? intf.pop(proto,None) # Nope, no need to run IGP on that interface # # remove_unused_igp -- remove IGP module if it's not configured on any interface diff --git a/netsim/modules/isis.py b/netsim/modules/isis.py index 2cecaef03..6f357f715 100644 --- a/netsim/modules/isis.py +++ b/netsim/modules/isis.py @@ -13,9 +13,7 @@ def isis_unnumbered(node: Box, features: Box) -> bool: for af in ('ipv4','ipv6'): is_unnumbered = False for l in node.get('interfaces',[]): - is_unnumbered = is_unnumbered or \ - 'unnumbered' in l or \ - (af in l and isinstance(l[af],bool) and l[af]) + is_unnumbered = is_unnumbered or (af in l and isinstance(l[af],bool) and l[af]) if is_unnumbered and not features.isis.unnumbered[af]: log.error( @@ -26,13 +24,12 @@ def isis_unnumbered(node: Box, features: Box) -> bool: OK = True for l in node.get('interfaces',[]): - unnum_v4 = 'unnumbered' in l or ('ipv4' in l and l.ipv4 is True) + unnum_v4 = l.get('ipv4',None) is True if unnum_v4 and \ len(l.neighbors) > 1 and \ not features.isis.unnumbered.network: log.error( - f'Device {node.device} used on node {node.name} cannot run IS-IS over\n'+ - f'.. unnumbered multi-access interfaces (link {l.name})', + f'Device {node.device} (node {node.name}) cannot run IS-IS over unnumbered multi-access link {l.name}', log.IncorrectValue, 'interfaces') OK = False diff --git a/netsim/modules/ospf.py b/netsim/modules/ospf.py index 3c6ea6db9..e80a05294 100644 --- a/netsim/modules/ospf.py +++ b/netsim/modules/ospf.py @@ -24,9 +24,7 @@ def ospf_unnumbered(node: Box, features: Box) -> bool: OK = True for l in node.get('interfaces',[]): - is_unnumbered = \ - 'unnumbered' in l or \ - ('ipv4' in l and isinstance(l.ipv4,bool) and l.ipv4) + is_unnumbered = l.get('ipv4',None) is True if is_unnumbered and 'ospf' in l: node.ospf.unnumbered = True if len(l.get('neighbors',[])) > 1: diff --git a/tests/errors/isis-capability.log b/tests/errors/isis-capability.log index f230cba18..84ed02fc5 100644 --- a/tests/errors/isis-capability.log +++ b/tests/errors/isis-capability.log @@ -1,2 +1,3 @@ IncorrectValue in interfaces: Device nxos used on node r2 cannot run IS-IS over unnumbered ipv4 interfaces +IncorrectValue in interfaces: Device eos (node r3) cannot run IS-IS over unnumbered multi-access link r3 -> [r1,r2] Fatal error in netlab: Cannot proceed beyond this point due to errors, exiting diff --git a/tests/errors/isis-capability.yml b/tests/errors/isis-capability.yml index bbb841268..bc43bff3e 100644 --- a/tests/errors/isis-capability.yml +++ b/tests/errors/isis-capability.yml @@ -1,7 +1,10 @@ +# The scenario changed to use 'unnumbered: True' as a regression test for #1697 +# defaults: devices: iosv.features.initial.ipv4.unnumbered: True nxos.features.isis.unnumbered.ipv4: False + eos.features.isis.unnumbered.network: False module: [ isis ] @@ -17,6 +20,4 @@ links: - r1: r2: r3: - prefix: - ipv4: True - ipv6: True + unnumbered: True