mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] net: Do not route traffic to interfaces that are not up
@ 2018-08-21  6:28 Andrey Smirnov
  2018-08-22  7:20 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Andrey Smirnov @ 2018-08-21  6:28 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

In the case when:

  - Board has multiple network interfaces

  - Two ore more of those interfaces are statically configured to be
    on the same network

  - Only one of those interfaces is up and it is preceeded (as far as
    for_each_netdev is concerned) by interface in the same network
    that isn't

net_route() will choose "non-up" device as a route for traffic
resulting in no network connectivity. Change the routing logic to also
consider if interface is "up", so that only such interfaces would be
considered for sending network traffic out.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 net/net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/net.c b/net/net.c
index d21855415..63f42fa5c 100644
--- a/net/net.c
+++ b/net/net.c
@@ -149,7 +149,7 @@ struct eth_device *net_route(IPaddr_t dest)
 	struct eth_device *edev;
 
 	for_each_netdev(edev) {
-		if (!edev->ipaddr)
+		if (!edev->ipaddr || !edev->ifup)
 			continue;
 
 		if ((dest & edev->netmask) == (edev->ipaddr & edev->netmask)) {
-- 
2.17.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-08-22  7:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-21  6:28 [PATCH] net: Do not route traffic to interfaces that are not up Andrey Smirnov
2018-08-22  7:20 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox