Module Name:    src
Committed By:   roy
Date:           Thu Sep 18 20:46:30 UTC 2014

Modified Files:
        src/external/bsd/dhcpcd/dist: dhcpcd.c if-bsd.c ipv6nd.c

Log Message:
Sync


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/external/bsd/dhcpcd/dist/dhcpcd.c \
    src/external/bsd/dhcpcd/dist/if-bsd.c
cvs rdiff -u -r1.11 -r1.12 src/external/bsd/dhcpcd/dist/ipv6nd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/dhcpcd/dist/dhcpcd.c
diff -u src/external/bsd/dhcpcd/dist/dhcpcd.c:1.8 src/external/bsd/dhcpcd/dist/dhcpcd.c:1.9
--- src/external/bsd/dhcpcd/dist/dhcpcd.c:1.8	Tue Sep 16 22:27:04 2014
+++ src/external/bsd/dhcpcd/dist/dhcpcd.c	Thu Sep 18 20:46:30 2014
@@ -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 @@ read_pid(const char *pidfile)
 	return pid;
 }
 
-static inline int
+static int
 write_pid(int fd, pid_t pid)
 {
 
@@ -381,7 +381,7 @@ configure_interface1(struct interface *i
 	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;
Index: src/external/bsd/dhcpcd/dist/if-bsd.c
diff -u src/external/bsd/dhcpcd/dist/if-bsd.c:1.8 src/external/bsd/dhcpcd/dist/if-bsd.c:1.9
--- src/external/bsd/dhcpcd/dist/if-bsd.c:1.8	Tue Sep 16 22:27:04 2014
+++ src/external/bsd/dhcpcd/dist/if-bsd.c	Thu Sep 18 20:46:30 2014
@@ -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 @@ int
 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 @@ if_managelink(struct dhcpcd_ctx *ctx)
 	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 @@ if_managelink(struct dhcpcd_ctx *ctx)
 #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 @@ if_managelink(struct dhcpcd_ctx *ctx)
 				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 @@ if_managelink(struct dhcpcd_ctx *ctx)
 		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 @@ if_managelink(struct dhcpcd_ctx *ctx)
 #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 @@ if_managelink(struct dhcpcd_ctx *ctx)
 				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 @@ if_managelink(struct dhcpcd_ctx *ctx)
 				    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_raflush(void)
 	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_checkipv6(struct dhcpcd_ctx *ctx, con
 		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 @@ if_checkipv6(struct dhcpcd_ctx *ctx, con
 #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

Index: src/external/bsd/dhcpcd/dist/ipv6nd.c
diff -u src/external/bsd/dhcpcd/dist/ipv6nd.c:1.11 src/external/bsd/dhcpcd/dist/ipv6nd.c:1.12
--- src/external/bsd/dhcpcd/dist/ipv6nd.c:1.11	Tue Sep 16 22:27:04 2014
+++ src/external/bsd/dhcpcd/dist/ipv6nd.c	Thu Sep 18 20:46:30 2014
@@ -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 @@ ipv6nd_sendrsprobe(void *arg)
 
 	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 @@ ipv6nd_addrexists(struct dhcpcd_ctx *ctx
 	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) {

Reply via email to