openresolv-discuss

openresolv metric logic is flawed

Scott Barker

Tue Nov 13 00:52:25 2018

The documentation for the -m options says:

  Set the metric of the interface when adding it, default of 0.  Lower metrics take precedence.

However, if you assign any metric to an interface, it will actually take
precedence over any interface which doesn't have a metric defined and isn't
in the interface_order or dynamic_order. Hence, the default metric is
actually one more than 9999999. For example:

# /sbin/resolvconf -i
lo.unbound wlan0

# cat myvpn_resolvconf | /sbin/resolvconf -m 99 -a myvpn

# /sbin/resolvconf -i
lo.unbound myvpn wlan0

# find /run/resolvconf/ -type f
/run/resolvconf/interfaces/myvpn
/run/resolvconf/interfaces/lo.unbound
/run/resolvconf/interfaces/wlan0
/run/resolvconf/metrics/0000099 myvpn

I've attached a trivial patch that fixes this behaviour.

-- 
Scott Barker
--- /sbin/resolvconf	2016-04-20 13:30:01.000000000 -0600
+++ resolvconf	2018-11-12 17:04:16.296605415 -0700
@@ -404,13 +404,15 @@
 				fi
 			done
 		done
+		for i in *; do
+			[ ! -e "$METRICDIR/"*" $i" ] && list="$list $i"
+		done
 		if [ -d "$METRICDIR" ]; then
 			cd "$METRICDIR"
 			for i in *; do
 				[ -f "$i" ] && list="$list ${i#* }"
 			done
 		fi
-		list="$list *"
 	fi
 
 	cd "$IFACEDIR"

Follow-Ups:
Re: openresolv metric logic is flawedRoy Marples
Archive administrator: postmaster@marples.name