From: Roy Marples Date: Thu, 3 Jul 2014 09:47:42 +0000 (+0000) Subject: Fix dumping DHCPv6 leases. This broke when we ignored IAIDs we didn't ask for. X-Git-Tag: v6.4.1~30 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=39e51da4e7b941566e0df4cbbe50d8bacba87e4d;p=thirdparty%2Fdhcpcd.git Fix dumping DHCPv6 leases. This broke when we ignored IAIDs we didn't ask for. --- diff --git a/dhcp6.c b/dhcp6.c index 1c10e1cf..921ea00c 100644 --- a/dhcp6.c +++ b/dhcp6.c @@ -1822,7 +1822,7 @@ dhcp6_readlease(struct interface *ifp) if (fd == -1) goto ex; if (fd == 0) { - syslog(LOG_INFO, "%s: lease was for different IA type", + syslog(LOG_INFO, "%s: no useable IA found in lease", ifp->name); goto ex; } @@ -1867,7 +1867,8 @@ ex: free(state->new); state->new = NULL; state->new_len = 0; - unlink(state->leasefile); + if (!(ifp->ctx->options & DHCPCD_DUMPLEASE)) + unlink(state->leasefile); return 0; } diff --git a/dhcpcd.c b/dhcpcd.c index 47481ded..3322a271 100644 --- a/dhcpcd.c +++ b/dhcpcd.c @@ -1383,20 +1383,22 @@ main(int argc, char **argv) goto exit_failure; } i = 0; - if (ctx.ifaces == NULL) { - ctx.ifaces = malloc(sizeof(*ctx.ifaces)); - if (ctx.ifaces == NULL) { + /* We need to try and find the interface so we can + * load the hardware address to compare automated IAID */ + ctx.ifaces = if_discover(&ctx, 1, argv + optind); + if (ctx.ifaces == NULL) + goto exit_failure; + ifp = TAILQ_FIRST(ctx.ifaces); + if (ifp == NULL) { + ifp = calloc(1, sizeof(*ifp)); + if (ifp == NULL) { syslog(LOG_ERR, "%s: %m", __func__); goto exit_failure; } - TAILQ_INIT(ctx.ifaces); + strlcpy(ifp->name, argv[optind], sizeof(ifp->name)); + ifp->ctx = &ctx; + TAILQ_INSERT_HEAD(ctx.ifaces, ifp, next); } - ifp = calloc(1, sizeof(*ifp)); - if (ifp == NULL) - goto exit_failure; - strlcpy(ifp->name, argv[optind], sizeof(ifp->name)); - ifp->ctx = &ctx; - TAILQ_INSERT_HEAD(ctx.ifaces, ifp, next); configure_interface(ifp, 0, NULL); if (family == 0 || family == AF_INET) { if (dhcp_dump(ifp) == -1)