diff --git a/executor-scripts/linux/ppp b/executor-scripts/linux/ppp new file mode 100755 index 0000000..3ba001b --- /dev/null +++ b/executor-scripts/linux/ppp @@ -0,0 +1,8 @@ +#!/bin/sh +set -e +[ -z "$IF_PPP_PROVIDER" ] && exit 0 +case "$PHASE" in +pre-up) ${MOCK} pon $IF_PPP_PROVIDER ;; +post-down) ${MOCK} poff $IF_PPP_PROVIDER ;; +depend) echo "$IF_PPP_PHYSDEV" ;; +esac diff --git a/libifupdown/interface-file.c b/libifupdown/interface-file.c index b59ca8a..82a3328 100644 --- a/libifupdown/interface-file.c +++ b/libifupdown/interface-file.c @@ -25,7 +25,8 @@ struct remap_token { }; static const struct remap_token tokens[] = { - {"vrf", "vrf-member"} + {"provider", "ppp-provider"}, /* legacy ifupdown, ifupdown2 */ + {"vrf", "vrf-member"}, }; static int @@ -119,6 +120,10 @@ lif_interface_file_parse(struct lif_dict *collection, const char *filename) cur_iface->is_dhcp = true; lif_dict_add(&cur_iface->vars, "use", strdup("dhcp")); } + else if (!strcmp(token, "ppp")) + { + lif_dict_add(&cur_iface->vars, "use", strdup("ppp")); + } else if (!strcmp(token, "inherits")) { token = lif_next_token(&bufp); diff --git a/tests/fixtures/ppp-legacy.interfaces b/tests/fixtures/ppp-legacy.interfaces new file mode 100644 index 0000000..8a83490 --- /dev/null +++ b/tests/fixtures/ppp-legacy.interfaces @@ -0,0 +1,4 @@ +auto ppp0 +iface ppp0 inet ppp + requires eth0 + provider someisp diff --git a/tests/fixtures/ppp.interfaces b/tests/fixtures/ppp.interfaces new file mode 100644 index 0000000..4d4cb9b --- /dev/null +++ b/tests/fixtures/ppp.interfaces @@ -0,0 +1,4 @@ +auto ppp0 +iface ppp0 + requires eth0 + ppp-provider someisp diff --git a/tests/ifquery_test b/tests/ifquery_test index f6afe13..67284ec 100755 --- a/tests/ifquery_test +++ b/tests/ifquery_test @@ -21,7 +21,9 @@ tests_init \ implicit_vlan \ vrf_dependency \ vrf_ifupdown2_rewrite \ - vrf_ifupdown2_dependency + vrf_ifupdown2_dependency \ + ppp_dependency \ + ppp_legacy_rewrite noargs_body() { atf_check -s exit:1 -e ignore ifquery -S/dev/null @@ -130,3 +132,13 @@ vrf_ifupdown2_dependency_body() { atf_check -s exit:0 -o match:"requires vrf-red" \ ifquery -E $EXECUTORS_LINUX -i $FIXTURES/vrf-ifupdown2.interfaces eth0 } + +ppp_dependency_body() { + atf_check -s exit:0 -o match:"requires eth0" \ + ifquery -E $EXECUTORS_LINUX -i $FIXTURES/ppp.interfaces ppp0 +} + +ppp_legacy_rewrite_body() { + atf_check -s exit:0 -o match:"ppp-provider someisp" \ + ifquery -E $EXECUTORS_LINUX -i $FIXTURES/ppp-legacy.interfaces ppp0 +} diff --git a/tests/linux/Kyuafile b/tests/linux/Kyuafile index 22bb701..471a8ff 100644 --- a/tests/linux/Kyuafile +++ b/tests/linux/Kyuafile @@ -7,3 +7,4 @@ atf_test_program{name='ipv6-ra_test'} atf_test_program{name='dhcp_test'} atf_test_program{name='static_test'} atf_test_program{name='vrf_test'} +atf_test_program{name='ppp_test'} diff --git a/tests/linux/ppp_test b/tests/linux/ppp_test new file mode 100755 index 0000000..46bb0e0 --- /dev/null +++ b/tests/linux/ppp_test @@ -0,0 +1,22 @@ +#!/usr/bin/env atf-sh + +. $(atf_get_srcdir)/../test_env.sh +EXECUTOR="$(atf_get_srcdir)/../../executor-scripts/linux/ppp" + +tests_init \ + bringup \ + teardown \ + +bringup_body() { + export MOCK=echo IFACE=ppp0 PHASE=pre-up IF_PPP_PROVIDER=someisp + atf_check -s exit:0 \ + -o match:'pon someisp' \ + ${EXECUTOR} +} + +teardown_body() { + export MOCK=echo IFACE=ppp0 PHASE=post-down IF_PPP_PROVIDER=someisp + atf_check -s exit:0 \ + -o match:'poff someisp' \ + ${EXECUTOR} +}