From ff69fd0f08a9e0d9c28a3345076dd947e1de6bf2 Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Fri, 31 Jan 2003 21:28:49 +0000 Subject: 802.1Q VLAN support (, #82593) --- rc.d/init.d/network | 15 +++++++++- sysconfig.txt | 17 ++++++++++++ sysconfig/network-scripts/ifdown | 10 +++++++ sysconfig/network-scripts/ifup | 59 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 100 insertions(+), 1 deletion(-) diff --git a/rc.d/init.d/network b/rc.d/init.d/network index e7fd388f..fc8237b8 100755 --- a/rc.d/init.d/network +++ b/rc.d/init.d/network @@ -33,6 +33,9 @@ fi # Even if IPX is configured, without the utilities we can't do much [ ! -x /sbin/ipx_internal_net -o ! -x /sbin/ipx_configure ] && IPX= +# Even if VLAN is configured, without the utility we can't do much +[ ! -x /sbin/vconfig ] && VLAN= + # If IPv6 is explicitly configured, make sure it's available. if [ "$NETWORKING_IPV6" = "yes" ]; then alias=`modprobe -c | awk '/^alias net-pf-10 / { print $3 }'` @@ -50,7 +53,7 @@ cd /etc/sysconfig/network-scripts # ignore aliases, alternative configurations, and editor backup files interfaces=`ls ifcfg* | LANG=C egrep -v '(ifcfg-lo|:|rpmsave|rpmorig|rpmnew)' | \ LANG=C egrep -v '(~|\.bak)$' | \ - LANG=C egrep 'ifcfg-[A-Za-z0-9_-]+$' | \ + LANG=C egrep 'ifcfg-[A-Za-z0-9\._-]+$' | \ sed 's/^ifcfg-//g'` # See how we were called. @@ -78,6 +81,16 @@ case "$1" in ;; esac + case "$VLAN" in + yes|true) + if [ -d /proc/net/vlan ] || modprobe 8021q >/dev/null 2>&1 ; then + action $"Setting 802.1Q VLAN parameters: " /sbin/vconfig set_name_type DEV_PLUS_VID_NO_PAD + else + echo $"No 802.1Q VLAN support available in kernel." + fi + ;; + esac + oldhotplug=`sysctl kernel.hotplug 2>/dev/null | \ awk '{ print $3 }' 2>/dev/null` sysctl -w kernel.hotplug="/bin/true" > /dev/null 2>&1 diff --git a/sysconfig.txt b/sysconfig.txt index 879de70e..1df63156 100644 --- a/sysconfig.txt +++ b/sysconfig.txt @@ -168,6 +168,7 @@ Files in /etc/sysconfig GATEWAY= GATEWAYDEV= (e.g. eth0) NISDOMAIN= + VLAN=yes|no IPX=yes|no IPXAUTOPRIMARY=on|off (note, that MUST be on|off, not yes|no) IPXAUTOFRAME=on|off (again, not yes|no) @@ -622,6 +623,22 @@ Files in /etc/sysconfig/network-scripts/ To properly set these, use the packet socket interface. + Ethernet 802.1q VLAN items: + DEVICE=eth0.42 + Initscripts use DEV_PLUS_VID_NO_PAD naming mode for VLAN + devices. + Example: eth0.42 for vlan 42 on device eth0. + Valid VLAN ID range is 0-4095. Most ethernet switches reserve + VLAN ID 1 to be used as management VLAN; starting from VLAN + ID 2 is recommended. + REORDER_HDR=yes|no + When enabled the VLAN device will move the ethernet header + around to make it look exactly like a real ethernet device. + This may help programs such as ISC dhcpd which read the raw + ethernet packet and make assumptions about the location of + bytes. If you don't need it turn it off because there + is a small performance penalty. Default is on. + PPP/SLIP items: PERSIST=yes|no MODEMPORT= diff --git a/sysconfig/network-scripts/ifdown b/sysconfig/network-scripts/ifdown index 992fd5ae..29fb9674 100755 --- a/sysconfig/network-scripts/ifdown +++ b/sysconfig/network-scripts/ifdown @@ -122,4 +122,14 @@ if [ "$retcode" = 0 ] ; then # the interface went down. fi +if [ -n "$VLAN" -a -x /sbin/vconfig ]; then + # 802.1q VLAN + if echo ${DEVICE} | LANG=C egrep -v '(:)' | LANG=C egrep -q 'eth[0-9][0-9]*\.[0-9][0-9]?[0-9]?[0-9]?' ; then + [ -f /proc/net/vlan/${DEVICE} ] && { + /sbin/vconfig rem ${DEVICE} + retcode=$? + } + fi +fi + exit $retcode diff --git a/sysconfig/network-scripts/ifup b/sysconfig/network-scripts/ifup index 4f870d16..b54abe43 100755 --- a/sysconfig/network-scripts/ifup +++ b/sysconfig/network-scripts/ifup @@ -62,6 +62,65 @@ else ISALIAS=no fi +if [ -x /sbin/vconfig -a "${VLAN}" = "yes" ]; then + # 802.1q VLAN + if echo ${DEVICE} | LANG=C egrep -v '(:)' | LANG=C egrep -q 'eth[0-9][0-9]*\.[0-9][0-9]?[0-9]?[0-9]?' ; then + [ -d /proc/net/vlan ] || modprobe 8021q >/dev/null 2>&1 || { + echo $"No 802.1Q VLAN support available in kernel." + echo $"Error initializing device ${DEVICE}" + logger -p daemon.info -t ifup \ + $"No 802.1Q VLAN support available in kernel for device ${DEVICE}" + exit 1 + } + + VID="`echo ${DEVICE} | \ + LANG=C egrep 'eth[0-9]+\.[0-9][0-9]?[0-9]?[0-9]?$' | \ + LANG=C sed 's/^[a-z0-9]*\.//g;s/^0*//'`" + PHYSDEV="`echo ${DEVICE} | \ + LANG=C egrep 'eth[0-9]+\.[0-9][0-9]?[0-9]?[0-9]?$' | \ + LANG=C sed 's/\.[a-z0-9]*$//g'`" + + is_available ${PHYSDEV} || { + if [ "$?" = "1" ] ; then + echo $"$alias device ${DEVICE} does not seem to be present, delaying initialization." + exit 1 + else + exit 0 + fi + } + + # Link on Physical device needs to be up but no ip required + ip addr add 0.0.0.0/32 dev ${PHYSDEV} + ip -o link set dev ${PHYSDEV} up + + if [ ! -f /proc/net/vlan/${DEVICE} ]; then + /sbin/vconfig add ${PHYSDEV} ${VID} || { + (logger -p daemon.info -t ifup \ + $"ERROR: could not add vlan ${VID} as ${DEVICE} on dev ${PHYSDEV}" &)& + echo $"ERROR: could not add vlan ${VID} as ${DEVICE} on dev ${PHYSDEV}" + exit 1 + } + fi + + if [ -f /proc/net/vlan/${DEVICE} ]; then + case "$REORDER_HDR" in + yes|1) + /sbin/vconfig set_flag ${DEVICE} 1 1 || { + (logger -p daemon.info -t ifup \ + "WARNING: vconfig not able to enable REORDER_HDR on ${DEVICE}" &)& + } + ;; + no|0) + /sbin/vconfig set_flag ${DEVICE} 1 0 || { + (logger -p daemon.info -t ifup \ + $"WARNING: vconfig not able to disable REORDER_HDR on ${DEVICE}" &)& + } + ;; + esac + fi + fi +fi + # Old BOOTP variable if [ "${BOOTP}" = "yes" ]; then BOOTPROTO=bootp -- cgit v1.2.1