assert isset device
local address
+ local id
local parent
- local tag
# Parse command line arguments
while [ $# -gt 0 ]; do
--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}
# 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
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}
}
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() {
return ${EXIT_CONF_ERROR}
fi
;;
+ --id=*)
+ ID=$(cli_get_val "${1}")
+ ;;
--port=*)
PARENT_PORT=$(cli_get_val "${1}")
return ${EXIT_CONF_ERROR}
fi
;;
- --tag=*)
- TAG=$(cli_get_val "${1}")
- ;;
*)
error "Unknown argument '${1}'"
return ${EXIT_CONF_ERROR}
# 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
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