From: Roy Marples Date: Wed, 1 Jul 2015 19:36:32 +0000 (+0000) Subject: If we load a saved lease we are trying to rebind, set ciaddr correctly. X-Git-Tag: v6.9.1~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=970661d30fc3cc2b540aa45b91caabc9871aec1a;p=thirdparty%2Fdhcpcd.git If we load a saved lease we are trying to rebind, set ciaddr correctly. --- diff --git a/dhcp.c b/dhcp.c index 80ca5962..f9fb4643 100644 --- a/dhcp.c +++ b/dhcp.c @@ -1660,31 +1660,26 @@ send_message(struct interface *ifp, uint8_t type, !(ia->addr_flags & IN_IFF_NOTUSEABLE)) && #endif (state->lease.server.s_addr || - ifp->options->options & DHCPCD_INFORM)) + ifp->options->options & DHCPCD_INFORM) && + !IS_BOOTP(ifp, state->new)) { s = dhcp_openudp(ifp); - if (s == -1 && errno != EADDRINUSE) - logger(ifp->ctx, LOG_ERR, - "%s: dhcp_openudp: %m", ifp->name); + if (s == -1) { + if (errno != EADDRINUSE) + logger(ifp->ctx, LOG_ERR, + "%s: dhcp_openudp: %m", ifp->name); + /* We cannot renew */ + a = state->addr.s_addr; + state->addr.s_addr = INADDR_ANY; + } } - /* If we couldn't open a UDP port for our IP address - * then we cannot renew. - * This could happen if our IP was pulled out from underneath us. - * Also, we should not unicast from a BOOTP lease. */ - if (s == -1 || - (!(ifo->options & DHCPCD_INFORM) && - IS_BOOTP(ifp, state->new))) - { - a = state->addr.s_addr; - state->addr.s_addr = INADDR_ANY; - } r = make_message(&dhcp, ifp, type); + if (a != INADDR_ANY) + state->addr.s_addr = a; if (r == -1) goto fail; len = (size_t)r; - if (a) - state->addr.s_addr = a; from.s_addr = dhcp->ciaddr; if (from.s_addr) to.s_addr = state->lease.server.s_addr; diff --git a/dhcp.h b/dhcp.h index 04d1df8a..daa4f560 100644 --- a/dhcp.h +++ b/dhcp.h @@ -243,7 +243,7 @@ void dhcp_printoptions(const struct dhcpcd_ctx *, const struct dhcp_opt *, size_t); int get_option_addr(struct dhcpcd_ctx *,struct in_addr *, const struct dhcp_message *, uint8_t); -#define IS_BOOTP(i, m) ((m) && \ +#define IS_BOOTP(i, m) ((m) != NULL && \ get_option_uint8((i)->ctx, NULL, (m), DHO_MESSAGETYPE) == -1) struct rt_head *get_option_routes(struct interface *, const struct dhcp_message *);