From: Michael Tremer Date: Mon, 3 Jun 2019 10:34:49 +0000 (+0200) Subject: vlan: Rename tag to id X-Git-Url: http://git.ipfire.org/?p=people%2Fms%2Fnetwork.git;a=commitdiff_plain;h=f24529e498b1c3fe60196c34356e5b005a22ae4c vlan: Rename tag to id Signed-off-by: Michael Tremer --- diff --git a/src/functions/functions.vlan b/src/functions/functions.vlan index c542bb5f..9a70c954 100644 --- a/src/functions/functions.vlan +++ b/src/functions/functions.vlan @@ -31,8 +31,8 @@ vlan_create() { assert isset device local address + local id local parent - local tag # Parse command line arguments while [ $# -gt 0 ]; do @@ -40,12 +40,12 @@ vlan_create() { --address=*) address=$(cli_get_val "${1}") ;; + --id=*) + id=$(cli_get_val "${1}") + ;; --parent=*) parent=$(cli_get_val "${1}") ;; - --tag=*) - tag=$(cli_get_val "${1}") - ;; *) error "Unrecognized argument: ${1}" return ${EXIT_ERROR} @@ -80,7 +80,7 @@ vlan_create() { # Make the command local command=( ip link add link "${parent}" name "${device}" - address "${address}" type vlan id "${tag}" + address "${address}" type vlan id "${id}" ) # Run the command @@ -89,7 +89,7 @@ vlan_create() { return ${EXIT_ERROR} fi - log DEBUG "Created VLAN device ${device} (parent = ${parent}, id = ${tag})" + log DEBUG "Created VLAN device ${device} (parent = ${parent}, id = ${id})" return ${EXIT_OK} } diff --git a/src/hooks/ports/vlan b/src/hooks/ports/vlan index 384ad50f..97b69851 100644 --- a/src/hooks/ports/vlan +++ b/src/hooks/ports/vlan @@ -23,39 +23,39 @@ HOOK_SETTINGS=( "ADDRESS" + "ID" "PARENT_PORT" - "TAG" ) PORT_PARENTS_VAR="PARENT_PORT" hook_check_settings() { assert isset PARENT_PORT - assert isinteger TAG + assert isinteger ID if isset ADDRESS; then assert ismac ADDRESS fi - if [ ${TAG} -gt 4096 ]; then - error "TAG is greater than 4096." + if [ ${ID} -gt 4096 ]; then + error "ID is greater than 4096." exit ${EXIT_ERROR} fi local reserved for reserved in 0 4095; do - if [ "${TAG}" = "${reserved}" ]; then - error "TAG=${reserved} is reserved." + if [ "${ID}" = "${reserved}" ]; then + error "ID=${reserved} is reserved." exit ${EXIT_ERROR} fi done } hook_find_port_name() { + assert isset ID assert isset PARENT_PORT - assert isset TAG - print "${PARENT_PORT}${VLAN_PORT_INTERFIX}${TAG}" + print "${PARENT_PORT}${VLAN_PORT_INTERFIX}${ID}" } hook_parse_cmdline() { @@ -70,6 +70,9 @@ hook_parse_cmdline() { return ${EXIT_CONF_ERROR} fi ;; + --id=*) + ID=$(cli_get_val "${1}") + ;; --port=*) PARENT_PORT=$(cli_get_val "${1}") @@ -79,9 +82,6 @@ hook_parse_cmdline() { return ${EXIT_CONF_ERROR} fi ;; - --tag=*) - TAG=$(cli_get_val "${1}") - ;; *) error "Unknown argument '${1}'" return ${EXIT_CONF_ERROR} @@ -122,8 +122,8 @@ hook_create() { # Create the VLAN device if ! vlan_create "${port}" \ --address="${ADDRESS}" \ - --parent="${PARENT_PORT}" \ - --tag="${TAG}"; then + --id="${id}" \ + --parent="${PARENT_PORT}"; then error "Could not create port: ${port}" return ${EXIT_ERROR} fi diff --git a/test/nitsi/test/port-vlan/recipe b/test/nitsi/test/port-vlan/recipe index 7a99251b..2341e197 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 --port="${p_net1}" --tag=42 +all: network port new vlan --port="${p_net1}" --id=42 all: network zone upl0 port attach "${p_net1}v42" # Test if the vlan works by pinging bob