From: Michael Tremer Date: Mon, 3 Jun 2019 10:08:05 +0000 (+0200) Subject: vlan: Rename PARENT_DEVICE to PARENT_PORT X-Git-Url: http://git.ipfire.org/?p=people%2Fms%2Fnetwork.git;a=commitdiff_plain;h=a2f35a67d83bd3a4a4438c2b7b8cbc2ee0002e38;ds=sidebyside vlan: Rename PARENT_DEVICE to PARENT_PORT It technically is a port Signed-off-by: Michael Tremer --- diff --git a/src/hooks/ports/vlan b/src/hooks/ports/vlan index 39dbfffb..f19eda49 100644 --- a/src/hooks/ports/vlan +++ b/src/hooks/ports/vlan @@ -23,14 +23,14 @@ HOOK_SETTINGS=( "ADDRESS" - "PARENT_DEVICE" + "PARENT_PORT" "TAG" ) -PORT_PARENTS_VAR="PARENT" +PORT_PARENTS_VAR="PARENT_PORT" hook_check_settings() { - assert isset PARENT_DEVICE + assert isset PARENT_PORT assert isinteger TAG if isset ADDRESS; then @@ -52,18 +52,15 @@ hook_check_settings() { } hook_find_port_name() { - assert isset PARENT_DEVICE + assert isset PARENT_PORT assert isset TAG - print "${PARENT_DEVICE}${VLAN_PORT_INTERFIX}${TAG}" + print "${PARENT_PORT}${VLAN_PORT_INTERFIX}${TAG}" } hook_parse_cmdline() { while [ $# -gt 0 ]; do case "${1}" in - --parent-device=*) - PARENT_DEVICE=$(cli_get_val "${1}") - ;; --address=*) ADDRESS=$(cli_get_val "${1}") @@ -73,10 +70,19 @@ hook_parse_cmdline() { return ${EXIT_CONF_ERROR} fi ;; + --port=*) + PARENT_PORT=$(cli_get_val "${1}") + + # Check if PARENT_PORT exists + if ! port_exists "${PARENT_PORT}"; then + error "Port '${PARENT_PORT}' does not exist" + return ${EXIT_CONF_ERROR} + fi + ;; --tag=*) TAG=$(cli_get_val "${1}") ;; - -*) + *) error "Unknown argument '${1}'" return ${EXIT_CONF_ERROR} ;; @@ -100,7 +106,7 @@ hook_create() { port_settings_read "${port}" # Create the VLAN device - vlan_create "${port}" "${PARENT_DEVICE}" "${TAG}" "${ADDRESS}" + vlan_create "${port}" "${PARENT_PORT}" "${TAG}" "${ADDRESS}" exit ${EXIT_OK} } diff --git a/test/nitsi/test/port-vlan/recipe b/test/nitsi/test/port-vlan/recipe index d41377b4..7a99251b 100644 --- a/test/nitsi/test/port-vlan/recipe +++ b/test/nitsi/test/port-vlan/recipe @@ -17,7 +17,7 @@ bob: network zone upl0 config new static 192.168.100.102/24 all: network status # Create a vlan device with parent port attached to net1 -all: network port new vlan --parent-device=${p_net1} --tag=42 +all: network port new vlan --port="${p_net1}" --tag=42 all: network zone upl0 port attach "${p_net1}v42" # Test if the vlan works by pinging bob