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
details: https://anonhg.NetBSD.org/src/rev/767214a6451c
branches: trunk
changeset: 353525:767214a6451c
user: roy <roy%NetBSD.org@localhost>
date: Wed May 10 11:03:44 2017 +0000
description:
Sync
diffstat:
external/bsd/dhcpcd/dist/src/dhcpcd.c | 49 +++++++++++++++++++-----------
external/bsd/dhcpcd/dist/src/if-options.c | 28 +++++++++++++++--
2 files changed, 55 insertions(+), 22 deletions(-)
diffs (214 lines):
diff -r d6fd52580175 -r 767214a6451c external/bsd/dhcpcd/dist/src/dhcpcd.c
--- a/external/bsd/dhcpcd/dist/src/dhcpcd.c Wed May 10 11:00:37 2017 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcpcd.c Wed May 10 11:03:44 2017 +0000
@@ -477,6 +477,10 @@
* between reboots without persitent storage,
* generating the IAID from the MAC address is the only
* logical default.
+ * Saying that, if a VLANID has been specified then we
+ * can use that. It's possible that different interfaces
+ * can have the same VLANID, but this is no worse than
+ * generating the IAID from the duplicate MAC address.
*
* dhclient uses the last 4 bytes of the MAC address.
* dibbler uses an increamenting counter.
@@ -487,11 +491,18 @@
* dhcpcd-6.1.0 and earlier used the interface name,
* falling back to interface index if name > 4.
*/
- if (ifp->hwlen >= sizeof(ifo->iaid))
+ if (ifp->vlanid != 0) {
+ uint32_t vlanid;
+
+ /* Maximal VLANID is 4095, so prefix with 0xff
+ * so we don't conflict with an interface index. */
+ vlanid = htonl(ifp->vlanid | 0xff000000);
+ memcpy(ifo->iaid, &vlanid, sizeof(vlanid));
+ } else if (ifp->hwlen >= sizeof(ifo->iaid)) {
memcpy(ifo->iaid,
ifp->hwaddr + ifp->hwlen - sizeof(ifo->iaid),
sizeof(ifo->iaid));
- else {
+ } else {
uint32_t len;
len = (uint32_t)strlen(ifp->name);
@@ -503,7 +514,7 @@
} else {
/* IAID is the same size as a uint32_t */
len = htonl(ifp->index);
- memcpy(ifo->iaid, &len, sizeof(len));
+ memcpy(ifo->iaid, &len, sizeof(ifo->iaid));
}
}
ifo->options |= DHCPCD_IAID;
@@ -775,7 +786,7 @@
/* This is only a problem if the interfaces are on the same network. */
if (ifn)
- logerr("%s: IAID conflicts with one assigned to %s",
+ logerrx("%s: IAID conflicts with one assigned to %s",
ifp->name, ifn->name);
}
@@ -1510,6 +1521,7 @@
#endif
case 'P':
ctx.options |= DHCPCD_PRINT_PIDFILE;
+ logopts &= ~(LOGERR_LOG | LOGERR_ERR);
break;
case 'T':
i = 1;
@@ -1603,10 +1615,12 @@
* instance for that interface. */
if (optind == argc - 1 && !(ctx.options & DHCPCD_MASTER)) {
const char *per;
+ const char *ifname;
- if (strlen(argv[optind]) > IF_NAMESIZE) {
- logerrx("%s: interface name too long",
- argv[optind]);
+ ifname = *ctx.ifv;
+ if (ifname == NULL || strlen(ifname) > IF_NAMESIZE) {
+ errno = ifname == NULL ? EINVAL : E2BIG;
+ logerr("%s: ", ifname);
goto exit_failure;
}
/* Allow a dhcpcd interface per address family */
@@ -1621,7 +1635,7 @@
per = "";
}
snprintf(ctx.pidfile, sizeof(ctx.pidfile),
- PIDFILE, "-", argv[optind], per);
+ PIDFILE, "-", ifname, per);
} else {
snprintf(ctx.pidfile, sizeof(ctx.pidfile),
PIDFILE, "", "", "");
@@ -1643,20 +1657,13 @@
goto exit_failure;
}
- /* Open our persistent sockets.
- * This is needed early for dumping leases on valid interfaces. */
-#ifdef USE_SIGNALS
- if (sig == 0) {
-#endif
+ if (ctx.options & DHCPCD_DUMPLEASE) {
+ /* Open sockets so we can dump something about
+ * valid interfaces. */
if (if_opensockets(&ctx) == -1) {
logerr("%s: if_opensockets", __func__);
goto exit_failure;
}
-#ifdef USE_SIGNALS
- }
-#endif
-
- if (ctx.options & DHCPCD_DUMPLEASE) {
if (optind != argc) {
/* We need to try and find the interface so we can load
* the hardware address to compare automated IAID */
@@ -1803,6 +1810,12 @@
logdebugx(PACKAGE "-" VERSION " starting");
ctx.options |= DHCPCD_STARTED;
+
+ if (if_opensockets(&ctx) == -1) {
+ logerr("%s: if_opensockets", __func__);
+ goto exit_failure;
+ }
+
#ifdef USE_SIGNALS
if (eloop_signal_set_cb(ctx.eloop,
dhcpcd_signals, dhcpcd_signals_len,
diff -r d6fd52580175 -r 767214a6451c external/bsd/dhcpcd/dist/src/if-options.c
--- a/external/bsd/dhcpcd/dist/src/if-options.c Wed May 10 11:00:37 2017 +0000
+++ b/external/bsd/dhcpcd/dist/src/if-options.c Wed May 10 11:03:44 2017 +0000
@@ -93,7 +93,7 @@
#define O_IPV6 O_BASE + 33
#define O_CONTROLGRP O_BASE + 34
#define O_SLAAC O_BASE + 35
-// unused O_BASE + 36
+#define O_GATEWAY O_BASE + 36
#define O_NOUP O_BASE + 37
#define O_IPV6RA_AUTOCONF O_BASE + 38
#define O_IPV6RA_NOAUTOCONF O_BASE + 39
@@ -196,6 +196,7 @@
{"nodhcp6", no_argument, NULL, O_NODHCP6},
{"controlgroup", required_argument, NULL, O_CONTROLGRP},
{"slaac", required_argument, NULL, O_SLAAC},
+ {"gateway", no_argument, NULL, O_GATEWAY},
{"reject", required_argument, NULL, O_REJECT},
{"bootp", no_argument, NULL, O_BOOTP},
{"nodelay", no_argument, NULL, O_NODELAY},
@@ -978,6 +979,9 @@
return -1;
}
break;
+ case 'G':
+ ifo->options &= ~DHCPCD_GATEWAY;
+ break;
case 'H':
ifo->options |= DHCPCD_XID_HWADDR;
break;
@@ -1062,8 +1066,14 @@
strncmp(arg, "ms_classless_static_routes=",
strlen("ms_classless_static_routes=")) == 0)
{
+ struct interface *ifp;
struct in_addr addr3;
+ ifp = if_find(ctx->ifaces, ifname);
+ if (ifp == NULL) {
+ logerrx("static routes require an interface");
+ return -1;
+ }
fp = np = strwhite(p);
if (np == NULL) {
logerrx("all routes need a gateway");
@@ -1077,7 +1087,7 @@
*fp = ' ';
return -1;
}
- if ((rt = rt_new(if_find(ctx->ifaces, ifname))) == NULL) {
+ if ((rt = rt_new(ifp)) == NULL) {
*fp = ' ';
return -1;
}
@@ -1087,9 +1097,16 @@
TAILQ_INSERT_TAIL(&ifo->routes, rt, rt_next);
*fp = ' ';
} else if (strncmp(arg, "routers=", strlen("routers=")) == 0) {
+ struct interface *ifp;
+
+ ifp = if_find(ctx->ifaces, ifname);
+ if (ifp == NULL) {
+ logerrx("static routes require an interface");
+ return -1;
+ }
if (parse_addr(&addr, NULL, p) == -1)
return -1;
- if ((rt = rt_new(if_find(ctx->ifaces, ifname))) == NULL)
+ if ((rt = rt_new(ifp)) == NULL)
return -1;
addr2.s_addr = INADDR_ANY;
sa_in_init(&rt->rt_dest, &addr2);
@@ -2078,6 +2095,9 @@
ctx->control_group = grp->gr_gid;
#endif
break;
+ case O_GATEWAY:
+ ifo->options |= DHCPCD_GATEWAY;
+ break;
case O_NOUP:
ifo->options &= ~DHCPCD_IF_UP;
break;
@@ -2257,7 +2277,7 @@
/* Seed our default options */
if ((ifo = default_config(ctx)) == NULL)
return NULL;
- ifo->options |= DHCPCD_DAEMONISE;
+ ifo->options |= DHCPCD_DAEMONISE | DHCPCD_GATEWAY;
#ifdef PLUGIN_DEV
ifo->options |= DHCPCD_DEV;
#endif
Home |
Main Index |
Thread Index |
Old Index