lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] Routing and link up/down vs. netif up/down


From: Fabian Koch
Subject: [lwip-users] Routing and link up/down vs. netif up/down
Date: Wed, 4 Jun 2014 12:30:52 +0000

Hey guys,

 

I ran into a problem and wonder if my solution is the right thing to do or if maybe LwIP should be changed:

 

I have two netifs and they are both in the same subnet.

When I create connections to other hosts on the net, they end up getting physically sent on the first netif because that is the first in the for loop in ip_route().

Now if I pull the plug on the second netif, all connections keep running, even the ones I bound to the IP of the second netif because the routing still is happy with finding the first netif as a match for the target.

All fine and dandy.

But when I pull the plug on netif one, all established connections no longer work and I also can’t establish new ones, because the ACKs are still tried to be sent out on the first netif in ip_route() because even though the link is down, the netif is still “up”, so lwip tries to send on that first one.

 

Now my solution is that I have a link_callback_fn that also sets netif_up() or netif_down() depending on how the link status changed and thus takes the netif “out of the routing” when its link is down.

 

Do you think it would make sense to also check for link down in ip_route() so that this scenario (which isn’t really routing when both interfaces are in the same subnet) does work?

 

  /* iterate through netifs */

  for (netif = netif_list; netif != NULL; netif = netif->next) {

    /* network mask matches? */

    if ((netif_is_up(netif) && netif_is_link_up(netif))

#if LWIP_IPV6

        /* prevent using IPv6-only interfaces */

        && (!ip_addr_isany(&(netif->ip_addr)))

#endif /* LWIP_IPV6 */

        ) {

      if (ip_addr_netcmp(dest, &(netif->ip_addr), &(netif->netmask))) {

        /* return netif on which to forward IP packet */

        return netif;

      }

    }

  }

 

Granted that this would probably mean that packets for a network where the link is down are then sent on the default route which might be total nonsense…

 

Any ideas/comments?

 

Kind regards,
Fabian


reply via email to

[Prev in Thread] Current Thread [Next in Thread]