From: Roy Marples Date: Thu, 4 Sep 2008 09:43:52 +0000 (+0000) Subject: If we fail to send a packet, remove the interface from consideration. X-Git-Tag: v5.0.0~303 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4570862e65882adb2b2b60e45b6ba7e6dec21229;p=thirdparty%2Fdhcpcd.git If we fail to send a packet, remove the interface from consideration. --- diff --git a/dhcpcd.c b/dhcpcd.c index 6601aa3d..1afa77a2 100644 --- a/dhcpcd.c +++ b/dhcpcd.c @@ -190,6 +190,28 @@ close_sockets(struct interface *iface) } } +static void +stop_interface(struct interface *iface) +{ + struct interface *ifp, *ifl = NULL; + + drop_config(iface, "STOP"); + close_sockets(iface); + delete_timeout(NULL, iface); + for (ifp = ifaces; ifp; ifp = ifp->next) { + if (ifp == iface) + break; + ifl = ifp; + } + if (ifl) + ifl->next = iface->next; + else + ifaces = iface->next; + free_interface(ifp); + if (!master) + exit(EXIT_FAILURE); +} + static void send_message(struct interface *iface, int type, void (*callback)(void *)) @@ -249,8 +271,14 @@ send_message(struct interface *iface, int type, iface->name, strerror(errno)); } free(dhcp); - if (callback) - add_timeout_tv(&tv, callback, iface); + if (r == -1) { + logger(LOG_ERR, "%s: removing interface from dhcpcd", + iface->name); + stop_interface(iface); + } else { + if (callback) + add_timeout_tv(&tv, callback, iface); + } } static void