From 23d545de15d63869c769db4190d34998064ecfb4 Mon Sep 17 00:00:00 2001 From: Lars Wendler Date: Fri, 3 Jan 2020 21:30:28 +0100 Subject: [PATCH] pppd.sh: ppp-2.4.8 introduced "defaultroute-metric" option That option name differs from the one we patched into previous pppd releases so check if we are on >=2.4.8 version and use the correct option name accordingly Signed-off-by: Lars Wendler --- net/pppd.sh | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/net/pppd.sh b/net/pppd.sh index 6ca1396..796722e 100644 --- a/net/pppd.sh +++ b/net/pppd.sh @@ -21,6 +21,32 @@ requote() printf "'%s' " "$@" } +pppd_is_ge_248() +{ + local ver_str="$(/usr/sbin/pppd --version 2>&1 | grep -o '[[:digit:]\.]\+')" + local maj_ver="$(echo ${ver_str} | cut -d . -f 1)" + local min_ver="$(echo ${ver_str} | cut -d . -f 2)" + local patch_ver="$(echo ${ver_str} | cut -d . -f 3)" + + if [ "${maj_ver}" -gt 2 ] ; then + return 0 + elif [ "${maj_ver}" -eq 2 ] ; then + if [ "${min_ver}" -gt 4 ] ; then + return 0 + elif [ "${min_ver}" -eq 4 ] ; then + if [ "${patch_ver}" -ge 8 ] ; then + return 0 + else + return 1 + fi + else + return 1 + fi + else + return 1 + fi +} + pppd_pre_start() { # Interface has to be called ppp @@ -39,7 +65,10 @@ pppd_pre_start() return 0 fi - local link= i= unit="${IFACE#ppp}" opts= + local link= i= unit="${IFACE#ppp}" opts= routemetric=defaultmetric + + # https://github.com/paulusmack/ppp/commit/35e5a569c988b1ff865b02a24d9a727a00db4da9 + pppd_is_ge_248 && routemetric=defaultroute-metric # PPP requires a link to communicate over - normally a serial port # PPPoE communicates over Ethernet @@ -76,6 +105,7 @@ pppd_pre_start() return 1 ;; defaultmetric) hasdefaultmetric=true;; + defaultroute-metric) hasdefaultmetric=true;; mtu) hasmtu=true;; mru) hasmru=true;; maxfail) hasmaxfail=true;; @@ -98,7 +128,7 @@ pppd_pre_start() local m= eval m=\$metric_${IFVAR} [ -z "${m}" ] && : $(( m = metric + $(_ifindex) )) - opts="${opts} defaultmetric ${m}" + opts="${opts} ${routemetric} ${m}" fi if [ -n "${mtu}" ]; then ${hasmtu} || opts="${opts} mtu ${mtu}" -- 2.24.1