4
4
from bisect import bisect_right
5
5
6
6
from sonic_ax_impl import mibs
7
- from sonic_ax_impl import logger
8
7
from sonic_ax_impl .mibs import Namespace
9
8
from ax_interface .mib import MIBMeta , ValueType , MIBUpdater , MIBEntry , SubtreeMIBEntry , OverlayAdpaterMIBEntry , OidMIBEntry
10
9
from ax_interface .encodings import ObjectIdentifier
@@ -50,8 +49,7 @@ class DbTables(int, Enum):
50
49
class IfTypes (int , Enum ):
51
50
""" IANA ifTypes """
52
51
ethernetCsmacd = 6
53
- l3ipvlan = 136
54
- ieee8023adLag = 161
52
+ ieee8023adLag = 161
55
53
56
54
class ArpUpdater (MIBUpdater ):
57
55
def __init__ (self ):
@@ -159,13 +157,8 @@ def __init__(self):
159
157
self .lag_name_if_name_map = {}
160
158
self .if_name_lag_name_map = {}
161
159
self .oid_lag_name_map = {}
162
- self .lag_sai_map = {}
163
160
self .mgmt_oid_name_map = {}
164
161
self .mgmt_alias_map = {}
165
- self .vlan_oid_name_map = {}
166
- self .vlan_name_map = {}
167
- self .rif_port_map = {}
168
- self .port_rif_map = {}
169
162
170
163
# cache of interface counters
171
164
self .if_counters = {}
@@ -175,7 +168,6 @@ def __init__(self):
175
168
self .if_id_map = {}
176
169
self .oid_sai_map = {}
177
170
self .oid_name_map = {}
178
- self .rif_counters = {}
179
171
180
172
def reinit_data (self ):
181
173
"""
@@ -194,13 +186,6 @@ def reinit_data(self):
194
186
self .mgmt_oid_name_map , \
195
187
self .mgmt_alias_map = mibs .init_mgmt_interface_tables (self .db_conn [0 ])
196
188
197
- self .vlan_name_map , \
198
- self .vlan_oid_sai_map , \
199
- self .vlan_oid_name_map = Namespace .init_namespace_sync_d_vlan_tables (self .db_conn )
200
-
201
- self .rif_port_map , \
202
- self .port_rif_map = Namespace .init_namespace_sync_d_rif_tables (self .db_conn )
203
-
204
189
def update_data (self ):
205
190
"""
206
191
Update redis (caches config)
@@ -210,24 +195,13 @@ def update_data(self):
210
195
{sai_id : Namespace .dbs_get_all (self .db_conn , mibs .COUNTERS_DB , mibs .counter_table (sai_id ), blocking = True )
211
196
for sai_id in self .if_id_map }
212
197
213
- rif_sai_ids = list (self .rif_port_map ) + list (self .vlan_name_map )
214
-
215
- self .rif_counters = \
216
- {sai_id : Namespace .dbs_get_all (self .db_conn , mibs .COUNTERS_DB , mibs .counter_table (sai_id ), blocking = True )
217
- for sai_id in rif_sai_ids }
218
-
219
- if self .rif_counters :
220
- self .aggregate_counters ()
221
-
222
198
self .lag_name_if_name_map , \
223
199
self .if_name_lag_name_map , \
224
- self .oid_lag_name_map , \
225
- self .lag_sai_map = Namespace .init_namespace_sync_d_lag_tables (self .db_conn )
200
+ self .oid_lag_name_map = Namespace .init_namespace_sync_d_lag_tables (self .db_conn )
226
201
227
202
self .if_range = sorted (list (self .oid_sai_map .keys ()) +
228
203
list (self .oid_lag_name_map .keys ()) +
229
- list (self .mgmt_oid_name_map .keys ()) +
230
- list (self .vlan_oid_name_map .keys ()))
204
+ list (self .mgmt_oid_name_map .keys ()))
231
205
self .if_range = [(i ,) for i in self .if_range ]
232
206
233
207
def get_next (self , sub_id ):
@@ -271,8 +245,6 @@ def interface_description(self, sub_id):
271
245
return self .oid_lag_name_map [oid ]
272
246
elif oid in self .mgmt_oid_name_map :
273
247
return self .mgmt_alias_map [self .mgmt_oid_name_map [oid ]]
274
- elif oid in self .vlan_oid_name_map :
275
- return self .vlan_oid_name_map [oid ]
276
248
277
249
return self .if_alias_map [self .oid_name_map [oid ]]
278
250
@@ -282,13 +254,7 @@ def _get_counter(self, oid, table_name):
282
254
:param table_name: the redis table (either IntEnum or string literal) to query.
283
255
:return: the counter for the respective sub_id/table.
284
256
"""
285
- sai_id = ''
286
- if oid in self .oid_sai_map :
287
- sai_id = self .oid_sai_map [oid ]
288
- elif oid in self .vlan_oid_sai_map :
289
- sai_id = self .vlan_oid_sai_map [oid ]
290
- else :
291
- logger .warning ("Unexpected oid {}" .format (oid ))
257
+ sai_id = self .oid_sai_map [oid ]
292
258
# Enum.name or table_name = 'name_of_the_table'
293
259
_table_name = bytes (getattr (table_name , 'name' , table_name ), 'utf-8' )
294
260
@@ -302,29 +268,6 @@ def _get_counter(self, oid, table_name):
302
268
mibs .logger .warning ("SyncD 'COUNTERS_DB' missing attribute '{}'." .format (e ))
303
269
return None
304
270
305
- def aggregate_counters (self ):
306
- """
307
- For ports with l3 router interfaces l3 drops may be counted separately (RIF counters)
308
- add l3 drops to l2 drop counters cache according to mapping
309
-
310
- For l3vlan map l3 counters to l2 counters
311
- """
312
- for rif_sai_id , port_sai_id in self .rif_port_map .items ():
313
- if port_sai_id in self .if_id_map :
314
- for port_counter_name , rif_counter_name in mibs .RIF_DROPS_AGGR_MAP .items ():
315
- self .if_counters [port_sai_id ][port_counter_name ] = \
316
- int (self .if_counters [port_sai_id ][port_counter_name ]) + \
317
- int (self .rif_counters [rif_sai_id ][rif_counter_name ])
318
-
319
- for vlan_sai_id in self .vlan_name_map :
320
- for port_counter_name , rif_counter_name in mibs .RIF_COUNTERS_AGGR_MAP .items ():
321
- try :
322
- self .if_counters .setdefault (vlan_sai_id , {})
323
- self .if_counters [vlan_sai_id ][port_counter_name ] = \
324
- int (self .rif_counters [vlan_sai_id ][rif_counter_name ])
325
- except KeyError as e :
326
- logger .warning ("Not able to aggregate counters for {}: {}\n {}" .format (vlan_sai_id , rif_counter_name , e ))
327
-
328
271
def get_counter (self , sub_id , table_name ):
329
272
"""
330
273
:param sub_id: The 1-based sub-identifier query.
@@ -344,13 +287,7 @@ def get_counter(self, sub_id, table_name):
344
287
counter_value = 0
345
288
for lag_member in self .lag_name_if_name_map [self .oid_lag_name_map [oid ]]:
346
289
counter_value += self ._get_counter (mibs .get_index (lag_member ), table_name )
347
- sai_lag_id = self .lag_sai_map [self .oid_lag_name_map [oid ]]
348
- sai_lag_rif_id = self .port_rif_map [sai_lag_id ]
349
- if sai_lag_rif_id in self .rif_port_map :
350
- table_name = bytes (getattr (table_name , 'name' , table_name ), 'utf-8' )
351
- if table_name in mibs .RIF_DROPS_AGGR_MAP :
352
- rif_table_name = mibs .RIF_DROPS_AGGR_MAP [table_name ]
353
- counter_value += int (self .rif_counters [sai_lag_rif_id ][rif_table_name ])
290
+
354
291
# truncate to 32-bit counter
355
292
return counter_value & 0x00000000ffffffff
356
293
else :
@@ -380,8 +317,6 @@ def _get_if_entry(self, sub_id):
380
317
elif oid in self .mgmt_oid_name_map :
381
318
if_table = mibs .mgmt_if_entry_table (self .mgmt_oid_name_map [oid ])
382
319
db = mibs .CONFIG_DB
383
- elif oid in self .vlan_oid_name_map :
384
- if_table = mibs .vlan_entry_table (self .vlan_oid_name_map [oid ])
385
320
elif oid in self .oid_name_map :
386
321
if_table = mibs .if_entry_table (self .oid_name_map [oid ])
387
322
else :
@@ -486,7 +421,6 @@ def get_if_type(self, sub_id):
486
421
487
422
ethernetCsmacd(6), -- for all ethernet-like interfaces,
488
423
-- regardless of speed, as per RFC3635
489
- l3ipvlan(136) -- Layer 3 Virtual LAN using IP
490
424
ieee8023adLag(161) -- IEEE 802.3ad Link Aggregate
491
425
"""
492
426
oid = self .get_oid (sub_id )
@@ -495,8 +429,6 @@ def get_if_type(self, sub_id):
495
429
496
430
if oid in self .oid_lag_name_map :
497
431
return IfTypes .ieee8023adLag
498
- elif oid in self .vlan_oid_name_map :
499
- return IfTypes .l3ipvlan
500
432
else :
501
433
return IfTypes .ethernetCsmacd
502
434
0 commit comments