Artyom A Anikeev

vlan ip cmd system corrected

... ... @@ -77,11 +77,11 @@ parse_vlan_subvlan_bridge() {
WORDS=( ${VLAN_N_BRIDGE//[:]/ } )
# The second word defines interface name. If it's empty, "vlan$VLAN.$SUBVLAN" is used.
VLAN="${WORDS[0]}"
VLANNAME="${WORDS[0]}"
BRNAME="${WORDS[1]}"
# Splitting by "."
WORDS=( ${VLAN//[.]/ } )
WORDS=( ${VLANNAME//[.]/ } )
# The second word defines subvlan (1q-in-1q) if it's used. It's empty if no subvlan is used.
VLAN="${WORDS[0]}"
... ... @@ -199,19 +199,16 @@ case "$CMD" in
NEWCONFIG=1 # we need to update the config after the command
NEW_BRIDGE="$1"; shift
[[ -z $NEW_BRIDGE ]] && NEW_VLAN_N_BRIDGE="${NEW_VLAN_SUBVLAN}" || NEW_VLAN_N_BRIDGE="${NEW_VLAN_SUBVLAN}:${NEW_BRIDGE}"
NEW_IP_CMD="$@"
parse_vlan_subvlan_bridge "${NEW_VLAN_N_BRIDGE}"
if [[ "${BRNAME}" != "" ]]; then
if [[ "${NEW_BRIDGE}" != "" ]]; then
# Getting commands for "ip"
IP_CMDS_VARIABLE="${BRNAME//[.]/_}_IP"
IP_CMDS_VARIABLE="${NEW_BRIDGE//[.]/_}_IP" # br is used to start variable's name from non numerical symbol
IP_CMDS_VARIABLE="${IP_CMDS_VARIABLE}"
eval "${IP_CMDS_VARIABLE}[\${#${IP_CMDS_VARIABLE}}]=\"$NEW_IP_CMD\""
#echo $IP_CMDS_VARIABLE
fi
... ... @@ -264,7 +261,7 @@ for D1Q_IFACE in ${D1Q_IFACES[@]}; do
# Checking if no "vlan(.subvlan)?" is set
if [[ "${BRNAME}" != "" ]]; then
#echo $BRNAME
# Getting commands for "ip"
IP_CMDS_VARIABLE="${BRNAME//[.]/_}_IP"
newconfig_push 128 "${IP_CMDS_VARIABLE}=("
... ... @@ -280,6 +277,25 @@ for D1Q_IFACE in ${D1Q_IFACES[@]}; do
newconfig_push 128 ""
[[ $hasanIP_CMD -ne 0 ]] && newconfig_pushpopall 2 128 || newconfig_popall 128
else
# Getting commands for "ip"
#echo OK
IP_CMDS_VARIABLE="vlan${VLANNAME//[.]/_}_IP"
newconfig_push 128 "${IP_CMDS_VARIABLE}=("
IP_CMDS_VARIABLE="${IP_CMDS_VARIABLE}[@]"
hasanIP_CMD=0
for IP_CMD in "${!IP_CMDS_VARIABLE}"; do
newconfig_push 128 " \"$IP_CMD\""
echo ip $IP_CMD dev $VLANNAME
hasanIP_CMD=1
done
newconfig_push 128 ")"
newconfig_push 128 ""
[[ $hasanIP_CMD -ne 0 ]] && newconfig_pushpopall 2 128 || newconfig_popall 128
fi
printf "br: %-10s vlan:%4s subvlan:%4s\n" "$BRNAME" "$VLAN" "$SUBVLAN"
... ...
... ... @@ -14,6 +14,7 @@ bond0_VLAN_N_BRIDGES=(
10.2:thor.ext
10.3:cps
10.4
10.5
50
12:
55
... ... @@ -33,3 +34,6 @@ thor_ext_IP=(
"route add default gw 10.10.2.1"
)
vlan10_5_IP=(
"addr add 10.10.5.0/24"
)
... ...