diff --git a/doc/interfaces.scd b/doc/interfaces.scd index c8be881..9d51481 100644 --- a/doc/interfaces.scd +++ b/doc/interfaces.scd @@ -70,6 +70,13 @@ the system will only respond to certain keywords by default: is for backwards compatibility and should not be used in new deployments. +*point-to-point* _address_ + 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 a /32 netmask. + For compatiblity with ifupdown and ifupdown2, _pointopoint_ is + an alias for this parameter. + *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..cb9af18 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_POINT_TO_POINT}" -a "${addrfam}" = "-4" ]; then + PEER="peer ${IF_POINT_TO_POINT}" + 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/libifupdown/interface-file.c b/libifupdown/interface-file.c index f2123fa..4cefd42 100644 --- a/libifupdown/interface-file.c +++ b/libifupdown/interface-file.c @@ -81,6 +81,7 @@ static const struct remap_token tokens[] = { {"offload-tso", "ethtool-offload-tso"}, /* Debian ethtool integration */ {"offload-tx", "ethtool-offload-tx"}, /* Debian ethtool integration */ {"offload-ufo", "ethtool-offload-ufo"}, /* Debian ethtool integration */ + {"pointopoint", "point-to-point"}, /* legacy ifupdown, ifupdown2 */ {"provider", "ppp-provider"}, /* legacy ifupdown, ifupdown2 */ {"rx-offload", "ethtool-offload-rx"}, /* ifupdown2 */ {"tso-offload", "ethtool-offload-tso"}, /* ifupdown2 */ diff --git a/tests/fixtures/static-eth0-ptp.interfaces b/tests/fixtures/static-eth0-ptp.interfaces new file mode 100644 index 0000000..e6a3f53 --- /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..04c1a85 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_POINT_TO_POINT="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 \