Merge pull request #31 from ifupdown-ng/feature/ppp

ppp executor
This commit is contained in:
Ariadne Conill 2020-08-19 06:17:44 -06:00 committed by GitHub
commit ac56a85074
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 58 additions and 2 deletions

8
executor-scripts/linux/ppp Executable file
View file

@ -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

View file

@ -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);

4
tests/fixtures/ppp-legacy.interfaces vendored Normal file
View file

@ -0,0 +1,4 @@
auto ppp0
iface ppp0 inet ppp
requires eth0
provider someisp

4
tests/fixtures/ppp.interfaces vendored Normal file
View file

@ -0,0 +1,4 @@
auto ppp0
iface ppp0
requires eth0
ppp-provider someisp

View file

@ -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
}

View file

@ -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'}

22
tests/linux/ppp_test Executable file
View file

@ -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}
}