]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Hook the new RA options into resolv.conf
authorRoy Marples <roy@marples.name>
Thu, 15 Dec 2011 03:02:46 +0000 (03:02 +0000)
committerRoy Marples <roy@marples.name>
Thu, 15 Dec 2011 03:02:46 +0000 (03:02 +0000)
dhcpcd-hooks/20-resolv.conf

index 73ae92a79747338164aa3a81d389a53cf9c0792b..13af0d59172995bca7d35af42a3bc9bc231f0902 100644 (file)
@@ -12,7 +12,7 @@ NL="
 
 build_resolv_conf()
 {
-       local cf="$state_dir/resolv.conf.$interface"
+       local cf="$state_dir/resolv.conf.$interface$ifsuffix"
        local interfaces= header= search= srvs= servers= x=
 
        # Build a list of interfaces
@@ -71,7 +71,15 @@ build_resolv_conf()
 
 add_resolv_conf()
 {
-       local x= conf="$signature$NL"
+       local x= conf="$signature$NL" i=${new_ra_count:-0} ra=
+
+       while [ $i -ne 0 ]; do
+               eval ra=\$new_ra${i}_rdnss
+               new_domain_name_servers="$new_domain_name_servers${new_domain_name_servers:+ }$ra"
+               eval ra=\$new_ra${i}_dnssl
+               new_domain_search="$new_domain_search${new_domain_search:+ }$ra"
+               i=$(($i - 1))
+       done
 
        # If we don't have any configuration, remove it
        if [ -z "$new_domain_name_servers" -a \
@@ -106,30 +114,36 @@ add_resolv_conf()
        done
        if type resolvconf >/dev/null 2>&1; then
                [ -n "$ifmetric" ] && export IF_METRIC="$ifmetric"
-               printf %s "$conf" | resolvconf -a "$interface"
+               printf %s "$conf" | resolvconf -a "$interface$ifsuffix"
                return $?
        fi
 
-       if [ -e "$resolv_conf_dir/$interface" ]; then
-               rm -f "$resolv_conf_dir/$interface"
+       if [ -e "$resolv_conf_dir/$interface$ifsuffix" ]; then
+               rm -f "$resolv_conf_dir/$interface$ifsuffix"
        fi
        [ -d "$resolv_conf_dir" ] || mkdir -p "$resolv_conf_dir"
-       printf %s "$conf" > "$resolv_conf_dir/$interface"
+       printf %s "$conf" > "$resolv_conf_dir/$interface$ifsuffix"
        build_resolv_conf
 }
 
 remove_resolv_conf()
 {
        if type resolvconf >/dev/null 2>&1; then
-               resolvconf -d "$interface" -f
+               resolvconf -d "$interface$ifsuffix" -f
        else
-               if [ -e "$resolv_conf_dir/$interface" ]; then
-                       rm -f "$resolv_conf_dir/$interface"
+               if [ -e "$resolv_conf_dir/$interface$ifsuffix" ]; then
+                       rm -f "$resolv_conf_dir/$interface$ifsuffix"
                fi
                build_resolv_conf
        fi
 }
 
+if [ "$reason" = ROUTERADVERT ]; then
+       ifsuffix=":ra"
+else
+       ifsuffix=
+fi
+
 if $if_up; then
        add_resolv_conf
 elif $if_down; then