Commit f1b9066c authored by Julien Muchembled's avatar Julien Muchembled

Fix crash when a buggy neighbour claims to have multiple subnets

No need for more logging since the culprit is visible everywhere
in routing tables.
parent 7c135c39
...@@ -261,6 +261,7 @@ class Babel(object): ...@@ -261,6 +261,7 @@ class Babel(object):
self.write_buffer.send(self.socket) self.write_buffer.send(self.socket)
def handle_dump(self, interfaces, neighbours, xroutes, routes): def handle_dump(self, interfaces, neighbours, xroutes, routes):
self.interfaces = {i.index: name for i, name in interfaces}
# neighbours = {neigh_prefix: (neighbour, {dst_prefix: route})} # neighbours = {neigh_prefix: (neighbour, {dst_prefix: route})}
n = {(n.address, n.ifindex): (n, {}) for n in neighbours} n = {(n.address, n.ifindex): (n, {}) for n in neighbours}
unidentified = set(n) unidentified = set(n)
...@@ -278,20 +279,16 @@ class Babel(object): ...@@ -278,20 +279,16 @@ class Babel(object):
prefix = ip[a:route.plen] prefix = ip[a:route.plen]
if prefix and not route.refmetric: if prefix and not route.refmetric:
neighbours[prefix] = neigh_routes neighbours[prefix] = neigh_routes
# XXX: Temporary logging to understand when a KeyError
# happens. Then, we'll problably replace 'remove' by
# 'discard'.
try: try:
unidentified.remove(address) unidentified.remove(address)
except KeyError as e: except KeyError:
logging.warning("address: %s; prefix: %s", logging.debug("Buggy neighbour %s%%%s with multiple"
address, prefix) " subnets within the same re6st network"
logging.warning("neighbours: %r", neighbours) " (one of them is %s/%s).",
logging.warning("routes: %r", routes) socket.inet_ntop(socket.AF_INET6, address[0]),
try: self.interfaces[address[1]],
tm.sendto(tm.cache.registry_prefix, '\7%s' % e) socket.inet_ntop(socket.AF_INET6, route.prefix),
except AttributeError: route.plen)
pass
else: else:
prefix = None prefix = None
neigh_routes[1][prefix] = route neigh_routes[1][prefix] = route
...@@ -307,7 +304,6 @@ class Babel(object): ...@@ -307,7 +304,6 @@ class Babel(object):
neighbours[None] = None, routes neighbours[None] = None, routes
logging.trace("Routes via unidentified neighbours. %r", logging.trace("Routes via unidentified neighbours. %r",
neighbours) neighbours)
self.interfaces = {i.index: name for i, name in interfaces}
self.handler.babel_dump() self.handler.babel_dump()
def handle_set_cost_multiplier(self, flags): def handle_set_cost_multiplier(self, flags):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment