From a6db2374fe69704ec55de86d815b127432328f24 Mon Sep 17 00:00:00 2001 From: "Robin H. Johnson" Date: Fri, 20 Jul 2012 10:20:19 -0700 Subject: Bug #427152: Port of VLAN code to sysfs/iproue2 from vconfig lost the ability to create different vlans with the same ID but different interfaces on a single system. Implement it now. Signed-off-by: Robin H. Johnson --- doc/net.example.Linux.in | 22 +++++++++++++++------- net/vlan.sh | 31 +++++++++++++++++++++++-------- 2 files changed, 38 insertions(+), 15 deletions(-) diff --git a/doc/net.example.Linux.in b/doc/net.example.Linux.in index 870c794..31da4cb 100644 --- a/doc/net.example.Linux.in +++ b/doc/net.example.Linux.in @@ -552,26 +552,34 @@ # You can also configure the VLAN - see for ip man page for more details # To change the vlan interface name. If not set, the standard "iface.vlanid" # will be used. This is the replacement for the old 'vconfig set_name_type' -# functionality. +# functionality. If you previously relied on the DEV_PLUS_VID or +# DEV_PLUS_VID_NO_PAD options to have different VLANs with same ID value, on +# different interfaces, please note that you need to use both the interface and +# vlan number in the numbering. This applies for all of the options: name, +# txqueuelen, mac, broadcast, mtu, ingress, egress, flags #vlan1_name="vlan1" -#vlan2_name="eth0.2" +#eth0_vlan2_name="eth0.2" +#eth1_vlan2_name="eth1.2" # The following shows the old set_name_type setting and what new option to set: # Using eth9 & VLAN VID 26 as an example. # VLAN_PLUS_VID vlan26_name="vlan0026" # VLAN_PLUS_VID_NO_PAD vlan26_name="vlan26" -# DEV_PLUS_VID vlan26_name="eth9.0026" -# DEV_PLUS_VID_NO_PAD vlan26_name="eth9.26" +# DEV_PLUS_VID eth9_vlan26_name="eth9.0026" +# DEV_PLUS_VID_NO_PAD eth9_vlan26_name="eth9.26" # Set the vlan flags #vlan1_flags="reorder_hdr off gvrp on loose_binding on" +#eth0_vlan1_flags="reorder_hdr off gvrp on loose_binding on" # Configure in/egress maps #vlan1_ingress="2:6 3:5" -#vlan1_egress="1:2" +#eth0_vlan1_egress="1:2" -#config_vlan1="172.16.3.1/23" -#config_vlan2="172.16.2.1/23" +#config_vlan1="172.16.2.1/24" +#config_vlan2="172.16.3.1/24" +#config_eth0_1="172.16.4.1/24" +#config_eth1_1="172.16.5.1/24" # NOTE: Vlans can be configured with a . in their interface names # When configuring vlans with this name type, you need to replace . with a _ diff --git a/net/vlan.sh b/net/vlan.sh index ff63dfd..b29af80 100644 --- a/net/vlan.sh +++ b/net/vlan.sh @@ -66,26 +66,41 @@ vlan_post_start() einfo "Adding VLAN ${vlan} to ${IFACE}" # We need to gather all interface configuration options # 1) naming. Default to the standard "${IFACE}.${vlan}" but it can be anything - eval vname=\$vlan${vlan}_name + eval vname=\$${IFACE}_vlan${vlan}_name + [ -z "${vname}" ] && eval vname=\$vlan${vlan}_name [ -z "${vname}" ] && vname="${IFACE}.${vlan}" # 2) flags - eval vflags=\$vlan${vlan}_flags + eval vflags=\$${IFACE}_vlan${vlan}_flags + [ -z "${vname}" ] && eval vflags=\$vlan${vlan}_flags # 3) ingress/egress map - eval vingress=\$vlan${vlan}_ingress + eval vingress=\$${IFACE}_vlan${vlan}_ingress + [ -z "${vingress}" ] && eval vingress=\$vlan${vlan}_ingress [ -z "${vingress}" ] || vingress="ingress-qos-map ${vingress}" - eval vegress=\$vlan${vlan}_egress + eval vegress=\$${IFACE}_vlan${vlan}_egress + [ -z "${vegress}" ] && eval vegress=\$vlan${vlan}_egress [ -z "${vegress}" ] || vegress="egress-qos-map ${vegress}" + # txqueue local txqueuelen= - eval txqueuelen=\$txqueuelen_vlan${vlan} + eval txqueuelen=\$txqueuelen_${IFACE}_vlan${vlan} + [ -z "${txqueuelen}" ] && eval txqueuelen=\$txqueuelen_vlan${vlan} + # mac local mac= - eval mac=\$mac_vlan${vlan} + eval mac=\$mac_${IFACE}_vlan${vlan} + [ -z "${mac}" ] && eval mac=\$mac_vlan${vlan} + # broadcast local broadcast= - eval broadcast=\$broadcast_vlan${vlan} + eval broadcast=\$broadcast_${IFACE}_vlan${vlan} + [ -z "${broadcast}" ] && eval broadcast=\$broadcast_vlan${vlan} + # mtu local mtu= - eval mtu=\$mtu_vlan${vlan} + eval mtu=\$mtu_${IFACE}_vlan${vlan} + [ -z "${mtu}" ] && eval mtu=\$mtu_vlan${vlan} + + # combine it all local opts="${txqueuelen:+txqueuelen} ${txqueuelen} ${mac:+address} ${mac} ${broadcast:+broadcast} ${broadcast} ${mtu:+mtu} ${mtu}" + veinfo "ip link add link \"${IFACE}\" name \"${vname}\" ${opts} type vlan id \"${vlan}\" ${vflags} ${vingress} ${vegress}" e="$(ip link add link "${IFACE}" name "${vname}" ${opts} type vlan id "${vlan}" ${vflags} ${vingress} ${vegress} 2>&1 1>/dev/null)" if [ -n "${e}" ]; then eend 1 "${e}" -- cgit v1.2.3