start_interface(ifp);
}
-void
-dhcp_release(struct interface *ifp)
-{
- struct dhcp_state *state;
- struct timespec ts;
-
- state = D_STATE(ifp);
- if (state == NULL)
- return;
-
- if (state->new != NULL && state->new->cookie == htonl(MAGIC_COOKIE)) {
- syslog(LOG_INFO, "%s: releasing lease of %s",
- ifp->name, inet_ntoa(state->lease.addr));
- state->xid = dhcp_xid(ifp);
- send_message(ifp, DHCP_RELEASE, NULL);
- /* Give the packet a chance to go before dropping the ip */
- ts.tv_sec = RELEASE_DELAY_S;
- ts.tv_nsec = RELEASE_DELAY_NS;
- nanosleep(&ts, NULL);
- dhcp_drop(ifp, "RELEASE");
- }
- unlink(state->leasefile);
-}
-
void
dhcp_decline(struct interface *ifp)
{
}
void
-dhcp_drop(struct interface *iface, const char *reason)
+dhcp_drop(struct interface *ifp, const char *reason)
{
- struct dhcp_state *state = D_STATE(iface);
+ struct dhcp_state *state;
+#ifdef RELEASE_SLOW
+ struct timespec ts;
+#endif
+ state = D_STATE(ifp);
if (state == NULL)
return;
- eloop_timeouts_delete(iface, dhcp_expire, NULL);
- if (iface->options->options & DHCPCD_RELEASE)
+ eloop_timeouts_delete(ifp, dhcp_expire, NULL);
+ if (ifp->options->options & DHCPCD_RELEASE) {
unlink(state->leasefile);
+ if (ifp->carrier != LINK_DOWN &&
+ state->new != NULL &&
+ state->new->cookie == htonl(MAGIC_COOKIE))
+ {
+ syslog(LOG_INFO, "%s: releasing lease of %s",
+ ifp->name, inet_ntoa(state->lease.addr));
+ state->xid = dhcp_xid(ifp);
+ send_message(ifp, DHCP_RELEASE, NULL);
+#ifdef RELEASE_SLOW
+ /* Give the packet a chance to go */
+ ts.tv_sec = RELEASE_DELAY_S;
+ ts.tv_nsec = RELEASE_DELAY_NS;
+ nanosleep(&ts, NULL);
+#endif
+ }
+ }
free(state->old);
state->old = state->new;
state->new = NULL;
state->reason = reason;
- ipv4_applyaddr(iface);
+ ipv4_applyaddr(ifp);
free(state->old);
state->old = NULL;
state->lease.addr.s_addr = 0;
- iface->options->options &= ~ DHCPCD_CSR_WARNED;
+ ifp->options->options &= ~ DHCPCD_CSR_WARNED;
}
static void
void dhcp_decline(struct interface *);
void dhcp_discover(void *);
void dhcp_inform(struct interface *);
-void dhcp_release(struct interface *);
void dhcp_bind(void *);
void dhcp_reboot_newopts(struct interface *, int);
void dhcp_close(struct interface *);
#define dhcp_printoptions
#define dhcp_drop(a, b)
#define dhcp_start(a) {}
-#define dhcp_release(a) {}
#define dhcp_reboot(a, b) b = b
#define dhcp_close(a)
#define dhcp_free(a)
#include "script.h"
#include "signals.h"
-/* Wait N nanoseconds between sending a RELEASE and dropping the address.
- * This gives the kernel enough time to actually send it. */
-#define RELEASE_DELAY_S 0
-#define RELEASE_DELAY_NS 10000000
-
struct if_head *ifaces = NULL;
char vendor[VENDORCLASSID_MAX_LEN];
int pidfd = -1;
TAILQ_REMOVE(ifaces, ifp, next);
dhcp6_drop(ifp, NULL);
ipv6rs_drop(ifp);
-// if (strcmp(ifp->state->reason, "RELEASE") != 0)
- dhcp_drop(ifp, "STOP");
+ dhcp_drop(ifp, "STOP");
dhcp_close(ifp);
eloop_timeout_delete(NULL, ifp);
free_interface(ifp);
ifp = TAILQ_LAST(ifaces, if_head);
if (ifp == NULL)
break;
- if (ifp->carrier != LINK_DOWN &&
- (do_release ||
- ifp->options->options & DHCPCD_RELEASE))
- dhcp_release(ifp);
+ if (do_release)
+ ifp->options->options |= DHCPCD_RELEASE;
stop_interface(ifp);
}
exit(EXIT_FAILURE);
continue;
if (do_release)
ifp->options->options |= DHCPCD_RELEASE;
- if (ifp->options->options & DHCPCD_RELEASE &&
- ifp->carrier != LINK_DOWN)
- dhcp_release(ifp);
stop_interface(ifp);
}
return 0;