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.1.2 with these chan...
details: https://anonhg.NetBSD.org/src/rev/95779221ade9
branches: trunk
changeset: 748211:95779221ade9
user: roy <roy%NetBSD.org@localhost>
date: Fri Oct 16 21:50:41 2009 +0000
description:
Import dhcpcd-5.1.2 with these changes:
* ClientID is now reported when interface starts.
* -w, --wait forces dhcpcd to wait until an interface gets a lease or
times out.
* Ensure DHCP socket is open when sending a DECLINE.
* Uses new hwaddr if existing interface is downed and then changed.
* No longer works on firewire interfaces by default.
dhcpcd-5.1.2 has a new behaviour change - when starting up and at least 1
interface has a carrier then it tries to get a lease or times out.
It still daemonises regardless. This, along with the -b and -w flags
allows total control over the desired behaviour of dhcpcd.
diffstat:
external/bsd/dhcpcd/dist/arp.c | 5 +-
external/bsd/dhcpcd/dist/config.h | 2 +-
external/bsd/dhcpcd/dist/defs.h | 2 +-
external/bsd/dhcpcd/dist/dhcp.h | 2 +
external/bsd/dhcpcd/dist/dhcpcd.c | 110 ++++++++++------
external/bsd/dhcpcd/dist/dhcpcd.conf.5.in | 4 +-
external/bsd/dhcpcd/dist/getline.h | 36 +++++
external/bsd/dhcpcd/dist/if-bsd.c | 15 +-
external/bsd/dhcpcd/dist/if-options.c | 4 +
external/bsd/dhcpcd/dist/if-options.h | 4 +-
external/bsd/dhcpcd/dist/net.c | 199 +++++++++++++----------------
external/bsd/dhcpcd/dist/net.h | 10 +-
12 files changed, 223 insertions(+), 170 deletions(-)
diffs (truncated from 761 to 300 lines):
diff -r 26d7cb18a7b2 -r 95779221ade9 external/bsd/dhcpcd/dist/arp.c
--- a/external/bsd/dhcpcd/dist/arp.c Fri Oct 16 21:23:08 2009 +0000
+++ b/external/bsd/dhcpcd/dist/arp.c Fri Oct 16 21:50:41 2009 +0000
@@ -82,9 +82,8 @@
handle_ipv4ll_failure(iface);
return;
}
- if (iface->state->lease.frominfo)
- unlink(iface->leasefile);
- else
+ unlink(iface->leasefile);
+ if (!iface->state->lease.frominfo)
send_decline(iface);
close_sockets(iface);
delete_timeout(NULL, iface);
diff -r 26d7cb18a7b2 -r 95779221ade9 external/bsd/dhcpcd/dist/config.h
--- a/external/bsd/dhcpcd/dist/config.h Fri Oct 16 21:23:08 2009 +0000
+++ b/external/bsd/dhcpcd/dist/config.h Fri Oct 16 21:50:41 2009 +0000
@@ -4,4 +4,4 @@
#define LIBEXECDIR "/libexec"
#define DBDIR "/var/db"
#define RUNDIR "/var/run"
-#include "compat/getline.h"
+#include "compat/getline.h"
diff -r 26d7cb18a7b2 -r 95779221ade9 external/bsd/dhcpcd/dist/defs.h
--- a/external/bsd/dhcpcd/dist/defs.h Fri Oct 16 21:23:08 2009 +0000
+++ b/external/bsd/dhcpcd/dist/defs.h Fri Oct 16 21:50:41 2009 +0000
@@ -28,7 +28,7 @@
#define CONFIG_H
#define PACKAGE "dhcpcd"
-#define VERSION "5.1.1"
+#define VERSION "5.1.2"
#ifndef CONFIG
# define CONFIG SYSCONFDIR "/" PACKAGE ".conf"
diff -r 26d7cb18a7b2 -r 95779221ade9 external/bsd/dhcpcd/dist/dhcp.h
--- a/external/bsd/dhcpcd/dist/dhcp.h Fri Oct 16 21:23:08 2009 +0000
+++ b/external/bsd/dhcpcd/dist/dhcp.h Fri Oct 16 21:50:41 2009 +0000
@@ -33,6 +33,8 @@
#include <stdint.h>
+#include "common.h"
+
/* Max MTU - defines dhcp option length */
#define MTU_MAX 1500
#define MTU_MIN 576
diff -r 26d7cb18a7b2 -r 95779221ade9 external/bsd/dhcpcd/dist/dhcpcd.c
--- a/external/bsd/dhcpcd/dist/dhcpcd.c Fri Oct 16 21:23:08 2009 +0000
+++ b/external/bsd/dhcpcd/dist/dhcpcd.c Fri Oct 16 21:50:41 2009 +0000
@@ -137,7 +137,7 @@
static void
usage(void)
{
- printf("usage: "PACKAGE" [-dgknpqxyADEGHKLOTV] [-c script] [-f file]"
+ printf("usage: "PACKAGE" [-dgknpqwxyADEGHKLOTV] [-c script] [-f file]"
" [-e var=val]\n"
" [-h hostname] [-i classID ] [-l leasetime]"
" [-m metric] [-o option]\n"
@@ -185,11 +185,18 @@
}
/* ARGSUSED */
-_noreturn void
+void
handle_exit_timeout(_unused void *arg)
{
+ int timeout;
+
syslog(LOG_ERR, "timed out");
- exit(EXIT_FAILURE);
+ if (!(options & DHCPCD_TIMEOUT_IPV4LL))
+ exit(EXIT_FAILURE);
+ options &= ~DHCPCD_TIMEOUT_IPV4LL;
+ timeout = (PROBE_NUM * PROBE_MAX) + PROBE_WAIT + 1;
+ syslog(LOG_WARNING, "allowing %d seconds for IPv4LL timeout", timeout);
+ add_timeout_sec(timeout, handle_exit_timeout, NULL);
}
void
@@ -387,12 +394,6 @@
start_interface(iface);
}
-void
-send_decline(struct interface *iface)
-{
- send_message(iface, DHCP_DECLINE, NULL);
-}
-
static void
log_dhcp(int lvl, const char *msg,
const struct interface *iface, const struct dhcp_message *dhcp)
@@ -715,6 +716,13 @@
unlink(iface->leasefile);
}
+void
+send_decline(struct interface *iface)
+{
+ open_sockets(iface);
+ send_message(iface, DHCP_DECLINE, NULL);
+}
+
static void
configure_interface1(struct interface *iface)
{
@@ -728,7 +736,7 @@
if (iface->flags & IFF_NOARP ||
ifo->options & (DHCPCD_INFORM | DHCPCD_STATIC))
ifo->options &= ~(DHCPCD_ARP | DHCPCD_IPV4LL);
- if (ifo->options & DHCPCD_LINK && carrier_status(iface->name) == -1)
+ if (ifo->options & DHCPCD_LINK && carrier_status(iface) == -1)
ifo->options &= ~DHCPCD_LINK;
if (ifo->metric != -1)
@@ -773,6 +781,9 @@
iface->hwlen);
}
}
+ if (ifo->options & DHCPCD_CLIENTID)
+ syslog(LOG_DEBUG, "%s: using ClientID %s", iface->name,
+ hwaddr_ntoa(iface->clientid + 1, *iface->clientid));
}
int
@@ -821,6 +832,7 @@
handle_carrier(const char *ifname)
{
struct interface *iface;
+ int carrier;
if (!(options & DHCPCD_LINK))
return;
@@ -829,11 +841,10 @@
break;
if (!iface || !(iface->state->options->options & DHCPCD_LINK))
return;
- switch (carrier_status(iface->name)) {
- case -1:
- syslog(LOG_ERR, "carrier_status: %m");
- break;
- case 0:
+ carrier = carrier_status(iface);
+ if (carrier == -1)
+ syslog(LOG_ERR, "%s: carrier_status: %m", ifname);
+ else if (carrier == 0 || !(iface->flags & IFF_RUNNING)) {
if (iface->carrier != LINK_DOWN) {
iface->carrier = LINK_DOWN;
syslog(LOG_INFO, "%s: carrier lost", iface->name);
@@ -841,8 +852,7 @@
delete_timeouts(iface, start_expire, NULL);
drop_config(iface, "NOCARRIER");
}
- break;
- default:
+ } else if (carrier == 1 && (iface->flags & IFF_RUNNING)) {
if (iface->carrier != LINK_UP) {
iface->carrier = LINK_UP;
syslog(LOG_INFO, "%s: carrier acquired", iface->name);
@@ -854,7 +864,6 @@
run_script(iface);
start_interface(iface);
}
- break;
}
}
@@ -1165,7 +1174,7 @@
run_script(iface);
if (ifs->options->options & DHCPCD_LINK) {
- switch (carrier_status(iface->name)) {
+ switch (carrier_status(iface)) {
case 0:
iface->carrier = LINK_DOWN;
ifs->reason = "NOCARRIER";
@@ -1220,13 +1229,19 @@
break;
ifl = ifn;
}
- if (ifn)
- continue;
+ if (ifn) {
+ /* The flags and hwaddr could have changed */
+ ifn->flags = ifp->flags;
+ ifn->hwlen = ifp->hwlen;
+ if (ifp->hwlen != 0)
+ memcpy(ifn->hwaddr, ifp->hwaddr, ifn->hwlen);
+ } else {
+ if (ifl)
+ ifl->next = ifp;
+ else
+ ifaces = ifp;
+ }
init_state(ifp, 0, NULL);
- if (ifl)
- ifl->next = ifp;
- else
- ifaces = ifp;
start_interface(ifp);
}
}
@@ -1665,6 +1680,10 @@
if (pid == 0 || kill(pid, sig) != 0) {
if (sig != SIGALRM)
syslog(LOG_ERR, ""PACKAGE" not running");
+ if (pid != 0 && errno != ESRCH) {
+ syslog(LOG_ERR, "kill: %m");
+ exit(EXIT_FAILURE);
+ }
unlink(pidfile);
if (sig != SIGALRM)
exit(EXIT_FAILURE);
@@ -1736,7 +1755,7 @@
}
}
- if (init_socket() == -1) {
+ if (init_sockets() == -1) {
syslog(LOG_ERR, "init_socket: %m");
exit(EXIT_FAILURE);
}
@@ -1750,17 +1769,6 @@
ifc = argc - optind;
ifv = argv + optind;
- if (options & DHCPCD_BACKGROUND ||
- (ifc == 0 && options & DHCPCD_LINK && options & DHCPCD_DAEMONISE))
- {
- daemonise();
- } else if (options & DHCPCD_DAEMONISE && ifo->timeout > 0) {
- oi = ifo->timeout;
- if (ifo->options & DHCPCD_IPV4LL)
- oi += 10;
- add_timeout_sec(oi, handle_exit_timeout, NULL);
- }
- free_options(ifo);
ifaces = discover_interfaces(ifc, ifv);
for (i = 0; i < ifc; i++) {
@@ -1774,15 +1782,37 @@
if (!ifaces) {
if (ifc == 0)
syslog(LOG_ERR, "no valid interfaces found");
+ else
+ exit(EXIT_FAILURE);
if (!(options & DHCPCD_LINK)) {
- syslog(LOG_ERR, "aborting as we're not backgrounding"
- " with link detection");
+ syslog(LOG_ERR,
+ "aborting as link detection is disabled");
exit(EXIT_FAILURE);
}
}
- for (iface = ifaces; iface; iface = iface->next)
+ if (options & DHCPCD_BACKGROUND)
+ daemonise();
+
+ opt = 0;
+ for (iface = ifaces; iface; iface = iface->next) {
init_state(iface, argc, argv);
+ if (iface->carrier != LINK_DOWN)
+ opt = 1;
+ }
+ if (opt == 0 &&
+ options & DHCPCD_LINK &&
+ !(options & DHCPCD_WAITIP))
+ {
+ syslog(LOG_WARNING, "no interfaces have a carrier");
+ daemonise();
+ } else if (options & DHCPCD_DAEMONISE && ifo->timeout > 0) {
+ if (options & DHCPCD_IPV4LL)
+ options |= DHCPCD_TIMEOUT_IPV4LL;
+ add_timeout_sec(ifo->timeout, handle_exit_timeout, NULL);
+ }
+ free_options(ifo);
+
sort_interfaces();
for (iface = ifaces; iface; iface = iface->next)
add_timeout_sec(0, start_interface, iface);
diff -r 26d7cb18a7b2 -r 95779221ade9 external/bsd/dhcpcd/dist/dhcpcd.conf.5.in
--- a/external/bsd/dhcpcd/dist/dhcpcd.conf.5.in Fri Oct 16 21:23:08 2009 +0000
+++ b/external/bsd/dhcpcd/dist/dhcpcd.conf.5.in Fri Oct 16 21:50:41 2009 +0000
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd September 2, 2009
+.Dd October 16, 2009
.Dt DHCPCD.CONF 5 SMM
.Os
.Sh NAME
@@ -272,6 +272,8 @@
.It Ic vendorclassid Ar string
Change the default vendorclassid sent from dhcpcd-version.
If not set then none is sent.
+.It Ic waitip
Home |
Main Index |
Thread Index |
Old Index