| From 98b6b37cdb8bf28f97d2f8f7c5bf9646cbdc6ca8 Mon Sep 17 00:00:00 2001 |
| From: Peter Qiu <zqiu@chromium.org> |
| Date: Thu, 25 Jun 2015 13:50:02 -0700 |
| Subject: [PATCH] DHCPv6: Fix prefix delegation lease file name |
| |
| For DHCPv6, daemon creates two lease files, one for non-temporary |
| address and the other for prefix delegation. Currently only non-temporary |
| address lease is using the lease identifier obtained from command line |
| for its file name, since dhcpcd is using a separate pseudo interface |
| for handling prefix delegation messages. |
| |
| So fix it to have both lease files using the same identifier obtained |
| from the command line, with non-temporary address lease ends in ".lease6" |
| and prefix delegation ends is ".pd.lease6". |
| |
| BUG=chromium:504223 |
| TEST=Run network_Dhcpv6Basic test, verify there is two lease |
| file for the same network with one ends in ".lease6" and |
| the other ends in ".pd.lease6" |
| --- |
| dhcp-common.c | 4 ++-- |
| dhcp6.c | 8 ++++++++ |
| 2 files changed, 10 insertions(+), 2 deletions(-) |
| |
| diff --git a/dhcp-common.c b/dhcp-common.c |
| index 5aef054..d880312 100644 |
| --- a/dhcp-common.c |
| +++ b/dhcp-common.c |
| @@ -750,11 +750,11 @@ dhcp_set_leasefile(char *leasefile, size_t len, int family, |
| if (strlen(ifp->lease_identifier) > 0) { |
| return snprintf(leasefile, len, |
| family == AF_INET ? LEASEFILE : LEASEFILE6, |
| - ifp->lease_identifier, "", ""); |
| + ifp->lease_identifier, "", extra); |
| } |
| return snprintf(leasefile, len, |
| family == AF_INET ? LEASEFILE : LEASEFILE6, |
| - ifp->name, "", ""); |
| + ifp->name, "", extra); |
| } |
| |
| static size_t |
| diff --git a/dhcp6.c b/dhcp6.c |
| index 79b7cf1..238acd4 100644 |
| --- a/dhcp6.c |
| +++ b/dhcp6.c |
| @@ -3207,6 +3207,14 @@ dhcp6_start1(void *arg) |
| ifp->name); |
| ifp->options->options |= |
| DHCPCD_NOPFXDLG; |
| + /* |
| + * Maintain the same lease identifier |
| + * for the pseudo interface for |
| + * obtaining prefix delegation. |
| + */ |
| + strlcpy(ifn->lease_identifier, |
| + ifp->lease_identifier, |
| + sizeof(ifn->lease_identifier)); |
| TAILQ_REMOVE(ifs, ifn, next); |
| TAILQ_INSERT_AFTER(ifp->ctx->ifaces, |
| ifp, ifn, next); |
| -- |
| 2.2.0.rc0.207.ga3a616c |
| |