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/src Sync with dhcpcd-9.3.4



details:   https://anonhg.NetBSD.org/src/rev/b33f71d9b645
branches:  trunk
changeset: 978650:b33f71d9b645
user:      roy <roy%NetBSD.org@localhost>
date:      Sat Nov 28 14:27:20 2020 +0000

description:
Sync with dhcpcd-9.3.4

diffstat:

 external/bsd/dhcpcd/dist/src/dhcp.c       |  14 ++++++++--
 external/bsd/dhcpcd/dist/src/dhcp6.c      |   4 +++
 external/bsd/dhcpcd/dist/src/dhcpcd.8.in  |  19 +++++++++++---
 external/bsd/dhcpcd/dist/src/dhcpcd.c     |  39 ++++++++++++++++++++----------
 external/bsd/dhcpcd/dist/src/if-options.c |  34 +++++++++++++++++++-------
 5 files changed, 80 insertions(+), 30 deletions(-)

diffs (278 lines):

diff -r 8a02c491bf37 -r b33f71d9b645 external/bsd/dhcpcd/dist/src/dhcp.c
--- a/external/bsd/dhcpcd/dist/src/dhcp.c       Sat Nov 28 14:26:16 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp.c       Sat Nov 28 14:27:20 2020 +0000
@@ -2364,13 +2364,21 @@
                return;
        }
 
+       /* Add the address */
+       if (ipv4_applyaddr(ifp) == NULL) {
+               /* There was an error adding the address.
+                * If we are in oneshot, exit with a failure. */
+               if (ctx->options & DHCPCD_ONESHOT) {
+                       loginfox("exiting due to oneshot");
+                       eloop_exit(ctx->eloop, EXIT_FAILURE);
+               }
+               return;
+       }
+
        /* Close the BPF filter as we can now receive DHCP messages
         * on a UDP socket. */
        dhcp_closebpf(ifp);
 
-       /* Add the address */
-       ipv4_applyaddr(ifp);
-
 openudp:
        /* If not in master mode, open an address specific socket. */
        if (ctx->options & DHCPCD_MASTER ||
diff -r 8a02c491bf37 -r b33f71d9b645 external/bsd/dhcpcd/dist/src/dhcp6.c
--- a/external/bsd/dhcpcd/dist/src/dhcp6.c      Sat Nov 28 14:26:16 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp6.c      Sat Nov 28 14:27:20 2020 +0000
@@ -2064,6 +2064,10 @@
        free(sbuf);
        state->lerror = code;
        errno = 0;
+
+       if (code != 0 && ifp->ctx->options & DHCPCD_TEST)
+               eloop_exit(ifp->ctx->eloop, EXIT_FAILURE);
+
        return (int)code;
 }
 
diff -r 8a02c491bf37 -r b33f71d9b645 external/bsd/dhcpcd/dist/src/dhcpcd.8.in
--- a/external/bsd/dhcpcd/dist/src/dhcpcd.8.in  Sat Nov 28 14:26:16 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcpcd.8.in  Sat Nov 28 14:27:20 2020 +0000
@@ -24,7 +24,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd November 3, 2020
+.Dd November 25, 2020
 .Dt DHCPCD 8
 .Os
 .Sh NAME
@@ -264,18 +264,29 @@
 .Ar script
 instead of the default
 .Pa @SCRIPT@ .
-.It Fl D , Fl Fl duid
+.It Fl D , Fl Fl duid Op Ar ll | lt | uuid | value
 Use a DHCP Unique Identifier.
 If a system UUID is available, that will be used to create a DUID-UUID,
 otheriwse if persistent storage is available then a DUID-LLT
 (link local address + time) is generated,
 otherwise DUID-LL is generated (link local address).
+The DUID type can be hinted as an optional parameter if the file
+.Pa @DBDIR@/duid
+does not exist.
+If not
+.Va ll ,
+.Va lt
+or
+.Va uuid
+then
+.Va value
+will be converted from 00:11:22:33 format.
 This, plus the IAID will be used as the
 .Fl I , Fl Fl clientid .
 The DUID generated will be held in
 .Pa @DBDIR@/duid
 and should not be copied to other hosts.
