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 Import dhcpcd-5.1.5 with the follow...



details:   https://anonhg.NetBSD.org/src/rev/4b92c17f752c
branches:  trunk
changeset: 751324:4b92c17f752c
user:      roy <roy%NetBSD.org@localhost>
date:      Sun Jan 31 20:50:16 2010 +0000

description:
Import dhcpcd-5.1.5 with the following changes:
* -H, --xidhwaddr uses the last 4 bytes of the hardware address as
  the DHCP xid
* -J, --broadcast tells the DHCP server to broadcast replies
* no longer warn about InfiniBand being an unsupported family
* infinite lease times are valid when reading old leases
* discard address correctly if lease is invalid

diffstat:

 external/bsd/dhcpcd/dist/defs.h           |   4 +-
 external/bsd/dhcpcd/dist/dhcp.c           |  21 +++++------
 external/bsd/dhcpcd/dist/dhcpcd.c         |  56 +++++++++++++++++++++++-------
 external/bsd/dhcpcd/dist/dhcpcd.conf.5.in |  26 +++++++++----
 external/bsd/dhcpcd/dist/if-options.c     |  10 ++++-
 external/bsd/dhcpcd/dist/if-options.h     |   6 ++-
 external/bsd/dhcpcd/dist/net.c            |   8 +++-
 7 files changed, 93 insertions(+), 38 deletions(-)

diffs (truncated from 406 to 300 lines):

diff -r e71a00969dc4 -r 4b92c17f752c external/bsd/dhcpcd/dist/defs.h
--- a/external/bsd/dhcpcd/dist/defs.h   Sun Jan 31 20:38:11 2010 +0000
+++ b/external/bsd/dhcpcd/dist/defs.h   Sun Jan 31 20:50:16 2010 +0000
@@ -1,6 +1,6 @@
 /*
  * dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2009 Roy Marples <roy%marples.name@localhost>
+ * Copyright (c) 2006-2010 Roy Marples <roy%marples.name@localhost>
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -28,7 +28,7 @@
 #define CONFIG_H
 
 #define PACKAGE                        "dhcpcd"
-#define VERSION                        "5.1.4"
+#define VERSION                        "5.1.5"
 
 #ifndef CONFIG
 # define CONFIG                        SYSCONFDIR "/" PACKAGE ".conf"
diff -r e71a00969dc4 -r 4b92c17f752c external/bsd/dhcpcd/dist/dhcp.c
--- a/external/bsd/dhcpcd/dist/dhcp.c   Sun Jan 31 20:38:11 2010 +0000
+++ b/external/bsd/dhcpcd/dist/dhcp.c   Sun Jan 31 20:50:16 2010 +0000
@@ -1,6 +1,6 @@
 /* 
  * dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2009 Roy Marples <roy%marples.name@localhost>
+ * Copyright (c) 2006-2010 Roy Marples <roy%marples.name@localhost>
  * All rights reserved
 
  * Redistribution and use in source and binary forms, with or without
@@ -421,7 +421,7 @@
 }
 
 /* Decode an RFC3397 DNS search order option into a space
- * seperated string. Returns length of string (including 
+ * separated string. Returns length of string (including
  * terminating zero) or zero on error. out may be NULL
  * to just determine output length. */
 static ssize_t
@@ -863,18 +863,17 @@
        switch (iface->family) {
        case ARPHRD_ETHER:
        case ARPHRD_IEEE802:
-               dhcp->hwlen = ETHER_ADDR_LEN;
-               memcpy(&dhcp->chaddr, &iface->hwaddr, ETHER_ADDR_LEN);
-               break;
-       case ARPHRD_IEEE1394:
-       case ARPHRD_INFINIBAND:
-               dhcp->hwlen = 0;
-               if (dhcp->ciaddr == 0 &&
-                   type != DHCP_DECLINE && type != DHCP_RELEASE)
-                       dhcp->flags = htons(BROADCAST_FLAG);
+               dhcp->hwlen = iface->hwlen;
+               memcpy(&dhcp->chaddr, &iface->hwaddr, iface->hwlen);
                break;
        }
 
