Skip to content

Commit 28f6820

Browse files
authored
[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
1 parent 0a7557b commit 28f6820

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

tests/ipv6_link_local_test.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
+------------------+----------+
3131
| Ethernet36 | Disabled |
3232
+------------------+----------+
33-
| Ethernet40 | Disabled |
33+
| Ethernet40 | Enabled |
3434
+------------------+----------+
3535
| Ethernet44 | Disabled |
3636
+------------------+----------+
@@ -224,6 +224,16 @@ def test_config_enable_disable_ipv6_link_local_on_all_valid_interfaces(self):
224224
assert result.exit_code == 0
225225
assert result.output == ''
226226

227+
def test_vlan_member_add_on_link_local_interface(self):
228+
runner = CliRunner()
229+
db = Db()
230+
obj = {'config_db':db.cfgdb, 'namespace':db.db.namespace}
231+
232+
result = runner.invoke(config.config.commands["vlan"].commands["member"].commands["add"], ["4000", "Ethernet40"], obj=obj)
233+
print(result.output)
234+
assert result.exit_code != 0
235+
assert 'Error: Ethernet40 is a router interface!' in result.output
236+
227237
@classmethod
228238
def teardown_class(cls):
229239
os.environ['UTILITIES_UNIT_TESTING'] = "0"

tests/mock_tables/config_db.json

+3
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,9 @@
708708
"INTERFACE|Ethernet0|14.14.0.1/24": {
709709
"NULL": "NULL"
710710
},
711+
"INTERFACE|Ethernet40": {
712+
"ipv6_use_link_local_only": "enable"
713+
},
711714
"DEBUG_COUNTER|DEBUG_0": {
712715
"type": "PORT_INGRESS_DROPS"
713716
},

utilities_common/cli.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ def is_port_router_interface(config_db, port):
294294

295295
interface_table = config_db.get_table('INTERFACE')
296296
for intf in interface_table:
297-
if port == intf[0]:
297+
if port == intf:
298298
return True
299299

300300
return False
@@ -304,7 +304,7 @@ def is_pc_router_interface(config_db, pc):
304304

305305
pc_interface_table = config_db.get_table('PORTCHANNEL_INTERFACE')
306306
for intf in pc_interface_table:
307-
if pc == intf[0]:
307+
if pc == intf:
308308
return True
309309

310310
return False

0 commit comments

Comments
 (0)