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-6.0.3 with the follow...
details: https://anonhg.NetBSD.org/src/rev/74f894314a06
branches: trunk
changeset: 788777:74f894314a06
user: roy <roy%NetBSD.org@localhost>
date: Fri Jul 19 11:52:56 2013 +0000
description:
Import dhcpcd-6.0.3 with the following changes:
* dhcpcd will now assign a short hostname by default
To use a FQDN hostname, set this in dhcpcd.conf(5)
env hostname_fqdn=YES
* Only start DHCPv6 if the RA is new or has changed
* Fixed dhcpcd owning RA addressing and routes if disabled in kernel
diffstat:
external/bsd/dhcpcd/dist/defs.h | 4 +-
external/bsd/dhcpcd/dist/dhcpcd-hooks/30-hostname | 70 +++++++++++++++++----
external/bsd/dhcpcd/dist/dhcpcd.c | 74 ++++++++++------------
external/bsd/dhcpcd/dist/dhcpcd.h | 4 +-
external/bsd/dhcpcd/dist/if-bsd.c | 28 ++++----
external/bsd/dhcpcd/dist/ipv6.c | 13 ++-
external/bsd/dhcpcd/dist/ipv6rs.c | 18 +++--
external/bsd/dhcpcd/dist/platform-bsd.c | 59 +++++++++--------
external/bsd/dhcpcd/dist/platform.h | 4 +-
9 files changed, 158 insertions(+), 116 deletions(-)
diffs (truncated from 545 to 300 lines):
diff -r ec0f79bc63df -r 74f894314a06 external/bsd/dhcpcd/dist/defs.h
--- a/external/bsd/dhcpcd/dist/defs.h Fri Jul 19 11:44:51 2013 +0000
+++ b/external/bsd/dhcpcd/dist/defs.h Fri Jul 19 11:52:56 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: defs.h,v 1.1.1.28 2013/06/22 09:25:34 roy Exp $ */
+/* $NetBSD: defs.h,v 1.1.1.29 2013/07/19 11:52:57 roy Exp $ */
/*
* dhcpcd - DHCP client daemon
@@ -30,7 +30,7 @@
#define CONFIG_H
#define PACKAGE "dhcpcd"
-#define VERSION "6.0.1"
+#define VERSION "6.0.3"
#ifndef CONFIG
# define CONFIG SYSCONFDIR "/" PACKAGE ".conf"
diff -r ec0f79bc63df -r 74f894314a06 external/bsd/dhcpcd/dist/dhcpcd-hooks/30-hostname
--- a/external/bsd/dhcpcd/dist/dhcpcd-hooks/30-hostname Fri Jul 19 11:44:51 2013 +0000
+++ b/external/bsd/dhcpcd/dist/dhcpcd-hooks/30-hostname Fri Jul 19 11:52:56 2013 +0000
@@ -1,7 +1,10 @@
-# $NetBSD: 30-hostname,v 1.1.1.8 2013/06/21 19:33:08 roy Exp $
+# $NetBSD: 30-hostname,v 1.1.1.9 2013/07/19 11:52:57 roy Exp $
# Set the hostname from DHCP data if required
+# Generally we should not set the system hostname to be fully qualified
+: ${hostname_fqdn:=false}
+
# Some systems don't have hostname(1)
_hostname()
{
@@ -40,24 +43,47 @@
need_hostname()
{
- local hostname=""
+ local hostname hfqdn
case "$force_hostname" in
- [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|1) ;;
- *) hostname="$(_hostname)";;
+ [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|1) return 0;;
esac
+
+ hostname="$(_hostname)"
case "$hostname" in
- ""|"(none)"|localhost|localhost.localdomain)
- [ -n "$new_host_name" -o -n "$new_fqdn_name" ];;
- "$old_host_name"|"$old_fqdn_name")
- true;;
- *)
- false;;
+ ""|"(none)"|localhost|localhost.localdomain) return 0;;
+ esac
+
+ case "$hostname_fqdn" in
+ [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|1) hfqdn=true;;
+ *) hfqdn=false;;
esac
+
+ if [ -n "$old_fqdn_name" ]; then
+ if ${hfqdn}; then
+ [ "$hostname" = "$old_fqdn_name" ]
+ else
+ [ "$hostname" = "${old_fqdn_name%%.*}" ]
+ fi
+ elif [ -n "$old_host_name" ]; then
+ if ${hfqdn}; then
+ if [ -n "$old_domain_name" -a \
+ "$old_host_name" = "${old_host_name#*.}" ]
+ then
+ [ "$hostname" = \
+ "$old_host_name.$old_domain_name" ]
+ else
+ [ "$hostname" = "$old_host_name" ]
+ fi
+ else
+ [ "$hostname" = "${old_host_name%%.*}" ]
+ fi
+ fi
}
try_hostname()
{
+
if valid_domainname "$1"; then
_hostname "$1"
else
@@ -67,16 +93,32 @@
set_hostname()
{
+ local hfqdn
need_hostname || return
+ case "$hostname_fqdn" in
+ [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|1) hfqdn=true;;
+ *) hfqdn=false;;
+ esac
+
if [ -n "$new_fqdn_name" ]; then
- try_hostname "$new_fqdn_name"
+ if ${hfqdn}; then
+ try_hostname "$new_fqdn_name"
+ else
+ try_hostname "${new_fqdn_name%%.*}"
+ fi
elif [ -n "$new_host_name" ]; then
- if [ -n "$new_domain_name" ]; then
- try_hostname "$new_host_name.$new_domain_name"
+ if ${hfqdn}; then
+ if [ -n "$new_domain_name" -a \
+ "$new_host_name" = "${new_host_name#*.}" ]
+ then
+ try_hostname "$new_host_name.$new_domain_name"
+ else
+ try_hostname "$new_host_name"
+ fi
else
- try_hostname "$new_host_name"
+ try_hostname "${new_host_name%%.*}"
fi
fi
}
diff -r ec0f79bc63df -r 74f894314a06 external/bsd/dhcpcd/dist/dhcpcd.c
--- a/external/bsd/dhcpcd/dist/dhcpcd.c Fri Jul 19 11:44:51 2013 +0000
+++ b/external/bsd/dhcpcd/dist/dhcpcd.c Fri Jul 19 11:52:56 2013 +0000
@@ -1,5 +1,5 @@
#include <sys/cdefs.h>
- __RCSID("$NetBSD: dhcpcd.c,v 1.1.1.37 2013/06/21 19:33:07 roy Exp $");
+ __RCSID("$NetBSD: dhcpcd.c,v 1.1.1.38 2013/07/19 11:52:56 roy Exp $");
/*
* dhcpcd - DHCP client daemon
@@ -297,6 +297,7 @@
configure_interface1(struct interface *ifp)
{
struct if_options *ifo = ifp->options;
+ int ra_global, ra_iface;
/* Do any platform specific configuration */
if_conf(ifp);
@@ -316,8 +317,13 @@
/* We want to disable kernel interface RA as early as possible. */
if (ifo->options & DHCPCD_IPV6RS) {
- if (check_ipv6(NULL) != 1 || check_ipv6(ifp->name) != 1)
+ ra_global = check_ipv6(NULL, options & DHCPCD_IPV6RA_OWN ? 1:0);
+ ra_iface = check_ipv6(ifp->name,
+ ifp->options->options & DHCPCD_IPV6RA_OWN ? 1 : 0);
+ if (ra_global == -1 || ra_iface == -1)
ifo->options &= ~DHCPCD_IPV6RS;
+ else if (ra_iface == 0)
+ ifo->options |= DHCPCD_IPV6RA_OWN;
}
/* If we haven't specified a ClientID and our hardware address
@@ -415,6 +421,12 @@
if (ifp->carrier != LINK_UP) {
syslog(LOG_INFO, "%s: carrier acquired", ifp->name);
ifp->carrier = LINK_UP;
+#if !defined(__linux__) && !defined(__NetBSD__)
+ /* BSD does not emit RTM_NEWADDR or RTM_CHGADDR when the
+ * hardware address changes so we have to go
+ * through the disovery process to work it out. */
+ handle_interface(0, ifp->name);
+#endif
if (ifp->wireless)
getifssid(ifp->name, ifp->ssid);
configure_interface(ifp, margc, margv);
@@ -563,8 +575,10 @@
TAILQ_REMOVE(ifs, ifp, next);
TAILQ_INSERT_TAIL(ifaces, ifp, next);
}
- init_state(ifp, margc, margv);
- start_interface(ifp);
+ if (action == 1) {
+ init_state(ifp, margc, margv);
+ start_interface(ifp);
+ }
}
/* Free our discovered list */
@@ -575,47 +589,29 @@
free(ifs);
}
-#ifdef RTM_CHGADDR
void
-handle_hwaddr(const char *ifname, unsigned char *hwaddr, size_t hwlen)
+handle_hwaddr(const char *ifname, const uint8_t *hwaddr, size_t hwlen)
{
struct interface *ifp;
- struct if_options *ifo;
- struct dhcp_state *state;
+
+ ifp = find_interface(ifname);
+ if (ifp == NULL)
+ return;
- TAILQ_FOREACH(ifp, ifaces, next) {
- if (strcmp(ifp->name, ifname) == 0 && ifp->hwlen <= hwlen) {
- state = D_STATE(ifp);
- if (state == NULL)
- continue;
- ifo = ifp->options;
- if (!(ifo->options &
- (DHCPCD_INFORM | DHCPCD_STATIC | DHCPCD_CLIENTID))
- && state->new != NULL &&
- state->new->cookie == htonl(MAGIC_COOKIE))
- {
- syslog(LOG_INFO,
- "%s: expiring for new hardware address",
- ifp->name);
- dhcp_drop(ifp, "EXPIRE");
- }
- memcpy(ifp->hwaddr, hwaddr, hwlen);
- ifp->hwlen = hwlen;
- if (!(ifo->options &
- (DHCPCD_INFORM | DHCPCD_STATIC | DHCPCD_CLIENTID)))
- {
- syslog(LOG_DEBUG, "%s: using hwaddr %s",
- ifp->name,
- hwaddr_ntoa(ifp->hwaddr, ifp->hwlen));
- state->interval = 0;
- state->nakoff = 0;
- start_interface(ifp);
- }
- }
+ if (hwlen > sizeof(ifp->hwaddr)) {
+ errno = ENOBUFS;
+ syslog(LOG_ERR, "%s: %s: %m", ifp->name, __func__);
+ return;
}
- free(hwaddr);
+
+ if (ifp->hwlen == hwlen && memcmp(ifp->hwaddr, hwaddr, hwlen) == 0)
+ return;
+
+ syslog(LOG_INFO, "%s: new hardware address: %s", ifp->name,
+ hwaddr_ntoa(hwaddr, hwlen));
+ ifp->hwlen = hwlen;
+ memcpy(ifp->hwaddr, hwaddr, hwlen);
}
-#endif
static void
if_reboot(struct interface *ifp, int argc, char **argv)
diff -r ec0f79bc63df -r 74f894314a06 external/bsd/dhcpcd/dist/dhcpcd.h
--- a/external/bsd/dhcpcd/dist/dhcpcd.h Fri Jul 19 11:44:51 2013 +0000
+++ b/external/bsd/dhcpcd/dist/dhcpcd.h Fri Jul 19 11:52:56 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dhcpcd.h,v 1.1.1.13 2013/06/21 19:33:08 roy Exp $ */
+/* $NetBSD: dhcpcd.h,v 1.1.1.14 2013/07/19 11:52:57 roy Exp $ */
/*
* dhcpcd - DHCP client daemon
@@ -86,7 +86,7 @@
int handle_args(struct fd_list *, int, char **);
void handle_carrier(int, int, const char *);
void handle_interface(int, const char *);
-void handle_hwaddr(const char *, unsigned char *, size_t);
+void handle_hwaddr(const char *, const unsigned char *, size_t);
void drop_interface(struct interface *, const char *);
int select_profile(struct interface *, const char *);
diff -r ec0f79bc63df -r 74f894314a06 external/bsd/dhcpcd/dist/if-bsd.c
--- a/external/bsd/dhcpcd/dist/if-bsd.c Fri Jul 19 11:44:51 2013 +0000
+++ b/external/bsd/dhcpcd/dist/if-bsd.c Fri Jul 19 11:52:56 2013 +0000
@@ -1,5 +1,5 @@
#include <sys/cdefs.h>
- __RCSID("$NetBSD: if-bsd.c,v 1.1.1.19 2013/06/21 19:33:07 roy Exp $");
+ __RCSID("$NetBSD: if-bsd.c,v 1.1.1.20 2013/07/19 11:52:56 roy Exp $");
/*
* dhcpcd - DHCP client daemon
@@ -82,6 +82,10 @@
sin.s6_addr = ((sa) != NULL) ? \
(((struct sockaddr_in6 *)(void *)sa)->sin6_addr).s6_addr : 0
+#ifndef CLLADDR
+# define CLLADDR(s) ((const char *)((s)->sdl_data + (s)->sdl_nlen))
+#endif
+
static int r_fd = -1;
static char *link_buf;
static ssize_t link_buflen;
@@ -534,10 +538,7 @@
struct ifa_msghdr *ifam;
struct sockaddr *sa, *rti_info[RTAX_MAX];
int len;
-#ifdef RTM_CHGADDR
struct sockaddr_dl sdl;
- unsigned char *hwaddr;
-#endif
#ifdef INET
struct rt rt;
Home |
Main Index |
Thread Index |
Old Index