Merge pull request #36 from ifupdown-ng/feature/static-metric

static: add support for the metric property
This commit is contained in:
Ariadne Conill 2020-08-20 04:41:51 -06:00 committed by GitHub
commit 885778a412
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 3 deletions

View file

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
VRF_TABLE=""
[ -n "$IF_VRF_TABLE" ] && VRF_TABLE="table $IF_VRF_TABLE" [ -n "$IF_VRF_TABLE" ] && VRF_TABLE="table $IF_VRF_TABLE"
[ -n "$IF_METRIC" ] && METRIC="metric $IF_METRIC"
addr_family() { addr_family() {
if [ "$1" != "${1#*[0-9].[0-9]}" ]; then if [ "$1" != "${1#*[0-9].[0-9]}" ]; then
@ -23,7 +23,7 @@ configure_addresses() {
configure_gateways() { configure_gateways() {
for i in $(ifquery -p gateway -i $INTERFACES_FILE $IFACE); do for i in $(ifquery -p gateway -i $INTERFACES_FILE $IFACE); do
addrfam=$(addr_family $i) addrfam=$(addr_family $i)
${MOCK} ip $addrfam route $1 default via $i $VRF_TABLE ${MOCK} ip $addrfam route $1 default via $i $VRF_TABLE $METRIC
done done
} }

View file

@ -4,7 +4,7 @@
EXECUTOR="$(atf_get_srcdir)/../../executor-scripts/linux/static" EXECUTOR="$(atf_get_srcdir)/../../executor-scripts/linux/static"
FIXTURES="$(atf_get_srcdir)/../fixtures" FIXTURES="$(atf_get_srcdir)/../fixtures"
tests_init up down vrf_up vrf_down tests_init up down vrf_up vrf_down metric_up metric_down
up_body() { up_body() {
export IFACE=eth0 PHASE=up MOCK=echo INTERFACES_FILE="$FIXTURES/static-eth0.interfaces" export IFACE=eth0 PHASE=up MOCK=echo INTERFACES_FILE="$FIXTURES/static-eth0.interfaces"
@ -41,3 +41,19 @@ vrf_down_body() {
-o match:'route del default via 203.0.113.2 table 1' \ -o match:'route del default via 203.0.113.2 table 1' \
${EXECUTOR} ${EXECUTOR}
} }
metric_up_body() {
export IFACE=vrf-red PHASE=up MOCK=echo INTERFACES_FILE="$FIXTURES/vrf.interfaces" \
IF_VRF_TABLE=1 IF_METRIC=20
atf_check -s exit:0 \
-o match:'route add default via 203.0.113.2 table 1 metric 20' \
${EXECUTOR}
}
metric_down_body() {
export IFACE=vrf-red PHASE=down MOCK=echo INTERFACES_FILE="$FIXTURES/vrf.interfaces" \
IF_VRF_TABLE=1 IF_METRIC=20
atf_check -s exit:0 \
-o match:'route del default via 203.0.113.2 table 1 metric 20' \
${EXECUTOR}
}