From: Roy Marples Date: Fri, 15 May 2015 14:32:54 +0000 (+0000) Subject: For now, ignore ND DNS lifetimes unless they are absent or zero, in X-Git-Tag: v6.9.0~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0c049a01de2fee448f5e27a72f572f6c425b24cb;p=thirdparty%2Fdhcpcd.git For now, ignore ND DNS lifetimes unless they are absent or zero, in which case they are removed from consideration. --- diff --git a/dhcpcd-hooks/20-resolv.conf b/dhcpcd-hooks/20-resolv.conf index e010ab7c..d99cc7fa 100644 --- a/dhcpcd-hooks/20-resolv.conf +++ b/dhcpcd-hooks/20-resolv.conf @@ -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"