+       if (ifo->options & DHCPCD_BROADCAST &&
+           dhcp->ciaddr == 0 &&
+           type != DHCP_DECLINE &&
+           type != DHCP_RELEASE)
+               dhcp->flags = htons(BROADCAST_FLAG);
+
        if (type != DHCP_DECLINE && type != DHCP_RELEASE) {
                if (up < 0 || up > (time_t)UINT16_MAX)
                        dhcp->secs = htons((uint16_t)UINT16_MAX);
diff -r e71a00969dc4 -r 4b92c17f752c external/bsd/dhcpcd/dist/dhcpcd.c
--- a/external/bsd/dhcpcd/dist/dhcpcd.c Sun Jan 31 20:38:11 2010 +0000
+++ b/external/bsd/dhcpcd/dist/dhcpcd.c Sun Jan 31 20:50:16 2010 +0000
@@ -1,6 +1,6 @@
 /* 
  * dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2009 Roy Marples <roy%marples.name@localhost>
+ * Copyright (c) 2006-2010 Roy Marples <roy%marples.name@localhost>
  * All rights reserved
 
  * Redistribution and use in source and binary forms, with or without
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  */
 
-const char copyright[] = "Copyright (c) 2006-2009 Roy Marples";
+const char copyright[] = "Copyright (c) 2006-2010 Roy Marples";
 
 #include <sys/file.h>
 #include <sys/socket.h>
@@ -142,7 +142,7 @@
 static void
 usage(void)
 {
-       printf("usage: "PACKAGE" [-dgknpqwxyADEGHKLOTV] [-c script] [-f file]"
+       printf("usage: "PACKAGE" [-dgknpqwxyADEGHJKLOTV] [-c script] [-f file]"
            " [-e var=val]\n"
            "              [-h hostname] [-i classID ] [-l leasetime]"
            " [-m metric] [-o option]\n"
@@ -271,6 +271,22 @@
                exit(EXIT_FAILURE);
 }
 
+static uint32_t
+dhcp_xid(struct interface *iface)
+{
+       uint32_t xid;
+
+       if (iface->state->options->options & DHCPCD_XID_HWADDR &&
+           iface->hwlen >= sizeof(xid)) 
+               /* The lower bits are probably more unique on the network */
+               memcpy(&xid, (iface->hwaddr + iface->hwlen) - sizeof(xid),
+                   sizeof(xid));
+       else
+               xid = arc4random();
+
+       return xid;
+}
+
 static void
 send_message(struct interface *iface, int type,
     void (*callback)(void *))
@@ -387,6 +403,7 @@
        iface->state->interval = 0;
        if (iface->addr.s_addr == 0) {
                /* We failed to reboot, so enter discovery. */
+               iface->state->lease.addr.s_addr = 0;
                start_discover(iface);
                return;
        }
@@ -717,7 +734,7 @@
                syslog(LOG_INFO, "%s: releasing lease of %s",
                    iface->name, inet_ntoa(iface->state->lease.addr));
                open_sockets(iface);
-               iface->state->xid = arc4random();
+               iface->state->xid = dhcp_xid(iface);
                send_message(iface, DHCP_RELEASE, NULL);
                /* Give the packet a chance to go before dropping the ip */
                ts.tv_sec = RELEASE_DELAY_S;
@@ -760,6 +777,15 @@
        if (iface->hwlen > DHCP_CHADDR_LEN)
                ifo->options |= DHCPCD_CLIENTID;
 
+       /* Firewire and InfiniBand interfaces require ClientID and
+        * the broadcast option being set. */
+       switch (iface->family) {
+       case ARPHRD_IEEE1394:   /* FALLTHROUGH */
+       case ARPHRD_INFINIBAND:
+               ifo->options |= DHCPCD_CLIENTID | DHCPCD_BROADCAST;
+               break;
+       }
+
        free(iface->clientid);
        if (*ifo->clientid) {
                iface->clientid = xmalloc(ifo->clientid[0] + 1);
@@ -886,7 +912,7 @@
        struct if_options *ifo = iface->state->options;
 
        iface->state->state = DHS_DISCOVER;
-       iface->state->xid = arc4random();
+       iface->state->xid = dhcp_xid(iface);
        open_sockets(iface);
        delete_timeout(NULL, iface);
        if (ifo->fallback)
@@ -920,7 +946,7 @@
        syslog(LOG_INFO, "%s: renewing lease of %s",
            iface->name, inet_ntoa(iface->state->lease.addr));
        iface->state->state = DHS_RENEW;
-       iface->state->xid = arc4random();
+       iface->state->xid = dhcp_xid(iface);
        open_sockets(iface);
        send_renew(iface);
 }
@@ -1020,7 +1046,7 @@
        }
 
        iface->state->state = DHS_INFORM;
-       iface->state->xid = arc4random();
+       iface->state->xid = dhcp_xid(iface);
        open_sockets(iface);
        send_inform(iface);
 }
@@ -1058,7 +1084,7 @@
                    iface->name, inet_ntoa(iface->state->lease.addr));
        }
        iface->state->state = DHS_REBOOT;
-       iface->state->xid = arc4random();
+       iface->state->xid = dhcp_xid(iface);
        iface->state->lease.server.s_addr = 0;
        delete_timeout(NULL, iface);
        if (ifo->fallback)
