diff --git a/doc/interfaces.scd b/doc/interfaces.scd index 6e01c74..318c71f 100644 --- a/doc/interfaces.scd +++ b/doc/interfaces.scd @@ -70,6 +70,11 @@ the system will only respond to certain keywords by default: is for backwards compatibility and should not be used in new deployments. +*pointopoint* + Sets the given IPv4 address as the peer address on the interface. + This setting only takes effect for the IPv4 address familiy and + only makes sense in combination with as /32 netmask. + *link-type* _link-type_ Denotes the link-type of the interface. When set to _dummy_, the interface is created as a virtual dummy interfaces. diff --git a/executor-scripts/linux/static b/executor-scripts/linux/static index ed6bd10..81f77ec 100755 --- a/executor-scripts/linux/static +++ b/executor-scripts/linux/static @@ -2,6 +2,8 @@ set -e +[ -z "$VERBOSE" ] || set -x + [ -z "$IF_METRIC" ] && IF_METRIC="1" [ -n "$IF_VRF_TABLE" ] && VRF_TABLE="table $IF_VRF_TABLE" [ -n "$IF_VRF_MEMBER" ] && VRF_TABLE="vrf $IF_VRF_MEMBER" @@ -20,7 +22,13 @@ addr_family() { configure_addresses() { for i in $(ifquery -p address -i $INTERFACES_FILE $IFACE); do addrfam=$(addr_family $i) - ${MOCK} ip $addrfam addr $1 $i dev $IFACE + if [ "${IF_POINTOPOINT}" -a "${addrfam}" = "-4" ]; then + PEER="peer ${IF_POINTOPOINT}" + else + PEER="" + fi + + ${MOCK} ip $addrfam addr $1 $i $PEER dev $IFACE done } @@ -31,8 +39,6 @@ configure_gateways() { done } -[ -z "$VERBOSE" ] || set -x - case "$PHASE" in up) configure_addresses add diff --git a/tests/fixtures/static-eth0-ptp.interfaces b/tests/fixtures/static-eth0-ptp.interfaces new file mode 100644 index 0000000..c9b5c77 --- /dev/null +++ b/tests/fixtures/static-eth0-ptp.interfaces @@ -0,0 +1,7 @@ +auto eth0 +iface eth0 + address 203.0.113.2/32 + pointopoint 192.0.2.1 + gateway 192.0.2.1 + address 2001:db8:1000:2::2/64 + gateway 2001:db8:1000:2::1 diff --git a/tests/linux/static_test b/tests/linux/static_test index 04c5e8f..b02915e 100755 --- a/tests/linux/static_test +++ b/tests/linux/static_test @@ -4,7 +4,14 @@ EXECUTOR="$(atf_get_srcdir)/../../executor-scripts/linux/static" FIXTURES="$(atf_get_srcdir)/../fixtures" -tests_init up down vrf_up vrf_down metric_up metric_down +tests_init \ + up \ + up_ptp \ + down \ + vrf_up \ + vrf_down \ + metric_up \ + metric_down up_body() { export IFACE=eth0 PHASE=up MOCK=echo INTERFACES_FILE="$FIXTURES/static-eth0.interfaces" @@ -16,6 +23,17 @@ up_body() { ${EXECUTOR} } +up_ptp_body() { + export IFACE=eth0 PHASE=up MOCK=echo INTERFACES_FILE="$FIXTURES/static-eth0-ptp.interfaces" \ + IF_POINTOPOINT="192.0.2.1" + atf_check -s exit:0 \ + -o match:'addr add 203.0.113.2/32 peer 192.0.2.1 dev eth0' \ + -o match:'route add default via 192.0.2.1 metric 1 dev eth0' \ + -o match:'addr add 2001:db8:1000:2::2/64 dev eth0' \ + -o match:'route add default via 2001:db8:1000:2::1 metric 1 dev eth0' \ + ${EXECUTOR} +} + down_body() { export IFACE=eth0 PHASE=down MOCK=echo INTERFACES_FILE="$FIXTURES/static-eth0.interfaces" atf_check -s exit:0 \