]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
For now, ignore ND DNS lifetimes unless they are absent or zero, in
authorRoy Marples <roy@marples.name>
Fri, 15 May 2015 14:32:54 +0000 (14:32 +0000)
committerRoy Marples <roy@marples.name>
Fri, 15 May 2015 14:32:54 +0000 (14:32 +0000)
which case they are removed from consideration.

dhcpcd-hooks/20-resolv.conf

index e010ab7cf4e279dd3437cd9bae474f03b13d7bcf..d99cc7fab3105d128028d9b2062f5758fdb84e44 100644 (file)
@@ -68,31 +68,51 @@ build_resolv_conf()
        rm -f "$cf"
 }
 
+# Extract any ND DNS options from the RA
+# For now, we ignore the lifetime of the DNS options unless they
+# are absent or zero.
+# In this case they are removed from consideration.
+# See draft-gont-6man-slaac-dns-config-issues-01 for issues
+# regarding DNS option lifetime in ND messages.
+eval_nd_dns()
+{
+
+       eval ltime=\$nd${i}_rdnss${j}_lifetime
+       if [ -z "$ltime" -o "$ltime" = 0 ]; then
+               rdnss=
+       else
+               eval rdnss=\$nd${i}_rdnss${j}_servers
+       fi
+       eval ltime=\$nd${i}_dnssl${j}_lifetime
+       if [ -z "$ltime" -o "$ltime" = 0 ]; then
+               dnssl=
+       else
+               eval dnssl=\$nd${i}_dnssl${j}_search
+       fi
+
+       [ -z "$rdnss" -a -z "$dnssl" ] && return 1
+
+       new_rdnss="$new_rdnss${new_rdnss:+ }$rdnss"
+       new_dnssl="$new_dnssl${new_dnssl:+ }$dnssl"
+       j=$(($j + 1))
+       return 0
+}
+
 add_resolv_conf()
 {
        local x= conf="$signature$NL" warn=true
-       local i j rdnss dnssl new_rdnss new_dnssl
+       local i j ltime rdnss dnssl new_rdnss new_dnssl
 
-       # Extract any ND DNS options from the RA
+       # Loop to extract the ND DNS options using our indexed shell values
        i=1
        j=1
        while true; do
                while true; do
-                       eval rdnss=\$nd${i}_rdnss${j}_servers
-                       eval dnssl=\$nd${i}_dnssl${j}_search
-                       [ -z "$rdnss" -a -z "$dnssl" ] && break
-                       new_rdnss="$new_rdnss${new_rdnss:+ }$rdnss"
-                       new_dnssl="$new_dnssl${new_dnssl:+ }$dnssl"
-                       j=$(($j + 1))
+                       eval_nd_dns || break
                done
                i=$(($i + 1))
                j=1
-               eval rdnss=\$nd${i}_rdnss${j}_servers
-               eval dnssl=\$nd${i}_dnssl${j}_search
-               [ -z "$rdnss" -a -z "$dnssl" ] && break
-               new_rdnss="$new_rdnss${new_rdnss:+ }$rdnss"
-               new_dnssl="$new_dnssl${new_dnssl:+ }$dnssl"
-               j=$(($j + 1))
+               eval_nd_dns || break
        done
        new_domain_name_servers="$new_domain_name_servers${new_domain_name_servers:+ }$new_rdnss"
        new_domain_search="$new_domain_search${new_domain_search:+ }$new_dnssl"