From 99ed8ea66abbc9d91ca5487ac4e0a89b51fa6831 Mon Sep 17 00:00:00 2001 From: Sudharsan Dhamal Gopalarathnam Date: Wed, 21 Sep 2022 18:47:30 -0700 Subject: [PATCH] [link-local]Modify RIF check to include link-local enabled interfaces (#2394) * Modify RIF check to include interfaces with link-local mode. The existing RIF check will only work if the key is tuple which is applicable only when interface has IP address. However if the interface has IPv6 only enable the key is of type string. So in common if the interface is either IPv6 enabled or ip configured it has both string and tuple keys as illustrated below. Hence modified the if check to check directly for interface name which will match the key of type string --- tests/ipv6_link_local_test.py | 12 +++++++++++- tests/mock_tables/config_db.json | 3 +++ utilities_common/cli.py | 4 ++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/tests/ipv6_link_local_test.py b/tests/ipv6_link_local_test.py index a01bfa726d..50b691be6b 100644 --- a/tests/ipv6_link_local_test.py +++ b/tests/ipv6_link_local_test.py @@ -30,7 +30,7 @@ +------------------+----------+ | Ethernet36 | Disabled | +------------------+----------+ -| Ethernet40 | Disabled | +| Ethernet40 | Enabled | +------------------+----------+ | Ethernet44 | Disabled | +------------------+----------+ @@ -224,6 +224,16 @@ def test_config_enable_disable_ipv6_link_local_on_all_valid_interfaces(self): assert result.exit_code == 0 assert result.output == '' + def test_vlan_member_add_on_link_local_interface(self): + runner = CliRunner() + db = Db() + obj = {'config_db':db.cfgdb, 'namespace':db.db.namespace} + + result = runner.invoke(config.config.commands["vlan"].commands["member"].commands["add"], ["4000", "Ethernet40"], obj=obj) + print(result.output) + assert result.exit_code != 0 + assert 'Error: Ethernet40 is a router interface!' in result.output + @classmethod def teardown_class(cls): os.environ['UTILITIES_UNIT_TESTING'] = "0" diff --git a/tests/mock_tables/config_db.json b/tests/mock_tables/config_db.json index 1f8ed478fa..2417f94f93 100644 --- a/tests/mock_tables/config_db.json +++ b/tests/mock_tables/config_db.json @@ -704,6 +704,9 @@ "INTERFACE|Ethernet0|14.14.0.1/24": { "NULL": "NULL" }, + "INTERFACE|Ethernet40": { + "ipv6_use_link_local_only": "enable" + }, "DEBUG_COUNTER|DEBUG_0": { "type": "PORT_INGRESS_DROPS" }, diff --git a/utilities_common/cli.py b/utilities_common/cli.py index 6aaedcb209..163ed9bed0 100644 --- a/utilities_common/cli.py +++ b/utilities_common/cli.py @@ -294,7 +294,7 @@ def is_port_router_interface(config_db, port): interface_table = config_db.get_table('INTERFACE') for intf in interface_table: - if port == intf[0]: + if port == intf: return True return False @@ -304,7 +304,7 @@ def is_pc_router_interface(config_db, pc): pc_interface_table = config_db.get_table('PORTCHANNEL_INTERFACE') for intf in pc_interface_table: - if pc == intf[0]: + if pc == intf: return True return False