Mercurial > hg > dhcpcd
changeset 2567:91bec8cafd6d draft
Fix dumping DHCPv6 leases. This broke when we ignored IAIDs we didn't ask for.
| author | Roy Marples <roy@marples.name> |
|---|---|
| date | Thu, 03 Jul 2014 09:47:42 +0000 |
| parents | 4e83d8f9ee4f |
| children | 5563419bd36a |
| files | dhcp6.c dhcpcd.c |
| diffstat | 2 files changed, 15 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/dhcp6.c Wed Jul 02 18:59:19 2014 +0000 +++ b/dhcp6.c Thu Jul 03 09:47:42 2014 +0000 @@ -1822,7 +1822,7 @@ 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 @@ free(state->new); state->new = NULL; state->new_len = 0; - unlink(state->leasefile); + if (!(ifp->ctx->options & DHCPCD_DUMPLEASE)) + unlink(state->leasefile); return 0; }
--- a/dhcpcd.c Wed Jul 02 18:59:19 2014 +0000 +++ b/dhcpcd.c Thu Jul 03 09:47:42 2014 +0000 @@ -1383,20 +1383,22 @@ 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)
