router: fix lingering uloop socket descriptor
authorHans Dedecker <dedeckeh@gmail.com>
Thu, 8 Aug 2019 19:42:15 +0000 (21:42 +0200)
committerHans Dedecker <dedeckeh@gmail.com>
Sat, 10 Aug 2019 08:13:18 +0000 (10:13 +0200)
In case setting one of the socket options fails; make sure the raw
socket is removed from the uloop file descriptor list before the
socket is closed.
In case this is not done and a new raw socket is created with the
same fd value odhcpd will not be triggered by uloop in case RS messages
are received on the socket as reported in https://github.com/openwrt/odhcpd/issues/135

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
src/router.c

index 63571a3f025623242a187b20c7944fd66d3aea1f..13c9117b6dc3b5809689c8ad4e64afa4412f5c98 100644 (file)
@@ -213,6 +213,9 @@ int router_setup_interface(struct interface *iface, bool enable)
        }
 out:
        if (ret < 0 && iface->router_event.uloop.fd >= 0) {
+               if (iface->router_event.uloop.registered)
+                       uloop_fd_delete(&iface->router_event.uloop);
+
                close(iface->router_event.uloop.fd);
                iface->router_event.uloop.fd = -1;
        }