Skip to content

Commit e4268f4

Browse files
test: handle endpoint lookup in case of gateway route
Currently find_endpoint incorrectly tries to find physical address for sent EID. This fails in case EID is a gatewayed endpoint because don't have neighbors or physical address. For gateway routes, return the gateway's physical address instead. The gateway endpoint will then forward the message to the correct bridged endpoint internally via looking into its bridged endpoint list. Signed-off-by: Faizan Ali <[email protected]>
1 parent 70c2196 commit e4268f4

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

tests/mctpenv/__init__.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,21 @@ def find_endpoint(self, addr):
258258
route = self.lookup_route(addr.net, addr.eid)
259259
if route is None:
260260
return None
261-
iface = route.iface
262-
263-
neigh = self.lookup_neighbour(route.iface, addr.eid)
264-
# if no neighbour, return an empty lladdr (eg mctpusb)
265-
lladdr = neigh.lladdr if neigh else bytes()
261+
if route.gw is not None:
262+
# In case of gateway routes, we need not have neighbours
263+
# for the gated endpoints, but only need to find the
264+
# gateway's physical address
265+
gw_net, gw_eid = route.gw
266+
gw_route = self.lookup_route(gw_net, gw_eid)
267+
if gw_route is None or gw_route.iface is None:
268+
return None
269+
iface = gw_route.iface
270+
neigh = self.lookup_neighbour(gw_route.iface, gw_eid)
271+
lladdr = neigh.lladdr if neigh else bytes()
272+
else:
273+
iface = route.iface
274+
neigh = self.lookup_neighbour(route.iface, addr.eid)
275+
lladdr = neigh.lladdr if neigh else bytes()
266276

267277
if iface is None or lladdr is None:
268278
return None

0 commit comments

Comments
 (0)