]> www.infradead.org Git - users/dwmw2/vpnc-scripts.git/commitdiff
preserve metric in fix_ip_get_output
authorDaniel Lenski <dlenski@gmail.com>
Wed, 30 Sep 2020 19:22:43 +0000 (12:22 -0700)
committerDaniel Lenski <dlenski@gmail.com>
Tue, 10 Nov 2020 22:57:01 +0000 (14:57 -0800)
This will allow us to keep, for example, both a lower-metric route to the
VPN gateway through an Ethernet interface, and a higher-metric route to the
VPN gateway through a WiFi interface.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
vpnc-script

index 0321cf6312a30bc274859992ef8789fee68e85e9..6b8aff46917dc71bcdbd3f1e6475b98e788f2e8f 100755 (executable)
@@ -237,7 +237,7 @@ destroy_tun_device() {
 if [ -n "$IPROUTE" ]; then
        fix_ip_get_output () {
                sed -e 's/ /\n/g' | \
-                   sed -ne "1 s|\$|${1}|p;/via/{N;p};/dev/{N;p};/src/{N;p};/mtu/{N;p}"
+                   sed -ne "1 s|\$|${1}|p;/via/{N;p};/dev/{N;p};/src/{N;p};/mtu/{N;p};/metric/{N;p}"
        }
 
        set_vpngateway_route() {
@@ -258,8 +258,7 @@ if [ -n "$IPROUTE" ]; then
                        # We do not want to use 'replace', since a route to the gateway that already
                        # exists is mostly likely the correct one (e.g. the case of a reconnect attempt
                        # after dead-peer detection, but no change in the underlying network devices).
-                       # Using "add" will succeed at most once
-                       $IPROUTE $FAMILY route add `echo "$VPNGATEWAY $LINE" | fix_ip_get_output` 2>/dev/null && break
+                       $IPROUTE $FAMILY route add `echo "$VPNGATEWAY $LINE" | fix_ip_get_output` 2>/dev/null
                done
                $IPROUTE $FAMILY route flush cache 2>/dev/null
         }