Browse Source

Adapting for "FWSM" container

Dmitry Yu Okunev 3 years ago
parent
commit
a1cd1ca1ca
1 changed files with 26 additions and 2 deletions
  1. 26 2
      ipw

+ 26 - 2
ipw

@@ -19,6 +19,7 @@
 CMD="$1"; shift;
 
 DEFAULT_BONDING_MODE='balance-tlb'
+LXC_ISV2="$(lxc --version 2>/dev/null)"
 
 modprobe bonding
 
@@ -190,6 +191,16 @@ BRIDGE_FORWARD_DELAY=0
 
 source "$IPW_CONFIG_PATH"
 
+if [ "$LXC_ISV2" != "" ]; then
+	LXC_DIR=""
+fi
+
+declare -A SKIP_BRIDGE_MAP
+
+for SKIP_BRIDGE in ${SKIP_BRIDGES[@]}; do
+	SKIP_BRIDGES_MAP[$SKIP_BRIDGE]=1
+done
+
 NEWCONFIG_TMPPATH="/tmp/.~ipw"
 
 NEWCONFIG=0
@@ -363,7 +374,7 @@ case "$CMD" in
 		if [[ "$LXC_DIR" != "" ]]; then
 			LXC_BRIDGE_SLAVES=($(cat "$LXC_DIR"/*/config 2>/dev/null | tr -d " \t" | awk -F '=' '{if($1=="lxc.network.link") {BRIDGE=$2}; if($1=="lxc.network.veth.pair") {if(BRIDGE!="") {print $2":"BRIDGE; BRIDGE=""}} }'))
 		fi
-		
+
 		#REMOVING UNNECESSARY D1Q
 
 		OLD_D1Q_IFACES="`cat /sys/class/net/bonding_masters`"
@@ -379,6 +390,9 @@ case "$CMD" in
 					break
 				fi
 			done
+			if [[ "${SKIP_BRIDGES_MAP[${OLD_D1Q_IFACE}br]}" = "1" ]]; then
+				TRUNK_BRIDGE_IS_USED=1
+			fi
 
 			if [[ "$TRUNK_BRIDGE_IS_USED" -eq 0 ]]; then
 				OLD_TRUNK_BRIDGE="$OLD_D1Q_IFACE"br
@@ -462,6 +476,7 @@ case "$CMD" in
 				
 				if ! iface_isexists "$BRNAME"; then
 					ip link add "$BRNAME" type bridge
+					ip link set dev "$BRNAME" mtu "$DEFAULT_MTU"
 					ip link set dev "$BRNAME" up
 				fi
 				ip link set "$IFACE" master "$BRNAME"
@@ -486,7 +501,8 @@ case "$CMD" in
 			BRIDGE_IN_USE=0
 			IFACE_IN_USE=0
 			VLAN_N_BRIDGE_IN_USE=0
-			if [[ "${REQUIRED_FULLNAME_HASH[$LINE]}" != "" ]]; then
+
+			if [[ "${REQUIRED_FULLNAME_HASH[$LINE]}" != "" ]] || [[ "${SKIP_BRIDGES_MAP[$OLD_BRNAME]}" = "1" ]]; then
 				BRIDGE_IN_USE=1
 				IFACE_IN_USE=1
 				VLAN_N_BRIDGE_IN_USE=1
@@ -558,6 +574,7 @@ case "$CMD" in
 			# Creating bond-ifaces
 			if [[ "$D1Q_EXISTS" == 0 ]]; then #make all
 				echo "+$D1Q_IFACE" > /sys/class/net/bonding_masters 2>/dev/null
+				ip link set dev "$D1Q_IFACE" mtu "$DEFAULT_MTU"
 
 				if [[ -d /sys/class/net/"$D1Q_IFACE"/bonding ]]; then
 					echo "$MODE" > /sys/class/net/"$D1Q_IFACE"/bonding/mode
@@ -573,6 +590,7 @@ case "$CMD" in
 			ip link set dev "$D1Q_IFACE" up
 
 			for SLAVE in "${!SLAVES_VARIABLE}"; do #slave starts after bond
+				ip link set dev "$SLAVE" mtu "$DEFAULT_MTU"
 				ip link set dev "$SLAVE" up
 			done
 
@@ -582,6 +600,7 @@ case "$CMD" in
 			if ! [[ -d /sys/class/net/"$TRUNK_BRIDGE" ]]; then
 				ip link add "$TRUNK_BRIDGE" type bridge
 				echo "$BRIDGE_FORWARD_DELAY" > /sys/devices/virtual/net/"$TRUNK_BRIDGE"/bridge/forward_delay
+				ip link set dev "$TRUNK_BRIDGE" mtu "$DEFAULT_MTU"
 				ip link set dev "$TRUNK_BRIDGE" up
 				ip link set "$D1Q_IFACE" master "$TRUNK_BRIDGE"
 			fi
@@ -605,13 +624,16 @@ case "$CMD" in
 
 							if ! iface_isexists "$FULL_PARVLAN_NAME"; then #should we create a new parent vlan?
 								ip link add link "$D1Q_IFACE" name "$FULL_PARVLAN_NAME" type vlan id "$VLAN" #vlan in bond
+								ip link set dev "$FULL_PARVLAN_NAME" mtu "$DEFAULT_MTU"
 								ip link set dev "$FULL_PARVLAN_NAME" up
 							fi
 							ip link add link "$FULL_PARVLAN_NAME" name "$FULL_VLAN_NAME" type vlan id "$SUBVLAN" #subvlan in vlan
+							#ip link set dev "$FULL_VLAN_NAME" mtu "$(( $DEFAULT_MTU - 4 ))"
 							ip link set dev "$FULL_VLAN_NAME" mtu 1496
 							ip link set dev "$FULL_VLAN_NAME" up
 						else
 							ip link add link "$D1Q_IFACE" name "$FULL_VLAN_NAME" type vlan id "$VLANNAME" #vlan in bond
+							ip link set dev "$FULL_VLAN_NAME" mtu "$DEFAULT_MTU"
 							ip link set dev "$FULL_VLAN_NAME" up
 						fi
 					fi
@@ -626,6 +648,7 @@ case "$CMD" in
 					if ! iface_isexists "$BRNAME"; then #do this bridge exists?
 						ip link add "$BRNAME" type bridge
 						echo "$BRIDGE_FORWARD_DELAY" > /sys/devices/virtual/net/"$BRNAME"/bridge/forward_delay
+						ip link set dev "$BRNAME" mtu "$DEFAULT_MTU"
 						ip link set dev "$BRNAME" up
 					fi
 
@@ -686,6 +709,7 @@ case "$CMD" in
 
 					ip link add name "$HNAME" type veth peer name ".c$GNAME" &&
 					lxc-attach -n "$CONTAINER" ifdown "$GNAME"
+					ip link set "$HNAME" mtu "$DEFAULT_MTU"
 					ip link set "$HNAME" up
 					ip link set ".c$GNAME" netns "$CONTAINER_PID"
 					lxc-attach -n "$CONTAINER" ip link set ".c$GNAME" name "$GNAME"