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/6e98fcaf02da
branches:  trunk
changeset: 332368:6e98fcaf02da
user:      roy <roy%NetBSD.org@localhost>
date:      Thu Sep 18 20:46:30 2014 +0000

description:
Sync

diffstat:

 external/bsd/dhcpcd/dist/dhcpcd.c |   6 +-
 external/bsd/dhcpcd/dist/if-bsd.c |  65 +++++++++++++++++++-------------------
 external/bsd/dhcpcd/dist/ipv6nd.c |  12 +++----
 3 files changed, 41 insertions(+), 42 deletions(-)

diffs (289 lines):

diff -r 002a49b83db1 -r 6e98fcaf02da external/bsd/dhcpcd/dist/dhcpcd.c
--- a/external/bsd/dhcpcd/dist/dhcpcd.c Thu Sep 18 20:43:55 2014 +0000
+++ b/external/bsd/dhcpcd/dist/dhcpcd.c Thu Sep 18 20:46:30 2014 +0000
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: dhcpcd.c,v 1.8 2014/09/16 22:27:04 roy Exp $");
+ __RCSID("$NetBSD: dhcpcd.c,v 1.9 2014/09/18 20:46:30 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -102,7 +102,7 @@
        return pid;
 }
 
-static inline int
+static int
 write_pid(int fd, pid_t pid)
 {
 
@@ -381,7 +381,7 @@
        if (ifo->options & DHCPCD_IPV6RS) {
                ra_global = if_checkipv6(ifp->ctx, NULL,
                    ifp->ctx->options & DHCPCD_IPV6RA_OWN ? 1 : 0);
-               ra_iface = if_checkipv6(ifp->ctx, ifp->name,
+               ra_iface = if_checkipv6(ifp->ctx, ifp,
                    ifp->options->options & DHCPCD_IPV6RA_OWN ? 1 : 0);
                if (ra_global == -1 || ra_iface == -1)
                        ifo->options &= ~DHCPCD_IPV6RS;
diff -r 002a49b83db1 -r 6e98fcaf02da external/bsd/dhcpcd/dist/if-bsd.c
--- a/external/bsd/dhcpcd/dist/if-bsd.c Thu Sep 18 20:43:55 2014 +0000
+++ b/external/bsd/dhcpcd/dist/if-bsd.c Thu Sep 18 20:46:30 2014 +0000
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: if-bsd.c,v 1.8 2014/09/16 22:27:04 roy Exp $");
+ __RCSID("$NetBSD: if-bsd.c,v 1.9 2014/09/18 20:46:30 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -772,7 +772,7 @@
 if_managelink(struct dhcpcd_ctx *ctx)
 {
        /* route and ifwatchd like a msg buf size of 2048 */
-       char msg[2048], *p, *e, *cp, ifname[IF_NAMESIZE];
+       char msg[2048], *p, *e, *cp;
        ssize_t bytes;
        struct rt_msghdr *rtm;
        struct if_announcemsghdr *ifan;
@@ -781,6 +781,7 @@
        struct sockaddr *sa, *rti_info[RTAX_MAX];
        int len;
        struct sockaddr_dl sdl;
+       struct interface *ifp;
 #ifdef INET
        struct rt rt;
 #endif
@@ -819,8 +820,7 @@
 #endif
                case RTM_IFINFO:
                        ifm = (struct if_msghdr *)(void *)p;
-                       memset(ifname, 0, sizeof(ifname));
-                       if (!(if_indextoname(ifm->ifm_index, ifname)))
+                       if ((ifp = if_findindex(ctx, ifm->ifm_index)) == NULL)
                                break;
                        switch (ifm->ifm_data.ifi_link_state) {
                        case LINK_STATE_DOWN:
@@ -841,7 +841,7 @@
                                break;
                        }
                        dhcpcd_handlecarrier(ctx, len,
-                           (unsigned int)ifm->ifm_flags, ifname);
+                           (unsigned int)ifm->ifm_flags, ifp->name);
                        break;
                case RTM_DELETE:
                        if (~rtm->rtm_addrs &
@@ -867,7 +867,7 @@
                case RTM_DELADDR:       /* FALLTHROUGH */
                case RTM_NEWADDR:
                        ifam = (struct ifa_msghdr *)(void *)p;
-                       if (!if_indextoname(ifam->ifam_index, ifname))
+                       if ((ifp = if_findindex(ctx, ifam->ifam_index)) == NULL)
                                break;
                        cp = (char *)(void *)(ifam + 1);
                        get_addrs(ifam->ifam_addrs, cp, rti_info);
@@ -884,7 +884,7 @@
 #endif
                                memcpy(&sdl, rti_info[RTAX_IFA],
                                    rti_info[RTAX_IFA]->sa_len);
-                               dhcpcd_handlehwaddr(ctx, ifname,
+                               dhcpcd_handlehwaddr(ctx, ifp->name,
                                    (const unsigned char*)CLLADDR(&sdl),
                                    sdl.sdl_alen);
                                break;
@@ -895,7 +895,7 @@
                                COPYOUT(rt.net, rti_info[RTAX_NETMASK]);
                                COPYOUT(rt.gate, rti_info[RTAX_BRD]);
                                ipv4_handleifa(ctx, rtm->rtm_type,
-                                   NULL, ifname,
+                                   NULL, ifp->name,
                                    &rt.dest, &rt.net, &rt.gate);
                                break;
 #endif
@@ -905,13 +905,14 @@
                                    rti_info[RTAX_IFA];
                                ia6 = sin6->sin6_addr;
                                if (rtm->rtm_type == RTM_NEWADDR) {
-                                       ifa_flags = if_addrflags6(ifname, &ia6);
+                                       ifa_flags = if_addrflags6(ifp->name,
+                                           &ia6);
                                        if (ifa_flags == -1)
                                                break;
                                } else
                                        ifa_flags = 0;
                                ipv6_handleifa(ctx, rtm->rtm_type, NULL,
-                                   ifname, &ia6, ifa_flags);
+                                   ifp->name, &ia6, ifa_flags);
                                break;
 #endif
                        }
@@ -1042,38 +1043,38 @@
        if (s == -1)
                return -1;
        strlcpy(dummy, "lo0", sizeof(dummy));
-       if (ioctl(s, SIOCSRTRFLUSH_IN6, (caddr_t)&dummy) == -1)
+       if (ioctl(s, SIOCSRTRFLUSH_IN6, (void *)&dummy) == -1)
                syslog(LOG_ERR, "SIOSRTRFLUSH_IN6: %m");
-       if (ioctl(s, SIOCSPFXFLUSH_IN6, (caddr_t)&dummy) == -1)
+       if (ioctl(s, SIOCSPFXFLUSH_IN6, (void *)&dummy) == -1)
                syslog(LOG_ERR, "SIOSPFXFLUSH_IN6: %m");
        close(s);
        return 0;
 }
 
 int
-if_checkipv6(struct dhcpcd_ctx *ctx, const char *ifname, int own)
+if_checkipv6(struct dhcpcd_ctx *ctx, const struct interface *ifp, int own)
 {
        int ra;
 
-       if (ifname) {
+       if (ifp) {
 #ifdef ND6_IFF_OVERRIDE_RTADV
                int override;
 #endif
 
 #ifdef ND6_IFF_IFDISABLED
-               if (del_if_nd6_flag(ifname, ND6_IFF_IFDISABLED) == -1) {
+               if (del_if_nd6_flag(ifp->name, ND6_IFF_IFDISABLED) == -1) {
                        syslog(LOG_ERR,
                            "%s: del_if_nd6_flag: ND6_IFF_IFDISABLED: %m",
-                           ifname);
+                           ifp->name);
                        return -1;
                }
 #endif
 
 #ifdef ND6_IFF_PERFORMNUD
-               if (set_if_nd6_flag(ifname, ND6_IFF_PERFORMNUD) == -1) {
+               if (set_if_nd6_flag(ifp->name, ND6_IFF_PERFORMNUD) == -1) {
                        syslog(LOG_ERR,
                            "%s: set_if_nd6_flag: ND6_IFF_PERFORMNUD: %m",
-                           ifname);
+                           ifp->name);
                        return -1;
                }
 #endif
@@ -1082,24 +1083,24 @@
                if (own) {
                        int all;
 
-                       all = get_if_nd6_flag(ifname, ND6_IFF_AUTO_LINKLOCAL);
+                       all = get_if_nd6_flag(ifp->name,ND6_IFF_AUTO_LINKLOCAL);
                        if (all == -1)
                                syslog(LOG_ERR,
                                    "%s: get_if_nd6_flag: "
                                    "ND6_IFF_AUTO_LINKLOCAL: %m",
-                                   ifname);
+                                   ifp->name);
                        else if (all != 0) {
                                syslog(LOG_DEBUG,
                                    "%s: disabling Kernel IPv6 "
                                    "auto link-local support",
-                                   ifname);
-                               if (del_if_nd6_flag(ifname,
+                                   ifp->name);
+                               if (del_if_nd6_flag(ifp->name,
                                    ND6_IFF_AUTO_LINKLOCAL) == -1)
                                {
                                        syslog(LOG_ERR,
                                            "%s: del_if_nd6_flag: "
                                            "ND6_IFF_AUTO_LINKLOCAL: %m",
-                                           ifname);
+                                           ifp->name);
                                        return -1;
                                }
                        }
@@ -1107,43 +1108,43 @@
 #endif
 
 #ifdef ND6_IFF_OVERRIDE_RTADV
-               override = get_if_nd6_flag(ifname, ND6_IFF_OVERRIDE_RTADV);
+               override = get_if_nd6_flag(ifp->name, ND6_IFF_OVERRIDE_RTADV);
                if (override == -1)
                        syslog(LOG_ERR,
                            "%s: get_if_nd6_flag: ND6_IFF_OVERRIDE_RTADV: %m",
-                           ifname);
+                           ifp->name);
                else if (override == 0 && !own)
                        return 0;
 #endif
 
 #ifdef ND6_IFF_ACCEPT_RTADV
-               ra = get_if_nd6_flag(ifname, ND6_IFF_ACCEPT_RTADV);
+               ra = get_if_nd6_flag(ifp->name, ND6_IFF_ACCEPT_RTADV);
                if (ra == -1)
                        syslog(LOG_ERR,
                            "%s: get_if_nd6_flag: ND6_IFF_ACCEPT_RTADV: %m",
-                           ifname);
+                           ifp->name);
                else if (ra != 0 && own) {
                        syslog(LOG_DEBUG,
                            "%s: disabling Kernel IPv6 RA support",
-                           ifname);
-                       if (del_if_nd6_flag(ifname, ND6_IFF_ACCEPT_RTADV)
+                           ifp->name);
+                       if (del_if_nd6_flag(ifp->name, ND6_IFF_ACCEPT_RTADV)
                            == -1)
                        {
                                syslog(LOG_ERR,
                                    "%s: del_if_nd6_flag: "
                                    "ND6_IFF_ACCEPT_RTADV: %m",
-                                   ifname);
+                                   ifp->name);
                                return ra;
                        }
 #ifdef ND6_IFF_OVERRIDE_RTADV
                        if (override == 0 &&
-                           set_if_nd6_flag(ifname, ND6_IFF_OVERRIDE_RTADV)
+                           set_if_nd6_flag(ifp->name, ND6_IFF_OVERRIDE_RTADV)
                            == -1)
                        {
                                syslog(LOG_ERR,
                                    "%s: set_if_nd6_flag: "
                                    "ND6_IFF_OVERRIDE_RTADV: %m",
-                                   ifname);
+                                   ifp->name);
                                return ra;
                        }
 #endif
diff -r 002a49b83db1 -r 6e98fcaf02da external/bsd/dhcpcd/dist/ipv6nd.c
--- a/external/bsd/dhcpcd/dist/ipv6nd.c Thu Sep 18 20:43:55 2014 +0000
+++ b/external/bsd/dhcpcd/dist/ipv6nd.c Thu Sep 18 20:46:30 2014 +0000
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: ipv6nd.c,v 1.11 2014/09/16 22:27:04 roy Exp $");
+ __RCSID("$NetBSD: ipv6nd.c,v 1.12 2014/09/18 20:46:30 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -36,11 +36,6 @@
 #include <netinet/ip6.h>
 #include <netinet/icmp6.h>
 
-#ifdef __linux__
-#  define _LINUX_IN6_H
-#  include <linux/ipv6.h>
-#endif
-
 #include <errno.h>
 #include <fcntl.h>
 #include <stddef.h>
@@ -290,7 +285,7 @@
 
        state = RS_STATE(ifp);
        ctx = ifp->ctx->ipv6;
-       ctx->sndhdr.msg_name = (caddr_t)&dst;
+       ctx->sndhdr.msg_name = (void *)&dst;
        ctx->sndhdr.msg_iov[0].iov_base = state->rs;
        ctx->sndhdr.msg_iov[0].iov_len = state->rslen;
 
@@ -405,6 +400,9 @@
        struct ra *rap;
        struct ipv6_addr *ap;
 
+       if (ctx->ipv6 == NULL)
+               return 0;
+
        TAILQ_FOREACH(rap, ctx->ipv6->ra_routers, next) {
                TAILQ_FOREACH(ap, &rap->addrs, next) {
                        if (addr == NULL) {



Home | Main Index | Thread Index | Old Index