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.2.8 with the follow...
details: https://anonhg.NetBSD.org/src/rev/d56f3776f9a7
branches: trunk
changeset: 757963:d56f3776f9a7
user: roy <roy%NetBSD.org@localhost>
date: Thu Oct 07 14:35:56 2010 +0000
description:
Import dhcpcd-5.2.8 with the following changes from 5.2.4
* Use dynamically sized buffers for reading kernel link events
* Use the active link address
* Added option to dump a lease to stdout
* TEST mode now works correctly if an old lease is NAKed
* routes with the gateway = leased ip are now treated as host routes
diffstat:
external/bsd/dhcpcd/dist/configure.c | 16 +
external/bsd/dhcpcd/dist/defs.h | 2 +-
external/bsd/dhcpcd/dist/dhcp.c | 2 +-
external/bsd/dhcpcd/dist/dhcpcd-hooks/02-dump | 5 +
external/bsd/dhcpcd/dist/dhcpcd-hooks/10-mtu | 16 +-
external/bsd/dhcpcd/dist/dhcpcd-hooks/20-resolv.conf | 9 +-
external/bsd/dhcpcd/dist/dhcpcd-hooks/29-lookup-hostname | 6 +-
external/bsd/dhcpcd/dist/dhcpcd-hooks/30-hostname | 6 +-
external/bsd/dhcpcd/dist/dhcpcd-hooks/50-ntp.conf | 32 +-
external/bsd/dhcpcd/dist/dhcpcd-hooks/50-ypbind | 22 +-
external/bsd/dhcpcd/dist/dhcpcd-run-hooks.8.in | 7 +-
external/bsd/dhcpcd/dist/dhcpcd-run-hooks.in | 62 ++-
external/bsd/dhcpcd/dist/dhcpcd.c | 309 +++++++++-----
external/bsd/dhcpcd/dist/eloop.c | 43 +-
external/bsd/dhcpcd/dist/eloop.h | 12 +-
external/bsd/dhcpcd/dist/if-bsd.c | 21 +-
external/bsd/dhcpcd/dist/if-options.c | 15 +-
external/bsd/dhcpcd/dist/if-options.h | 3 +-
external/bsd/dhcpcd/dist/net.c | 31 +
19 files changed, 423 insertions(+), 196 deletions(-)
diffs (truncated from 1113 to 300 lines):
diff -r 0463d06c2521 -r d56f3776f9a7 external/bsd/dhcpcd/dist/configure.c
--- a/external/bsd/dhcpcd/dist/configure.c Thu Oct 07 12:40:34 2010 +0000
+++ b/external/bsd/dhcpcd/dist/configure.c Thu Oct 07 14:35:56 2010 +0000
@@ -551,6 +551,21 @@
iface->name, &iface->state->options->options);
}
+/* Some DHCP servers add set host routes by setting the gateway
+ * to the assinged IP address. This differs from our notion of a host route
+ * where the gateway is the destination address, so we fix it. */
+static struct rt *
+massage_host_routes(struct rt *rt, const struct interface *iface)
+{
+ struct rt *r;
+
+ for (r = rt; r; r = r->next)
+ if (r->gate.s_addr == iface->addr.s_addr &&
+ r->net.s_addr == INADDR_BROADCAST)
+ r->gate.s_addr = r->dest.s_addr;
+ return rt;
+}
+
static struct rt *
add_destination_route(struct rt *rt, const struct interface *iface)
{
@@ -629,6 +644,7 @@
if (ifp->state->new == NULL)
continue;
dnr = get_routes(ifp);
+ dnr = massage_host_routes(dnr, ifp);
dnr = add_subnet_route(dnr, ifp);
dnr = add_router_host_route(dnr, ifp);
dnr = add_destination_route(dnr, ifp);
diff -r 0463d06c2521 -r d56f3776f9a7 external/bsd/dhcpcd/dist/defs.h
--- a/external/bsd/dhcpcd/dist/defs.h Thu Oct 07 12:40:34 2010 +0000
+++ b/external/bsd/dhcpcd/dist/defs.h Thu Oct 07 14:35:56 2010 +0000
@@ -28,7 +28,7 @@
#define CONFIG_H
#define PACKAGE "dhcpcd"
-#define VERSION "5.2.4"
+#define VERSION "5.2.8"
#ifndef CONFIG
# define CONFIG SYSCONFDIR "/" PACKAGE ".conf"
diff -r 0463d06c2521 -r d56f3776f9a7 external/bsd/dhcpcd/dist/dhcp.c
--- a/external/bsd/dhcpcd/dist/dhcp.c Thu Oct 07 12:40:34 2010 +0000
+++ b/external/bsd/dhcpcd/dist/dhcp.c Thu Oct 07 14:35:56 2010 +0000
@@ -1052,7 +1052,7 @@
syslog(LOG_DEBUG, "%s: writing lease `%s'",
iface->name, iface->leasefile);
- fd = open(iface->leasefile, O_WRONLY | O_CREAT | O_TRUNC, 0400);
+ fd = open(iface->leasefile, O_WRONLY | O_CREAT | O_TRUNC, 0444);
if (fd == -1) {
syslog(LOG_ERR, "%s: open: %m", iface->name);
return -1;
diff -r 0463d06c2521 -r d56f3776f9a7 external/bsd/dhcpcd/dist/dhcpcd-hooks/02-dump
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/dhcpcd/dist/dhcpcd-hooks/02-dump Thu Oct 07 14:35:56 2010 +0000
@@ -0,0 +1,5 @@
+# Just echo our DHCP options we have
+
+if [ "$reason" = "DUMP" ]; then
+ set | sed -ne 's/^new_//p' | sort
+fi
diff -r 0463d06c2521 -r d56f3776f9a7 external/bsd/dhcpcd/dist/dhcpcd-hooks/10-mtu
--- a/external/bsd/dhcpcd/dist/dhcpcd-hooks/10-mtu Thu Oct 07 12:40:34 2010 +0000
+++ b/external/bsd/dhcpcd/dist/dhcpcd-hooks/10-mtu Thu Oct 07 14:35:56 2010 +0000
@@ -4,7 +4,7 @@
if [ "$reason" = PREINIT -a -e "$mtu_dir/$interface" ]; then
rm "$mtu_dir/$interface"
-elif [ "$reason" != TEST -a -n "$new_interface_mtu" ]; then
+elif [ -n "$new_interface_mtu" ] && $if_up; then
# The smalled MTU dhcpcd can work with is 576
if [ "$new_interface_mtu" -ge 576 ]; then
if ifconfig "$interface" mtu "$new_interface_mtu"; then
@@ -16,10 +16,12 @@
fi
fi
fi
-elif [ "$reason" != TEST -a -e "$mtu_dir/$interface" ]; then
- # No MTU in this state, so restore the prior MTU
- mtu=$(cat "$mtu_dir/$interface")
- syslog info "$interface: MTU restored to $mtu"
- ifconfig "$interface" mtu "$mtu"
- rm "$mtu_dir/$interface"
+elif [ -e "$mtu_dir/$interface" ]; then
+ if $if_up || $if_down; then
+ # No MTU in this state, so restore the prior MTU
+ mtu=$(cat "$mtu_dir/$interface")
+ syslog info "$interface: MTU restored to $mtu"
+ ifconfig "$interface" mtu "$mtu"
+ rm "$mtu_dir/$interface"
+ fi
fi
diff -r 0463d06c2521 -r d56f3776f9a7 external/bsd/dhcpcd/dist/dhcpcd-hooks/20-resolv.conf
--- a/external/bsd/dhcpcd/dist/dhcpcd-hooks/20-resolv.conf Thu Oct 07 12:40:34 2010 +0000
+++ b/external/bsd/dhcpcd/dist/dhcpcd-hooks/20-resolv.conf Thu Oct 07 14:35:56 2010 +0000
@@ -119,7 +119,8 @@
fi
}
-case "$reason" in
-BOUND|INFORM|REBIND|REBOOT|RENEW|TIMEOUT|STATIC) add_resolv_conf;;
-PREINIT|EXPIRE|FAIL|IPV4LL|NAK|NOCARRIER|RELEASE|STOP) remove_resolv_conf;;
-esac
+if $if_up; then
+ add_resolv_conf
+elif $if_down; then
+ remove_resolv_conf
+fi
diff -r 0463d06c2521 -r d56f3776f9a7 external/bsd/dhcpcd/dist/dhcpcd-hooks/29-lookup-hostname
--- a/external/bsd/dhcpcd/dist/dhcpcd-hooks/29-lookup-hostname Thu Oct 07 12:40:34 2010 +0000
+++ b/external/bsd/dhcpcd/dist/dhcpcd-hooks/29-lookup-hostname Thu Oct 07 14:35:56 2010 +0000
@@ -29,6 +29,6 @@
fi
}
-case "$reason" in
-BOUND|INFORM|REBIND|REBOOT|RENEW|TIMEOUT|STATIC) set_hostname;;
-esac
+if $if_up; then
+ set_hostname
+fi
diff -r 0463d06c2521 -r d56f3776f9a7 external/bsd/dhcpcd/dist/dhcpcd-hooks/30-hostname
--- a/external/bsd/dhcpcd/dist/dhcpcd-hooks/30-hostname Thu Oct 07 12:40:34 2010 +0000
+++ b/external/bsd/dhcpcd/dist/dhcpcd-hooks/30-hostname Thu Oct 07 14:35:56 2010 +0000
@@ -29,6 +29,6 @@
fi
}
-case "$reason" in
-BOUND|INFORM|REBIND|REBOOT|RENEW|TIMEOUT|STATIC) set_hostname;;
-esac
+if $if_up; then
+ set_hostname
+fi
diff -r 0463d06c2521 -r d56f3776f9a7 external/bsd/dhcpcd/dist/dhcpcd-hooks/50-ntp.conf
--- a/external/bsd/dhcpcd/dist/dhcpcd-hooks/50-ntp.conf Thu Oct 07 12:40:34 2010 +0000
+++ b/external/bsd/dhcpcd/dist/dhcpcd-hooks/50-ntp.conf Thu Oct 07 14:35:56 2010 +0000
@@ -8,14 +8,12 @@
# NTP_CONF=/usr/pkg/etc/ntpd.conf
# to use openntpd from pkgsrc instead of the system provided ntp.
-# Detect OpenRC or BSD rc
-# Distributions may want to just have their command here instead of this
-if type rc-service >/dev/null 2>&1 && rc-service --exists ntpd; then
- ntpd_restart_cmd="rc-service ntpd -- -Ds restart"
-elif [ -x /etc/rc.d/ntpd ]; then
- ntpd_restart_cmd="/etc/rc.d/ntpd status >/dev/null 2>&1 && /etc/rc.d/ntpd restart"
-elif [ -x /usr/local/etc/rc.d/ntpd ]; then
- ntpd_restart_cmd="/usr/local/etc/rc.d/ntpd status >/dev/null 2>&1 && /usr/local/etc/rc.d/ntpd restart"
+: ${ntpd_restart_cmd:="service_condcommand ntpd restart || service_condcommand ntp restart"}
+if type invoke-rc.d >/dev/null 2>&1; then
+ # Debian has a seperate file for DHCP config to avoid stamping on
+ # the master.
+ [ -e /var/lib/ntp ] || mkdir /var/lib/ntp
+ : ${NTP_DHCP_CONF:=/var/lib/ntp/ntp.conf.dhcp}
fi
ntp_conf_dir="$state_dir/ntp.conf"
@@ -48,14 +46,21 @@
# Merge our config into ntp.conf
[ -e "$cf" ] && rm -f "$cf"
[ -d "$ntp_conf_dir" ] || mkdir -p "$ntp_conf_dir"
- if [ -e "$ntp_conf" ]; then
+
+ if [ -n "$NTP_DHCP_CONF" ]; then
+ cp "$ntp_conf" "$cf"
+ ntp_conf="$NTP_DHCP_CONF"
+ elif [ -e "$ntp_conf" ]; then
remove_markers "$signature_base" "$signature_base_end" \
"$ntp_conf" > "$cf"
fi
+
if [ -n "$servers" ]; then
echo "$signature_base${header:+ $from }$header" >> "$cf"
printf "$search$servers" >> "$cf"
echo "$signature_base_end${header:+ $from }$header" >> "$cf"
+ else
+ [ -e "$ntp_conf" ] || return
fi
# If we changed anything, restart ntpd
@@ -86,7 +91,8 @@
build_ntp_conf
}
-case "$reason" in
-BOUND|INFORM|REBIND|REBOOT|RENEW|TIMEOUT|STATIC) add_ntp_conf add;;
-PREINIT|EXPIRE|FAIL|IPV4LL|NAK|NOCARRIER|RELEASE|STOP) remove_ntp_conf del;;
-esac
+if $if_up; then
+ add_ntp_conf add
+elif $if_down; then
+ remove_ntp_conf del
+fi
diff -r 0463d06c2521 -r d56f3776f9a7 external/bsd/dhcpcd/dist/dhcpcd-hooks/50-ypbind
--- a/external/bsd/dhcpcd/dist/dhcpcd-hooks/50-ypbind Thu Oct 07 12:40:34 2010 +0000
+++ b/external/bsd/dhcpcd/dist/dhcpcd-hooks/50-ypbind Thu Oct 07 14:35:56 2010 +0000
@@ -1,15 +1,8 @@
# Sample dhcpcd hook for ypbind
# This script is only suitable for the Linux version.
-# Distributions may want to just have their command here instead of this
-if [ -x /etc/rc.d/ypbind ]; then
- ypbind_restart_cmd="/etc/rc.d/ypbind restart"
- ypbind_stop_cmd="/etc/rc.d/ypbind stop"
-elif [ -x /usr/local/etc/rc.d/ypbind ]; then
- ypbind_restart_cmd="/usr/local/etc/rc.d/ypbind restart"
- ypbind_stop_cmd="/usr/local/etc/rc.d/ypbind stop"
-fi
-
+: ${ypbind_restart_cmd:="service_command ypbind restart"}
+: ${ypbind_stop_cmd:="service_condcommand ypbind stop"}
ypbind_dir="$state_dir/ypbind"
best_domain()
@@ -70,17 +63,12 @@
fi
}
-case "$reason" in
-PREINIT)
+if [ "$reason" = PREINIT ]; then
rm -f "$ypbind_dir/$interface"
- ;;
-TEST)
- ;;
-*)
+else if $if_up || $if_down; then
if [ -n "$new_nis_domain" ]; then
make_yp_binding
elif [ -n "$old_nis_domain" ]; then
restore_yp_binding
fi
- ;;
-esac
+fi
diff -r 0463d06c2521 -r d56f3776f9a7 external/bsd/dhcpcd/dist/dhcpcd-run-hooks.8.in
--- a/external/bsd/dhcpcd/dist/dhcpcd-run-hooks.8.in Thu Oct 07 12:40:34 2010 +0000
+++ b/external/bsd/dhcpcd/dist/dhcpcd-run-hooks.8.in Thu Oct 07 14:35:56 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 March 23, 2009
+.Dd August 24, 2010
.Dt DHCPCD-RUN-HOOKS 8 SMM
.Os
.Sh NAME
@@ -110,11 +110,14 @@
Static configuration and DHCP INFORM is still allowed.
.It Dv STOP
dhcpcd stopped running on the interface.
+.iT Dv DUMP
+dhcpcd has been asked to dump the last lease for the interface.
.It Dv TEST
dhcpcd received an OFFER from a DHCP server but will not configure the
interface.
This is primarily used to test the variables are filled correctly for the
script to process them.
+
.El
.Sh FILES
When
diff -r 0463d06c2521 -r d56f3776f9a7 external/bsd/dhcpcd/dist/dhcpcd-run-hooks.in
--- a/external/bsd/dhcpcd/dist/dhcpcd-run-hooks.in Thu Oct 07 12:40:34 2010 +0000
+++ b/external/bsd/dhcpcd/dist/dhcpcd-run-hooks.in Thu Oct 07 14:35:56 2010 +0000
@@ -9,6 +9,13 @@
signature_end="$signature_base_end $from $interface"
state_dir=/var/run/dhcpcd
+if_up=false
+if_down=false
+case "$reason" in
+BOUND|INFORM|REBIND|REBOOT|RENEW|TIMEOUT|STATIC) if_up=true;;
+PREINIT|EXPIRE|FAIL|IPV4LL|NAK|NOCARRIER|RELEASE|STOP) if_down=true;;
+esac
+
# Ensure that all arguments are unique
uniqify()
{
@@ -91,17 +98,19 @@
# If different, replace first with second otherwise remove second
change_file()
{
- if type cmp >/dev/null 2>&1; then
- cmp -s "$1" "$2"
- elif type diff >/dev/null 2>&1; then
- diff -q "$1" "$2" >/dev/null
- else
Home |
Main Index |
Thread Index |
Old Index