Skip to content

Commit aaea0a6

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 28db776 commit aaea0a6

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

tests/mctpenv/__init__.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,23 @@ 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+
# TODO: handle recursive gateway and alternate routes
267+
# for downstream endpoints
268+
gw_net, gw_eid = route.gw
269+
gw_route = self.lookup_route(gw_net, gw_eid)
270+
if gw_route is None or gw_route.iface is None:
271+
return None
272+
iface = gw_route.iface
273+
neigh = self.lookup_neighbour(gw_route.iface, gw_eid)
274+
lladdr = neigh.lladdr if neigh else bytes()
275+
else:
276+
iface = route.iface
277+
neigh = self.lookup_neighbour(route.iface, addr.eid)
278+
lladdr = neigh.lladdr if neigh else bytes()
267279

268280
if iface is None or lladdr is None:
269281
return None

0 commit comments

Comments
 (0)