]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
If we fail to send a packet, remove the interface from consideration.
authorRoy Marples <roy@marples.name>
Thu, 4 Sep 2008 09:43:52 +0000 (09:43 +0000)
committerRoy Marples <roy@marples.name>
Thu, 4 Sep 2008 09:43:52 +0000 (09:43 +0000)
dhcpcd.c

index 6601aa3d224d82f1a013c504f388e2b86a83fc67..1afa77a2b446582395128d1f401f1f9748a9eb0f 100644 (file)
--- 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