]> git.ipfire.org Git - people/ms/network.git/commitdiff
vlan: Rename tag to id
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 3 Jun 2019 10:34:49 +0000 (12:34 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 3 Jun 2019 10:34:49 +0000 (12:34 +0200)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/functions/functions.vlan
src/hooks/ports/vlan
test/nitsi/test/port-vlan/recipe

index c542bb5f35c2f45a296a9ff5d4aeea0ad3fcbce6..9a70c95480e3a99609e3e7e5c66b0a729e5f411f 100644 (file)
@@ -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}
 }
index 384ad50f7dcbfc68fd364e477eb03a72d0e1f373..97b69851742ea56c8cc9574a197d4f21e83395c4 100644 (file)
 
 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
index 7a99251b5e6161c6a8cdf45e587e6f67cfc489b2..2341e1978993e0ee1233f0d1d2e190735efc3d35 100644 (file)
@@ -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