Skip to content

Commit d60afe1

Browse files
authored
Fix ipCidrRouteStatus for loopback: no need to check route table (sonic-net#60)
* Fix ipCidrRouteStatus for loopback: no need to check route table Signed-off-by: Qi Luo <[email protected]> * (comment) Signed-off-by: Qi Luo <[email protected]>
1 parent 375363c commit d60afe1

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/sonic_ax_impl/mibs/ietf/rfc4292.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def reinit_data(self):
2929
if not loopbacks:
3030
return
3131

32-
# collect only ipv4 interfaces
32+
## Collect only ipv4 lo interfaces
3333
for loopback in loopbacks:
3434
lostr = loopback.decode()
3535
loip = lostr[len("INTF_TABLE:lo:"):]
@@ -45,6 +45,12 @@ def update_data(self):
4545
self.route_dest_map = {}
4646
self.route_dest_list = []
4747

48+
## The nexthop for loopbacks should be all zero
49+
for loip in self.loips:
50+
sub_id = ip2tuple_v4(loip) + (255, 255, 255, 255) + (self.tos,) + (0, 0, 0, 0)
51+
self.route_dest_list.append(sub_id)
52+
self.route_dest_map[sub_id] = self.loips[loip].packed
53+
4854
self.db_conn.connect(mibs.APPL_DB)
4955
route_entries = self.db_conn.keys(mibs.APPL_DB, "ROUTE_TABLE:*")
5056
if not route_entries:
@@ -66,11 +72,6 @@ def update_data(self):
6672
sub_id = ip2tuple_v4(ipn.network_address) + ip2tuple_v4(ipn.netmask) + (self.tos,) + ip2tuple_v4(nh)
6773
self.route_dest_list.append(sub_id)
6874
self.route_dest_map[sub_id] = ipn.network_address.packed
69-
elif ipnstr in self.loips:
70-
## Note: ipv4 /32 or ipv6 /128 routes will has no prefix ending
71-
sub_id = ip2tuple_v4(ipnstr) + (255, 255, 255, 255) + (self.tos,) + (0, 0, 0, 0)
72-
self.route_dest_list.append(sub_id)
73-
self.route_dest_map[sub_id] = self.loips[ipnstr].packed
7475

7576
self.route_dest_list.sort()
7677

0 commit comments

Comments
 (0)