From: Roy Marples Date: Sun, 29 Jan 2012 16:45:14 +0000 (+0000) Subject: Only set if_up for a ROUTERADVERT if we have any RAs X-Git-Tag: v5.5.1~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b1a20121fbd29597d81b0b6b2157a08aa58c0ec0;p=thirdparty%2Fdhcpcd.git Only set if_up for a ROUTERADVERT if we have any RAs Conversely, we need to pretend it's up without any RAs to successfully remove it. --- diff --git a/dhcpcd-hooks/20-resolv.conf b/dhcpcd-hooks/20-resolv.conf index 13af0d59..baa18d2d 100644 --- a/dhcpcd-hooks/20-resolv.conf +++ b/dhcpcd-hooks/20-resolv.conf @@ -12,7 +12,7 @@ NL=" build_resolv_conf() { - local cf="$state_dir/resolv.conf.$interface$ifsuffix" + local cf="$state_dir/resolv.conf.$interface$if_suffix" local interfaces= header= search= srvs= servers= x= # Build a list of interfaces @@ -114,37 +114,31 @@ add_resolv_conf() done if type resolvconf >/dev/null 2>&1; then [ -n "$ifmetric" ] && export IF_METRIC="$ifmetric" - printf %s "$conf" | resolvconf -a "$interface$ifsuffix" + printf %s "$conf" | resolvconf -a "$interface$if_suffix" return $? fi - if [ -e "$resolv_conf_dir/$interface$ifsuffix" ]; then - rm -f "$resolv_conf_dir/$interface$ifsuffix" + if [ -e "$resolv_conf_dir/$interface$if_suffix" ]; then + rm -f "$resolv_conf_dir/$interface$if_suffix" fi [ -d "$resolv_conf_dir" ] || mkdir -p "$resolv_conf_dir" - printf %s "$conf" > "$resolv_conf_dir/$interface$ifsuffix" + printf %s "$conf" > "$resolv_conf_dir/$interface$if_suffix" build_resolv_conf } remove_resolv_conf() { if type resolvconf >/dev/null 2>&1; then - resolvconf -d "$interface$ifsuffix" -f + resolvconf -d "$interface$if_suffix" -f else - if [ -e "$resolv_conf_dir/$interface$ifsuffix" ]; then - rm -f "$resolv_conf_dir/$interface$ifsuffix" + if [ -e "$resolv_conf_dir/$interface$if_suffix" ]; then + rm -f "$resolv_conf_dir/$interface$if_suffix" fi build_resolv_conf fi } -if [ "$reason" = ROUTERADVERT ]; then - ifsuffix=":ra" -else - ifsuffix= -fi - -if $if_up; then +if $if_up || [ "$reason" = ROUTERADVERT ]; then add_resolv_conf elif $if_down; then remove_resolv_conf diff --git a/dhcpcd-run-hooks.in b/dhcpcd-run-hooks.in index 8e594709..c9765793 100644 --- a/dhcpcd-run-hooks.in +++ b/dhcpcd-run-hooks.in @@ -16,7 +16,12 @@ BOUND|INFORM|REBIND|REBOOT|RENEW|TIMEOUT|STATIC) if_up=true;; PREINIT|EXPIRE|FAIL|IPV4LL|NAK|NOCARRIER|RELEASE|STOP) if_down=true;; esac -[ "$reason" = ROUTERADVERT -a "$new_ra_count" != 0 ] && if_up=true +if [ "$reason" = ROUTERADVERT ]; then + if_suffix=":ra" + [ "$new_ra_count" != 0 ] && if_up=true +else + if_suffix= +fi # Ensure that all arguments are unique uniqify()