router: close socket upon NETEV_IFINDEX_CHANGE
authorKoen Aerts <aertskoen5@gmail.com>
Tue, 13 Aug 2019 13:02:19 +0000 (15:02 +0200)
committerHans Dedecker <dedeckeh@gmail.com>
Wed, 14 Aug 2019 21:06:40 +0000 (23:06 +0200)
Make sure the socket is closed in a case where the bridge goes down
as a result of NO-CARRIER on the bridge.
If not present Router Discovery and Router Advertisement will break
permanently after the bridge went down.

Related to  https://github.com/openwrt/odhcpd/issues/135

Signed-off-by: Koen Aerts <aertskoen5@gmail.com>
src/router.c

index 13c9117b6dc3b5809689c8ad4e64afa4412f5c98..5d09a3a6e0aa4571f1bd33cce91df27dbb8115e5 100644 (file)
@@ -229,6 +229,11 @@ static void router_netevent_cb(unsigned long event, struct netevent_handler_info
        struct interface *iface;
 
        switch (event) {
+       case NETEV_IFINDEX_CHANGE:
+               iface = info->iface;
+               if (iface && iface->router_event.uloop.fd >= 0)
+                       close(iface->router_event.uloop.fd);
+               break;
        case NETEV_ROUTE6_ADD:
        case NETEV_ROUTE6_DEL:
                if (info->rt.dst_len)