This patch adds basic vlan support in network module.
The cmdline syntax for vlan is:
vlan=<vlanname>:<phydevice>
for an example:
vlan=eth0.2:eth0
or
vlan=vlan2:eth0
See also patch 2/8.
Cc: Harald Hoyer <harald@redhat.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
fi
fi
+if [ -e /tmp/vlan.info ]; then
+ . /tmp/vlan.info
+ if [ "$netif" = "$phydevice" ]; then
+ if [ "$netif" = "$bondname" ] && [ -n "$DO_BOND_SETUP" ] ; then
+ : # We need to really setup bond (recursive call)
+ else
+ netif="$vlanname"
+ fi
+ fi
+fi
+
# disable manual ifup while netroot is set for simplifying our logic
# in netroot case we prefer netroot to bringup $netif automaticlly
[ -n "$2" -a "$2" = "-m" ] && [ -z "$netroot" ] && manualup="$2"
brctl addif $bridgename $ethname
fi
+get_vid() {
+ case "$1" in
+ vlan*)
+ return ${1#vlan}
+ ;;
+ *.*)
+ return ${1##*.}
+ ;;
+ esac
+}
+
+if [ "$netif" = "$vlanname" ] && [ ! -e /tmp/net.$vlanname.up ]; then
+ modprobe 8021q
+ ip link set "$phydevice" up
+ wait_for_if_up "$phydevice"
+ ip link add dev "$vlanname" link "$phydevice" type vlan id "$(get_vid $vlanname; echo $?)"
+fi
+
# No ip lines default to dhcp
ip=$(getarg ip)
instmods ipv6
# bonding
instmods bonding
+ # vlan
+ instmods 8021q
}
install() {
inst_hook pre-udev 50 "$moddir/ifname-genrules.sh"
inst_hook pre-udev 60 "$moddir/net-genrules.sh"
inst_hook cmdline 91 "$moddir/dhcp-root.sh"
+ inst_hook cmdline 95 "$moddir/parse-vlan.sh"
inst_hook cmdline 96 "$moddir/parse-bond.sh"
inst_hook cmdline 97 "$moddir/parse-bridge.sh"
inst_hook cmdline 98 "$moddir/parse-ip-opts.sh"
IFACES=${bondslaves%% *}
fi
+ if [ -e /tmp/vlan.info ]; then
+ . /tmp/vlan.info
+ IFACES=$phydevice
+ fi
+
ifup='/sbin/ifup $env{INTERFACE}'
[ -z "$netroot" ] && ifup="$ifup -m"
--- /dev/null
+#!/bin/sh
+#
+# Format:
+# vlan=<vlanname>:<phydevice>
+#
+
+# return if vlan already parsed
+[ -n "$vlanname" ] && return
+
+# Check if vlan parameter is valid
+if getarg vlan= >/dev/null ; then
+ if [ -z "$netroot" ] ; then
+ die "No netboot configured, vlan is invalid"
+ fi
+ :
+fi
+
+parsevlan() {
+ local v=${1}:
+ set --
+ while [ -n "$v" ]; do
+ set -- "$@" "${v%%:*}"
+ v=${v#*:}
+ done
+
+ unset vlanname phydevice
+ case $# in
+ 2) vlanname=$1; phydevice=$2 ;;
+ *) die "vlan= requires two parameters" ;;
+ esac
+}
+
+unset vlanname phydevice
+
+if getarg vlan >/dev/null; then
+ # Read vlan= parameters if they exist
+ vlan="$(getarg vlan=)"
+ if [ ! "$vlan" = "vlan" ]; then
+ parsevlan "$(getarg vlan=)"
+ fi
+
+ echo "vlanname=\"$vlanname\"" > /tmp/vlan.info
+ echo "phydevice=\"$phydevice\"" >> /tmp/vlan.info
+ return
+fi