Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/roy]: src/external/bsd/dhcpcd/dist/src Upate to dhcpcd-9.3.4 with the fo...



details:   https://anonhg.NetBSD.org/src/rev/272e481e8c14
branches:  roy
changeset: 946462:272e481e8c14
user:      roy <roy%NetBSD.org@localhost>
date:      Sat Nov 28 14:26:16 2020 +0000

description:
Upate to dhcpcd-9.3.4 with the following changes:

With the following changes:
 * DHCP: If error adding the address in oneshot, exit with failure
 * DHCP: Only listen to the address if we successfully added it
 * DHCP6: Fix segfault introduced in dhcpcd-9.3.3
 * DHCP6: Abort in test mode when an error is returned by server
 * options: allow --ia_na=1 and --ia_pd=2 on the command line
 * options: Allow duid to take a value

diffstat:

 external/bsd/dhcpcd/dist/src/defs.h           |   2 +-
 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/dhcpcd.conf.5.in |  14 +++++++--
 external/bsd/dhcpcd/dist/src/if-options.c     |  34 ++++++++++++++++------
 external/bsd/dhcpcd/dist/src/ipv4.c           |  15 +++++----
 external/bsd/dhcpcd/dist/src/ipv4.h           |   2 +-
 external/bsd/dhcpcd/dist/src/route.c          |   5 ++-
 10 files changed, 105 insertions(+), 43 deletions(-)

diffs (truncated from 425 to 300 lines):

diff -r b876d7d6636f -r 272e481e8c14 external/bsd/dhcpcd/dist/src/defs.h
--- a/external/bsd/dhcpcd/dist/src/defs.h       Fri Nov 20 13:23:38 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/defs.h       Sat Nov 28 14:26:16 2020 +0000
@@ -29,7 +29,7 @@
 #define CONFIG_H
 
 #define PACKAGE                        "dhcpcd"
-#define VERSION                        "9.3.3"
+#define VERSION                        "9.3.4"
 
 #ifndef PRIVSEP_USER
 # define PRIVSEP_USER          "_" PACKAGE
diff -r b876d7d6636f -r 272e481e8c14 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       Sat Nov 28 14:26:16 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 b876d7d6636f -r 272e481e8c14 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      Sat Nov 28 14:26:16 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 b876d7d6636f -r 272e481e8c14 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  Sat Nov 28 14:26:16 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 b876d7d6636f -r 272e481e8c14 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     Sat Nov 28 14:26:16 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 b876d7d6636f -r 272e481e8c14 external/bsd/dhcpcd/dist/src/dhcpcd.conf.5.in
--- a/external/bsd/dhcpcd/dist/src/dhcpcd.conf.5.in     Fri Nov 20 13:23:38 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcpcd.conf.5.in     Sat Nov 28 14:26:16 2020 +0000
@@ -24,7 +24,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd October 25, 2020
+.Dd November 25, 2020
 .Dt DHCPCD.CONF 5
 .Os
 .Sh NAME
@@ -211,7 +211,7 @@
 sends a default
 .Ar clientid
 of the hardware family and the hardware address.
-.It Ic duid Op ll | lt | uuid
+.It Ic duid Op 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
@@ -220,12 +220,20 @@
 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
 .Ic 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 Ic iaid Ar iaid
 Set the Interface Association Identifier to
 .Ar iaid .
diff -r b876d7d6636f -r 272e481e8c14 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 Sat Nov 28 14:26:16 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 "



Home | Main Index | Thread Index | Old Index