. /usr/lib/network/header-port
-HOOK_SETTINGS="ADDRESS MIIMON MODE OFFLOADING SLAVES"
+HOOK_SETTINGS=(
+ "ADDRESS"
+ "MIIMON"
+ "MODE"
+ "OFFLOADING"
+ "SLAVES"
+)
-SLAVES=""
-MIIMON=100
-MODE="balance-rr"
+DEFAULT_MIIMON=100
+DEFAULT_MODE="balance-rr"
hook_check_settings() {
assert isset ADDRESS
MODE=$(cli_get_val "${1}")
;;
--offloading=*)
- OFFLOADING="$(cli_get_val "${1}")"
-
- if enabled OFFLOADING; then
- OFFLOADING="on"
- elif disabled OFFLOADING; then
- OFFLOADING="off"
- else
- error "Invalid value for offloading: ${OFFLOADING}"
- return ${EXIT_ERROR}
- fi
+ OFFLOADING="$(cli_get_bool "${1}")"
;;
+*)
local slave=$(cli_get_val "${1:1}")
assert isset port
# Save configuration
- if port_settings_write "${port}" ${HOOK_SETTINGS}; then
+ if port_settings_write "${port}"; then
log INFO "New port ${port} has been created"
else
error "Could not save configuration for ${port}"
# Exit silently if the device already exists
device_exists "${port}" && exit ${EXIT_OK}
- port_settings_read "${port}" ${HOOK_SETTINGS}
+ port_settings_read "${port}"
# Create the bonding devices
bonding_create "${port}" \
local port="${1}"
assert isset port
- port_settings_read "${port}" ${HOOK_SETTINGS}
+ port_settings_read "${port}"
# Remove the bonding device
if device_exists "${port}"; then
local port="${1}"
assert isset port
- port_settings_read "${port}" ${HOOK_SETTINGS}
+ port_settings_read "${port}"
# Auto-enable or disable hardware offloading
if ! isset OFFLOADING || enabled OFFLOADING; then
local port="${1}"
assert isset port
- port_settings_read "${port}" ${HOOK_SETTINGS}
+ port_settings_read "${port}"
# Bring down all slaves
local slave
# Handle events of the same interface
if hotplug_event_port_is_interface "${port}"; then
# Read configuration
- port_settings_read "${port}" ${HOOK_SETTINGS}
+ port_settings_read "${port}"
# Bring up all slaves
# Attach those which already exist and try to create