diff options
| author | Roy Marples <roy@marples.name> | 2008-09-04 09:43:52 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2008-09-04 09:43:52 +0000 |
| commit | 4570862e65882adb2b2b60e45b6ba7e6dec21229 (patch) | |
| tree | a63beba81ebd7dbd3873084fdd6cdc88fab8bc9c /dhcpcd.c | |
| parent | 87987af44e93241523279315ae75df6b40587531 (diff) | |
| download | dhcpcd-4570862e65882adb2b2b60e45b6ba7e6dec21229.tar.xz | |
If we fail to send a packet, remove the interface from consideration.
Diffstat (limited to 'dhcpcd.c')
| -rw-r--r-- | dhcpcd.c | 32 |
1 files changed, 30 insertions, 2 deletions
@@ -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 |
