55from ax_interface import MIBMeta , ValueType , MIBUpdater , SubtreeMIBEntry
66from ax_interface .util import mac_decimals
77from bisect import bisect_right
8- from sonic_ax_impl .mibs import Namespace
98
109class FdbUpdater (MIBUpdater ):
1110 def __init__ (self ):
@@ -30,16 +29,24 @@ def fdb_vlanmac(self, fdb):
3029 else :
3130 vlan_id = Namespace .dbs_get_vlan_id_from_bvid (self .db_conn , fdb ["bvid" ])
3231 self .bvid_vlan_map [fdb ["bvid" ]] = vlan_id
32+ else :
33+ return None
34+ if not isinstance (vlan_id , str ):
35+ return None
3336 return (int (vlan_id ),) + mac_decimals (fdb ["mac" ])
34-
37+
3538 def reinit_data (self ):
3639 """
3740 Subclass update interface information
3841 """
39- self .if_name_map , \
40- self .if_alias_map , \
41- self .if_id_map , \
42- self .oid_name_map = Namespace .get_sync_d_from_all_namespace (mibs .init_sync_d_interface_tables , self .db_conn )
42+ (
43+ self .if_name_map ,
44+ self .if_alias_map ,
45+ self .if_id_map ,
46+ self .oid_name_map ,
47+ ) = Namespace .get_sync_d_from_all_namespace (
48+ mibs .init_sync_d_interface_tables , self .db_conn
49+ )
4350
4451 self .if_bpid_map = Namespace .dbs_get_bridge_port_map (self .db_conn , mibs .ASIC_DB )
4552 self .bvid_vlan_map .clear ()
@@ -62,7 +69,7 @@ def update_data(self):
6269 fdb = json .loads (fdb_str .split (":" , maxsplit = 2 )[- 1 ])
6370 except ValueError as e : # includes simplejson.decoder.JSONDecodeError
6471 mibs .logger .error ("SyncD 'ASIC_DB' includes invalid FDB_ENTRY '{}': {}." .format (fdb_str , e ))
65- break
72+ continue
6673
6774 ent = Namespace .dbs_get_all (self .db_conn , mibs .ASIC_DB , s , blocking = True )
6875 # Example output: oid:0x3a000000000608
@@ -72,6 +79,9 @@ def update_data(self):
7279 port_id = self .if_bpid_map [bridge_port_id ]
7380
7481 vlanmac = self .fdb_vlanmac (fdb )
82+ if not vlanmac :
83+ mibs .logger .error ("SyncD 'ASIC_DB' includes invalid FDB_ENTRY '{}': failed in fdb_vlanmac()." .format (fdb_str ))
84+ continue
7585 self .vlanmac_ifindex_map [vlanmac ] = mibs .get_index_from_str (self .if_id_map [port_id ])
7686 self .vlanmac_ifindex_list .append (vlanmac )
7787 self .vlanmac_ifindex_list .sort ()
0 commit comments