Search
j0ke.net Open Build Service
>
Projects
>
home:jg
:
playground
>
dracut
> 0301-add-VLAN-support.patch
Sign Up
|
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File 0301-add-VLAN-support.patch of Package dracut
From f52ee9073eb357f7468adbdb4bb494d057b7dd13 Mon Sep 17 00:00:00 2001 From: Harald Hoyer <harald@redhat.com> Date: Fri, 19 Oct 2012 12:11:06 +0200 Subject: [PATCH] add VLAN support --- dracut.8 | 5 +++++ modules.d/40network/ifup | 32 ++++++++++++++++++++++++++- modules.d/40network/install | 1 + modules.d/40network/installkernel | 2 ++ modules.d/40network/net-genrules.sh | 7 +++++- modules.d/40network/parse-ip-opts.sh | 5 +++++ modules.d/40network/parse-vlan.sh | 42 ++++++++++++++++++++++++++++++++++++ 7 files changed, 92 insertions(+), 2 deletions(-) create mode 100755 modules.d/40network/parse-vlan.sh diff --git a/dracut.8 b/dracut.8 index 1e0f036..03f0966 100644 --- a/dracut.8 +++ b/dracut.8 @@ -314,6 +314,11 @@ Required if multiple ip= lines are used. .BR nameserver= "<IP> [nameserver=<IP> ...]" specify nameserver(s) to use .TP +.BR vlan= "<vlanname>:<phydevice>" +Setup vlan device named <vlanname> on <phydeivce>. + We support the four styles of vlan names: VLAN_PLUS_VID (vlan0005), VLAN_PLUS_VID_NO_PAD (vlan5), +DEV_PLUS_VID (eth0.0005), DEV_PLUS_VID_NO_PAD (eth0.5) +.TP .BR biosdevname={0|1]} turn off/on biosdevname network interface renaming .SS NFS diff --git a/modules.d/40network/ifup b/modules.d/40network/ifup index 4c73da8..2722e0f 100755 --- a/modules.d/40network/ifup +++ b/modules.d/40network/ifup @@ -104,6 +104,18 @@ if [ -e /tmp/bridge.info ]; then 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 + + # bail immediately if the interface is already up # or we don't need the network [ -f "/tmp/net.$netif.up" ] && exit 0 @@ -131,6 +143,24 @@ if [ "$netif" = "$bridgename" ] && [ ! -e /tmp/net.$bridgename.up ]; then 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) @@ -148,7 +178,7 @@ for p in $(getargs ip=); do ip_to_var $p # skip ibft [ "$autoconf" = "ibft" ] && continue - + # If this option isn't directed at our interface, skip it [ -n "$dev" ] && [ "$dev" != "$netif" ] && continue diff --git a/modules.d/40network/install b/modules.d/40network/install index a816260..43de2d8 100755 --- a/modules.d/40network/install +++ b/modules.d/40network/install @@ -7,6 +7,7 @@ inst "$moddir/dhclient.conf" "/etc/dhclient.conf" 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 97 "$moddir/parse-bridge.sh" inst_hook cmdline 98 "$moddir/parse-ip-opts.sh" inst_hook cmdline 99 "$moddir/parse-ifname.sh" diff --git a/modules.d/40network/installkernel b/modules.d/40network/installkernel index 4c7adcd..de2f806 100755 --- a/modules.d/40network/installkernel +++ b/modules.d/40network/installkernel @@ -15,3 +15,5 @@ instmods ecb arc4 # bridge modules instmods bridge stp llc instmods ipv6 +# vlan +instmods 8021q diff --git a/modules.d/40network/net-genrules.sh b/modules.d/40network/net-genrules.sh index 71d3bd0..3d38152 100755 --- a/modules.d/40network/net-genrules.sh +++ b/modules.d/40network/net-genrules.sh @@ -21,7 +21,12 @@ fix_bootif() { # bridge: attempt only the defined interface if [ -e /tmp/bridge.info ]; then . /tmp/bridge.info - IFACES=$ethname + IFACES="$IFACES $ethname" + fi + + if [ -e /tmp/vlan.info ]; then + . /tmp/vlan.info + IFACES="$IFACES $phydevice" fi # BOOTIF says everything, use only that one diff --git a/modules.d/40network/parse-ip-opts.sh b/modules.d/40network/parse-ip-opts.sh index 4960c7e..9401450 100755 --- a/modules.d/40network/parse-ip-opts.sh +++ b/modules.d/40network/parse-ip-opts.sh @@ -86,6 +86,11 @@ if [ "ibft" = "$(getarg ip=)" ]; then hostname=$(read a < ${iface}/hostname; echo $a) echo "ip=$ip::$gw:$mask:$hostname:$dev:none" fi + + if [ -e ${iface}/vlan ]; then + vlan=$(read a < ${iface}/vlan; echo $a) + echo "vlan=$vlan:$dev" + fi done ) >> /etc/cmdline # reread cmdline diff --git a/modules.d/40network/parse-vlan.sh b/modules.d/40network/parse-vlan.sh new file mode 100755 index 0000000..3ba2289 --- /dev/null +++ b/modules.d/40network/parse-vlan.sh @@ -0,0 +1,42 @@ +#!/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 + : +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 -- 1.8.3.1