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/cddb1ba40212
branches:  trunk
changeset: 816107:cddb1ba40212
user:      roy <roy%NetBSD.org@localhost>
date:      Fri Jun 17 19:42:31 2016 +0000

description:
Sync

diffstat:

 external/bsd/dhcpcd/dist/arp.c                       |  129 ++--
 external/bsd/dhcpcd/dist/arp.h                       |    5 +-
 external/bsd/dhcpcd/dist/bpf-filter.h                |   10 +-
 external/bsd/dhcpcd/dist/defs.h                      |    4 +-
 external/bsd/dhcpcd/dist/dhcp-common.c               |    4 +-
 external/bsd/dhcpcd/dist/dhcp.c                      |  349 ++++++-----
 external/bsd/dhcpcd/dist/dhcp.h                      |   47 +-
 external/bsd/dhcpcd/dist/dhcp6.c                     |   70 +-
 external/bsd/dhcpcd/dist/dhcp6.h                     |    3 +-
 external/bsd/dhcpcd/dist/dhcpcd-hooks/20-resolv.conf |   12 +-
 external/bsd/dhcpcd/dist/dhcpcd-hooks/30-hostname    |    6 +-
 external/bsd/dhcpcd/dist/dhcpcd.c                    |   25 +-
 external/bsd/dhcpcd/dist/dhcpcd.conf.5.in            |   20 +-
 external/bsd/dhcpcd/dist/dhcpcd.h                    |    4 +-
 external/bsd/dhcpcd/dist/if-bsd.c                    |  578 +++++++++---------
 external/bsd/dhcpcd/dist/if-options.c                |    6 +-
 external/bsd/dhcpcd/dist/if.c                        |   33 +-
 external/bsd/dhcpcd/dist/if.h                        |   38 +-
 external/bsd/dhcpcd/dist/ipv4.c                      |  325 +++++-----
 external/bsd/dhcpcd/dist/ipv4.h                      |   19 +-
 external/bsd/dhcpcd/dist/ipv4ll.c                    |   93 +-
 external/bsd/dhcpcd/dist/ipv4ll.h                    |   15 +-
 external/bsd/dhcpcd/dist/ipv6.c                      |   36 +-
 external/bsd/dhcpcd/dist/ipv6.h                      |    7 +-
 external/bsd/dhcpcd/dist/ipv6nd.c                    |   21 +-
 external/bsd/dhcpcd/dist/script.c                    |    4 +-
 26 files changed, 963 insertions(+), 900 deletions(-)

diffs (truncated from 3946 to 300 lines):