-This file also takes precedence over the above rules.
+This file also takes precedence over the above rules except for setting a value.
 .It Fl d , Fl Fl debug
 Echo debug messages to the stderr and syslog.
 .It Fl E , Fl Fl lastlease
@@ -747,7 +758,7 @@
 .Ev if_configured=true .
 .It Fl Fl noconfigure
 .Nm
-will not configure the system add all.
+will not configure the system at all.
 This is only of use if the
 .Fl Fl script
 that
diff -r 8a02c491bf37 -r b33f71d9b645 external/bsd/dhcpcd/dist/src/dhcpcd.c
--- a/external/bsd/dhcpcd/dist/src/dhcpcd.c     Sat Nov 28 14:26:16 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcpcd.c     Sat Nov 28 14:27:20 2020 +0000
@@ -841,13 +841,17 @@
 {
        char buf[DUID_LEN * 3];
 
-       if (ctx->duid != NULL)
+       if (ctx->duid != NULL) {
+               if (ifp == NULL)
+                       goto log;
                return;
+       }
 
        duid_init(ctx, ifp);
        if (ctx->duid == NULL)
                return;
 
+log:
        loginfox("DUID %s",
            hwaddr_ntoa(ctx->duid, ctx->duid_len, buf, sizeof(buf)));
 }
@@ -991,17 +995,20 @@
 dhcpcd_activateinterface(struct interface *ifp, unsigned long long options)
 {
 
-       if (!ifp->active) {
-               ifp->active = IF_ACTIVE;
-               dhcpcd_initstate2(ifp, options);
-               /* It's possible we might not have been able to load
-                * a config. */
-               if (ifp->active) {
-                       configure_interface1(ifp);
-                       run_preinit(ifp);
-                       dhcpcd_prestartinterface(ifp);
-               }
-       }
+       if (ifp->active)
+               return;
+
+       ifp->active = IF_ACTIVE;
+       dhcpcd_initstate2(ifp, options);
+
+       /* It's possible we might not have been able to load
+        * a config. */
+       if (!ifp->active)
+               return;
+
+       configure_interface1(ifp);
+       run_preinit(ifp);
+       dhcpcd_prestartinterface(ifp);
 }
 
 int
@@ -1880,6 +1887,7 @@
                logopts |= LOGERR_ERR;
 
        i = 0;
+
        while ((opt = getopt_long(argc, argv,
            ctx.options & DHCPCD_PRINT_PIDFILE ? NOERR_IF_OPTS : IF_OPTS,
            cf_options, &oi)) != -1)
@@ -1954,6 +1962,9 @@
                }
        }
 
+       if (optind != argc - 1)
+               ctx.options |= DHCPCD_MASTER;
+
        logsetopts(logopts);
        logopen(ctx.logfile);
 
@@ -1970,6 +1981,7 @@
                        goto printpidfile;
                goto exit_failure;
        }
+
        opt = add_options(&ctx, NULL, ifo, argc, argv);
        if (opt != 1) {
                if (ctx.options & DHCPCD_PRINT_PIDFILE)
@@ -2010,6 +2022,7 @@
                goto exit_success;
        }
        ctx.options |= ifo->options;
