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
details: https://anonhg.NetBSD.org/src/rev/246ea8227261
branches: trunk
changeset: 790125:246ea8227261
user: roy <roy%NetBSD.org@localhost>
date: Fri Sep 20 10:56:32 2013 +0000
description:
Sync
diffstat:
external/bsd/dhcpcd/dist/dhcp.c | 159 ++-
external/bsd/dhcpcd/dist/dhcpcd.8.in | 82 +-
external/bsd/dhcpcd/dist/dhcpcd.conf | 5 +-
external/bsd/dhcpcd/dist/dhcpcd.conf.5.in | 34 +-
external/bsd/dhcpcd/dist/ipv6ns.c | 690 ---------------
external/bsd/dhcpcd/dist/ipv6ns.h | 51 -
external/bsd/dhcpcd/dist/ipv6rs.c | 1277 -----------------------------
external/bsd/dhcpcd/dist/ipv6rs.h | 100 --
external/bsd/dhcpcd/dist/net.c | 45 +-
9 files changed, 243 insertions(+), 2200 deletions(-)
diffs (truncated from 2770 to 300 lines):
diff -r 20d099339eac -r 246ea8227261 external/bsd/dhcpcd/dist/dhcp.c
--- a/external/bsd/dhcpcd/dist/dhcp.c Fri Sep 20 10:51:29 2013 +0000
+++ b/external/bsd/dhcpcd/dist/dhcp.c Fri Sep 20 10:56:32 2013 +0000
@@ -1,5 +1,5 @@
#include <sys/cdefs.h>
- __RCSID("$NetBSD: dhcp.c,v 1.6 2013/07/29 20:39:28 roy Exp $");
+ __RCSID("$NetBSD: dhcp.c,v 1.7 2013/09/20 10:56:32 roy Exp $");
/*
* dhcpcd - DHCP client daemon
@@ -1702,7 +1702,6 @@
send_rebind(ifp);
}
-
void
dhcp_bind(void *arg)
{
@@ -1724,10 +1723,10 @@
state->offer = NULL;
get_lease(lease, state->new);
if (ifo->options & DHCPCD_STATIC) {
- syslog(LOG_INFO, "%s: using static address %s",
- iface->name, inet_ntoa(lease->addr));
+ syslog(LOG_INFO, "%s: using static address %s/%d",
+ iface->name, inet_ntoa(lease->addr),
+ inet_ntocidr(lease->net));
lease->leasetime = ~0U;
- lease->net.s_addr = ifo->req_mask.s_addr;
state->reason = "STATIC";
} else if (state->new->cookie != htonl(MAGIC_COOKIE)) {
syslog(LOG_INFO, "%s: using IPv4LL address %s",
@@ -1834,7 +1833,7 @@
}
struct dhcp_message *
-dhcp_message_new(struct in_addr *addr, struct in_addr *mask)
+dhcp_message_new(const struct in_addr *addr, const struct in_addr *mask)
{
struct dhcp_message *dhcp;
uint8_t *p;
@@ -1854,60 +1853,65 @@
return dhcp;
}
-static int
-handle_3rdparty(struct interface *ifp)
-{
- struct if_options *ifo;
- struct dhcp_state *state;
- struct in_addr addr, net, dst;
-
- ifo = ifp->options;
- if (ifo->req_addr.s_addr != INADDR_ANY)
- return 0;
-
- if (ipv4_getaddress(ifp->name, &addr, &net, &dst) == 1)
- ipv4_handleifa(RTM_NEWADDR, ifp->name, &addr, &net, &dst);
- else {
- syslog(LOG_INFO,
- "%s: waiting for 3rd party to configure IP address",
- ifp->name);
- state = D_STATE(ifp);
- state->reason = "3RDPARTY";
- script_runreason(ifp, state->reason);
- }
- return 1;
-}
-
static void
dhcp_static(struct interface *ifp)
{
struct if_options *ifo;
struct dhcp_state *state;
- if (handle_3rdparty(ifp))
- return;
+ state = D_STATE(ifp);
ifo = ifp->options;
- state = D_STATE(ifp);
+ if (ifo->req_addr.s_addr == INADDR_ANY) {
+ syslog(LOG_INFO,
+ "%s: waiting for 3rd party to "
+ "configure IP address",
+ ifp->name);
+ state->reason = "3RDPARTY";
+ script_runreason(ifp, state->reason);
+ return;
+ }
state->offer = dhcp_message_new(&ifo->req_addr, &ifo->req_mask);
- eloop_timeout_delete(NULL, ifp);
- dhcp_bind(ifp);
+ if (state->offer) {
+ eloop_timeout_delete(NULL, ifp);
+ dhcp_bind(ifp);
+ }
}
void
dhcp_inform(struct interface *ifp)
{
struct dhcp_state *state;
-
- if (handle_3rdparty(ifp))
- return;
+ struct if_options *ifo;
+ struct ipv4_addr *ap;
state = D_STATE(ifp);
+ ifo = ifp->options;
if (options & DHCPCD_TEST) {
- state->addr.s_addr = ifp->options->req_addr.s_addr;
- state->net.s_addr = ifp->options->req_mask.s_addr;
+ state->addr.s_addr = ifo->req_addr.s_addr;
+ state->net.s_addr = ifo->req_mask.s_addr;
} else {
- ifp->options->options |= DHCPCD_STATIC;
- dhcp_static(ifp);
+ if (ifo->req_addr.s_addr == INADDR_ANY) {
+ state = D_STATE(ifp);
+ ap = ipv4_findaddr(ifp, NULL, NULL);
+ if (ap == NULL) {
+ syslog(LOG_INFO,
+ "%s: waiting for 3rd party to "
+ "configure IP address",
+ ifp->name);
+ state->reason = "3RDPARTY";
+ script_runreason(ifp, state->reason);
+ return;
+ }
+ state->offer =
+ dhcp_message_new(&ap->addr, &ap->net);
+ } else
+ state->offer =
+ dhcp_message_new(&ifo->req_addr, &ifo->req_mask);
+ if (state->offer) {
+ ifo->options |= DHCPCD_STATIC;
+ dhcp_bind(ifp);
+ ifo->options &= ~DHCPCD_STATIC;
+ }
}
state->state = DHS_INFORM;
@@ -2220,6 +2224,8 @@
if (!(ifo->options & DHCPCD_INFORM))
log_dhcp(LOG_DEBUG, "acknowledged", iface, dhcp, from);
+ else
+ ifo->options &= ~DHCPCD_STATIC;
}
/* BOOTP could have already assigned this above, so check we still
@@ -2244,7 +2250,7 @@
/* If the interface already has the address configured
* then we can't ARP for duplicate detection. */
addr.s_addr = state->offer->yiaddr;
- if (ipv4_hasaddress(iface->name, &addr, NULL) != 1) {
+ if (!ipv4_findaddr(iface, &addr, NULL)) {
state->claims = 0;
state->probes = 0;
state->conflicts = 0;
@@ -2687,3 +2693,70 @@
else
dhcp_reboot(ifp);
}
+
+void
+dhcp_handleifa(int type, struct interface *ifp,
+ const struct in_addr *addr,
+ const struct in_addr *net,
+ const struct in_addr *dst)
+{
+ struct dhcp_state *state;
+ struct if_options *ifo;
+ int i;
+
+ state = D_STATE(ifp);
+ if (state == NULL)
+ return;
+
+ if (type == RTM_DELADDR) {
+ if (state->new &&
+ (state->new->yiaddr == addr->s_addr ||
+ (state->new->yiaddr == INADDR_ANY &&
+ state->new->ciaddr == addr->s_addr)))
+ {
+ syslog(LOG_INFO, "%s: removing IP address %s/%d",
+ ifp->name, inet_ntoa(state->lease.addr),
+ inet_ntocidr(state->lease.net));
+ dhcp_drop(ifp, "EXPIRE");
+ }
+ return;
+ }
+
+ if (type != RTM_NEWADDR)
+ return;
+
+ ifo = ifp->options;
+ if (ifo->options & DHCPCD_INFORM) {
+ if (state->state != DHS_INFORM)
+ dhcp_inform(ifp);
+ return;
+ }
+
+ if (!(ifo->options & DHCPCD_STATIC))
+ return;
+ if (ifo->req_addr.s_addr != INADDR_ANY)
+ return;
+
+ free(state->old);
+ state->old = state->new;
+ state->new = dhcp_message_new(addr, net);
+ if (state->new == NULL)
+ return;
+ state->dst.s_addr = dst ? dst->s_addr : INADDR_ANY;
+ if (dst) {
+ for (i = 1; i < 255; i++)
+ if (i != DHO_ROUTER && has_option_mask(ifo->dstmask,i))
+ dhcp_message_add_addr(state->new, i, *dst);
+ }
+ state->reason = "STATIC";
+ ipv4_buildroutes();
+ script_runreason(ifp, state->reason);
+ if (ifo->options & DHCPCD_INFORM) {
+ state->state = DHS_INFORM;
+ state->xid = dhcp_xid(ifp);
+ state->lease.server.s_addr = dst ? dst->s_addr : INADDR_ANY;
+ state->addr = *addr;
+ state->net = *net;
+ dhcp_inform(ifp);
+ }
+}
diff -r 20d099339eac -r 246ea8227261 external/bsd/dhcpcd/dist/dhcpcd.8.in
--- a/external/bsd/dhcpcd/dist/dhcpcd.8.in Fri Sep 20 10:51:29 2013 +0000
+++ b/external/bsd/dhcpcd/dist/dhcpcd.8.in Fri Sep 20 10:56:32 2013 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: dhcpcd.8.in,v 1.21 2013/07/29 20:39:28 roy Exp $
+.\" $NetBSD: dhcpcd.8.in,v 1.22 2013/09/20 10:56:32 roy Exp $
.\" Copyright (c) 2006-2013 Roy Marples
.\" All rights reserved
.\"
@@ -23,7 +23,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd June 6, 2013
+.Dd September 12, 2013
.Dt DHCPCD 8
.Os
.Sh NAME
@@ -31,7 +31,7 @@
.Nd a DHCP client
.Sh SYNOPSIS
.Nm
-.Op Fl 46ABbDdEGgHJKkLnpqTVw
+.Op Fl 46ABbDdEGgHJKLpqTV
.Op Fl C , Fl Fl nohook Ar hook
.Op Fl c , Fl Fl script Ar script
.Op Fl e , Fl Fl env Ar value
@@ -52,6 +52,7 @@
.Op Fl u , Fl Fl userclass Ar class
.Op Fl v , Fl Fl vendor Ar code , Ar value
.Op Fl W , Fl Fl whitelist Ar address Ns Op Ar /cidr
+.Op Fl w , Fl Fl waitip Op 4 | 6
.Op Fl y , Fl Fl reboot Ar seconds
.Op Fl X , Fl Fl blacklist Ar address Ns Op Ar /cidr
.Op Fl Z , Fl Fl denyinterfaces Ar pattern
@@ -59,6 +60,9 @@
.Op interface
.Op ...
.Nm
+.Fl n , Fl Fl rebind
+.Op interface
+.Nm
.Fl k , Fl Fl release
.Op interface
.Nm
@@ -300,16 +304,19 @@
If not set then none is sent.
Some badly configured DHCP servers reject unknown vendorclassids.
To work around it, try and impersonate Windows by using the MSFT vendorclassid.
-.It Fl k , Fl Fl release
+.It Fl k , Fl Fl release Op Ar interface
This causes an existing
.Nm
process running on the
.Ar interface
-to release its lease, de-configure the
+to release its lease and de-configure the
+.Ar interface .
+If no
.Ar interface
-and then exit.
+is specified then this applies to all interfaces.
+If no interfaces are left running,
.Nm
-then waits until this process has exited.
+will exit.
.It Fl l , Fl Fl leasetime Ar seconds
Request a specific lease time in
Home |
Main Index |
Thread Index |
Old Index