diff -r 6917d9508100 -r cddb1ba40212 external/bsd/dhcpcd/dist/arp.c
--- a/external/bsd/dhcpcd/dist/arp.c    Fri Jun 17 18:48:07 2016 +0000
+++ b/external/bsd/dhcpcd/dist/arp.c    Fri Jun 17 19:42:31 2016 +0000
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: arp.c,v 1.19 2016/05/09 10:15:59 roy Exp $");
+ __RCSID("$NetBSD: arp.c,v 1.20 2016/06/17 19:42:31 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -65,6 +65,7 @@
        struct arphdr ar;
        size_t len;
        uint8_t *p;
+       const struct iarp_state *state;
 
        ar.ar_hrd = htons(ifp->family);
        ar.ar_pro = htons(ETHERTYPE_IP);
@@ -91,7 +92,9 @@
        APPEND(&sip, sizeof(sip));
        ZERO(ifp->hwlen);
        APPEND(&tip, sizeof(tip));
-       return if_sendrawpacket(ifp, ETHERTYPE_ARP, arp_buffer, len);
+
+       state = ARP_CSTATE(ifp);
+       return if_sendraw(ifp, state->fd, ETHERTYPE_ARP, arp_buffer, len);
 
 eexit:
        errno = ENOBUFS;
@@ -123,7 +126,7 @@
 {
        struct interface *ifp = arg;
        const struct interface *ifn;
-       uint8_t arp_buffer[ARP_LEN];
+       uint8_t buf[ARP_LEN];
        struct arphdr ar;
        struct arp_msg arm;
        ssize_t bytes;
@@ -134,65 +137,62 @@
 
        state = ARP_STATE(ifp);
        flags = 0;
-       while (!(flags & RAW_EOF)) {
-               bytes = if_readrawpacket(ifp, ETHERTYPE_ARP,
-                   arp_buffer, sizeof(arp_buffer), &flags);
-               if (bytes == -1) {
-                       logger(ifp->ctx, LOG_ERR,
-                           "%s: arp if_readrawpacket: %m", ifp->name);
-                       arp_close(ifp);
-                       return;
-               }
-               /* We must have a full ARP header */
-               if ((size_t)bytes < sizeof(ar))
-                       continue;
-               memcpy(&ar, arp_buffer, sizeof(ar));
-               /* Families must match */
-               if (ar.ar_hrd != htons(ifp->family))
-                       continue;
+       bytes = if_readraw(ifp, state->fd, buf, sizeof(buf), &flags);
+       if (bytes == -1) {
+               logger(ifp->ctx, LOG_ERR,
+                   "%s: arp if_readrawpacket: %m", ifp->name);
+               arp_close(ifp);
+               return;
+       }
+       /* We must have a full ARP header */
+       if ((size_t)bytes < sizeof(ar))
+               return;
+       memcpy(&ar, buf, sizeof(ar));
+       /* Families must match */
+       if (ar.ar_hrd != htons(ifp->family))
+               return;
 #if 0
-               /* These checks are enforced in the BPF filter. */
-               /* Protocol must be IP. */
-               if (ar.ar_pro != htons(ETHERTYPE_IP))
-                       continue;
-               /* Only these types are recognised */
-               if (ar.ar_op != htons(ARPOP_REPLY) &&
-                   ar.ar_op != htons(ARPOP_REQUEST))
-                       continue;
+       /* These checks are enforced in the BPF filter. */
+       /* Protocol must be IP. */
+       if (ar.ar_pro != htons(ETHERTYPE_IP))
+               continue;
+       /* Only these types are recognised */
+       if (ar.ar_op != htons(ARPOP_REPLY) &&
+           ar.ar_op != htons(ARPOP_REQUEST))
+               continue;
 #endif
-               if (ar.ar_pln != sizeof(arm.sip.s_addr))
-                       continue;
+       if (ar.ar_pln != sizeof(arm.sip.s_addr))
+               return;
 
-               /* Get pointers to the hardware addreses */
-               hw_s = arp_buffer + sizeof(ar);
-               hw_t = hw_s + ar.ar_hln + ar.ar_pln;
-               /* Ensure we got all the data */
-               if ((hw_t + ar.ar_hln + ar.ar_pln) - arp_buffer > bytes)
-                       continue;
-               /* Ignore messages from ourself */
-               TAILQ_FOREACH(ifn, ifp->ctx->ifaces, next) {
-                       if (ar.ar_hln == ifn->hwlen &&
-                           memcmp(hw_s, ifn->hwaddr, ifn->hwlen) == 0)
-                               break;
-               }
-               if (ifn) {
+       /* Get pointers to the hardware addreses */
+       hw_s = buf + sizeof(ar);
+       hw_t = hw_s + ar.ar_hln + ar.ar_pln;
+       /* Ensure we got all the data */
+       if ((hw_t + ar.ar_hln + ar.ar_pln) - buf > bytes)
+               return;
+       /* Ignore messages from ourself */
+       TAILQ_FOREACH(ifn, ifp->ctx->ifaces, next) {
+               if (ar.ar_hln == ifn->hwlen &&
+                   memcmp(hw_s, ifn->hwaddr, ifn->hwlen) == 0)
+                       break;
+       }
+       if (ifn) {
 #if 0
-                       logger(ifp->ctx, LOG_DEBUG,
-                           "%s: ignoring ARP from self", ifp->name);
+               logger(ifp->ctx, LOG_DEBUG,
+                   "%s: ignoring ARP from self", ifp->name);
 #endif
-                       continue;
-               }
-               /* Copy out the HW and IP addresses */
-               memcpy(&arm.sha, hw_s, ar.ar_hln);
-               memcpy(&arm.sip.s_addr, hw_s + ar.ar_hln, ar.ar_pln);
-               memcpy(&arm.tha, hw_t, ar.ar_hln);
-               memcpy(&arm.tip.s_addr, hw_t + ar.ar_hln, ar.ar_pln);
+               return;
+       }
+       /* Copy out the HW and IP addresses */
+       memcpy(&arm.sha, hw_s, ar.ar_hln);
+       memcpy(&arm.sip.s_addr, hw_s + ar.ar_hln, ar.ar_pln);
+       memcpy(&arm.tha, hw_t, ar.ar_hln);
+       memcpy(&arm.tip.s_addr, hw_t + ar.ar_hln, ar.ar_pln);
 
-               /* Run the conflicts */
-               TAILQ_FOREACH_SAFE(astate, &state->arp_states, next, astaten) {
-                       if (astate->conflicted_cb)
-                               astate->conflicted_cb(astate, &arm);
-               }
+       /* Run the conflicts */
+       TAILQ_FOREACH_SAFE(astate, &state->arp_states, next, astaten) {
+               if (astate->conflicted_cb)
+                       astate->conflicted_cb(astate, &arm);
        }
 }
 
@@ -203,7 +203,7 @@
 
        state = ARP_STATE(ifp);
        if (state->fd == -1) {
-               state->fd = if_openrawsocket(ifp, ETHERTYPE_ARP);
+               state->fd = if_openraw(ifp, ETHERTYPE_ARP);
                if (state->fd == -1) {
                        logger(ifp->ctx, LOG_ERR, "%s: %s: %m",
                            __func__, ifp->name);
@@ -391,7 +391,7 @@
                    TAILQ_FIRST(&state->arp_states) == NULL)
                {
                        eloop_event_delete(ifp->ctx->eloop, state->fd);
-                       close(state->fd);
+                       if_closeraw(ifp, state->fd);
                        free(state);
                        ifp->if_data[IF_DATA_ARP] = NULL;
                }
@@ -428,22 +428,21 @@
 }
 
 void
-arp_handleifa(int cmd, struct interface *ifp, const struct in_addr *addr,
-    int flags)
+arp_handleifa(int cmd, struct ipv4_addr *addr)
 {
 #ifdef IN_IFF_DUPLICATED
        struct iarp_state *state;
        struct arp_state *astate, *asn;
 
-       if (cmd != RTM_NEWADDR || (state = ARP_STATE(ifp)) == NULL)
+       if (cmd != RTM_NEWADDR || (state = ARP_STATE(addr->iface)) == NULL)
                return;
 
        TAILQ_FOREACH_SAFE(astate, &state->arp_states, next, asn) {
-               if (astate->addr.s_addr == addr->s_addr) {
-                       if (flags & IN_IFF_DUPLICATED) {
+               if (astate->addr.s_addr == addr->addr.s_addr) {
+                       if (addr->addr_flags & IN_IFF_DUPLICATED) {
                                if (astate->conflicted_cb)
                                        astate->conflicted_cb(astate, NULL);
-                       } else if (!(flags & IN_IFF_NOTUSEABLE)) {
+                       } else if (!(addr->addr_flags & IN_IFF_NOTUSEABLE)) {
                                if (astate->probed_cb)
                                        astate->probed_cb(astate);
                        }
@@ -451,8 +450,6 @@
        }
 #else
        UNUSED(cmd);
-       UNUSED(ifp);
        UNUSED(addr);
-       UNUSED(flags);
 #endif
 }
diff -r 6917d9508100 -r cddb1ba40212 external/bsd/dhcpcd/dist/arp.h
--- a/external/bsd/dhcpcd/dist/arp.h    Fri Jun 17 18:48:07 2016 +0000
+++ b/external/bsd/dhcpcd/dist/arp.h    Fri Jun 17 19:42:31 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: arp.h,v 1.13 2016/05/09 10:15:59 roy Exp $ */
+/* $NetBSD: arp.h,v 1.14 2016/06/17 19:42:31 roy Exp $ */
 
 /*
  * dhcpcd - DHCP client daemon
@@ -43,6 +43,7 @@
 #define DEFEND_INTERVAL                10
 
 #include "dhcpcd.h"
+#include "if.h"
 
 struct arp_msg {
        uint16_t op;
@@ -91,7 +92,7 @@
 struct arp_state *arp_find(struct interface *, const struct in_addr *);
 void arp_close(struct interface *);
 
-void arp_handleifa(int, struct interface *, const struct in_addr *, int);
+void arp_handleifa(int, struct ipv4_addr *);
 #else
 #define arp_close(a) {}
 #endif
diff -r 6917d9508100 -r cddb1ba40212 external/bsd/dhcpcd/dist/bpf-filter.h
--- a/external/bsd/dhcpcd/dist/bpf-filter.h     Fri Jun 17 18:48:07 2016 +0000
+++ b/external/bsd/dhcpcd/dist/bpf-filter.h     Fri Jun 17 19:42:31 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bpf-filter.h,v 1.10 2016/01/07 20:09:43 roy Exp $ */
+/* $NetBSD: bpf-filter.h,v 1.11 2016/06/17 19:42:31 roy Exp $ */
 
 /*
  * dhcpcd - DHCP client daemon
@@ -51,7 +51,7 @@
        /* Otherwise, drop it. */
        BPF_STMT(BPF_RET + BPF_K, 0),
 };
-#define arp_bpf_filter_len sizeof(arp_bpf_filter) / sizeof(arp_bpf_filter[0])
+#define arp_bpf_filter_len __arraycount(arp_bpf_filter)
 
 
 /* dhcp_bpf_filter taken from bpf.c in dhcp-3.1.0
@@ -78,7 +78,7 @@
  *   http://www.isc.org/
  */
 
-static const struct bpf_insn dhcp_bpf_filter [] = {
+static const struct bpf_insn bootp_bpf_filter [] = {
 #ifndef BPF_SKIPTYPE
        /* Make sure this is an IP packet... */
        BPF_STMT(BPF_LD + BPF_H + BPF_ABS, 12),
@@ -94,10 +94,10 @@
        BPF_STMT(BPF_LDX + BPF_B + BPF_MSH, 14 + BPF_ETHCOOK),
        /* Make sure it's to the right port... */
        BPF_STMT(BPF_LD + BPF_H + BPF_IND, 16 + BPF_ETHCOOK),
-       BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, DHCP_CLIENT_PORT, 0, 1),
+       BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, BOOTPC, 0, 1),
        /* If we passed all the tests, ask for the whole packet. */
        BPF_STMT(BPF_RET + BPF_K, BPF_WHOLEPACKET),
        /* Otherwise, drop it. */
        BPF_STMT(BPF_RET + BPF_K, 0),
 };
-#define dhcp_bpf_filter_len sizeof(dhcp_bpf_filter) / sizeof(dhcp_bpf_filter[0])
+#define bootp_bpf_filter_len __arraycount(bootp_bpf_filter)
diff -r 6917d9508100 -r cddb1ba40212 external/bsd/dhcpcd/dist/defs.h
--- a/external/bsd/dhcpcd/dist/defs.h   Fri Jun 17 18:48:07 2016 +0000
+++ b/external/bsd/dhcpcd/dist/defs.h   Fri Jun 17 19:42:31 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: defs.h,v 1.27 2016/05/09 10:15:59 roy Exp $ */
+/* $NetBSD: defs.h,v 1.28 2016/06/17 19:42:31 roy Exp $ */
 
 /*
  * dhcpcd - DHCP client daemon
@@ -30,7 +30,7 @@
 #define CONFIG_H
 
 #define PACKAGE                        "dhcpcd"
-#define VERSION                        "6.11.0"
+#define VERSION                        "6.11.1"
 
 #ifndef CONFIG
 # define CONFIG                        SYSCONFDIR "/" PACKAGE ".conf"
diff -r 6917d9508100 -r cddb1ba40212 external/bsd/dhcpcd/dist/dhcp-common.c
--- a/external/bsd/dhcpcd/dist/dhcp-common.c    Fri Jun 17 18:48:07 2016 +0000
+++ b/external/bsd/dhcpcd/dist/dhcp-common.c    Fri Jun 17 19:42:31 2016 +0000
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: dhcp-common.c,v 1.17 2016/06/08 01:33:08 christos Exp $");
+ __RCSID("$NetBSD: dhcp-common.c,v 1.18 2016/06/17 19:42:31 roy Exp $");



Home | Main Index | Thread Index | Old Index