{ 0, NULL }
};
+static void send_release(struct interface *);
+
static const char *
get_dhcp_op(uint8_t type)
{
}
}
+
static void
stop_interface(struct interface *iface, const char *reason)
{
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);
close_sockets(iface);
delete_timeout(NULL, iface);
for (ifp = ifaces; ifp; ifp = ifp->next) {
syslog(LOG_ERR, "%s: lease expired", iface->name);
delete_timeout(NULL, iface);
drop_config(iface, "EXPIRE");
+ unlink(iface->leasefile);
iface->state->interval = 0;
if (iface->carrier != LINK_DOWN) {
if (IN_LINKLOCAL(htonl(iface->state->lease.addr.s_addr)))
if (type == DHCP_NAK) {
log_dhcp(LOG_WARNING, "NAK:", iface, dhcp);
drop_config(iface, "EXPIRE");
+ unlink(iface->leasefile);
delete_event(iface->raw_fd);
close(iface->raw_fd);
iface->raw_fd = -1;
add_event(iface->raw_fd, handle_dhcp_packet, iface);
}
+static void
+send_release(struct interface *iface)
+{
+ if (iface->state->lease.addr.s_addr &&
+ !IN_LINKLOCAL(htonl(iface->state->lease.addr.s_addr)))
+ {
+ syslog(LOG_INFO, "%s: releasing lease of %s",
+ iface->name, inet_ntoa(iface->state->lease.addr));
+ open_sockets(iface);
+ send_message(iface, DHCP_RELEASE, NULL);
+ }
+}
+
static void
handle_carrier(const char *ifname)
{
send_request(iface);
}
-static void
-send_release(struct interface *iface)
-{
- if (iface->state->lease.addr.s_addr &&
- !IN_LINKLOCAL(htonl(iface->state->lease.addr.s_addr)))
- {
- syslog(LOG_INFO, "%s: releasing lease of %s",
- iface->name, inet_ntoa(iface->state->lease.addr));
- open_sockets(iface);
- send_message(iface, DHCP_RELEASE, NULL);
- }
-}
-
void
start_interface(void *arg)
{
ifl = iface;
if (!ifl)
break;
- if (do_release)
+ if (do_release || ifl->state->options->options & DHCPCD_RELEASE)
send_release(ifl);
if (!(ifl->state->options->options & DHCPCD_PERSISTENT))
drop_config(ifl, do_release ? "RELEASE" : "STOP");
+ if (do_release || ifl->state->options->options & DHCPCD_RELEASE)
+ unlink(ifl->leasefile);
}
exit(EXIT_FAILURE);
}
if (!ifp)
continue;
if (do_release)
- send_release(ifp);
+ ifp->state->options->options |= DHCPCD_RELEASE;
if (do_exit || do_release) {
stop_interface(ifp, do_release ? "RELEASE" : "STOP");
} else if (do_reboot) {