From 95d462cb02ff78af4af82e24f4305cd1e20a7245 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 27 Sep 2013 08:21:33 -0600 Subject: [PATCH] Networking: If sending out of the subnet, device lookup by IP will fail. Fall back to ETH0 for now. From Max Holtzberg --- ChangeLog | 5 +++++ net/netdev_txnotify.c | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/ChangeLog b/ChangeLog index 6f39e782eb..f685333cac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5642,4 +5642,9 @@ definitions (2013-9-26). * arch/arm/src/sama5/sam_gmac.c and include/nuttx/net/gmii.h: Beginning of support for GMII/RGMII PHY support (2013-9-26) + * net/netdev_txnotify.c: Look up of device using subnet will fail + if the packet is being sent out of our subnet (via a router). + The fallback here is just to use "eth0" if the subnet lookup + fails. This will, of course, will have to be revisited if/when + multiple NICs are supported (2013-9-27). diff --git a/net/netdev_txnotify.c b/net/netdev_txnotify.c index 4cb705ea85..41f97c4019 100644 --- a/net/netdev_txnotify.c +++ b/net/netdev_txnotify.c @@ -95,6 +95,20 @@ void netdev_txnotify(const uip_ipaddr_t *raddr) /* Find the device driver that serves the subnet of the remote address */ struct uip_driver_s *dev = netdev_findbyaddr(raddr); + + /* The above lookup will fail if the packet is being sent out of our + * out subnet to a router. REVISIT: For now, we fall back and try "eth0". + */ + + if (dev == NULL) + { + /* If the destination address is not in our subnet, assume eth0 as the + * default device. + */ + + dev = netdev_findbyname("eth0"); + } + if (dev && dev->d_txavail) { /* Notify the device driver that new TX data is available. */