Skip to content

Commit c80321c

Browse files
authored
[fdbshow]: Handle FDB cleanup gracefully. (#1918)
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. Closes #1866 - What I did Fixed: [fdb] 'show mac' command failed with t0-56-po2vlan topology #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
1 parent 066b5ad commit c80321c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

scripts/fdbshow

+5-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class FdbShow(object):
5555
self.db.connect(self.db.ASIC_DB)
5656
self.bridge_mac_list = []
5757

58-
fdb_str = self.db.keys('ASIC_DB', "ASIC_STATE:SAI_OBJECT_TYPE_FDB_ENTRY:*")
58+
fdb_str = self.db.keys(self.db.ASIC_DB, "ASIC_STATE:SAI_OBJECT_TYPE_FDB_ENTRY:*")
5959
if not fdb_str:
6060
return
6161

@@ -69,7 +69,10 @@ class FdbShow(object):
6969
if not fdb:
7070
continue
7171

72-
ent = self.db.get_all('ASIC_DB', s, blocking=True)
72+
ent = self.db.get_all(self.db.ASIC_DB, s)
73+
if not ent:
74+
continue
75+
7376
br_port_id = ent[b"SAI_FDB_ENTRY_ATTR_BRIDGE_PORT_ID"][oid_pfx:]
7477
ent_type = ent[b"SAI_FDB_ENTRY_ATTR_TYPE"]
7578
fdb_type = ['Dynamic','Static'][ent_type == "SAI_FDB_ENTRY_TYPE_STATIC"]

0 commit comments

Comments
 (0)