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/e5054a5dd6d1
branches: trunk
changeset: 327692:e5054a5dd6d1
user: roy <roy%NetBSD.org@localhost>
date: Fri Mar 14 11:31:11 2014 +0000
description:
Sync
diffstat:
external/bsd/dhcpcd/dist/dhcp.c | 65 ++--
external/bsd/dhcpcd/dist/dhcpcd.8.in | 14 +-
external/bsd/dhcpcd/dist/dhcpcd.c | 84 +++--
external/bsd/dhcpcd/dist/if-bsd.c | 71 +++--
external/bsd/dhcpcd/dist/if-options.c | 6 +-
external/bsd/dhcpcd/dist/ipv6nd.c | 457 ++++-----------------------------
external/bsd/dhcpcd/dist/net.c | 43 ++-
7 files changed, 221 insertions(+), 519 deletions(-)
diffs (truncated from 1364 to 300 lines):
diff -r 7e568c4ac290 -r e5054a5dd6d1 external/bsd/dhcpcd/dist/dhcp.c
--- a/external/bsd/dhcpcd/dist/dhcp.c Fri Mar 14 11:29:44 2014 +0000
+++ b/external/bsd/dhcpcd/dist/dhcp.c Fri Mar 14 11:31:11 2014 +0000
@@ -1,5 +1,5 @@
#include <sys/cdefs.h>
- __RCSID("$NetBSD: dhcp.c,v 1.11 2014/03/01 11:04:21 roy Exp $");
+ __RCSID("$NetBSD: dhcp.c,v 1.12 2014/03/14 11:31:11 roy Exp $");
/*
* dhcpcd - DHCP client daemon
@@ -1064,8 +1064,12 @@
free(dhcp);
return NULL;
}
- syslog(LOG_DEBUG, "%s: validated using 0x%08" PRIu32,
- ifp->name, state->auth.token->secretid);
+ if (state->auth.token)
+ syslog(LOG_DEBUG, "%s: validated using 0x%08" PRIu32,
+ ifp->name, state->auth.token->secretid);
+ else
+ syslog(LOG_DEBUG, "%s: accepted reconfigure key",
+ ifp->name);
}
return dhcp;
@@ -1347,7 +1351,7 @@
state->raw_fd = -1;
}
if (state->udp_fd != -1) {
- /* we don't listen to events on the udp */
+ eloop_event_delete(ifp->ctx->eloop, state->udp_fd);
close(state->udp_fd);
state->udp_fd = -1;
}
@@ -2200,8 +2204,12 @@
iface, dhcp, from, 0);
return;
}
- syslog(LOG_DEBUG, "%s: validated using 0x%08" PRIu32,
- iface->name, state->auth.token->secretid);
+ if (state->auth.token)
+ syslog(LOG_DEBUG, "%s: validated using 0x%08" PRIu32,
+ iface->name, state->auth.token->secretid);
+ else
+ syslog(LOG_DEBUG, "%s: accepted reconfigure key",
+ iface->name);
} else if (ifo->auth.options & DHCPCD_AUTH_REQUIRE) {
log_dhcp1(LOG_ERR, "no authentication", iface, dhcp, from, 0);
return;
@@ -2614,7 +2622,7 @@
/* Just read what's in the UDP fd and discard it as we always read
* from the raw fd */
- read(ctx->udp_fd, buffer, sizeof(buffer));
+ (void)read(ctx->udp_fd, buffer, sizeof(buffer));
}
static void
@@ -2629,7 +2637,7 @@
/* Just read what's in the UDP fd and discard it as we always read
* from the raw fd */
- read(state->udp_fd, buffer, sizeof(buffer));
+ (void)read(state->udp_fd, buffer, sizeof(buffer));
}
static int
@@ -2673,25 +2681,23 @@
}
int
-dhcp_dump(const char *ifname)
+dhcp_dump(struct dhcpcd_ctx *ctx, const char *ifname)
{
- struct dhcpcd_ctx ctx;
struct interface *ifp;
struct dhcp_state *state;
- int r;
- ifp = NULL;
+ if (ctx->ifaces == NULL) {
+ ctx->ifaces = malloc(sizeof(*ctx->ifaces));
+ if (ctx->ifaces == NULL)
+ return -1;
+ TAILQ_INIT(ctx->ifaces);
+ }
state = NULL;
- memset(&ctx, 0, sizeof(ctx));
- ctx.ifaces = malloc(sizeof(*ctx.ifaces));
- if (ctx.ifaces == NULL)
- goto eexit;
- TAILQ_INIT(ctx.ifaces);
ifp = calloc(1, sizeof(*ifp));
if (ifp == NULL)
goto eexit;
- ifp->ctx = &ctx;
- TAILQ_INSERT_HEAD(ctx.ifaces, ifp, next);
+ ifp->ctx = ctx;
+ TAILQ_INSERT_HEAD(ctx->ifaces, ifp, next);
ifp->if_data[IF_DATA_DHCP] = state = calloc(1, sizeof(*state));
if (state == NULL)
goto eexit;
@@ -2701,7 +2707,6 @@
strlcpy(ifp->name, ifname, sizeof(ifp->name));
snprintf(state->leasefile, sizeof(state->leasefile),
LEASEFILE, ifp->name);
- strlcpy(ifp->options->script, SCRIPT, sizeof(ifp->options->script));
state->new = read_lease(ifp);
if (state->new == NULL && errno == ENOENT) {
strlcpy(state->leasefile, ifname, sizeof(state->leasefile));
@@ -2710,28 +2715,14 @@
if (state->new == NULL) {
if (errno == ENOENT)
syslog(LOG_ERR, "%s: no lease to dump", ifname);
- r = -1;
- goto cexit;
+ return -1;
}
state->reason = "DUMP";
- r = script_runreason(ifp, state->reason);
- goto cexit;
+ return script_runreason(ifp, state->reason);
eexit:
syslog(LOG_ERR, "%s: %m", __func__);
- r = -1;
-
-cexit:
- if (state) {
- free(state->new);
- free(state);
- }
- if (ifp) {
- free(ifp->options);
- free(ifp);
- }
- free(ctx.ifaces);
- return r;
+ return -1;
}
void
diff -r 7e568c4ac290 -r e5054a5dd6d1 external/bsd/dhcpcd/dist/dhcpcd.8.in
--- a/external/bsd/dhcpcd/dist/dhcpcd.8.in Fri Mar 14 11:29:44 2014 +0000
+++ b/external/bsd/dhcpcd/dist/dhcpcd.8.in Fri Mar 14 11:31:11 2014 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: dhcpcd.8.in,v 1.26 2014/02/25 13:20:23 roy Exp $
+.\" $NetBSD: dhcpcd.8.in,v 1.27 2014/03/14 11:31:11 roy Exp $
.\" Copyright (c) 2006-2014 Roy Marples
.\" All rights reserved
.\"
@@ -23,7 +23,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd February 25, 2014
+.Dd March 7, 2014
.Dt DHCPCD 8
.Os
.Sh NAME
@@ -31,7 +31,7 @@
.Nd a DHCP client
.Sh SYNOPSIS
.Nm
-.Op Fl 46ABbDdEGgHJKLpqTV
+.Op Fl 46ABbDdEGgHJKLMpqTV
.Op Fl C , Fl Fl nohook Ar hook
.Op Fl c , Fl Fl script Ar script
.Op Fl e , Fl Fl env Ar value
@@ -327,6 +327,10 @@
.Nm
does not request any lease time and leaves it in the hands of the
DHCP server.
+.It Fl M , Fl Fl master
+Start
+.Nm
+in master mode even if only one interface specified on the command line.
.It Fl m , Fl Fl metric Ar metric
Metrics are used to prefer an interface over another one, lowest wins.
.Nm
@@ -639,11 +643,11 @@
Stores the monotonic counter used in the
.Ar replay
field in Authentication Options.
-.It Pa @RUNDIR%dhcpcd.pid@localhost
+.It Pa @RUNDIR@/dhcpcd.pid
Stores the PID of
.Nm
running on all interfaces.
-.It Pa @RUNDIR@dhcpcd\- Ns Ar interface Ns .pid
+.It Pa @RUNDIR@/dhcpcd\- Ns Ar interface Ns .pid
Stores the PID of
.Nm
running on the
diff -r 7e568c4ac290 -r e5054a5dd6d1 external/bsd/dhcpcd/dist/dhcpcd.c
--- a/external/bsd/dhcpcd/dist/dhcpcd.c Fri Mar 14 11:29:44 2014 +0000
+++ b/external/bsd/dhcpcd/dist/dhcpcd.c Fri Mar 14 11:31:11 2014 +0000
@@ -1,5 +1,5 @@
#include <sys/cdefs.h>
- __RCSID("$NetBSD: dhcpcd.c,v 1.3 2014/03/01 11:04:21 roy Exp $");
+ __RCSID("$NetBSD: dhcpcd.c,v 1.4 2014/03/14 11:31:11 roy Exp $");
/*
* dhcpcd - DHCP client daemon
@@ -300,9 +300,11 @@
{
struct interface *ifp;
- TAILQ_FOREACH(ifp, ctx->ifaces, next) {
- if (strcmp(ifp->name, ifname) == 0)
- return ifp;
+ if (ctx != NULL && ctx->ifaces != NULL) {
+ TAILQ_FOREACH(ifp, ctx->ifaces, next) {
+ if (strcmp(ifp->name, ifname) == 0)
+ return ifp;
+ }
}
return NULL;
}
@@ -522,7 +524,8 @@
* them as some OS's will remove, mark tentative or
* do nothing. */
ipv6_free_ll_callbacks(ifp);
- dhcp_drop(ifp, "NOCARRIER");
+ dhcp_drop(ifp, "EXPIRE");
+ script_runreason(ifp, "NOCARRIER");
}
} else if (carrier == LINK_UP && ifp->flags & IFF_UP) {
if (ifp->carrier != LINK_UP) {
@@ -578,7 +581,8 @@
size_t i;
char buf[DUID_LEN * 3];
- handle_carrier(ifp->ctx, LINK_UNKNOWN, 0, ifp->name);
+ if (ifp->carrier == LINK_UNKNOWN)
+ handle_carrier(ifp->ctx, LINK_UNKNOWN, 0, ifp->name);
if (ifp->carrier == LINK_DOWN) {
syslog(LOG_INFO, "%s: waiting for carrier", ifp->name);
return;
@@ -852,6 +856,7 @@
pid_t pid;
} dhcpcd_siginfo;
+#define sigmsg "received signal %s from PID %d, %s"
static void
handle_signal1(void *arg)
{
@@ -866,17 +871,17 @@
do_release = 0;
switch (si->signo) {
case SIGINT:
- syslog(LOG_INFO, "received SIGINT from PID %d, stopping",
- (int)si->pid);
+ syslog(LOG_INFO, sigmsg, "INT", (int)si->pid, "stopping");
break;
case SIGTERM:
- syslog(LOG_INFO, "received SIGTERM from PID %d, stopping",
- (int)si->pid);
+ syslog(LOG_INFO, sigmsg, "TERM", (int)si->pid, "stopping");
break;
case SIGALRM:
- syslog(LOG_INFO, "received SIGALRM from PID %d, rebinding",
- (int)si->pid);
-
+ syslog(LOG_INFO, sigmsg, "ALRM", (int)si->pid, "releasing");
+ do_release = 1;
+ break;
+ case SIGHUP:
+ syslog(LOG_INFO, sigmsg, "HUP", (int)si->pid, "rebinding");
free_globals(ctx);
ifo = read_config(ctx, NULL, NULL, NULL);
add_options(ctx, NULL, ifo, ctx->argc, ctx->argv);
@@ -892,20 +897,14 @@
reconf_reboot(ctx, 1, ctx->argc, ctx->argv,
ctx->argc - ctx->ifc);
return;
- case SIGHUP:
- syslog(LOG_INFO, "received SIGHUP from PID %d, releasing",
- (int)si->pid);
- do_release = 1;
- break;
case SIGUSR1:
- syslog(LOG_INFO, "received SIGUSR from PID %d, reconfiguring",
- (int)si->pid);
+ syslog(LOG_INFO, sigmsg, "USR1", (int)si->pid, "reconfiguring");
TAILQ_FOREACH(ifp, ctx->ifaces, next) {
ipv4_applyaddr(ifp);
}
return;
case SIGPIPE:
- syslog(LOG_WARNING, "received SIGPIPE");
+ syslog(LOG_WARNING, "received signal PIPE");
return;
default:
syslog(LOG_ERR,
@@ -921,14 +920,14 @@
}
static void
-handle_signal(__unused int sig, siginfo_t *siginfo, __unused void *context)
Home |
Main Index |
Thread Index |
Old Index