@@ -1142,15 +1168,19 @@
                                free(iface->state->offer);
                                iface->state->offer = NULL;
                        }
-               } else if (stat(iface->leasefile, &st) == 0 &&
-                   get_option_uint32(&l, iface->state->offer,
-                       DHO_LEASETIME) == 0)
+               } else if (iface->state->lease.leasetime != ~0U &&
+                   stat(iface->leasefile, &st) == 0)
                {
                        /* Offset lease times and check expiry */
                        gettimeofday(&now, NULL);
-                       if ((time_t)l < now.tv_sec - st.st_mtime) {
+                       if ((time_t)iface->state->lease.leasetime <
+                           now.tv_sec - st.st_mtime)
+                       {
+                               syslog(LOG_DEBUG,
+                                   "%s: discarding expired lease", iface->name);
                                free(iface->state->offer);
                                iface->state->offer = NULL;
+                               iface->state->lease.addr.s_addr = 0;
                        } else {
                                l = now.tv_sec - st.st_mtime;
                                iface->state->lease.leasetime -= l;
@@ -1302,7 +1332,7 @@
                run_script(ifp);
                if (ifo->options & DHCPCD_INFORM) {
                        ifp->state->state = DHS_INFORM;
-                       ifp->state->xid = arc4random();
+                       ifp->state->xid = dhcp_xid(ifp);
                        ifp->state->lease.server.s_addr =
                            dst ? dst->s_addr : INADDR_ANY;
                        ifp->addr = *addr;
diff -r e71a00969dc4 -r 4b92c17f752c external/bsd/dhcpcd/dist/dhcpcd.conf.5.in
--- a/external/bsd/dhcpcd/dist/dhcpcd.conf.5.in Sun Jan 31 20:38:11 2010 +0000
+++ b/external/bsd/dhcpcd/dist/dhcpcd.conf.5.in Sun Jan 31 20:50:16 2010 +0000
@@ -1,4 +1,4 @@
-.\" Copyright (c) 2006-2009 Roy Marples
+.\" Copyright (c) 2006-2010 Roy Marples
 .\" All rights reserved
 .\"
 .\" Redistribution and use in source and binary forms, with or without
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd October 16, 2009
+.Dd January 28, 2010
 .Dt DHCPCD.CONF 5 SMM
 .Os
 .Sh NAME
@@ -83,6 +83,13 @@
 is ignored if
 .Ic whitelist
 is set.
+.It Ic broadcast
+Instructs the DHCP server to broadcast replies back to the client.
+Normally this is only set for non Ethernet interfaces,
+such as FireWire and InfiniBand.
+In most cases,
+.Nm dhcpcd
+will set this automatically.
 .It Ic env Ar value
 Push
 .Ar value
@@ -143,7 +150,7 @@
 .It Ic metric Ar metric
 Metrics are used to prefer an interface over another one, lowest wins.
 .Nm dhcpcd
-will supply a default metic of 200 +
+will supply a default metric of 200 +
 .Xr if_nametoindex 3 .
 An extra 100 will be added for wireless interfaces.
 .It Ic noarp
@@ -176,7 +183,7 @@
 It can be a variable to be used in
 .Xr dhcpcd-run-hooks 8
 or the numerical value.
-You can specify more options seperated by commas, spaces or more option lines.
+You can specify more options separated by commas, spaces or more option lines.
 .It Ic nooption Ar option
 Remove the option from the DHCP message.
 This should only be used when a DHCP server sends a non requested option
@@ -191,7 +198,7 @@
 Subsequent options are only parsed for this profile
 .Ar name .
 .It Ic quiet
-Supress any dhcpcd output to the console, except for errors.
+Suppress any dhcpcd output to the console, except for errors.
 .It Ic reboot Ar seconds
 Allow
 .Ar reboot
@@ -210,7 +217,7 @@
 It can be a variable to be used in
 .Xr dhcpcd-run-hooks 8
 or the numerical value.
-You can specify more options seperated by commas, spaces or more require lines.
+You can specify more options separated by commas, spaces or more require lines.
 To enforce that
 .Nm dhcpcd
 only responds to DHCP servers and not BOOTP servers, you can
@@ -253,7 +260,7 @@
 Tag the DHCP messages with the userclass.
 You can specify more than one.
 .It Ic vendor Ar code , Ns Ar value
-Add an enscapulated vendor option.
+Add an encapsulated vendor option.
 .Ar code
 should be between 1 and 254 inclusive.
 To add a raw vendor string, omit
@@ -267,13 +274,16 @@
 .D1 vendor 02,01:02:03:04:05



Home | Main Index | Thread Index | Old Index