summaryrefslogtreecommitdiffstats
path: root/dhcpcd.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-09-04 09:43:52 +0000
committerRoy Marples <roy@marples.name>2008-09-04 09:43:52 +0000
commit4570862e65882adb2b2b60e45b6ba7e6dec21229 (patch)
treea63beba81ebd7dbd3873084fdd6cdc88fab8bc9c /dhcpcd.c
parent87987af44e93241523279315ae75df6b40587531 (diff)
downloaddhcpcd-4570862e65882adb2b2b60e45b6ba7e6dec21229.tar.xz
If we fail to send a packet, remove the interface from consideration.
Diffstat (limited to 'dhcpcd.c')
-rw-r--r--dhcpcd.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/dhcpcd.c b/dhcpcd.c
index 6601aa3d..1afa77a2 100644
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -191,6 +191,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