diff options
| author | Roy Marples <roy@marples.name> | 2017-03-30 11:57:49 +0100 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2017-03-30 17:44:24 +0100 |
| commit | 172dca2255ba2cfa9100553dfdb050801ffdfe46 (patch) | |
| tree | 69e017bc08c91985365224acd28b12ec4b9ba658 /src/dhcpcd.c | |
| parent | 80131ddc96ced4569476b1b120a46b145859e96b (diff) | |
| download | dhcpcd-172dca2255ba2cfa9100553dfdb050801ffdfe46.tar.xz | |
dhcpcd: fix crash forcing lease renewals on inactive interfaces.
Summary:
Forcing a lease renewal on an interface assumes all interfaces
will have options. This is no longer the case because dhcpcd now
lists every interface on the system and the active flag indicates
whether dhcpcd is controlling it or not, so we need to check this
before blindly renewing.
While here, add a syslog entry to note the forced renew and make
the code a little more readable by returning early rather than
enclosing in if blocks.
Fixes T111.
Test Plan:
Start dhcpcd and send it SIGUSR1.
Check it does not crash and review renewal notice in syslog.
Reviewers: eiN5too0
Reviewed By: eiN5too0
Maniphest Tasks: T111
Differential Revision: https://dev.marples.name/D104
Diffstat (limited to 'src/dhcpcd.c')
| -rw-r--r-- | src/dhcpcd.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/dhcpcd.c b/src/dhcpcd.c index 6d5f9801..a5cdd071 100644 --- a/src/dhcpcd.c +++ b/src/dhcpcd.c @@ -1163,15 +1163,19 @@ static void dhcpcd_ifrenew(struct interface *ifp) { -#define DHCPCD_RARENEW (DHCPCD_IPV6 | DHCPCD_IPV6RS) + if (!ifp->active) + return; + if (ifp->options->options & DHCPCD_LINK && - ifp->carrier != LINK_DOWN) - { - dhcp_renew(ifp); - if ((ifp->options->options & DHCPCD_RARENEW) == DHCPCD_RARENEW) - ipv6nd_startrs(ifp); - dhcp6_renew(ifp); - } + ifp->carrier == LINK_DOWN) + return; + + syslog(LOG_INFO, "%s: renewing", ifp->name); + dhcp_renew(ifp); +#define DHCPCD_RARENEW (DHCPCD_IPV6 | DHCPCD_IPV6RS) + if ((ifp->options->options & DHCPCD_RARENEW) == DHCPCD_RARENEW) + ipv6nd_startrs(ifp); + dhcp6_renew(ifp); } static void |
