Skip to content

Commit

Permalink
[link-local]Modify RIF check to include link-local enabled interfaces (
Browse files Browse the repository at this point in the history
…#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
  • Loading branch information
dgsudharsan authored and yxieca committed Sep 22, 2022
1 parent 562188f commit 99ed8ea
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
12 changes: 11 additions & 1 deletion tests/ipv6_link_local_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
+------------------+----------+
| Ethernet36 | Disabled |
+------------------+----------+
| Ethernet40 | Disabled |
| Ethernet40 | Enabled |
+------------------+----------+
| Ethernet44 | Disabled |
+------------------+----------+
Expand Down Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions tests/mock_tables/config_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
4 changes: 2 additions & 2 deletions utilities_common/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 99ed8ea

Please sign in to comment.