We need to process dynamic interfaces without metrics before ones
authorRoy Marples <roy@marples.name>
Wed, 18 Mar 2009 18:24:15 +0000 (18:24 +0000)
committerRoy Marples <roy@marples.name>
Wed, 18 Mar 2009 18:24:15 +0000 (18:24 +0000)
with metrics.

resolvconf.8.in
resolvconf.conf.5.in
resolvconf.in

index c37f5e40c8268cc781117e100f99a87db682ded7..8dba96e5d29a5fff38bb98fcd7c8ea6561d249b5 100644 (file)
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd March 16, 2009
+.Dd March 18, 2009
 .Dt RESOLVCONF 8 SMM
 .Os
 .Sh NAME
@@ -136,7 +136,7 @@ what it already has for that interface.
 .El
 .Pp
 .Nm
-also has some options designed to be used by it's subcribers:-
+also has some options designed to be used by it's subscribers:-
 .Bl -tag -width indent
 .It Fl s Ar service Ar command ...
 Try and send the
@@ -151,6 +151,21 @@ operating system on the host.
 Echo variables DOMAINS, SEARCH and NAMESERVERS so that the subscriber can
 configure the resolver easily.
 .El
+.Sh INTERFACE ORDERING
+For
+.Nm
+to work effectively, it has to process the resolv.confs for the interfaces
+in the correct order.
+.Nm
+first processes interfaces from the
+.Sy interface_order
+list, then interfaces without a metic and that match the
+.Sy dynamic_order
+list, then interfaces with a metric in order and finally the rest in
+the operating systems lexical order.
+See
+.Xr resolvconf.conf 5
+for details on these lists.
 .Sh ENVIRONMENT
 .Bl -ohang
 .It Va IF_METRIC
index 7a12887f44493d4f145bf120aff9e7e0d7383d38..a2b6bd9f5dab76ff8e2ddb59d15b8d84fa7d9192 100644 (file)
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd March 16, 2009
+.Dd March 18, 2009
 .Dt RESOLVCONF.CONF 5 SMM
 .Os
 .Sh NAME
@@ -39,9 +39,13 @@ to apply the new configuration.
 .Sh RESOLVCONF OPTIONS
 .Bl -tag -width indent
 .It Sy interface_order
-If unset, the interfaces will be processed in metric order, then
-tun, tap, vpn, ppp and ippp interfaces. The loopback interface is always
-processed first regardless.
+These interfaces will always be processed first.
+If unset, defaults to the following:-
+.D1 lo lo[0-9]*
+.It Sy dynamic_order
+These interfaces will be processed next, unless they have a metric.
+If unset, defaults to the following:-
+.D1 tap[0-9]* tun[0-9]* vpn vpn[0-9]* ppp[0-9]* ippp[0-9]*
 .El
 .Sh LIBC OPTIONS
 The following variables affect
index 88480296010e5c6497c49b533df0d35020508ca2..dc2872ca0116f08dffe369db45711ab6e98adadd 100644 (file)
@@ -39,12 +39,11 @@ if [ -f "${SYSCONFDIR}"/resolvconf.conf ]; then
 elif [ -d "${SYSCONFDIR}/resolvconf" ]; then
        SYSCONFDIR="${SYSCONFDIR}/resolvconf"
        if [ -f "${SYSCONFDIR}"/interface-order ]; then
-               interface_order="$(cat "${SYSCONFDIR}"/interface-order) *"
+               interface_order="$(cat "${SYSCONFDIR}"/interface-order)"
        fi
 fi
-if [ -n "${interface_order}" ]; then
-       interface_order="lo lo[0-9]* ${interface_order} *"
-fi
+dynamic_order="${dynamic_order:-tap[0-9]* tun[0-9]* vpn vpn[0-9]* ppp[0-9]* ippp[0-9]*}"
+interface_order="${interface_order:-lo lo[0-9]*}"
 
 error_exit()
 {
@@ -240,20 +239,23 @@ if [ "${CMD}" = "l" -o "${CMD}" = "i" ]; then
                LIST="${ARGS}"
                ${FORCE} || REPORT=true
        else
-               LIST="${interface_order}"
-       fi
-       # If we don't have a list then prefer lo, metrics, tunnels, ppp
-       # and then anything else.
-       if [ -z "${LIST}" ]; then
-               LIST="lo lo[0-9]* "
+               cd "${IFACEDIR}"
+               for LST in ${interface_order}; do
+                       [ -e "${LST}" ] && LIST="${LIST} ${LST}"
+               done
+               for DYN in ${dynamic_order}; do
+                       if [ -e "${DYN}" -a ! -e "${METRICDIR}/"*" ${DYN}" ]
+                       then
+                               LIST="${LIST} ${DYN}"
+                       fi
+               done
                if [ -d "${METRICDIR}" ]; then
                        cd "${METRICDIR}"
                        for METRIC in *; do
                                LIST="${LIST} ${METRIC#* }"
                        done
                fi
-               LIST="${LIST} tap[0-9]* tun[0-9]* vpn vpn[0-9]*"
-               LIST="${LIST} ppp[0-9]* ippp[0-9]* *"
+               LIST="${LIST} *"
        fi
 
        RETVAL=0
@@ -384,15 +386,15 @@ if [ "${CMD}" = "a" ]; then
                rm "${IFACEDIR}/${IFACE}"
        fi
        printf "${RESOLV}" >"${IFACEDIR}/${IFACE}" || exit $?
-       rm -f "${METRICDIR}/"*" ${IFACE}"
        [ ! -d "${METRICDIR}" ] && mkdir "${METRICDIR}"
        rm -f "${METRICDIR}/"*" ${IFACE}"
-       # Pad metric to 6 characters, so 5 is less than 10
-       # All interfaces will get a default metric of 0
-       while [ ${#IF_METRIC} -le 6 ]; do
-               IF_METRIC="0${IF_METRIC}"
-       done
-       echo " " >"${METRICDIR}/${IF_METRIC} ${IFACE}"
+       if [ -n "${IF_METRIC}" ]; then
+               # Pad metric to 6 characters, so 5 is less than 10
+               while [ ${#IF_METRIC} -le 6 ]; do
+                       IF_METRIC="0${IF_METRIC}"
+               done
+               echo " " >"${METRICDIR}/${IF_METRIC} ${IFACE}"
+       fi
        case "${IF_PRIVATE}" in
        [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
                if [ ! -d "${PRIVATEDIR}" ]; then