F #83: Add route metric support (#208)

* F #83: Add route metric support

- BSD has no support for metrics:
  https://redmine.pfsense.org/issues/1521

Signed-off-by: Petr Ospalý <pospaly@opennebula.systems>
Signed-off-by: Petr Ospalý <pospaly@opennebula.io>

* 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ý <pospaly@opennebula.io>
pull/209/head
Petr Ospalý 5 years ago committed by GitHub
parent 556739406c
commit 3de259bf83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -172,10 +172,6 @@ EOT
if [ -n "$GATEWAY6" ]; then if [ -n "$GATEWAY6" ]; then
echo " gateway $GATEWAY6" echo " gateway $GATEWAY6"
if [ -n "$METRIC" ]; then
echo " metric $METRIC"
fi
fi fi
if [ -n "$IP6_ULA" ]; then if [ -n "$IP6_ULA" ]; then

@ -114,7 +114,12 @@ EOT
if [ -n "$GATEWAY" ]; then if [ -n "$GATEWAY" ]; then
echo " gateway $GATEWAY" echo " gateway $GATEWAY"
if [ -n "$METRIC" ]; then
echo " metric $METRIC"
fi
fi fi
echo "" echo ""
} }
@ -232,6 +237,7 @@ EOT
MASK=$(get_mask) MASK=$(get_mask)
MTU=$(get_mtu) MTU=$(get_mtu)
GATEWAY=$(get_gateway) GATEWAY=$(get_gateway)
METRIC=$(get_iface_var "METRIC")
IP6=$(get_iface_var "IP6") IP6=$(get_iface_var "IP6")
[[ -z $IP6 ]] && IP6=$(get_iface_var "IPV6") [[ -z $IP6 ]] && IP6=$(get_iface_var "IPV6")

@ -108,9 +108,13 @@ EOT
if [ -n "$GATEWAY" ]; then if [ -n "$GATEWAY" ]; then
if [ "$CONFIG_PATH" = "/etc/sysconfig/network" ]; 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 else
echo "GATEWAY=$GATEWAY" echo "GATEWAY=$GATEWAY"
if [ -n "$METRIC" ]; then
echo "METRIC=$METRIC"
fi
fi fi
fi fi
@ -225,6 +229,7 @@ gen_network_configuration()
MASK=$(get_mask) MASK=$(get_mask)
MTU=$(get_mtu) MTU=$(get_mtu)
GATEWAY=$(get_gateway) GATEWAY=$(get_gateway)
METRIC=$(get_iface_var "METRIC")
IP6=$(get_iface_var "IP6") IP6=$(get_iface_var "IP6")
[[ -z $IP6 ]] && IP6=$(get_iface_var "IPV6") [[ -z $IP6 ]] && IP6=$(get_iface_var "IPV6")

@ -169,10 +169,6 @@ EOT
fi fi
done done
if [ -n "$GATEWAY" ]; then
echo "Gateway=$GATEWAY"
fi
if [ -n "$DNS" ]; then if [ -n "$DNS" ]; then
for dns_server in $DNS; do for dns_server in $DNS; do
echo "DNS=$dns_server" echo "DNS=$dns_server"
@ -185,6 +181,18 @@ EOT
done done
fi fi
cat <<EOT
[Route]
EOT
if [ -n "$GATEWAY" ]; then
echo "Gateway=$GATEWAY"
if [ -n "$METRIC" ]; then
echo "Metric=$METRIC"
fi
fi
echo "" echo ""
} }
@ -219,10 +227,6 @@ EOT
echo "IPv6AcceptRA=false" echo "IPv6AcceptRA=false"
if [ -n "$GATEWAY6" ]; then
echo "Gateway=$GATEWAY6"
fi
if [ -n "$DNS" ]; then if [ -n "$DNS" ]; then
for dns_server in $DNS; do for dns_server in $DNS; do
echo "DNS=$dns_server" echo "DNS=$dns_server"
@ -235,6 +239,14 @@ EOT
done done
fi fi
cat <<EOT
[Route]
EOT
if [ -n "$GATEWAY6" ]; then
echo "Gateway=$GATEWAY6"
fi
if [ -n "$IP6_ULA" ]; then if [ -n "$IP6_ULA" ]; then
cat <<EOT cat <<EOT
[Network] [Network]
@ -286,6 +298,7 @@ gen_network_configuration()
CIDR=$(mask2cidr "$MASK") CIDR=$(mask2cidr "$MASK")
MTU=$(get_mtu) MTU=$(get_mtu)
GATEWAY=$(get_gateway) GATEWAY=$(get_gateway)
METRIC=$(get_iface_var "METRIC")
DNS=$(get_dns) DNS=$(get_dns)
SEARCH_DOMAIN=$(get_search_domain) SEARCH_DOMAIN=$(get_search_domain)

@ -56,6 +56,7 @@ for pci in $PCI_INTERFACES; do
MASK=$(get_iface_var "MASK") MASK=$(get_iface_var "MASK")
MASK=${MASK:-255.255.255.0} MASK=${MASK:-255.255.255.0}
GATEWAY=$(get_iface_var "GATEWAY") GATEWAY=$(get_iface_var "GATEWAY")
METRIC=$(get_iface_var "METRIC")
MTU=$(get_iface_var "MTU") MTU=$(get_iface_var "MTU")
MTU=${MTU:-1500} MTU=${MTU:-1500}
VLAN_ID=$(get_iface_var "VLAN_ID") VLAN_ID=$(get_iface_var "VLAN_ID")
@ -92,9 +93,9 @@ for pci in $PCI_INTERFACES; do
if [ -n "$IP" ]; then if [ -n "$IP" ]; then
ip address add $IP/$MASK dev $DEV ip address add $IP/$MASK dev $DEV
if [ -n "$GATEWAY" ]; then if [ -n "$GATEWAY" ]; then
ip route add default via $GATEWAY dev $DEV ip route add default via $GATEWAY dev $DEV ${METRIC:+metric ${METRIC}}
fi fi
fi fi
# IPv6 # IPv6

Loading…
Cancel
Save