From 3de259bf8311943b88e64b8e84b09673b8ecefa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Ospal=C3=BD?= Date: Thu, 21 May 2020 15:47:51 +0200 Subject: [PATCH] F #83: Add route metric support (#208) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * F #83: Add route metric support - BSD has no support for metrics: https://redmine.pfsense.org/issues/1521 Signed-off-by: Petr Ospalý Signed-off-by: Petr Ospalý * F #83: Remove unsupported ipv6 metric - distro's network scripts have no support for ipv6 metrics - no reason then to provide ipv6 specific METRIC6 variable - fix whitespace Signed-off-by: Petr Ospalý --- src/etc/one-context.d/loc-10-network##apk.one | 4 --- src/etc/one-context.d/loc-10-network##deb.one | 6 ++++ .../loc-10-network##network-scripts.one | 7 ++++- .../loc-10-network##networkd.one | 29 ++++++++++++++----- src/etc/one-context.d/loc-10-network-pci##one | 7 +++-- 5 files changed, 37 insertions(+), 16 deletions(-) diff --git a/src/etc/one-context.d/loc-10-network##apk.one b/src/etc/one-context.d/loc-10-network##apk.one index a8fac14..f90782b 100755 --- a/src/etc/one-context.d/loc-10-network##apk.one +++ b/src/etc/one-context.d/loc-10-network##apk.one @@ -172,10 +172,6 @@ EOT if [ -n "$GATEWAY6" ]; then echo " gateway $GATEWAY6" - - if [ -n "$METRIC" ]; then - echo " metric $METRIC" - fi fi if [ -n "$IP6_ULA" ]; then diff --git a/src/etc/one-context.d/loc-10-network##deb.one b/src/etc/one-context.d/loc-10-network##deb.one index f810ac8..c89705a 100755 --- a/src/etc/one-context.d/loc-10-network##deb.one +++ b/src/etc/one-context.d/loc-10-network##deb.one @@ -114,7 +114,12 @@ EOT if [ -n "$GATEWAY" ]; then echo " gateway $GATEWAY" + + if [ -n "$METRIC" ]; then + echo " metric $METRIC" + fi fi + echo "" } @@ -232,6 +237,7 @@ EOT MASK=$(get_mask) MTU=$(get_mtu) GATEWAY=$(get_gateway) + METRIC=$(get_iface_var "METRIC") IP6=$(get_iface_var "IP6") [[ -z $IP6 ]] && IP6=$(get_iface_var "IPV6") diff --git a/src/etc/one-context.d/loc-10-network##network-scripts.one b/src/etc/one-context.d/loc-10-network##network-scripts.one index 9867161..6069f96 100755 --- a/src/etc/one-context.d/loc-10-network##network-scripts.one +++ b/src/etc/one-context.d/loc-10-network##network-scripts.one @@ -108,9 +108,13 @@ EOT if [ -n "$GATEWAY" ]; then if [ "$CONFIG_PATH" = "/etc/sysconfig/network" ]; then - echo "default $GATEWAY - $DEV" >> /etc/sysconfig/network/ifroute-$DEV + echo "default $GATEWAY - $DEV" ${METRIC:+metric ${METRIC}} >> /etc/sysconfig/network/ifroute-$DEV else echo "GATEWAY=$GATEWAY" + + if [ -n "$METRIC" ]; then + echo "METRIC=$METRIC" + fi fi fi @@ -225,6 +229,7 @@ gen_network_configuration() MASK=$(get_mask) MTU=$(get_mtu) GATEWAY=$(get_gateway) + METRIC=$(get_iface_var "METRIC") IP6=$(get_iface_var "IP6") [[ -z $IP6 ]] && IP6=$(get_iface_var "IPV6") diff --git a/src/etc/one-context.d/loc-10-network##networkd.one b/src/etc/one-context.d/loc-10-network##networkd.one index e96ec25..9c1ffac 100755 --- a/src/etc/one-context.d/loc-10-network##networkd.one +++ b/src/etc/one-context.d/loc-10-network##networkd.one @@ -169,10 +169,6 @@ EOT fi done - if [ -n "$GATEWAY" ]; then - echo "Gateway=$GATEWAY" - fi - if [ -n "$DNS" ]; then for dns_server in $DNS; do echo "DNS=$dns_server" @@ -185,6 +181,18 @@ EOT done fi + cat <