Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add VoQ Recirc interface (i.e., Ethernet-Rec) to interface maps for S… #244

Merged
merged 9 commits into from
May 4, 2022
6 changes: 4 additions & 2 deletions src/sonic_ax_impl/mibs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,8 @@ def init_sync_d_interface_tables(db_conn):
if_name_str = if_name
if (re.match(port_util.SONIC_ETHERNET_RE_PATTERN, if_name_str) or \
re.match(port_util.SONIC_ETHERNET_BP_RE_PATTERN, if_name_str) or \
re.match(port_util.SONIC_ETHERNET_IB_RE_PATTERN, if_name_str)):
re.match(port_util.SONIC_ETHERNET_IB_RE_PATTERN, if_name_str) or \
re.match(port_util.SONIC_ETHERNET_REC_RE_PATTERN, if_name_str)):
if_name_map[if_name] = sai_id
# As sai_id is not unique in multi-asic platform, concatenate it with
# namespace to get a unique key. Assuming that ':' is not present in namespace
Expand All @@ -284,7 +285,8 @@ def init_sync_d_interface_tables(db_conn):
for sai_id, if_name in if_id_map_util.items():
if (re.match(port_util.SONIC_ETHERNET_RE_PATTERN, if_name) or \
re.match(port_util.SONIC_ETHERNET_BP_RE_PATTERN, if_name) or \
re.match(port_util.SONIC_ETHERNET_IB_RE_PATTERN, if_name)):
re.match(port_util.SONIC_ETHERNET_IB_RE_PATTERN, if_name) or \
re.match(port_util.SONIC_ETHERNET_REC_RE_PATTERN, if_name)):
if_id_map[get_sai_id_key(db_conn.namespace, sai_id)] = if_name
logger.debug("Port name map:\n" + pprint.pformat(if_name_map, indent=2))
logger.debug("Interface name map:\n" + pprint.pformat(if_id_map, indent=2))
Expand Down
10 changes: 10 additions & 0 deletions tests/mock_tables/asic0/appl_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@
"alias": "etp4",
"speed": 100000
},
"PORT_TABLE:Ethernet-IB0": {
"description": "inband",
"alias": "rec0",
"speed": 100000
},
"PORT_TABLE:Ethernet-Rec0": {
"description": "recirc",
"alias": "rec1",
"speed": 100000
},
"ROUTE_TABLE:0.0.0.0/0": {
"ifname": "Ethernet0,Ethernet4",
"nexthop": "10.0.0.1,10.0.0.3"
Expand Down
12 changes: 12 additions & 0 deletions tests/mock_tables/asic0/config_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@
"role": "Int",
"speed": 100000
},
"PORT_TABLE:Ethernet-IB0": {
"description": "inband",
"alias": "rec0",
"role": "Inb",
"speed": 100000
},
"PORT_TABLE:Ethernet-Rec0": {
"description": "recirc",
"alias": "rec1",
"role": "Rec",
"speed": 100000
},
"LAG_MEMBER_TABLE:PortChannel01:Ethernet-BP0": {
"status": "enabled"
},
Expand Down
4 changes: 3 additions & 1 deletion tests/mock_tables/asic0/counters_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,9 @@
"Ethernet0": "oid:0x1000000000003",
"Ethernet4": "oid:0x1000000000004",
"Ethernet-BP0": "oid:0x1000000000005",
"Ethernet-BP4": "oid:0x1000000000006"
"Ethernet-BP4": "oid:0x1000000000006",
"Ethernet-IB0": "oid:0x1000000000007",
"Ethernet-Rec0": "oid:0x1000000000008",
},
"COUNTERS_LAG_NAME_MAP": {
"PortChannel01": "oid:0x1000000000007"
Expand Down
11 changes: 11 additions & 0 deletions tests/namespace/test_mibs.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ def test_init_namespace_sync_d_lag_tables(self):
self.assertTrue("PortChannel_Temp" in lag_name_if_name_map)
self.assertTrue(lag_name_if_name_map["PortChannel_Temp"] == [])

def test_init_sync_d_interface_tables_for_recirc_ports(self):
db_conn = Namespace.init_namespace_dbs()

if_name_map, \
if_alias_map, \
if_id_map, \
oid_name_map = Namespace.get_sync_d_from_all_namespace(mibs.init_sync_d_interface_tables, db_conn)
for recirc_port_name, sai_id in [('Ethernet-IB0', 0), ('Ethernet-Rec0', 1)]:
self.assertTrue(if_name_map[recirc_port_name] == sai_id)
self.assertTrue(if_id_map[sai_id] == recirc_port_name)

@classmethod
def tearDownClass(cls):
tests.mock_tables.dbconnector.clean_up_config()