mkinitrd unification across distributions
 help / color / mirror / Atom feed
From: Harald Hoyer <harald-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: Cong Wang <amwang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Cong Wang
	<xiyou.wangcong-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Dave Young <dyoung-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Subject: Re: [RFC PATCH 1/3] Add vlan support in network module
Date: Mon, 21 May 2012 11:22:19 +0200	[thread overview]
Message-ID: <4FBA094B.5040303@redhat.com> (raw)
In-Reply-To: <1337591686-31875-1-git-send-email-amwang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

vconfig is deprecated. Please use iproute.

-           /sbin/vconfig add ${PHYSDEV} ${VID}
+           ip link add dev ${DEVICE} link ${PHYSDEV} type vlan id ${VID}

Am 21.05.2012 11:14, schrieb Cong Wang:
> From: Cong Wang <xiyou.wangcong-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> 
> 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=eth0.2
> 
> This is just the basic syntax, vlan has other styles of
> naming, like "vlan2". We need to extend the syntax in the future,
> this patch is just a starter. ;-)
> 
> TODO: Add doc for vlan= cmdline
> 
> Any comments?
> 
> Cc: Dave Young <dyoung-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> Cc: Harald Hoyer <harald-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> Signed-off-by: Cong Wang <xiyou.wangcong-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> 
> ---
>  modules.d/40network/ifup.sh         |   18 +++++++++++++
>  modules.d/40network/module-setup.sh |    5 +++-
>  modules.d/40network/net-genrules.sh |    5 ++++
>  modules.d/40network/parse-vlan.sh   |   46 +++++++++++++++++++++++++++++++++++
>  4 files changed, 73 insertions(+), 1 deletions(-)
>  create mode 100644 modules.d/40network/parse-vlan.sh
> 
> diff --git a/modules.d/40network/ifup.sh b/modules.d/40network/ifup.sh
> index 71b869d..aab0dfc 100755
> --- a/modules.d/40network/ifup.sh
> +++ b/modules.d/40network/ifup.sh
> @@ -40,6 +40,17 @@ 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
> +
>  # 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"
> @@ -178,6 +189,13 @@ if [ "$netif" = "$bridgename" ] && [ ! -e /tmp/net.$bridgename.up ]; then
>      brctl addif $bridgename $ethname
>  fi
>  
> +if [ "$netif" = "$vlanname" ] && [ ! -e /tmp/net.$vlanname.up ]; then
> +    modprobe 8021q
> +    ip link set "$phydevice" up
> +    wait_for_if_up "$phydevice"
> +    vconfig add "$phydevice" "${vlanname##*.}"
> +fi
> +
>  # No ip lines default to dhcp
>  ip=$(getarg ip)
>  
> diff --git a/modules.d/40network/module-setup.sh b/modules.d/40network/module-setup.sh
> index d49b594..07cdc7f 100755
> --- a/modules.d/40network/module-setup.sh
> +++ b/modules.d/40network/module-setup.sh
> @@ -68,12 +68,14 @@ installkernel() {
>      instmods ipv6
>      # bonding
>      instmods bonding
> +    # vlan
> +    instmods 8021q
>  }
>  
>  install() {
>      local _arch _i _dir
>      dracut_install ip arping tr dhclient
> -    dracut_install -o brctl ifenslave
> +    dracut_install -o brctl ifenslave vconfig
>      inst "$moddir/ifup.sh" "/sbin/ifup"
>      inst "$moddir/netroot.sh" "/sbin/netroot"
>      inst "$moddir/dhclient-script.sh" "/sbin/dhclient-script"
> @@ -82,6 +84,7 @@ 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"
> diff --git a/modules.d/40network/net-genrules.sh b/modules.d/40network/net-genrules.sh
> index 7176681..142634e 100755
> --- a/modules.d/40network/net-genrules.sh
> +++ b/modules.d/40network/net-genrules.sh
> @@ -31,6 +31,11 @@ fix_bootif() {
>          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"
>  
> diff --git a/modules.d/40network/parse-vlan.sh b/modules.d/40network/parse-vlan.sh
> new file mode 100644
> index 0000000..efe7bfa
> --- /dev/null
> +++ b/modules.d/40network/parse-vlan.sh
> @@ -0,0 +1,46 @@
> +#!/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
> +    command -v vconfig >/dev/null 2>&1 || die "No 'vconfig' installed"
> +fi
> +
> +parsevlan() {
> +    local v=${1}:
> +    set --
> +    while [ -n "$v" ]; do
> +        set -- "$@" "${v%%:*}"
> +        v=${v#*:}
> +    done
> +
> +    unset vlanname phydevice
> +    case $# in
> +    1)  vlanname=$1; phydevice="${1%.*}" ;;
> +    2)  vlanname=$1; phydevice=$2 ;;
> +    *)  die "vlan= requires one or 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

  parent reply	other threads:[~2012-05-21  9:22 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-21  9:14 [RFC PATCH 1/3] Add vlan support in network module Cong Wang
     [not found] ` <1337591686-31875-1-git-send-email-amwang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-05-21  9:14   ` [RFC PATCH 2/3] Remove netroot check in cmdline parsing code Cong Wang
2012-05-21  9:14   ` [RFC PATCH 3/3] Avoid generating udev rules for vlan interface Cong Wang
     [not found]     ` <1337591686-31875-3-git-send-email-amwang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-05-21  9:25       ` Harald Hoyer
     [not found]         ` <4FBA09F7.4030003-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-05-21  9:31           ` Cong Wang
     [not found]             ` <4FBA0B8D.1070708-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-05-21  9:44               ` Harald Hoyer
     [not found]                 ` <4FBA0E7E.1070004-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-05-21 10:19                   ` Cong Wang
     [not found]                     ` <4FBA1698.3090006-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-05-21 11:27                       ` Harald Hoyer
     [not found]                         ` <4FBA26A1.6010109-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-05-22  1:43                           ` Cong Wang
     [not found]                             ` <4FBAEF49.60108-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-05-22  9:32                               ` Harald Hoyer
     [not found]                                 ` <4FBB5D3D.2080101-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-05-22 13:43                                   ` Cong Wang
     [not found]                                     ` <4FBB97E7.6060804-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-05-23  9:45                                       ` Harald Hoyer
     [not found]                                         ` <4FBCB1AC.907-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-05-24  4:50                                           ` Cong Wang
2012-05-21  9:22   ` Harald Hoyer [this message]
     [not found]     ` <4FBA094B.5040303-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-05-21  9:26       ` [RFC PATCH 1/3] Add vlan support in network module Cong Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4FBA094B.5040303@redhat.com \
    --to=harald-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
    --cc=amwang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=dyoung-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=xiyou.wangcong-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox