Skip to content

Commit

Permalink
Don't aggregate L2 errors with L3 errors for physical ports with RIF
Browse files Browse the repository at this point in the history
Signed-off-by: Stepan Blyschak <[email protected]>
  • Loading branch information
stepanblyschak committed Aug 6, 2024
1 parent a281f9a commit 967f311
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 27 deletions.
11 changes: 0 additions & 11 deletions src/sonic_ax_impl/mibs/ietf/rfc1213.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,19 +360,8 @@ def _get_counter(self, oid, table_name):

def aggregate_counters(self):
"""
For ports with l3 router interfaces l3 drops may be counted separately (RIF counters)
add l3 drops to l2 drop counters cache according to mapping
For l3vlan map l3 counters to l2 counters
"""
for rif_sai_id, port_sai_id in self.rif_port_map.items():
if port_sai_id in self.if_id_map:
port_idx = mibs.get_index_from_str(self.if_id_map[port_sai_id])
for port_counter_name, rif_counter_name in mibs.RIF_DROPS_AGGR_MAP.items():
self.if_counters[port_idx][port_counter_name] = \
self.if_counters[port_idx].get(port_counter_name, 0) + \
self.rif_counters[rif_sai_id].get(rif_counter_name, 0)

for vlan_sai_id, vlan_name in self.vlan_name_map.items():
for port_counter_name, rif_counter_name in mibs.RIF_COUNTERS_AGGR_MAP.items():
vlan_idx = mibs.get_index_from_str(vlan_name)
Expand Down
16 changes: 8 additions & 8 deletions tests/namespace/test_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ def test_in_ucast_rif(self):

def test_in_errors_rif(self):
"""
For a port with RIF the counter values are aggregated
For a port with RIF the counter values are not aggregated
"""
oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 14, 9))
get_pdu = GetPDU(
Expand All @@ -480,7 +480,7 @@ def test_in_errors_rif(self):
value0 = response.values[0]
self.assertEqual(value0.type_, ValueType.COUNTER_32)
self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 14, 9))))
self.assertEqual(value0.data, 101)
self.assertEqual(value0.data, 100)

def test_out_octets_rif(self):
"""
Expand Down Expand Up @@ -520,7 +520,7 @@ def test_out_ucast_rif(self):

def test_out_errors_rif(self):
"""
For a port with RIF the counter values are aggregated
For a port with RIF the counter values are not aggregated
"""
oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 20, 9))
get_pdu = GetPDU(
Expand All @@ -534,7 +534,7 @@ def test_out_errors_rif(self):
value0 = response.values[0]
self.assertEqual(value0.type_, ValueType.COUNTER_32)
self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 20, 9))))
self.assertEqual(value0.data, 102)
self.assertEqual(value0.data, 100)

def test_in_octets_vlan(self):
"""
Expand Down Expand Up @@ -682,7 +682,7 @@ def test_in_ucast_vlan_subinterface(self):

def test_in_errors_vlan_subinterface(self):
"""
For a port with multiple vlan subinterfaces (RIF) all RIF drops are accumulated
For a port with multiple vlan subinterfaces (RIF) all RIF drops are not accumulated
"""
oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 14, 17))
get_pdu = GetPDU(
Expand All @@ -696,7 +696,7 @@ def test_in_errors_vlan_subinterface(self):
value0 = response.values[0]
self.assertEqual(value0.type_, ValueType.COUNTER_32)
self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 14, 17))))
self.assertEqual(value0.data, 203)
self.assertEqual(value0.data, 0)

def test_out_octets_vlan_subinterface(self):
"""
Expand Down Expand Up @@ -736,7 +736,7 @@ def test_out_ucast_vlan_subinterface(self):

def test_out_errors_vlan_subinterface(self):
"""
For a port with multiple vlan subinterfaces (RIF) all RIF drops are accumulated
For a port with multiple vlan subinterfaces (RIF) all RIF drops are not accumulated
"""
oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 20, 17))
get_pdu = GetPDU(
Expand All @@ -750,7 +750,7 @@ def test_out_errors_vlan_subinterface(self):
value0 = response.values[0]
self.assertEqual(value0.type_, ValueType.COUNTER_32)
self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 20, 17))))
self.assertEqual(value0.data, 203)
self.assertEqual(value0.data, 0)

def test_in_octets_portchannel(self):
"""
Expand Down
16 changes: 8 additions & 8 deletions tests/test_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ def test_in_ucast_rif(self):

def test_in_errors_rif(self):
"""
For a port with RIF the counter values are aggregated
For a port with RIF the counter values are not aggregated
"""
oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 14, 21))
get_pdu = GetPDU(
Expand All @@ -475,7 +475,7 @@ def test_in_errors_rif(self):
value0 = response.values[0]
self.assertEqual(value0.type_, ValueType.COUNTER_32)
self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 14, 21))))
self.assertEqual(value0.data, 101)
self.assertEqual(value0.data, 100)

def test_out_octets_rif(self):
"""
Expand Down Expand Up @@ -515,7 +515,7 @@ def test_out_ucast_rif(self):

def test_out_errors_rif(self):
"""
For a port with RIF the counter values are aggregated
For a port with RIF the counter values are not aggregated
"""
oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 20, 21))
get_pdu = GetPDU(
Expand All @@ -529,7 +529,7 @@ def test_out_errors_rif(self):
value0 = response.values[0]
self.assertEqual(value0.type_, ValueType.COUNTER_32)
self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 20, 21))))
self.assertEqual(value0.data, 102)
self.assertEqual(value0.data, 100)

def test_in_octets_vlan(self):
"""
Expand Down Expand Up @@ -677,7 +677,7 @@ def test_in_ucast_vlan_subinterface(self):

def test_in_errors_vlan_subinterface(self):
"""
For a port with multiple vlan subinterfaces (RIF) all RIF drops are accumulated
For a port with multiple vlan subinterfaces (RIF) all RIF drops are not accumulated
"""
oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 14, 9))
get_pdu = GetPDU(
Expand All @@ -691,7 +691,7 @@ def test_in_errors_vlan_subinterface(self):
value0 = response.values[0]
self.assertEqual(value0.type_, ValueType.COUNTER_32)
self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 14, 9))))
self.assertEqual(value0.data, 203)
self.assertEqual(value0.data, 0)

def test_out_octets_vlan_subinterface(self):
"""
Expand Down Expand Up @@ -731,7 +731,7 @@ def test_out_ucast_vlan_subinterface(self):

def test_out_errors_vlan_subinterface(self):
"""
For a port with multiple vlan subinterfaces (RIF) all RIF drops are accumulated
For a port with multiple vlan subinterfaces (RIF) all RIF drops are not accumulated
"""
oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 20, 9))
get_pdu = GetPDU(
Expand All @@ -745,7 +745,7 @@ def test_out_errors_vlan_subinterface(self):
value0 = response.values[0]
self.assertEqual(value0.type_, ValueType.COUNTER_32)
self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 20, 9))))
self.assertEqual(value0.data, 203)
self.assertEqual(value0.data, 0)

def test_in_octets_portchannel(self):
"""
Expand Down

0 comments on commit 967f311

Please sign in to comment.