Update to dhcpcd-9.4.0 with the following changes:
* DHCP: For anonymous, just use a generic ClientID * link: Split hardware address randomisation out of anonymous option * link: Only report hardware changes for active interfaces * link: Report errors obtaining recv buffer size on overflow * hooks: Add NOCARRIER_ROAMING reason * hooks: interface_order now reflects priorities again
This commit is contained in:
parent
ee4e0574e8
commit
c9893f654b
|
@ -7,9 +7,15 @@
|
|||
# or dnsmasq. This is important as the libc resolver isn't that powerful.
|
||||
|
||||
resolv_conf_dir="$state_dir/resolv.conf"
|
||||
nocarrier_roaming_dir="$state_dir/roaming"
|
||||
NL="
|
||||
"
|
||||
: ${resolvconf:=resolvconf}
|
||||
if type "$resolvconf" >/dev/null 2>&1; then
|
||||
have_resolvconf=true
|
||||
else
|
||||
have_resolvconf=false
|
||||
fi
|
||||
|
||||
build_resolv_conf()
|
||||
{
|
||||
|
@ -164,7 +170,7 @@ add_resolv_conf()
|
|||
for x in ${new_domain_name_servers}; do
|
||||
conf="${conf}nameserver $x$NL"
|
||||
done
|
||||
if type "$resolvconf" >/dev/null 2>&1; then
|
||||
if $have_resolvconf; then
|
||||
[ -n "$ifmetric" ] && export IF_METRIC="$ifmetric"
|
||||
printf %s "$conf" | "$resolvconf" -a "$ifname"
|
||||
return $?
|
||||
|
@ -180,7 +186,7 @@ add_resolv_conf()
|
|||
|
||||
remove_resolv_conf()
|
||||
{
|
||||
if type "$resolvconf" >/dev/null 2>&1; then
|
||||
if $have_resolvconf; then
|
||||
"$resolvconf" -d "$ifname" -f
|
||||
else
|
||||
if [ -e "$resolv_conf_dir/$ifname" ]; then
|
||||
|
@ -199,7 +205,18 @@ BOUND6|RENEW6|REBIND6|REBOOT6|INFORM6)
|
|||
esac
|
||||
|
||||
if $if_configured; then
|
||||
if $if_up || [ "$reason" = ROUTERADVERT ]; then
|
||||
if $have_resolvconf && [ "$reason" = NOCARRIER_ROAMING ]; then
|
||||
# avoid calling resolvconf -c on CARRIER unless we roam
|
||||
mkdir -p "$nocarrier_roaming_dir"
|
||||
echo " " >"$nocarrier_roaming_dir/$interface"
|
||||
"$resolvconf" -C "$interface.*"
|
||||
elif $have_resolvconf && [ "$reason" = CARRIER ]; then
|
||||
# Not all resolvconf implementations support -c
|
||||
if [ -e "$nocarrier_roaming_dir/$interface" ]; then
|
||||
rm -f "$nocarrier_roaming_dir/$interface"
|
||||
"$resolvconf" -c "$interface.*"
|
||||
fi
|
||||
elif $if_up || [ "$reason" = ROUTERADVERT ]; then
|
||||
add_resolv_conf
|
||||
elif $if_down; then
|
||||
remove_resolv_conf
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd May 24, 2020
|
||||
.Dd December 27, 2020
|
||||
.Dt DHCPCD-RUN-HOOKS 8
|
||||
.Os
|
||||
.Sh NAME
|
||||
|
@ -92,6 +92,9 @@ This is generally just a notification and no action need be taken.
|
|||
.It Dv NOCARRIER
|
||||
dhcpcd lost the carrier.
|
||||
The cable may have been unplugged or association to the wireless point lost.
|
||||
.It Dv NOCARRIER_ROAMING
|
||||
dhcpcd lost the carrier but the interface configuration is persisted.
|
||||
The OS has to support wireless roaming or IP Persistance for this to happen.
|
||||
.It Dv INFORM | Dv INFORM6
|
||||
dhcpcd informed a DHCP server about its address and obtained other
|
||||
configuration details.
|
||||
|
@ -147,10 +150,6 @@ will clear the environment variables aside from
|
|||
The following variables will then be set, along with any protocol supplied
|
||||
ones.
|
||||
.Bl -tag -width xnew_delegated_dhcp6_prefix
|
||||
.It Ev $chroot
|
||||
the directory where
|
||||
.Nm dhcpcd
|
||||
is chrooted.
|
||||
.It Ev $interface
|
||||
the name of the interface.
|
||||
.It Ev $protocol
|
||||
|
@ -193,12 +192,14 @@ if the
|
|||
.Ev interface
|
||||
is up, otherwise
|
||||
.Dv false .
|
||||
This is more than IFF_UP and may not be equal.
|
||||
.It Ev $if_down
|
||||
.Dv true
|
||||
if the
|
||||
.Ev interface
|
||||
is down, otherwise
|
||||
.Dv false .
|
||||
This is more than IFF_UP and may not be equal.
|
||||
.It Ev $af_waiting
|
||||
Address family waiting for, as defined in
|
||||
.Xr dhcpcd.conf 5 .
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#define CONFIG_H
|
||||
|
||||
#define PACKAGE "dhcpcd"
|
||||
#define VERSION "9.3.4"
|
||||
#define VERSION "9.4.0"
|
||||
|
||||
#ifndef PRIVSEP_USER
|
||||
# define PRIVSEP_USER "_" PACKAGE
|
||||
|
|
|
@ -3886,20 +3886,9 @@ dhcp_init(struct interface *ifp)
|
|||
state->clientid = NULL;
|
||||
|
||||
if (ifo->options & DHCPCD_ANONYMOUS) {
|
||||
uint8_t duid[DUID_LEN];
|
||||
uint8_t duid_len;
|
||||
|
||||
duid_len = (uint8_t)duid_make(duid, ifp, DUID_LL);
|
||||
if (duid_len != 0) {
|
||||
state->clientid = malloc((size_t)duid_len + 6);
|
||||
if (state->clientid == NULL)
|
||||
goto eexit;
|
||||
state->clientid[0] =(uint8_t)(duid_len + 5);
|
||||
state->clientid[1] = 255; /* RFC 4361 */
|
||||
memcpy(state->clientid + 2, ifo->iaid, 4);
|
||||
memset(state->clientid + 2, 0, 4); /* IAID */
|
||||
memcpy(state->clientid + 6, duid, duid_len);
|
||||
}
|
||||
/* Removing the option could show that we want anonymous.
|
||||
* As such keep it as it's already in the hwaddr field. */
|
||||
goto make_clientid;
|
||||
} else if (*ifo->clientid) {
|
||||
state->clientid = malloc((size_t)(ifo->clientid[0] + 1));
|
||||
if (state->clientid == NULL)
|
||||
|
@ -3917,6 +3906,7 @@ dhcp_init(struct interface *ifp)
|
|||
memcpy(state->clientid + 6, ifp->ctx->duid,
|
||||
ifp->ctx->duid_len);
|
||||
} else {
|
||||
make_clientid:
|
||||
len = (uint8_t)(ifp->hwlen + 1);
|
||||
state->clientid = malloc((size_t)len + 1);
|
||||
if (state->clientid == NULL)
|
||||
|
|
|
@ -2065,7 +2065,8 @@ dhcp6_checkstatusok(const struct interface *ifp,
|
|||
state->lerror = code;
|
||||
errno = 0;
|
||||
|
||||
if (code != 0 && ifp->ctx->options & DHCPCD_TEST)
|
||||
/* code cannot be D6_STATUS_OK, so there is a failure */
|
||||
if (ifp->ctx->options & DHCPCD_TEST)
|
||||
eloop_exit(ifp->ctx->eloop, EXIT_FAILURE);
|
||||
|
||||
return (int)code;
|
||||
|
|
|
@ -695,36 +695,55 @@ dhcpcd_reportssid(struct interface *ifp)
|
|||
loginfox("%s: connected to Access Point: %s", ifp->name, pssid);
|
||||
}
|
||||
|
||||
static void
|
||||
dhcpcd_nocarrier_roaming(struct interface *ifp)
|
||||
{
|
||||
|
||||
loginfox("%s: carrier lost - roaming", ifp->name);
|
||||
|
||||
#ifdef ARP
|
||||
arp_drop(ifp);
|
||||
#endif
|
||||
#ifdef INET
|
||||
dhcp_abort(ifp);
|
||||
#endif
|
||||
#ifdef DHCP6
|
||||
dhcp6_abort(ifp);
|
||||
#endif
|
||||
|
||||
rt_build(ifp->ctx, AF_UNSPEC);
|
||||
script_runreason(ifp, "NOCARRIER_ROAMING");
|
||||
}
|
||||
|
||||
void
|
||||
dhcpcd_handlecarrier(struct interface *ifp, int carrier, unsigned int flags)
|
||||
{
|
||||
bool was_link_up = if_is_link_up(ifp);
|
||||
bool was_roaming = if_roaming(ifp);
|
||||
|
||||
ifp->carrier = carrier;
|
||||
ifp->flags = flags;
|
||||
|
||||
if (!if_is_link_up(ifp)) {
|
||||
if (!was_link_up || !ifp->active)
|
||||
if (!ifp->active || (!was_link_up && !was_roaming))
|
||||
return;
|
||||
|
||||
/*
|
||||
* If the interface is roaming (generally on wireless)
|
||||
* then while we are not up, we are not down either.
|
||||
* Preserve the network state until we either disconnect
|
||||
* or re-connect.
|
||||
*/
|
||||
if (!ifp->options->randomise_hwaddr && if_roaming(ifp)) {
|
||||
dhcpcd_nocarrier_roaming(ifp);
|
||||
return;
|
||||
}
|
||||
|
||||
loginfox("%s: carrier lost", ifp->name);
|
||||
script_runreason(ifp, "NOCARRIER");
|
||||
#ifdef NOCARRIER_PRESERVE_IP
|
||||
if (ifp->flags & IFF_UP &&
|
||||
!(ifp->options->options & DHCPCD_ANONYMOUS))
|
||||
{
|
||||
#ifdef ARP
|
||||
arp_drop(ifp);
|
||||
#endif
|
||||
#ifdef INET
|
||||
dhcp_abort(ifp);
|
||||
#endif
|
||||
#ifdef DHCP6
|
||||
dhcp6_abort(ifp);
|
||||
#endif
|
||||
} else
|
||||
#endif
|
||||
dhcpcd_drop(ifp, 0);
|
||||
if (ifp->options->options & DHCPCD_ANONYMOUS) {
|
||||
dhcpcd_drop(ifp, 0);
|
||||
|
||||
if (ifp->options->randomise_hwaddr) {
|
||||
bool is_up = ifp->flags & IFF_UP;
|
||||
|
||||
if (is_up)
|
||||
|
@ -734,6 +753,7 @@ dhcpcd_handlecarrier(struct interface *ifp, int carrier, unsigned int flags)
|
|||
if (is_up)
|
||||
if_up(ifp);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -774,9 +794,7 @@ dhcpcd_handlecarrier(struct interface *ifp, int carrier, unsigned int flags)
|
|||
memcmp(ifp->ssid, ossid, ifp->ssid_len)) && ifp->active)
|
||||
{
|
||||
dhcpcd_reportssid(ifp);
|
||||
#ifdef NOCARRIER_PRESERVE_IP
|
||||
dhcpcd_drop(ifp, 0);
|
||||
#endif
|
||||
#ifdef IPV4LL
|
||||
ipv4ll_reset(ifp);
|
||||
#endif
|
||||
|
@ -788,17 +806,17 @@ dhcpcd_handlecarrier(struct interface *ifp, int carrier, unsigned int flags)
|
|||
|
||||
dhcpcd_initstate(ifp, 0);
|
||||
script_runreason(ifp, "CARRIER");
|
||||
|
||||
#ifdef INET6
|
||||
#ifdef NOCARRIER_PRESERVE_IP
|
||||
/* Set any IPv6 Routers we remembered to expire faster than they
|
||||
* would normally as we maybe on a new network. */
|
||||
ipv6nd_startexpire(ifp);
|
||||
#endif
|
||||
#ifdef IPV6_MANAGETEMPADDR
|
||||
/* RFC4941 Section 3.5 */
|
||||
ipv6_regentempaddrs(ifp);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
dhcpcd_startinterface(ifp);
|
||||
}
|
||||
|
||||
|
@ -951,22 +969,22 @@ dhcpcd_prestartinterface(void *arg)
|
|||
{
|
||||
struct interface *ifp = arg;
|
||||
struct dhcpcd_ctx *ctx = ifp->ctx;
|
||||
bool anondown;
|
||||
bool randmac_down;
|
||||
|
||||
if (ifp->carrier <= LINK_DOWN &&
|
||||
ifp->options->options & DHCPCD_ANONYMOUS &&
|
||||
ifp->options->randomise_hwaddr &&
|
||||
ifp->flags & IFF_UP)
|
||||
{
|
||||
if_down(ifp);
|
||||
anondown = true;
|
||||
randmac_down = true;
|
||||
} else
|
||||
anondown = false;
|
||||
randmac_down = false;
|
||||
|
||||
if ((!(ctx->options & DHCPCD_MASTER) ||
|
||||
ifp->options->options & DHCPCD_IF_UP || anondown) &&
|
||||
ifp->options->options & DHCPCD_IF_UP || randmac_down) &&
|
||||
!(ifp->flags & IFF_UP))
|
||||
{
|
||||
if (ifp->options->options & DHCPCD_ANONYMOUS &&
|
||||
if (ifp->options->randomise_hwaddr &&
|
||||
if_randomisemac(ifp) == -1)
|
||||
logerr(__func__);
|
||||
if (if_up(ifp) == -1)
|
||||
|
@ -1161,8 +1179,10 @@ dhcpcd_linkoverflow(struct dhcpcd_ctx *ctx)
|
|||
|
||||
socklen = sizeof(rcvbuflen);
|
||||
if (getsockopt(ctx->link_fd, SOL_SOCKET,
|
||||
SO_RCVBUF, &rcvbuflen, &socklen) == -1)
|
||||
SO_RCVBUF, &rcvbuflen, &socklen) == -1) {
|
||||
logerr("%s: getsockopt", __func__);
|
||||
rcvbuflen = 0;
|
||||
}
|
||||
#ifdef __linux__
|
||||
else
|
||||
rcvbuflen /= 2;
|
||||
|
@ -1239,8 +1259,9 @@ dhcpcd_handlehwaddr(struct interface *ifp,
|
|||
}
|
||||
|
||||
if (ifp->hwtype != hwtype) {
|
||||
loginfox("%s: hardware address type changed from %d to %d",
|
||||
ifp->name, ifp->hwtype, hwtype);
|
||||
if (ifp->active)
|
||||
loginfox("%s: hardware address type changed"
|
||||
" from %d to %d", ifp->name, ifp->hwtype, hwtype);
|
||||
ifp->hwtype = hwtype;
|
||||
}
|
||||
|
||||
|
@ -1248,8 +1269,12 @@ dhcpcd_handlehwaddr(struct interface *ifp,
|
|||
(hwlen == 0 || memcmp(ifp->hwaddr, hwaddr, hwlen) == 0))
|
||||
return;
|
||||
|
||||
loginfox("%s: new hardware address: %s", ifp->name,
|
||||
hwaddr_ntoa(hwaddr, hwlen, buf, sizeof(buf)));
|
||||
if (ifp->active) {
|
||||
loginfox("%s: old hardware address: %s", ifp->name,
|
||||
hwaddr_ntoa(ifp->hwaddr, ifp->hwlen, buf, sizeof(buf)));
|
||||
loginfox("%s: new hardware address: %s", ifp->name,
|
||||
hwaddr_ntoa(hwaddr, hwlen, buf, sizeof(buf)));
|
||||
}
|
||||
ifp->hwlen = hwlen;
|
||||
if (hwaddr != NULL)
|
||||
memcpy(ifp->hwaddr, hwaddr, hwlen);
|
||||
|
@ -2257,10 +2282,10 @@ printpidfile:
|
|||
if (ctx.stdin_valid && freopen(_PATH_DEVNULL, "w", stdin) == NULL)
|
||||
logwarn("freopen stdin");
|
||||
|
||||
#if defined(USE_SIGNALS) && !defined(THERE_IS_NO_FORK)
|
||||
if (!(ctx.options & DHCPCD_DAEMONISE))
|
||||
goto start_master;
|
||||
|
||||
#if defined(USE_SIGNALS) && !defined(THERE_IS_NO_FORK)
|
||||
if (xsocketpair(AF_UNIX, SOCK_DGRAM | SOCK_CXNB, 0, fork_fd) == -1 ||
|
||||
(ctx.stderr_valid &&
|
||||
xsocketpair(AF_UNIX, SOCK_DGRAM | SOCK_CXNB, 0, stderr_fd) == -1))
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd November 25, 2020
|
||||
.Dd December 27, 2020
|
||||
.Dt DHCPCD.CONF 5
|
||||
.Os
|
||||
.Sh NAME
|
||||
|
@ -61,9 +61,7 @@ which is a space or comma separated list of patterns passed to
|
|||
.Xr fnmatch 3 .
|
||||
.It Ic anonymous
|
||||
Enables Anonymity Profiles for DHCP, RFC 7844.
|
||||
This implementation forces a hardware address randomisaton when
|
||||
the interface link is down and that ClientID's are only LL.
|
||||
Any DUID is ignored.
|
||||
Any DUID is ignored and ClientID is set to LL only.
|
||||
All non essential options are then masked at this point,
|
||||
but they could be unmasked by explicitly requesting the option
|
||||
.Sy after
|
||||
|
@ -79,6 +77,10 @@ send something which could identify you.
|
|||
.Nm dhcpcd
|
||||
will not try and reboot an old lease, it will go straight into
|
||||
DISCOVER/SOLICIT.
|
||||
.It Ic randomise_hwaddr
|
||||
Forces a hardware address randomisation when the interface is brought up
|
||||
or when the carrier is lost.
|
||||
This is generally used in tandem with the anonymous option.
|
||||
.It Ic arping Ar address Op address
|
||||
.Nm dhcpcd
|
||||
will arping each address in order before attempting DHCP.
|
||||
|
|
|
@ -410,6 +410,21 @@ if_carrier(struct interface *ifp, const void *ifadata)
|
|||
return LINK_DOWN;
|
||||
}
|
||||
|
||||
bool
|
||||
if_roaming(struct interface *ifp)
|
||||
{
|
||||
|
||||
/* Check for NetBSD as a safety measure.
|
||||
* If other BSD's gain IN_IFF_TENTATIVE check they re-do DAD
|
||||
* when the carrier comes up again. */
|
||||
#if defined(IN_IFF_TENTATIVE) && defined(__NetBSD__)
|
||||
return ifp->flags & IFF_UP && ifp->carrier == LINK_DOWN;
|
||||
#else
|
||||
UNUSED(ifp);
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
if_linkaddr(struct sockaddr_dl *sdl, const struct interface *ifp)
|
||||
{
|
||||
|
|
|
@ -120,6 +120,7 @@ const struct option cf_options[] = {
|
|||
{"ipv4only", no_argument, NULL, '4'},
|
||||
{"ipv6only", no_argument, NULL, '6'},
|
||||
{"anonymous", no_argument, NULL, O_ANONYMOUS},
|
||||
{"randomise_hwaddr",no_argument, NULL, O_RANDOMISE_HWADDR},
|
||||
{"arping", required_argument, NULL, O_ARPING},
|
||||
{"destination", required_argument, NULL, O_DESTINATION},
|
||||
{"fallback", required_argument, NULL, O_FALLBACK},
|
||||
|
@ -1303,6 +1304,9 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
|
|||
del_option_mask(ifo->nomask6, D6_OPTION_INF_MAX_RT);
|
||||
#endif
|
||||
|
||||
break;
|
||||
case O_RANDOMISE_HWADDR:
|
||||
ifo->randomise_hwaddr = true;
|
||||
break;
|
||||
#ifdef INET
|
||||
case O_ARPING:
|
||||
|
|
|
@ -182,6 +182,7 @@
|
|||
#define O_MSUSERCLASS O_BASE + 49
|
||||
#define O_CONFIGURE O_BASE + 50
|
||||
#define O_NOCONFIGURE O_BASE + 51
|
||||
#define O_RANDOMISE_HWADDR O_BASE + 52
|
||||
|
||||
extern const struct option cf_options[];
|
||||
|
||||
|
@ -234,6 +235,7 @@ struct if_options {
|
|||
uint32_t timeout;
|
||||
uint32_t reboot;
|
||||
unsigned long long options;
|
||||
bool randomise_hwaddr;
|
||||
|
||||
struct in_addr req_addr;
|
||||
struct in_addr req_mask;
|
||||
|
|
|
@ -697,12 +697,11 @@ if_discover(struct dhcpcd_ctx *ctx, struct ifaddrs **ifaddrs,
|
|||
ifp->metric = (unsigned int)ifr.ifr_metric;
|
||||
if_getssid(ifp);
|
||||
#else
|
||||
/* We reserve the 100 range for virtual interfaces, if and when
|
||||
* we can work them out. */
|
||||
ifp->metric = 200 + ifp->index;
|
||||
/* Leave a low portion for user config */
|
||||
ifp->metric = RTMETRIC_BASE + ifp->index;
|
||||
if (if_getssid(ifp) != -1) {
|
||||
ifp->wireless = true;
|
||||
ifp->metric += 100;
|
||||
ifp->metric += RTMETRIC_WIRELESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -42,14 +42,6 @@
|
|||
* dhcpcd can poll it for the relevant flags periodically */
|
||||
#define IF_POLL_UP 100 /* milliseconds */
|
||||
|
||||
/* Some systems have in-built IPv4 DAD.
|
||||
* However, we need them to do DAD at carrier up as well. */
|
||||
#ifdef IN_IFF_TENTATIVE
|
||||
# ifdef __NetBSD__
|
||||
# define NOCARRIER_PRESERVE_IP
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Systems which handle 1 address per alias.
|
||||
* Currenly this is just Solaris.
|
||||
|
@ -161,6 +153,7 @@ int if_domtu(const struct interface *, short int);
|
|||
#define if_getmtu(ifp) if_domtu((ifp), 0)
|
||||
#define if_setmtu(ifp, mtu) if_domtu((ifp), (mtu))
|
||||
int if_carrier(struct interface *, const void *);
|
||||
bool if_roaming(struct interface *);
|
||||
|
||||
#ifdef ALIAS_ADDR
|
||||
int if_makealias(char *, size_t, const char *, int);
|
||||
|
|
|
@ -137,7 +137,7 @@ ipv4ll_defaultroute(rb_tree_t *routes, struct interface *ifp)
|
|||
sa_in_init(&rt->rt_ifa, &state->addr->addr);
|
||||
rt->rt_dflags |= RTDF_IPV4LL;
|
||||
#ifdef HAVE_ROUTE_METRIC
|
||||
rt->rt_metric += 10000;
|
||||
rt->rt_metric += RTMETRIC_IPV4LL;
|
||||
#endif
|
||||
return rt_proto_add(routes, rt) ? 1 : 0;
|
||||
}
|
||||
|
|
|
@ -1155,7 +1155,6 @@ ipv6nd_handlera(struct dhcpcd_ctx *ctx,
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef NOCARRIER_PRESERVE_IP
|
||||
/*
|
||||
* Because we preserve RA's and expire them quickly after
|
||||
* carrier up, it's important to reset the kernels notion of
|
||||
|
@ -1168,7 +1167,6 @@ ipv6nd_handlera(struct dhcpcd_ctx *ctx,
|
|||
}
|
||||
if (rap != NULL && rap->willexpire)
|
||||
ipv6nd_applyra(ifp);
|
||||
#endif
|
||||
|
||||
TAILQ_FOREACH(rap, ctx->ra_routers, next) {
|
||||
if (ifp == rap->iface &&
|
||||
|
|
|
@ -73,7 +73,8 @@ ps_bpf_recvbpf(void *arg)
|
|||
if (len == -1) {
|
||||
int error = errno;
|
||||
|
||||
logerr("%s: %s", psp->psp_ifname, __func__);
|
||||
if (errno != ENETDOWN)
|
||||
logerr("%s: %s", psp->psp_ifname, __func__);
|
||||
if (error != ENXIO)
|
||||
break;
|
||||
/* If the interface has departed, close the BPF
|
||||
|
|
|
@ -581,7 +581,9 @@ ps_mastersandbox(struct dhcpcd_ctx *ctx, const char *_pledge)
|
|||
}
|
||||
logerr("%s: %s", __func__, sandbox);
|
||||
return -1;
|
||||
} else if (ctx->options & DHCPCD_LAUNCHER)
|
||||
} else if (ctx->options & DHCPCD_LAUNCHER ||
|
||||
((!(ctx->options & DHCPCD_DAEMONISE)) &&
|
||||
ctx->options & DHCPCD_MASTER))
|
||||
logdebugx("sandbox: %s", sandbox);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -168,6 +168,15 @@ rt_compare_proto(void *context, const void *node1, const void *node2)
|
|||
if (c != 0)
|
||||
return -c;
|
||||
|
||||
/* Prefer roaming over non roaming if both carriers are down. */
|
||||
if (ifp1->carrier == LINK_DOWN && ifp2->carrier == LINK_DOWN) {
|
||||
bool roam1 = if_roaming(ifp1);
|
||||
bool roam2 = if_roaming(ifp2);
|
||||
|
||||
if (roam1 != roam2)
|
||||
return roam1 ? 1 : -1;
|
||||
}
|
||||
|
||||
#ifdef INET
|
||||
/* IPv4LL routes always come last */
|
||||
if (rt1->rt_dflags & RTDF_IPV4LL && !(rt2->rt_dflags & RTDF_IPV4LL))
|
||||
|
@ -374,6 +383,8 @@ rt_setif(struct rt *rt, struct interface *ifp)
|
|||
rt->rt_ifp = ifp;
|
||||
#ifdef HAVE_ROUTE_METRIC
|
||||
rt->rt_metric = ifp->metric;
|
||||
if (if_roaming(ifp))
|
||||
rt->rt_metric += RTMETRIC_ROAM;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -93,6 +93,15 @@ struct rt {
|
|||
#ifdef HAVE_ROUTE_METRIC
|
||||
unsigned int rt_metric;
|
||||
#endif
|
||||
/* Maximum interface index is generally USHORT_MAX or 65535.
|
||||
* Add some padding for other stuff and we get offsets for the
|
||||
* below that should work automatically.
|
||||
* This is only an issue if the user defines higher metrics in
|
||||
* their configuration, but then they might wish to override also. */
|
||||
#define RTMETRIC_BASE 1000U
|
||||
#define RTMETRIC_WIRELESS 2000U
|
||||
#define RTMETRIC_IPV4LL 1000000U
|
||||
#define RTMETRIC_ROAM 2000000U
|
||||
#ifdef HAVE_ROUTE_PREF
|
||||
int rt_pref;
|
||||
#endif
|
||||
|
|
|
@ -74,6 +74,9 @@ static const char * const if_params[] = {
|
|||
NULL
|
||||
};
|
||||
|
||||
static const char * true_str = "true";
|
||||
static const char * false_str = "false";
|
||||
|
||||
void
|
||||
if_printoptions(void)
|
||||
{
|
||||
|
@ -228,6 +231,10 @@ make_env(struct dhcpcd_ctx *ctx, const struct interface *ifp,
|
|||
const struct if_options *ifo;
|
||||
const struct interface *ifp2;
|
||||
int af;
|
||||
bool is_stdin = ifp->name[0] == '\0';
|
||||
const char *if_up, *if_down;
|
||||
rb_tree_t ifaces;
|
||||
struct rt *rt;
|
||||
#ifdef INET
|
||||
const struct dhcp_state *state;
|
||||
#ifdef IPV4LL
|
||||
|
@ -237,7 +244,6 @@ make_env(struct dhcpcd_ctx *ctx, const struct interface *ifp,
|
|||
#ifdef DHCP6
|
||||
const struct dhcp6_state *d6_state;
|
||||
#endif
|
||||
bool is_stdin = ifp->name[0] == '\0';
|
||||
|
||||
#ifdef HAVE_OPEN_MEMSTREAM
|
||||
if (ctx->script_fp == NULL) {
|
||||
|
@ -276,6 +282,7 @@ make_env(struct dhcpcd_ctx *ctx, const struct interface *ifp,
|
|||
if (efprintf(fp, "pid=%d", getpid()) == -1)
|
||||
goto eexit;
|
||||
}
|
||||
|
||||
if (!is_stdin) {
|
||||
if (efprintf(fp, "reason=%s", reason) == -1)
|
||||
goto eexit;
|
||||
|
@ -326,6 +333,7 @@ make_env(struct dhcpcd_ctx *ctx, const struct interface *ifp,
|
|||
else if (strcmp(reason, "PREINIT") == 0 ||
|
||||
strcmp(reason, "CARRIER") == 0 ||
|
||||
strcmp(reason, "NOCARRIER") == 0 ||
|
||||
strcmp(reason, "NOCARRIER_ROAMING") == 0 ||
|
||||
strcmp(reason, "UNKNOWN") == 0 ||
|
||||
strcmp(reason, "DEPARTED") == 0 ||
|
||||
strcmp(reason, "STOPPED") == 0)
|
||||
|
@ -382,34 +390,45 @@ make_env(struct dhcpcd_ctx *ctx, const struct interface *ifp,
|
|||
if (ifp->ctx->options & DHCPCD_DUMPLEASE)
|
||||
goto dumplease;
|
||||
|
||||
rb_tree_init(&ifaces, &rt_compare_proto_ops);
|
||||
TAILQ_FOREACH(ifp2, ifp->ctx->ifaces, next) {
|
||||
if (!ifp2->active)
|
||||
continue;
|
||||
rt = rt_new(UNCONST(ifp2));
|
||||
if (rt == NULL)
|
||||
goto eexit;
|
||||
if (rb_tree_insert_node(&ifaces, rt) != rt)
|
||||
goto eexit;
|
||||
}
|
||||
if (fprintf(fp, "interface_order=") == -1)
|
||||
goto eexit;
|
||||
TAILQ_FOREACH(ifp2, ifp->ctx->ifaces, next) {
|
||||
if (ifp2 != TAILQ_FIRST(ifp->ctx->ifaces)) {
|
||||
if (fputc(' ', fp) == EOF)
|
||||
return -1;
|
||||
}
|
||||
if (fprintf(fp, "%s", ifp2->name) == -1)
|
||||
return -1;
|
||||
RB_TREE_FOREACH(rt, &ifaces) {
|
||||
if (rt != RB_TREE_MIN(&ifaces) &&
|
||||
fprintf(fp, "%s", " ") == -1)
|
||||
goto eexit;
|
||||
if (fprintf(fp, "%s", rt->rt_ifp->name) == -1)
|
||||
goto eexit;
|
||||
}
|
||||
rt_headclear(&ifaces, AF_UNSPEC);
|
||||
if (fputc('\0', fp) == EOF)
|
||||
return -1;
|
||||
goto eexit;
|
||||
|
||||
if (strcmp(reason, "STOPPED") == 0) {
|
||||
if (efprintf(fp, "if_up=false") == -1)
|
||||
goto eexit;
|
||||
if (efprintf(fp, "if_down=%s",
|
||||
ifo->options & DHCPCD_RELEASE ? "true" : "false") == -1)
|
||||
goto eexit;
|
||||
if_up = false_str;
|
||||
if_down = ifo->options & DHCPCD_RELEASE ? true_str : false_str;
|
||||
} else if (strcmp(reason, "TEST") == 0 ||
|
||||
strcmp(reason, "PREINIT") == 0 ||
|
||||
strcmp(reason, "CARRIER") == 0 ||
|
||||
strcmp(reason, "UNKNOWN") == 0)
|
||||
{
|
||||
if (efprintf(fp, "if_up=false") == -1)
|
||||
goto eexit;
|
||||
if (efprintf(fp, "if_down=false") == -1)
|
||||
goto eexit;
|
||||
if_up = false_str;
|
||||
if_down = false_str;
|
||||
} else if (strcmp(reason, "NOCARRIER") == 0) {
|
||||
if_up = false_str;
|
||||
if_down = true_str;
|
||||
} else if (strcmp(reason, "NOCARRIER_ROAMING") == 0) {
|
||||
if_up = true_str;
|
||||
if_down = false_str;
|
||||
} else if (1 == 2 /* appease ifdefs */
|
||||
#ifdef INET
|
||||
|| (protocol == PROTO_DHCP && state && state->new)
|
||||
|
@ -426,16 +445,17 @@ make_env(struct dhcpcd_ctx *ctx, const struct interface *ifp,
|
|||
#endif
|
||||
)
|
||||
{
|
||||
if (efprintf(fp, "if_up=true") == -1)
|
||||
goto eexit;
|
||||
if (efprintf(fp, "if_down=false") == -1)
|
||||
goto eexit;
|
||||
if_up = true_str;
|
||||
if_down = false_str;
|
||||
} else {
|
||||
if (efprintf(fp, "if_up=false") == -1)
|
||||
goto eexit;
|
||||
if (efprintf(fp, "if_down=true") == -1)
|
||||
goto eexit;
|
||||
if_up = false_str;
|
||||
if_down = true_str;
|
||||
}
|
||||
if (efprintf(fp, "if_up=%s", if_up) == -1)
|
||||
goto eexit;
|
||||
if (efprintf(fp, "if_down=%s", if_down) == -1)
|
||||
goto eexit;
|
||||
|
||||
if ((af = dhcpcd_ifafwaiting(ifp)) != AF_MAX) {
|
||||
if (efprintf(fp, "if_afwaiting=%d", af) == -1)
|
||||
goto eexit;
|
||||
|
|
Loading…
Reference in New Issue