]> git.ipfire.org Git - network.git/commitdiff
Merge remote-tracking branch 'jschlag/master'
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 16 Sep 2018 11:53:53 +0000 (12:53 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 16 Sep 2018 11:53:53 +0000 (12:53 +0100)
Makefile.am
src/functions/functions.zone
src/hooks/zones/pppoe
src/ppp/pppoe-server
test/nitsi/test/pppoe/recipe [new file with mode: 0644]
test/nitsi/test/pppoe/settings [new file with mode: 0644]

index ae66e36079df8b29ec2e5d177a52f8843071a8a3..fe0b0c7bc82b036fcb09c79ef44ebfefb183fcd6 100644 (file)
@@ -193,12 +193,12 @@ dist_network_DATA = \
        src/network-radvd-config \
        src/header-config \
        src/header-port \
-       src/header-zone \
-       src/ppp/dialer \
-       src/ppp/pppoe-server
+       src/header-zone
 
 dist_network_SCRIPTS = \
-       src/dhclient-helper
+       src/dhclient-helper \
+       src/ppp/dialer \
+       src/ppp/pppoe-server
 
 dist_helpers_SCRIPTS = \
        src/helpers/dhcpd-config-helper \
@@ -599,6 +599,7 @@ CLEANFILES += \
 NITSI_TESTS = \
        test/nitsi/test/make-check \
        test/nitsi/test/phase1 \
+       test/nitsi/test/pppoe \
        test/nitsi/test/raw-device-get-by-mac \
        test/nitsi/test/zone-new-bridge \
        test/nitsi/test/zone-port-attach-bridge \
@@ -643,12 +644,12 @@ CLEANFILES += \
 NITSI_ENVIRONMENT =
 
 .PHONY: $(NITSI_TESTS)
-$(NITSI_TESTS): % : %/recipe %/settings test/nitsi/test/settings $(VIRTUAL_ENVIRONMENT_FILES) $(VIRTUAL_ENVIRONMENT_IMAGES) $(NITSI_INCLUDE_RECIPES)
-       $(AM_V_NITSI) $(NITSI_ENVIRONMENT) $(NITSI) --log-level debug run-test -d $@ --interactive-error-handling \
-               --default-settings $(abs_builddir)/test/nitsi/test/settings
+$(NITSI_TESTS): % : dist %/recipe %/settings test/nitsi/test/settings $(VIRTUAL_ENVIRONMENT_FILES) $(VIRTUAL_ENVIRONMENT_IMAGES) $(NITSI_INCLUDE_RECIPES)
+       $(AM_V_NITSI) $(NITSI_ENVIRONMENT) $(NITSI) --log-level error run-test -d $@ \
+               --default-settings $(abs_builddir)/test/nitsi/test/settings --interactive-error-handling
 
 .PHONY: nitsi
-nitsi: dist $(NITSI_TESTS)
+nitsi: $(NITSI_TESTS)
 
 # Downloads a virtual image file and extracts it
 $(VIRTUAL_ENVIRONMENT_IMAGES):
index 58c034722e926b9976033ea2dff19b4a183117a6..9a47f67ab1f1d947524e0ef1d6586e65bc1158ad 100644 (file)
@@ -1380,6 +1380,39 @@ zone_config_settings_destroy() {
        rm -f "${path}"
 
 }
+
+zone_config_find_by_hook() {
+       local zone="${1}"
+       assert isset zone
+
+       local hook="${2}"
+       assert isset hook
+
+       local config
+       for config in $(zone_configs_list "${zone}"); do
+               local h="$(zone_config_get_hook "${zone}" "${config}")"
+
+               [[ "${hook}" = "${h}" ]] && echo "${config}"
+       done
+
+       return ${EXIT_OK}
+}
+
+zone_config_settings_read_by_hook() {
+       local zone="${1}"
+       assert isset zone
+
+       local hook="${2}"
+       assert isset hook
+
+       local config
+       for config in $(zone_config_find_by_hook "${zone}" "${hook}"); do
+               zone_config_settings_read "${zone}" "${config}"
+       done
+
+       return ${EXIT_OK}
+}
+
 zone_port_settings_read() {
        assert [ $# -ge 2 ]
 
index 021d89b2dd5ff1ea1efb9284ff3bf27663ce4ac4..e113c92ea9751198db7d6a9cea58ab488a32da8c 100644 (file)
@@ -363,6 +363,36 @@ hook_port_detach() {
        exit ${EXIT_OK}
 }
 
+hook_port_up() {
+       assert [ $# -eq 2 ]
+
+       local zone="${1}"
+       local port="${2}"
+
+       # Try bringing up the port if it has not been brought up before
+       if ! device_exists "${port}"; then
+               port_create "${port}"
+       fi
+
+       # Make sure that the port is up
+       port_up "${port}"
+
+       exit ${EXIT_OK}
+}
+
+hook_port_down() {
+       assert [ $# -eq 2 ]
+
+       local zone="${1}"
+       local port="${2}"
+
+       if device_exists "${port}"; then
+               port_down "${port}"
+       fi
+
+       exit ${EXIT_OK}
+}
+
 hook_ppp_ipv6_up() {
        local zone="${1}"
 
index 96814653226058ba70aaa6866f441ecdb71932b8..5c46a90d39560b7b8b53918d99aa1b3dab7b09c9 100644 (file)
@@ -34,7 +34,7 @@ assert zone_exists ${zone}
 action=${2}
 
 # Read the configuration file of this hook.
-zone_config_settings_read "${zone}" "pppoe-server"
+zone_config_settings_read_by_hook "${zone}" "pppoe-server"
 assert isset SUBNET
 
 pppd_options="${RUN_DIR}/${zone}/pppoe-server-options"
@@ -91,7 +91,7 @@ case "${action}" in
                log DEBUG "pppoe-server options: ${pppoe_cmdline}"
 
                # Now exec the actual pppoe-server binary.
-               exec pppoe-server ${pppoe_cmdline}
+               exec /usr/sbin/pppoe-server ${pppoe_cmdline}
 
                error "Could not execute pppoe-server. Exiting."
                exit ${EXIT_ERROR}
diff --git a/test/nitsi/test/pppoe/recipe b/test/nitsi/test/pppoe/recipe
new file mode 100644 (file)
index 0000000..a164a83
--- /dev/null
@@ -0,0 +1,19 @@
+include: ../../include/setup
+
+# Get port names for Alice and Bob
+include: ../../include/alice-port-vars
+include: ../../include/bob-port-vars
+
+# Start a PPPoE server on Alice
+alice: network zone new upl0 bridge
+alice: network zone upl0 port attach ${p_net1}
+alice: network zone upl0 config new pppoe-server --subnet=192.168.123.0/24
+
+# Start a PPPoE client on Bob
+bob: network zone new upl0 pppoe --username=USER --password=PASSWORD
+bob: network zone upl0 port attach ${p_net1}
+
+# Show status
+all: network status
+
+# TODO need to check if the connection has come up
diff --git a/test/nitsi/test/pppoe/settings b/test/nitsi/test/pppoe/settings
new file mode 100644 (file)
index 0000000..c79a0b2
--- /dev/null
@@ -0,0 +1,3 @@
+[GENERAL]
+name = PPPoE Server/Client
+description = This test creates a PPPoE server and client and tries to connect the two of them