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 <robbat2@gentoo.org>
This commit is contained in:
Robin H. Johnson 2012-07-20 10:20:19 -07:00
parent 2e3715bb69
commit a6db2374fe
2 changed files with 38 additions and 15 deletions

View File

@ -552,26 +552,34 @@
# You can also configure the VLAN - see for ip man page for more details # 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" # 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' # 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" #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: # The following shows the old set_name_type setting and what new option to set:
# Using eth9 & VLAN VID 26 as an example. # Using eth9 & VLAN VID 26 as an example.
# VLAN_PLUS_VID vlan26_name="vlan0026" # VLAN_PLUS_VID vlan26_name="vlan0026"
# VLAN_PLUS_VID_NO_PAD vlan26_name="vlan26" # VLAN_PLUS_VID_NO_PAD vlan26_name="vlan26"
# DEV_PLUS_VID vlan26_name="eth9.0026" # DEV_PLUS_VID eth9_vlan26_name="eth9.0026"
# DEV_PLUS_VID_NO_PAD vlan26_name="eth9.26" # DEV_PLUS_VID_NO_PAD eth9_vlan26_name="eth9.26"
# Set the vlan flags # Set the vlan flags
#vlan1_flags="reorder_hdr off gvrp on loose_binding on" #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 # Configure in/egress maps
#vlan1_ingress="2:6 3:5" #vlan1_ingress="2:6 3:5"
#vlan1_egress="1:2" #eth0_vlan1_egress="1:2"
#config_vlan1="172.16.3.1/23" #config_vlan1="172.16.2.1/24"
#config_vlan2="172.16.2.1/23" #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 # NOTE: Vlans can be configured with a . in their interface names
# When configuring vlans with this name type, you need to replace . with a _ # When configuring vlans with this name type, you need to replace . with a _

View File

@ -66,26 +66,41 @@ vlan_post_start()
einfo "Adding VLAN ${vlan} to ${IFACE}" einfo "Adding VLAN ${vlan} to ${IFACE}"
# We need to gather all interface configuration options # We need to gather all interface configuration options
# 1) naming. Default to the standard "${IFACE}.${vlan}" but it can be anything # 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}" [ -z "${vname}" ] && vname="${IFACE}.${vlan}"
# 2) flags # 2) flags
eval vflags=\$vlan${vlan}_flags eval vflags=\$${IFACE}_vlan${vlan}_flags
[ -z "${vname}" ] && eval vflags=\$vlan${vlan}_flags
# 3) ingress/egress map # 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}" [ -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}" [ -z "${vegress}" ] || vegress="egress-qos-map ${vegress}"
# txqueue
local txqueuelen= local txqueuelen=
eval txqueuelen=\$txqueuelen_vlan${vlan} eval txqueuelen=\$txqueuelen_${IFACE}_vlan${vlan}
[ -z "${txqueuelen}" ] && eval txqueuelen=\$txqueuelen_vlan${vlan}
# mac
local mac= local mac=
eval mac=\$mac_vlan${vlan} eval mac=\$mac_${IFACE}_vlan${vlan}
[ -z "${mac}" ] && eval mac=\$mac_vlan${vlan}
# broadcast
local broadcast= local broadcast=
eval broadcast=\$broadcast_vlan${vlan} eval broadcast=\$broadcast_${IFACE}_vlan${vlan}
[ -z "${broadcast}" ] && eval broadcast=\$broadcast_vlan${vlan}
# mtu
local 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}" 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)" 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 if [ -n "${e}" ]; then
eend 1 "${e}" eend 1 "${e}"