Set this state so when we preserve config on carrier loss.
This allows us to remove config if the interface is then brought down.
if (!callback) {
/* No carrier? Don't bother sending the packet. */
- if (ifp->carrier == LINK_DOWN)
+ if (ifp->carrier <= LINK_DOWN)
return;
logdebugx("%s: sending %s with xid 0x%x",
ifp->name,
timespecnorm(&tv);
/* No carrier? Don't bother sending the packet.
* However, we do need to advance the timeout. */
- if (ifp->carrier == LINK_DOWN)
+ if (ifp->carrier <= LINK_DOWN)
goto fail;
logdebugx("%s: sending %s (xid 0x%x), next in %0.1f seconds",
ifp->name,
dhcp_drop(ifp, "EXPIRE");
unlink(state->leasefile);
state->interval = 0;
- if (!(ifp->options->options & DHCPCD_LINK) || ifp->carrier != LINK_DOWN)
+ if (!(ifp->options->options & DHCPCD_LINK) || ifp->carrier > LINK_DOWN)
dhcp_discover(ifp);
}
state->state = DHS_REBOOT;
state->interval = 0;
- if (ifo->options & DHCPCD_LINK && ifp->carrier == LINK_DOWN) {
+ if (ifo->options & DHCPCD_LINK && ifp->carrier <= LINK_DOWN) {
loginfox("%s: waiting for carrier", ifp->name);
return;
}
state->state = DHS_RELEASE;
unlink(state->leasefile);
- if (ifp->carrier != LINK_DOWN &&
+ if (ifp->carrier > LINK_DOWN &&
state->new != NULL &&
state->lease.server.s_addr != INADDR_ANY)
{
struct ipv6_addr *lla;
int s;
- if (!callback && ifp->carrier == LINK_DOWN)
+ if (!callback && ifp->carrier <= LINK_DOWN)
return 0;
memset(&dst, 0, sizeof(dst));
}
logsend:
- if (ifp->carrier != LINK_DOWN)
+ if (ifp->carrier > LINK_DOWN)
logdebugx("%s: %s %s (xid 0x%02x%02x%02x),"
" next in %0.1f seconds",
ifp->name,
}
}
- if (ifp->carrier == LINK_DOWN)
+ if (ifp->carrier <= LINK_DOWN)
return 0;
/* Update the elapsed time */
if (ifp->carrier != LINK_DOWN) {
if (ifp->carrier == LINK_UP)
loginfox("%s: carrier lost", ifp->name);
- ifp->carrier = LINK_DOWN;
+#ifdef NOCARRIER_PRESERVE_IP
+ if (ifp->flags & IFF_UP)
+ ifp->carrier = LINK_DOWN_IFFUP;
+ else
+#endif
+ ifp->carrier = LINK_DOWN;
script_runreason(ifp, "NOCARRIER");
#ifdef NOCARRIER_PRESERVE_IP
+ if (ifp->flags & IFF_UP) {
#ifdef ARP
- arp_drop(ifp);
+ arp_drop(ifp);
#endif
#ifdef INET
- dhcp_abort(ifp);
+ dhcp_abort(ifp);
#endif
#ifdef INET6
- ipv6nd_expire(ifp, 0);
+ ipv6nd_expire(ifp, 0);
#endif
#ifdef DHCP6
- dhcp6_abort(ifp);
+ dhcp6_abort(ifp);
#endif
-#else
- dhcpcd_drop(ifp, 0);
+ } else
#endif
+ dhcpcd_drop(ifp, 0);
}
} else if (carrier == LINK_UP && ifp->flags & IFF_UP) {
if (ifp->carrier != LINK_UP) {
#define IF_ACTIVE 1
#define IF_ACTIVE_USER 2
-#define LINK_UP 1
-#define LINK_UNKNOWN 0
-#define LINK_DOWN -1
+#define LINK_UP 1
+#define LINK_UNKNOWN 0
+#define LINK_DOWN -1
+#define LINK_DOWN_IFFUP -2
#define IF_DATA_IPV4 0
#define IF_DATA_ARP 1
struct in6_pktinfo pi;
const struct rs_state *state = RS_CSTATE(ifp);
- if (state == NULL || ifp->carrier == LINK_DOWN)
+ if (state == NULL || ifp->carrier <= LINK_DOWN)
goto freeit;
memset(&dst, 0, sizeof(dst));
iaf = NULL;
TAILQ_FOREACH(ifp, ctx->ifaces, next) {
state = IPV6_STATE(ifp);
- if (state == NULL || ifp->carrier == LINK_DOWN)
+ if (state == NULL || ifp->carrier <= LINK_DOWN)
continue;
TAILQ_FOREACH(iap, &state->addrs, next) {
reason = "CARRIER";
break;
case LINK_DOWN:
+ case LINK_DOWN_IFFUP:
reason = "NOCARRIER";
break;
default: