static void
-stop_interface(struct interface *iface, const char *reason)
+stop_interface(struct interface *iface)
{
struct interface *ifp, *ifl = NULL;
syslog(LOG_INFO, "%s: removing interface", iface->name);
- if (iface->state->options->options & DHCPCD_RELEASE)
- send_release(iface);
- drop_config(iface, reason ? reason : "STOP");
- if (iface->state->options->options & DHCPCD_RELEASE)
- unlink(iface->leasefile);
+ if (strcmp(iface->state->reason, "RELEASE") != 0)
+ drop_config(iface, "STOP");
close_sockets(iface);
delete_timeout(NULL, iface);
for (ifp = ifaces; ifp; ifp = ifp->next) {
}
free(dhcp);
if (r == -1) {
- stop_interface(iface, "STOP");
+ stop_interface(iface);
} else {
if (callback)
add_timeout_tv(&tv, callback, iface);
iface->name, inet_ntoa(iface->state->lease.addr));
open_sockets(iface);
send_message(iface, DHCP_RELEASE, NULL);
+ drop_config(iface, "RELEASE");
}
}
configure_interface(iface, margc, margv);
}
iface->state->reason = "CARRIER";
- run_script(iface);
+ configure(iface);
start_interface(iface);
}
break;
ifs->nakoff = 1;
configure_interface(iface, argc, argv);
if (!(options & DHCPCD_TEST))
- run_script(iface);
+ configure(iface);
if (ifs->options->options & DHCPCD_LINK) {
switch (carrier_status(iface->name)) {
return;
}
if (!(options & DHCPCD_TEST))
- run_script(iface);
+ configure(iface);
} else
iface->carrier = LINK_UNKNOWN;
}
struct interface *iface;
for (iface = ifaces; iface; iface = iface->next)
- if (strcmp(iface->name, ifname) == 0)
+ if (strcmp(iface->name, ifname) == 0) {
+ stop_interface(iface);
break;
- if (iface && iface->state->options->options & DHCPCD_LINK)
- stop_interface(iface, "STOP");
+ }
}
/* ARGSUSED */
syslog(LOG_INFO, "received SIGHUP, releasing lease");
do_release = 1;
break;
+ case SIGPIPE:
+ syslog(LOG_WARNING, "received SIGPIPE");
+ return;
default:
syslog(LOG_ERR,
"received signal %d, but don't know what to do with it",
for (;;) {
/* Be sane and drop the last config first */
ifl = NULL;
- for (iface = ifaces; iface; iface = iface->next)
- if (iface->state && iface->state->new)
- ifl = iface;
- if (!ifl)
- break;
- if (do_release || ifl->state->options->options & DHCPCD_RELEASE)
- send_release(ifl);
- if ((ifl->state->options->options & DHCPCD_PERSISTENT)) {
- free(ifl->state->new);
- ifl->state->new = NULL;
- } else {
- drop_config(ifl, do_release ? "RELEASE" : "STOP");
+ for (iface = ifaces; iface; iface = iface->next) {
+ if (iface->next == NULL)
+ break;
+ ifl = iface;
}
- if (do_release || ifl->state->options->options & DHCPCD_RELEASE)
- unlink(ifl->leasefile);
+ if (iface == NULL)
+ break;
+ if (iface->carrier != LINK_DOWN &&
+ (do_release ||
+ iface->state->options->options & DHCPCD_RELEASE))
+ send_release(iface);
+ stop_interface(iface);
}
exit(EXIT_FAILURE);
}
continue;
if (do_release)
ifp->state->options->options |= DHCPCD_RELEASE;
- stop_interface(ifp, do_release ? "RELEASE" : "STOP");
+ if (ifp->state->options->options & DHCPCD_RELEASE &&
+ ifp->carrier != LINK_DOWN)
+ send_release(ifp);
+ stop_interface(ifp);
}
- sort_interfaces();
return 0;
}