Skip to content

Commit 0d1af77

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 <faizana@nvidia.com>
1 parent cff738c commit 0d1af77

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
@@ -259,11 +259,21 @@ def find_endpoint(self, addr):
259259
route = self.lookup_route(addr.net, addr.eid)
260260
if route is None:
261261
return None
262-
iface = route.iface
263-
264-
neigh = self.lookup_neighbour(route.iface, addr.eid)
265-
# if no neighbour, return an empty lladdr (eg mctpusb)
266-
lladdr = neigh.lladdr if neigh else bytes()
262+
if route.gw is not None:
263+
# In case of gateway routes, we need not have neighbours
264+
# for the gated endpoints, but only need to find the
265+
# gateway's physical address
266+
gw_net, gw_eid = route.gw
267+
gw_route = self.lookup_route(gw_net, gw_eid)
268+
if gw_route is None or gw_route.iface is None:
269+
return None
270+
iface = gw_route.iface
271+
neigh = self.lookup_neighbour(gw_route.iface, gw_eid)
272+
lladdr = neigh.lladdr if neigh else bytes()
273+
else:
274+
iface = route.iface
275+
neigh = self.lookup_neighbour(route.iface, addr.eid)
276+
lladdr = neigh.lladdr if neigh else bytes()
267277

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

0 commit comments

Comments
 (0)