Skip to content

Commit

Permalink
Fix ipCidrRouteStatus for loopback: no need to check route table (son…
Browse files Browse the repository at this point in the history
…ic-net#60)

* Fix ipCidrRouteStatus for loopback: no need to check route table

Signed-off-by: Qi Luo <qiluo-msft@users.noreply.github.com>

* (comment)

Signed-off-by: Qi Luo <qiluo-msft@users.noreply.github.com>
  • Loading branch information
qiluo-msft authored Jan 17, 2018
1 parent 375363c commit d60afe1
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/sonic_ax_impl/mibs/ietf/rfc4292.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def reinit_data(self):
if not loopbacks:
return

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

## The nexthop for loopbacks should be all zero
for loip in self.loips:
sub_id = ip2tuple_v4(loip) + (255, 255, 255, 255) + (self.tos,) + (0, 0, 0, 0)
self.route_dest_list.append(sub_id)
self.route_dest_map[sub_id] = self.loips[loip].packed

self.db_conn.connect(mibs.APPL_DB)
route_entries = self.db_conn.keys(mibs.APPL_DB, "ROUTE_TABLE:*")
if not route_entries:
Expand All @@ -66,11 +72,6 @@ def update_data(self):
sub_id = ip2tuple_v4(ipn.network_address) + ip2tuple_v4(ipn.netmask) + (self.tos,) + ip2tuple_v4(nh)
self.route_dest_list.append(sub_id)
self.route_dest_map[sub_id] = ipn.network_address.packed
elif ipnstr in self.loips:
## Note: ipv4 /32 or ipv6 /128 routes will has no prefix ending
sub_id = ip2tuple_v4(ipnstr) + (255, 255, 255, 255) + (self.tos,) + (0, 0, 0, 0)
self.route_dest_list.append(sub_id)
self.route_dest_map[sub_id] = self.loips[ipnstr].packed

self.route_dest_list.sort()

Expand Down

0 comments on commit d60afe1

Please sign in to comment.