]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Unset $ifsuffix for non protocol reasons
authorRoy Marples <roy@marples.name>
Thu, 6 Jul 2017 16:13:51 +0000 (17:13 +0100)
committerRoy Marples <roy@marples.name>
Thu, 13 Jul 2017 15:25:16 +0000 (16:25 +0100)
Summary:
The default was to assume unspecified reasons were DHCP.
This is bad for non protocol events such as NOCARRIER which could
cause a dhcpcd instance running IPv6 only to wipe out the DNS
records created by a separate dhcpcd instance handling IPv4.

Fixes T129.

Test Plan:
Start `dhcpcd -4 -K eth0`.
Observe that a resolvconf entry is created for eth0.dhcp.
Start `dhcpcd -6 eth0`.
Observe that a resolvconf entry is created for eth0.dhcp6.
Bring the carrier down for eth0.
Because the -4 instance is ignoring carrier, it is expected that
the eth0.dhcp resolvconf entry is preserved.

Maniphest Tasks: T129

Differential Revision: https://dev.marples.name/D124

hooks/dhcpcd-run-hooks.in

index 4490fa9b2e803b989a4c2f512f6dfef690b2b8b2..ba882abbb4f93846d98fe1821666c2bf92848dea 100644 (file)
@@ -3,14 +3,18 @@
 
 # Handy variables and functions for our hooks to use
 case "$reason" in
+       PREINIT|CARRIER|NOCARRIER|DEPARTED|STOPPED|DUMP|TEST)
+               ifsuffix=;; #unset
        ROUTERADVERT)
                ifsuffix=".ra";;
        INFORM6|BOUND6|RENEW6|REBIND6|REBOOT6|EXPIRE6|RELEASE6|STOP6)
                ifsuffix=".dhcp6";;
        IPV4LL)
                ifsuffix=".ipv4ll";;
-       *)
+       INFORM|BOUND|RENEW|REBIND|REBOOT|EXPIRE|RELEASE|STOP)
                ifsuffix=".dhcp";;
+       *)
+               ifsuffix=;; #unset
 esac
 ifname="$interface$ifsuffix"