Skip to content

Commit

Permalink
[fdbshow]: Handle FDB cleanup gracefully. (sonic-net#1926)
Browse files Browse the repository at this point in the history
The race condition is caused by a blocking Redis call which gets the contents of the FDB entry from ASIC DB.
Since it has been implemented as a simple loop, there is no guarantee that entry will be present in DB when the contents are being read.

- What I did
Fixed: [fdb] 'show mac' command failed with t0-56-po2vlan topology sonic-net#1866

- How I did it
Removed blocking calls from fdbshow

- How to verify it
Run FDB test

- Previous command output (if the output of a command-line utility has changed)
root@sonic:/home/admin# show mac
Key 'ASIC_STATE:SAI_OBJECT_TYPE_FDB_ENTRY:{"bvid":"oid:0x260000000009cc","mac":"02:11:22:33:20:00","switch_id":"oid:0x21000000000000"}' unavailable in database '1'

- New command output (if the output of a command-line utility has changed)
root@sonic:/home/admin# show mac
No.    Vlan    MacAddress    Port    Type
-----  ------  ------------  ------  ------
Total number of entries 0

Signed-off-by: Nazarii Hnydyn <[email protected]>
  • Loading branch information
nazariig authored Nov 17, 2021
1 parent e7535ae commit fdedcbf
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions scripts/fdbshow
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class FdbShow(object):
if not self.if_br_oid_map:
return

fdb_str = self.db.keys('ASIC_DB', "ASIC_STATE:SAI_OBJECT_TYPE_FDB_ENTRY:*")
fdb_str = self.db.keys(self.db.ASIC_DB, "ASIC_STATE:SAI_OBJECT_TYPE_FDB_ENTRY:*")
if not fdb_str:
return

Expand All @@ -95,7 +95,10 @@ class FdbShow(object):
if not fdb:
continue

ent = self.db.get_all('ASIC_DB', s, blocking=True)
ent = self.db.get_all(self.db.ASIC_DB, s)
if not ent:
continue

br_port_id = ent["SAI_FDB_ENTRY_ATTR_BRIDGE_PORT_ID"][oid_pfx:]
ent_type = ent["SAI_FDB_ENTRY_ATTR_TYPE"]
fdb_type = ['Dynamic','Static'][ent_type == "SAI_FDB_ENTRY_TYPE_STATIC"]
Expand Down

0 comments on commit fdedcbf

Please sign in to comment.