Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/bsd/dhcpcd/dist Sync with dhcpcd-9.3.3
details: https://anonhg.NetBSD.org/src/rev/a7f82629b48d
branches: trunk
changeset: 978374:a7f82629b48d
user: roy <roy%NetBSD.org@localhost>
date: Fri Nov 20 13:24:58 2020 +0000
description:
Sync with dhcpcd-9.3.3
diffstat:
external/bsd/dhcpcd/dist/hooks/20-resolv.conf | 10 +++--
external/bsd/dhcpcd/dist/hooks/50-ntp.conf | 10 +++--
external/bsd/dhcpcd/dist/hooks/50-ypbind.in | 4 +-
external/bsd/dhcpcd/dist/src/dhcp.c | 42 +++++++++++++++++++++++++-
external/bsd/dhcpcd/dist/src/dhcp6.c | 14 +++++++-
external/bsd/dhcpcd/dist/src/dhcpcd.8.in | 23 ++++++++++++++-
external/bsd/dhcpcd/dist/src/dhcpcd.c | 9 +++++-
external/bsd/dhcpcd/dist/src/if-options.c | 24 ++++++++++++++-
external/bsd/dhcpcd/dist/src/ipv6.c | 3 +
external/bsd/dhcpcd/dist/src/ipv6nd.c | 7 +++-
external/bsd/dhcpcd/dist/src/privsep.c | 9 +++--
external/bsd/dhcpcd/dist/src/script.c | 3 +
12 files changed, 135 insertions(+), 23 deletions(-)
diffs (truncated from 417 to 300 lines):
diff -r 2ae8e3e997ae -r a7f82629b48d external/bsd/dhcpcd/dist/hooks/20-resolv.conf
--- a/external/bsd/dhcpcd/dist/hooks/20-resolv.conf Fri Nov 20 13:23:38 2020 +0000
+++ b/external/bsd/dhcpcd/dist/hooks/20-resolv.conf Fri Nov 20 13:24:58 2020 +0000
@@ -198,8 +198,10 @@
;;
esac
-if $if_up || [ "$reason" = ROUTERADVERT ]; then
- add_resolv_conf
-elif $if_down; then
- remove_resolv_conf
+if $if_configured; then
+ if $if_up || [ "$reason" = ROUTERADVERT ]; then
+ add_resolv_conf
+ elif $if_down; then
+ remove_resolv_conf
+ fi
fi
diff -r 2ae8e3e997ae -r a7f82629b48d external/bsd/dhcpcd/dist/hooks/50-ntp.conf
--- a/external/bsd/dhcpcd/dist/hooks/50-ntp.conf Fri Nov 20 13:23:38 2020 +0000
+++ b/external/bsd/dhcpcd/dist/hooks/50-ntp.conf Fri Nov 20 13:24:58 2020 +0000
@@ -135,8 +135,10 @@
;;
esac
-if $if_up; then
- add_ntp_conf
-elif $if_down; then
- remove_ntp_conf
+if $if_configured; then
+ if $if_up; then
+ add_ntp_conf
+ elif $if_down; then
+ remove_ntp_conf
+ fi
fi
diff -r 2ae8e3e997ae -r a7f82629b48d external/bsd/dhcpcd/dist/hooks/50-ypbind.in
--- a/external/bsd/dhcpcd/dist/hooks/50-ypbind.in Fri Nov 20 13:23:38 2020 +0000
+++ b/external/bsd/dhcpcd/dist/hooks/50-ypbind.in Fri Nov 20 13:24:58 2020 +0000
@@ -68,7 +68,9 @@
fi
}
-if [ "$reason" = PREINIT ]; then
+if ! $if_configured; then
+ ;
+elif [ "$reason" = PREINIT ]; then
rm -f "$ypbind_dir/$interface".*
elif $if_up || $if_down; then
if [ -n "$new_nis_domain" ]; then
diff -r 2ae8e3e997ae -r a7f82629b48d external/bsd/dhcpcd/dist/src/dhcp.c
--- a/external/bsd/dhcpcd/dist/src/dhcp.c Fri Nov 20 13:23:38 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp.c Fri Nov 20 13:24:58 2020 +0000
@@ -2346,6 +2346,24 @@
old_state = state->added;
+ if (!(ifo->options & DHCPCD_CONFIGURE)) {
+ struct ipv4_addr *ia;
+
+ script_runreason(ifp, state->reason);
+ dhcpcd_daemonise(ifp->ctx);
+
+ /* We we are not configuring the address, we need to keep
+ * the BPF socket open if the address does not exist. */
+ ia = ipv4_iffindaddr(ifp, &state->lease.addr, NULL);
+ if (ia != NULL) {
+ state->addr = ia;
+ state->added = STATE_ADDED;
+ dhcp_closebpf(ifp);
+ goto openudp;
+ }
+ return;
+ }
+
/* Close the BPF filter as we can now receive DHCP messages
* on a UDP socket. */
dhcp_closebpf(ifp);
@@ -2353,6 +2371,7 @@
/* Add the address */
ipv4_applyaddr(ifp);
+openudp:
/* If not in master mode, open an address specific socket. */
if (ctx->options & DHCPCD_MASTER ||
(state->old != NULL &&
@@ -2361,7 +2380,6 @@
return;
dhcp_closeinet(ifp);
-
#ifdef PRIVSEP
if (IN_PRIVSEP_SE(ctx)) {
if (ps_inet_openbootp(state->addr) == -1)
@@ -2805,7 +2823,13 @@
state->new = NULL;
state->new_len = 0;
state->reason = reason;
- ipv4_applyaddr(ifp);
+ if (ifp->options->options & DHCPCD_CONFIGURE)
+ ipv4_applyaddr(ifp);
+ else {
+ state->addr = NULL;
+ state->added = 0;
+ script_runreason(ifp, state->reason);
+ }
free(state->old);
state->old = NULL;
state->old_len = 0;
@@ -4219,6 +4243,20 @@
#endif
ifo = ifp->options;
+
+#ifdef PRIVSEP
+ if (IN_PRIVSEP_SE(ifp->ctx) &&
+ !(ifp->ctx->options & (DHCPCD_MASTER | DHCPCD_CONFIGURE)) &&
+ IN_ARE_ADDR_EQUAL(&state->lease.addr, &ia->addr))
+ {
+ state->addr = ia;
+ state->added = STATE_ADDED;
+ dhcp_closebpf(ifp);
+ if (ps_inet_openbootp(ia) == -1)
+ logerr(__func__);
+ }
+#endif
+
if (ifo->options & DHCPCD_INFORM) {
if (state->state != DHS_INFORM)
dhcp_inform(ifp);
diff -r 2ae8e3e997ae -r a7f82629b48d external/bsd/dhcpcd/dist/src/dhcp6.c
--- a/external/bsd/dhcpcd/dist/src/dhcp6.c Fri Nov 20 13:23:38 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp6.c Fri Nov 20 13:24:58 2020 +0000
@@ -2877,6 +2877,8 @@
TAILQ_FOREACH(ifd, ifp->ctx->ifaces, next) {
if (!ifd->active)
continue;
+ if (!(ifd->options->options & DHCPCD_CONFIGURE))
+ continue;
k = 0;
carrier_warned = false;
TAILQ_FOREACH(ap, &state->addrs, next) {
@@ -2970,6 +2972,10 @@
struct if_sla *sla;
struct interface *ifd;
+ if (ifp->options != NULL &&
+ !(ifp->options->options & DHCPCD_CONFIGURE))
+ return 0;
+
k = 0;
TAILQ_FOREACH(ifd, ifp->ctx->ifaces, next) {
ifo = ifd->options;
@@ -3195,9 +3201,11 @@
eloop_timeout_add_sec(ifp->ctx->eloop,
state->expire, dhcp6_startexpire, ifp);
- ipv6_addaddrs(&state->addrs);
- if (!timedout)
- dhcp6_deprecateaddrs(&state->addrs);
+ if (ifp->options->options & DHCPCD_CONFIGURE) {
+ ipv6_addaddrs(&state->addrs);
+ if (!timedout)
+ dhcp6_deprecateaddrs(&state->addrs);
+ }
if (state->state == DH6S_INFORMED)
logmessage(loglevel, "%s: refresh in %"PRIu32" seconds",
diff -r 2ae8e3e997ae -r a7f82629b48d external/bsd/dhcpcd/dist/src/dhcpcd.8.in
--- a/external/bsd/dhcpcd/dist/src/dhcpcd.8.in Fri Nov 20 13:23:38 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcpcd.8.in Fri Nov 20 13:24:58 2020 +0000
@@ -24,7 +24,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd October 30, 2020
+.Dd November 3, 2020
.Dt DHCPCD 8
.Os
.Sh NAME
@@ -62,6 +62,8 @@
.Op Fl Z , Fl Fl denyinterfaces Ar pattern
.Op Fl z , Fl Fl allowinterfaces Ar pattern
.Op Fl Fl inactive
+.Op Fl Fl configure
+.Op Fl Fl noconfigure
.Op interface
.Op ...
.Nm
@@ -737,6 +739,25 @@
to be started in Master mode and then wait for subsequent
.Nm
commands to start each interface as required.
+.It Fl Fl configure
+Allows
+.Nm
+to configure the system.
+This is the default behaviour and sets
+.Ev if_configured=true .
+.It Fl Fl noconfigure
+.Nm
+will not configure the system add all.
+This is only of use if the
+.Fl Fl script
+that
+.Nm
+calls at each network event configures the system instead.
+This is different from
+.Fl T , Fl Fl test
+mode in that it's not one shot and the only change to the environment is the
+addition of
+.Ev if_configured=false .
.It Fl Fl nodev
Don't load any
.Pa /dev
diff -r 2ae8e3e997ae -r a7f82629b48d external/bsd/dhcpcd/dist/src/dhcpcd.c
--- a/external/bsd/dhcpcd/dist/src/dhcpcd.c Fri Nov 20 13:23:38 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcpcd.c Fri Nov 20 13:24:58 2020 +0000
@@ -2179,6 +2179,9 @@
if (!(ctx.options & DHCPCD_MASTER))
ctx.control_fd = control_open(argv[optind], family,
ctx.options & DHCPCD_DUMPLEASE);
+ if (!(ctx.options & DHCPCD_MASTER) && ctx.control_fd == -1)
+ ctx.control_fd = control_open(argv[optind], AF_UNSPEC,
+ ctx.options & DHCPCD_DUMPLEASE);
if (ctx.control_fd == -1)
ctx.control_fd = control_open(NULL, AF_UNSPEC,
ctx.options & DHCPCD_DUMPLEASE);
@@ -2241,6 +2244,9 @@
if (ctx.stdin_valid && freopen(_PATH_DEVNULL, "w", stdin) == NULL)
logwarn("freopen stdin");
+ 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 &&
@@ -2332,8 +2338,9 @@
/* We have now forked, setsid, forked once more.
* From this point on, we are the controlling daemon. */
+ logdebugx("spawned master process on PID %d", getpid());
+start_master:
ctx.options |= DHCPCD_STARTED;
- logdebugx("spawned master process on PID %d", getpid());
if ((pid = pidfile_lock(ctx.pidfile)) != 0) {
logerr("%s: pidfile_lock %d", __func__, pid);
#ifdef PRIVSEP
diff -r 2ae8e3e997ae -r a7f82629b48d external/bsd/dhcpcd/dist/src/if-options.c
--- a/external/bsd/dhcpcd/dist/src/if-options.c Fri Nov 20 13:23:38 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/if-options.c Fri Nov 20 13:24:58 2020 +0000
@@ -165,6 +165,8 @@
{"inactive", no_argument, NULL, O_INACTIVE},
{"mudurl", required_argument, NULL, O_MUDURL},
{"link_rcvbuf", required_argument, NULL, O_LINK_RCVBUF},
+ {"configure", no_argument, NULL, O_CONFIGURE},
+ {"noconfigure", no_argument, NULL, O_NOCONFIGURE},
{NULL, 0, NULL, '\0'}
};
@@ -782,6 +784,8 @@
break;
case 'o':
ARG_REQUIRED;
+ if (ctx->options & DHCPCD_PRINT_PIDFILE)
+ break;
set_option_space(ctx, arg, &d, &dl, &od, &odl, ifo,
&request, &require, &no, &reject);
if (make_option_mask(d, dl, od, odl, request, arg, 1) != 0 ||
@@ -794,6 +798,8 @@
break;
case O_REJECT:
ARG_REQUIRED;
+ if (ctx->options & DHCPCD_PRINT_PIDFILE)
+ break;
set_option_space(ctx, arg, &d, &dl, &od, &odl, ifo,
&request, &require, &no, &reject);
if (make_option_mask(d, dl, od, odl, reject, arg, 1) != 0 ||
@@ -1057,6 +1063,8 @@
break;
case 'O':
ARG_REQUIRED;
+ if (ctx->options & DHCPCD_PRINT_PIDFILE)
+ break;
set_option_space(ctx, arg, &d, &dl, &od, &odl, ifo,
&request, &require, &no, &reject);
if (make_option_mask(d, dl, od, odl, request, arg, -1) != 0 ||
@@ -1069,6 +1077,8 @@
break;
case 'Q':
ARG_REQUIRED;
+ if (ctx->options & DHCPCD_PRINT_PIDFILE)
+ break;
set_option_space(ctx, arg, &d, &dl, &od, &odl, ifo,
&request, &require, &no, &reject);
if (make_option_mask(d, dl, od, odl, require, arg, 1) != 0 ||
@@ -1307,6 +1317,8 @@
break;
case O_DESTINATION:
Home |
Main Index |
Thread Index |
Old Index