+
        if (i == 1 || i == 3) {
                if (i == 1)
                        ctx.options |= DHCPCD_TEST;
@@ -2527,7 +2540,7 @@
        i = EXIT_FAILURE;
 
 exit1:
-       if (control_stop(&ctx) == -1)
+       if (!(ctx.options & DHCPCD_TEST) && control_stop(&ctx) == -1)
                logerr("%s: control_stop", __func__);
        if (ifaddrs != NULL) {
 #ifdef PRIVSEP_GETIFADDRS
diff -r 8a02c491bf37 -r b33f71d9b645 external/bsd/dhcpcd/dist/src/if-options.c
--- a/external/bsd/dhcpcd/dist/src/if-options.c Sat Nov 28 14:26:16 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/if-options.c Sat Nov 28 14:27:20 2020 +0000
@@ -134,9 +134,9 @@
        {"noipv6",          no_argument,       NULL, O_NOIPV6},
        {"noalias",         no_argument,       NULL, O_NOALIAS},
        {"iaid",            required_argument, NULL, O_IAID},
-       {"ia_na",           no_argument,       NULL, O_IA_NA},
-       {"ia_ta",           no_argument,       NULL, O_IA_TA},
-       {"ia_pd",           no_argument,       NULL, O_IA_PD},
+       {"ia_na",           optional_argument, NULL, O_IA_NA},
+       {"ia_ta",           optional_argument, NULL, O_IA_TA},
+       {"ia_pd",           optional_argument, NULL, O_IA_PD},
        {"hostname_short",  no_argument,       NULL, O_HOSTNAME_SHORT},
        {"dev",             required_argument, NULL, O_DEV},
        {"nodev",           no_argument,       NULL, O_NODEV},
@@ -1002,8 +1002,16 @@
                else if (strcmp(arg, "uuid") == 0)
                        ctx->duid_type = DUID_UUID;
                else {
-                       logwarnx("%s: invalid duid type", arg);
-                       ctx->duid_type = DUID_DEFAULT;
+                       dl = hwaddr_aton(NULL, arg);
+                       if (dl != 0) {
+                               no = realloc(ctx->duid, dl);
+                               if (no == NULL)
+                                       logerrx(__func__);
+                               else {
+                                       ctx->duid = no;
+                                       ctx->duid_len = hwaddr_aton(no, arg);
+                               }
+                       }
                }
                break;
        case 'E':
@@ -1344,7 +1352,7 @@
 #endif
        case O_IAID:
                ARG_REQUIRED;
-               if (!IN_CONFIG_BLOCK(ifo)) {
+               if (ctx->options & DHCPCD_MASTER && !IN_CONFIG_BLOCK(ifo)) {
                        logerrx("IAID must belong in an interface block");
                        return -1;
                }
@@ -1386,7 +1394,9 @@
                        logwarnx("%s: IA_PD not compiled in", ifname);
                        return -1;
 #else
-                       if (!IN_CONFIG_BLOCK(ifo)) {
+                       if (ctx->options & DHCPCD_MASTER &&
+                           !IN_CONFIG_BLOCK(ifo))
+                       {
                                logerrx("IA PD must belong in an "
                                    "interface block");
                                return -1;
@@ -1394,7 +1404,9 @@
                        i = D6_OPTION_IA_PD;
 #endif
                }
-               if (!IN_CONFIG_BLOCK(ifo) && arg) {
+               if (ctx->options & DHCPCD_MASTER &&
+                   !IN_CONFIG_BLOCK(ifo) && arg)
+               {
                        logerrx("IA with IAID must belong in an "
                            "interface block");
                        return -1;
@@ -2343,6 +2355,8 @@
 #endif
 
        /* Inherit some global defaults */
+       if (ctx->options & DHCPCD_CONFIGURE)
+               ifo->options |= DHCPCD_CONFIGURE;
        if (ctx->options & DHCPCD_PERSISTENT)
                ifo->options |= DHCPCD_PERSISTENT;
        if (ctx->options & DHCPCD_SLAACPRIVATE)
@@ -2371,8 +2385,8 @@
        if ((ifo = default_config(ctx)) == NULL)
                return NULL;
        if (default_options == 0) {
-               default_options |= DHCPCD_DAEMONISE |
-                       DHCPCD_CONFIGURE | DHCPCD_GATEWAY;
+               default_options |= DHCPCD_CONFIGURE | DHCPCD_DAEMONISE |
+                   DHCPCD_GATEWAY;
 #ifdef INET
                skip = socket(PF_INET, SOCK_DGRAM, 0);
                if (skip != -1) {



Home | Main Index | Thread Index | Old Index