All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 1/3] Add vlan support in network module
@ 2012-05-21  9:14 Cong Wang
       [not found] ` <1337591686-31875-1-git-send-email-amwang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 15+ messages in thread
From: Cong Wang @ 2012-05-21  9:14 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA; +Cc: Cong Wang, Dave Young, Harald Hoyer

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
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [RFC PATCH 2/3] Remove netroot check in cmdline parsing code
       [not found] ` <1337591686-31875-1-git-send-email-amwang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2012-05-21  9:14   ` Cong Wang
  2012-05-21  9:14   ` [RFC PATCH 3/3] Avoid generating udev rules for vlan interface Cong Wang
  2012-05-21  9:22   ` [RFC PATCH 1/3] Add vlan support in network module Harald Hoyer
  2 siblings, 0 replies; 15+ messages in thread
From: Cong Wang @ 2012-05-21  9:14 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA; +Cc: Cong Wang, Dave Young, Harald Hoyer

From: Cong Wang <xiyou.wangcong-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

Relax the rules for kdump, we don't specify netroot in kdump.

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/parse-bond.sh   |    3 ---
 modules.d/40network/parse-bridge.sh |    3 ---
 modules.d/40network/parse-vlan.sh   |    3 ---
 3 files changed, 0 insertions(+), 9 deletions(-)

diff --git a/modules.d/40network/parse-bond.sh b/modules.d/40network/parse-bond.sh
index 0a4c006..c7bbc63 100755
--- a/modules.d/40network/parse-bond.sh
+++ b/modules.d/40network/parse-bond.sh
@@ -15,9 +15,6 @@
 
 # Check if bond parameter is valid
 if getarg bond= >/dev/null ; then
-    if [ -z "$netroot" ] ; then
-        die "No netboot configured, bond is invalid"
-    fi
     command -v brctl >/dev/null 2>&1 || die "No 'brctl' installed"
 fi
 
diff --git a/modules.d/40network/parse-bridge.sh b/modules.d/40network/parse-bridge.sh
index aaa5a54..6e1fee1 100755
--- a/modules.d/40network/parse-bridge.sh
+++ b/modules.d/40network/parse-bridge.sh
@@ -13,9 +13,6 @@
 
 # Check if bridge parameter is valid
 if getarg bridge= >/dev/null ; then
-    if [ -z "$netroot" ] ; then
-        die "No netboot configured, bridge is invalid"
-    fi
     command -v brctl >/dev/null 2>&1 || die "No 'brctl' installed" 
 fi
 
diff --git a/modules.d/40network/parse-vlan.sh b/modules.d/40network/parse-vlan.sh
index efe7bfa..a99c858 100644
--- a/modules.d/40network/parse-vlan.sh
+++ b/modules.d/40network/parse-vlan.sh
@@ -9,9 +9,6 @@
 
 # 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
 
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [RFC PATCH 3/3] Avoid generating udev rules for vlan interface
       [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   ` Cong Wang
       [not found]     ` <1337591686-31875-3-git-send-email-amwang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  2012-05-21  9:22   ` [RFC PATCH 1/3] Add vlan support in network module Harald Hoyer
  2 siblings, 1 reply; 15+ messages in thread
From: Cong Wang @ 2012-05-21  9:14 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA; +Cc: Cong Wang, Dave Young, Harald Hoyer

From: Cong Wang <xiyou.wangcong-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

Vlan device has the same mac address with its physical device,
if we generate udev rules for vlan NIC too, its physical device
name will be override.

I used an ugly hack in ifname-genrules.sh, don't know if we have any
better ways to fix this?

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/ifname-genrules.sh |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/modules.d/40network/ifname-genrules.sh b/modules.d/40network/ifname-genrules.sh
index e188c88..b36f167 100755
--- a/modules.d/40network/ifname-genrules.sh
+++ b/modules.d/40network/ifname-genrules.sh
@@ -10,7 +10,11 @@ fi
 {
     for p in $(getargs ifname=); do
         parse_ifname_opts $p
-        printf 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="%s", ATTR{type}=="1", NAME="%s"\n' "$ifname_mac" "$ifname_if"
+        #Hack: vlan device has the same mac address with its physical device
+        [ -e /tmp/vlan.info ] && source /tmp/vlan.info
+        if [ "$ifname_if" != "$vlanname" ]; then
+            printf 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="%s", ATTR{type}=="1", NAME="%s"\n' "$ifname_mac" "$ifname_if"
+        fi
     done
 
     # Rename non named interfaces out of the way for named ones.
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [RFC PATCH 1/3] Add vlan support in network module
       [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
@ 2012-05-21  9:22   ` Harald Hoyer
       [not found]     ` <4FBA094B.5040303-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  2 siblings, 1 reply; 15+ messages in thread
From: Harald Hoyer @ 2012-05-21  9:22 UTC (permalink / raw)
  To: Cong Wang; +Cc: initramfs-u79uwXL29TY76Z2rM5mHXA, Cong Wang, Dave Young

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [RFC PATCH 3/3] Avoid generating udev rules for vlan interface
       [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>
  0 siblings, 1 reply; 15+ messages in thread
From: Harald Hoyer @ 2012-05-21  9:25 UTC (permalink / raw)
  To: Cong Wang; +Cc: initramfs-u79uwXL29TY76Z2rM5mHXA, Cong Wang, Dave Young

Am 21.05.2012 11:14, schrieb Cong Wang:
> From: Cong Wang <xiyou.wangcong-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> 
> Vlan device has the same mac address with its physical device,
> if we generate udev rules for vlan NIC too, its physical device
> name will be override.
> 
> I used an ugly hack in ifname-genrules.sh, don't know if we have any
> better ways to fix this?
> 
> 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/ifname-genrules.sh |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)
> 
> diff --git a/modules.d/40network/ifname-genrules.sh b/modules.d/40network/ifname-genrules.sh
> index e188c88..b36f167 100755
> --- a/modules.d/40network/ifname-genrules.sh
> +++ b/modules.d/40network/ifname-genrules.sh
> @@ -10,7 +10,11 @@ fi
>  {
>      for p in $(getargs ifname=); do
>          parse_ifname_opts $p
> -        printf 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="%s", ATTR{type}=="1", NAME="%s"\n' "$ifname_mac" "$ifname_if"
> +        #Hack: vlan device has the same mac address with its physical device
> +        [ -e /tmp/vlan.info ] && source /tmp/vlan.info
> +        if [ "$ifname_if" != "$vlanname" ]; then
> +            printf 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="%s", ATTR{type}=="1", NAME="%s"\n' "$ifname_mac" "$ifname_if"
> +        fi
>      done
>  
>      # Rename non named interfaces out of the way for named ones.

Maybe one of the /sys attributes indicate, that it is a vlan interface?

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [RFC PATCH 1/3] Add vlan support in network module
       [not found]     ` <4FBA094B.5040303-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2012-05-21  9:26       ` Cong Wang
  0 siblings, 0 replies; 15+ messages in thread
From: Cong Wang @ 2012-05-21  9:26 UTC (permalink / raw)
  To: Harald Hoyer; +Cc: Cong Wang, initramfs-u79uwXL29TY76Z2rM5mHXA, Dave Young

On 05/21/2012 05:22 PM, Harald Hoyer wrote:
> vconfig is deprecated. Please use iproute.
>
> -           /sbin/vconfig add ${PHYSDEV} ${VID}
> +           ip link add dev ${DEVICE} link ${PHYSDEV} type vlan id ${VID}
>

Fair enough, I will drop it. ;-)

BTW, I think ifenslave can be dropped too, as we can use the /proc 
interface to add slaves.

Thanks!

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [RFC PATCH 3/3] Avoid generating udev rules for vlan interface
       [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>
  0 siblings, 1 reply; 15+ messages in thread
From: Cong Wang @ 2012-05-21  9:31 UTC (permalink / raw)
  To: Harald Hoyer; +Cc: Cong Wang, initramfs-u79uwXL29TY76Z2rM5mHXA, Dave Young

On 05/21/2012 05:25 PM, Harald Hoyer wrote:
>> -        printf 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="%s", ATTR{type}=="1", NAME="%s"\n' "$ifname_mac" "$ifname_if"
>> +        #Hack: vlan device has the same mac address with its physical device
>> +        [ -e /tmp/vlan.info ]&&  source /tmp/vlan.info
>> +        if [ "$ifname_if" != "$vlanname" ]; then
>> +            printf 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="%s", ATTR{type}=="1", NAME="%s"\n' "$ifname_mac" "$ifname_if"
>> +        fi
>>       done
>>
>>       # Rename non named interfaces out of the way for named ones.
>
> Maybe one of the /sys attributes indicate, that it is a vlan interface?

Hmm... I tried DRIVERS!="8021q", then I got:

SUBSYSTEM=="net", ACTION=="add", DRIVERS!="8021q", ATTR{address}=="%s", 
ATTR{type}=="1" NAME="eth0"

SUBSYSTEM=="net", ACTION=="add", DRIVERS!="8021q", ATTR{address}=="%s", 
ATTR{type}=="1" NAME="eth0.2"

So, eth0 will be still renamed to eth0.2. :(

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [RFC PATCH 3/3] Avoid generating udev rules for vlan interface
       [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>
  0 siblings, 1 reply; 15+ messages in thread
From: Harald Hoyer @ 2012-05-21  9:44 UTC (permalink / raw)
  To: Cong Wang; +Cc: Cong Wang, initramfs-u79uwXL29TY76Z2rM5mHXA, Dave Young

Am 21.05.2012 11:31, schrieb Cong Wang:
> On 05/21/2012 05:25 PM, Harald Hoyer wrote:
>>> -        printf 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*",
>>> ATTR{address}=="%s", ATTR{type}=="1", NAME="%s"\n' "$ifname_mac" "$ifname_if"
>>> +        #Hack: vlan device has the same mac address with its physical device
>>> +        [ -e /tmp/vlan.info ]&&  source /tmp/vlan.info
>>> +        if [ "$ifname_if" != "$vlanname" ]; then
>>> +            printf 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*",
>>> ATTR{address}=="%s", ATTR{type}=="1", NAME="%s"\n' "$ifname_mac" "$ifname_if"
>>> +        fi
>>>       done
>>>
>>>       # Rename non named interfaces out of the way for named ones.
>>
>> Maybe one of the /sys attributes indicate, that it is a vlan interface?
> 
> Hmm... I tried DRIVERS!="8021q", then I got:
> 
> SUBSYSTEM=="net", ACTION=="add", DRIVERS!="8021q", ATTR{address}=="%s",
> ATTR{type}=="1" NAME="eth0"
> 
> SUBSYSTEM=="net", ACTION=="add", DRIVERS!="8021q", ATTR{address}=="%s",
> ATTR{type}=="1" NAME="eth0.2"
> 
> So, eth0 will be still renamed to eth0.2. :(


DEVPATH!="*/virtual/*" should help

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [RFC PATCH 3/3] Avoid generating udev rules for vlan interface
       [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>
  0 siblings, 1 reply; 15+ messages in thread
From: Cong Wang @ 2012-05-21 10:19 UTC (permalink / raw)
  To: Harald Hoyer; +Cc: Cong Wang, initramfs-u79uwXL29TY76Z2rM5mHXA, Dave Young

On 05/21/2012 05:44 PM, Harald Hoyer wrote:
> Am 21.05.2012 11:31, schrieb Cong Wang:
>> On 05/21/2012 05:25 PM, Harald Hoyer wrote:
>>>> -        printf 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*",
>>>> ATTR{address}=="%s", ATTR{type}=="1", NAME="%s"\n' "$ifname_mac" "$ifname_if"
>>>> +        #Hack: vlan device has the same mac address with its physical device
>>>> +        [ -e /tmp/vlan.info ]&&   source /tmp/vlan.info
>>>> +        if [ "$ifname_if" != "$vlanname" ]; then
>>>> +            printf 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*",
>>>> ATTR{address}=="%s", ATTR{type}=="1", NAME="%s"\n' "$ifname_mac" "$ifname_if"
>>>> +        fi
>>>>        done
>>>>
>>>>        # Rename non named interfaces out of the way for named ones.
>>>
>>> Maybe one of the /sys attributes indicate, that it is a vlan interface?
>>
>> Hmm... I tried DRIVERS!="8021q", then I got:
>>
>> SUBSYSTEM=="net", ACTION=="add", DRIVERS!="8021q", ATTR{address}=="%s",
>> ATTR{type}=="1" NAME="eth0"
>>
>> SUBSYSTEM=="net", ACTION=="add", DRIVERS!="8021q", ATTR{address}=="%s",
>> ATTR{type}=="1" NAME="eth0.2"
>>
>> So, eth0 will be still renamed to eth0.2. :(
>
>
> DEVPATH!="*/virtual/*" should help

The problem is not in udev rules themselves, the problem is we generate 
two same lines for eth0 and eth0.2, even with DEVPATH!="*/virtual/*" we 
will have:

SUBSYSTEM=="net", ACTION=="add", DEVPATH!="*/virtual/*", 
ATTR{address}=="%s", ATTR{type}=="1" NAME="eth0"

SUBSYSTEM=="net", ACTION=="add", DEVPATH!="*/virtual/*", 
ATTR{address}=="%s", ATTR{type}=="1" NAME="eth0.2"

eth0 will be still override. Thus, we should only generate one line for 
eth0, and let ip/vconfig to name the eth0.2 upon eth0.

The reason why we have two lines is that I passed two ifname= cmdline, 
one for eth0 and the other for eth0.2, this is required by ip=, all 
interfaces in ip= should be passed in ifname= too.


Thanks!

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [RFC PATCH 3/3] Avoid generating udev rules for vlan interface
       [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>
  0 siblings, 1 reply; 15+ messages in thread
From: Harald Hoyer @ 2012-05-21 11:27 UTC (permalink / raw)
  To: Cong Wang; +Cc: Cong Wang, initramfs-u79uwXL29TY76Z2rM5mHXA, Dave Young

Am 21.05.2012 12:19, schrieb Cong Wang:
> On 05/21/2012 05:44 PM, Harald Hoyer wrote:
>> Am 21.05.2012 11:31, schrieb Cong Wang:
>>> On 05/21/2012 05:25 PM, Harald Hoyer wrote:
>>>>> -        printf 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*",
>>>>> ATTR{address}=="%s", ATTR{type}=="1", NAME="%s"\n' "$ifname_mac" "$ifname_if"
>>>>> +        #Hack: vlan device has the same mac address with its physical device
>>>>> +        [ -e /tmp/vlan.info ]&&   source /tmp/vlan.info
>>>>> +        if [ "$ifname_if" != "$vlanname" ]; then
>>>>> +            printf 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*",
>>>>> ATTR{address}=="%s", ATTR{type}=="1", NAME="%s"\n' "$ifname_mac" "$ifname_if"
>>>>> +        fi
>>>>>        done
>>>>>
>>>>>        # Rename non named interfaces out of the way for named ones.
>>>>
>>>> Maybe one of the /sys attributes indicate, that it is a vlan interface?
>>>
>>> Hmm... I tried DRIVERS!="8021q", then I got:
>>>
>>> SUBSYSTEM=="net", ACTION=="add", DRIVERS!="8021q", ATTR{address}=="%s",
>>> ATTR{type}=="1" NAME="eth0"
>>>
>>> SUBSYSTEM=="net", ACTION=="add", DRIVERS!="8021q", ATTR{address}=="%s",
>>> ATTR{type}=="1" NAME="eth0.2"
>>>
>>> So, eth0 will be still renamed to eth0.2. :(
>>
>>
>> DEVPATH!="*/virtual/*" should help
> 
> The problem is not in udev rules themselves, the problem is we generate two same
> lines for eth0 and eth0.2, even with DEVPATH!="*/virtual/*" we will have:
> 
> SUBSYSTEM=="net", ACTION=="add", DEVPATH!="*/virtual/*", ATTR{address}=="%s",
> ATTR{type}=="1" NAME="eth0"
> 
> SUBSYSTEM=="net", ACTION=="add", DEVPATH!="*/virtual/*", ATTR{address}=="%s",
> ATTR{type}=="1" NAME="eth0.2"
> 
> eth0 will be still override. Thus, we should only generate one line for eth0,
> and let ip/vconfig to name the eth0.2 upon eth0.
> 
> The reason why we have two lines is that I passed two ifname= cmdline, one for
> eth0 and the other for eth0.2, this is required by ip=, all interfaces in ip=
> should be passed in ifname= too.
> 
> 
> Thanks!

it would skip eth0.2, because its DEVPATH contains "virtual" and the rule is
never matched

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [RFC PATCH 3/3] Avoid generating udev rules for vlan interface
       [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>
  0 siblings, 1 reply; 15+ messages in thread
From: Cong Wang @ 2012-05-22  1:43 UTC (permalink / raw)
  To: Harald Hoyer; +Cc: Cong Wang, initramfs-u79uwXL29TY76Z2rM5mHXA, Dave Young

On 05/21/2012 07:27 PM, Harald Hoyer wrote:!
>
> it would skip eth0.2, because its DEVPATH contains "virtual" and the rule is
> never matched

When eth0.2 comes up, yes.

When eth0 comes up, no, both lines will be applied to eth0 and the final 
result is that eth0 will be renamed to eth0.2.

And eth0 comes up before eth0.2, so...

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [RFC PATCH 3/3] Avoid generating udev rules for vlan interface
       [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>
  0 siblings, 1 reply; 15+ messages in thread
From: Harald Hoyer @ 2012-05-22  9:32 UTC (permalink / raw)
  To: Cong Wang; +Cc: Cong Wang, initramfs-u79uwXL29TY76Z2rM5mHXA, Dave Young

Am 22.05.2012 03:43, schrieb Cong Wang:
> On 05/21/2012 07:27 PM, Harald Hoyer wrote:!
>>
>> it would skip eth0.2, because its DEVPATH contains "virtual" and the rule is
>> never matched
> 
> When eth0.2 comes up, yes.
> 
> When eth0 comes up, no, both lines will be applied to eth0 and the final result
> is that eth0 will be renamed to eth0.2.
> 
> And eth0 comes up before eth0.2, so...

well, but you wouldn't specify "ifname=" on the kernel command line for eth0.2,
would you?

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [RFC PATCH 3/3] Avoid generating udev rules for vlan interface
       [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>
  0 siblings, 1 reply; 15+ messages in thread
From: Cong Wang @ 2012-05-22 13:43 UTC (permalink / raw)
  To: Harald Hoyer; +Cc: Cong Wang, initramfs-u79uwXL29TY76Z2rM5mHXA, Dave Young

On 05/22/2012 05:32 PM, Harald Hoyer wrote:
> Am 22.05.2012 03:43, schrieb Cong Wang:
>> On 05/21/2012 07:27 PM, Harald Hoyer wrote:!
>>>
>>> it would skip eth0.2, because its DEVPATH contains "virtual" and the rule is
>>> never matched
>>
>> When eth0.2 comes up, yes.
>>
>> When eth0 comes up, no, both lines will be applied to eth0 and the final result
>> is that eth0 will be renamed to eth0.2.
>>
>> And eth0 comes up before eth0.2, so...
>
> well, but you wouldn't specify "ifname=" on the kernel command line for eth0.2,
> would you?

We use ip=eth0.2:dhcp to get IP for eth0.2 via DHCP, so 
ifname=eth0.2:XXX is requried by ip=, no?

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [RFC PATCH 3/3] Avoid generating udev rules for vlan interface
       [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>
  0 siblings, 1 reply; 15+ messages in thread
From: Harald Hoyer @ 2012-05-23  9:45 UTC (permalink / raw)
  To: Cong Wang; +Cc: Cong Wang, initramfs-u79uwXL29TY76Z2rM5mHXA, Dave Young

Am 22.05.2012 15:43, schrieb Cong Wang:
> On 05/22/2012 05:32 PM, Harald Hoyer wrote:
>> Am 22.05.2012 03:43, schrieb Cong Wang:
>>> On 05/21/2012 07:27 PM, Harald Hoyer wrote:!
>>>>
>>>> it would skip eth0.2, because its DEVPATH contains "virtual" and the rule is
>>>> never matched
>>>
>>> When eth0.2 comes up, yes.
>>>
>>> When eth0 comes up, no, both lines will be applied to eth0 and the final result
>>> is that eth0 will be renamed to eth0.2.
>>>
>>> And eth0 comes up before eth0.2, so...
>>
>> well, but you wouldn't specify "ifname=" on the kernel command line for eth0.2,
>> would you?
> 
> We use ip=eth0.2:dhcp to get IP for eth0.2 via DHCP, so ifname=eth0.2:XXX is
> requried by ip=, no?

no, you would need ifname=eth0:XXX

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [RFC PATCH 3/3] Avoid generating udev rules for vlan interface
       [not found]                                         ` <4FBCB1AC.907-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2012-05-24  4:50                                           ` Cong Wang
  0 siblings, 0 replies; 15+ messages in thread
From: Cong Wang @ 2012-05-24  4:50 UTC (permalink / raw)
  To: Harald Hoyer; +Cc: Cong Wang, initramfs-u79uwXL29TY76Z2rM5mHXA, Dave Young

On Wed, May 23, 2012 at 5:45 PM, Harald Hoyer <harald-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote:
> Am 22.05.2012 15:43, schrieb Cong Wang:
>>
>> We use ip=eth0.2:dhcp to get IP for eth0.2 via DHCP, so ifname=eth0.2:XXX is
>> requried by ip=, no?
>
> no, you would need ifname=eth0:XXX
>

Yeah, only specifying ifname=eth0:XXX seems also work.

Actually I am confused by the doc of ifname=, which said:

    Note: If you use this option you _must_ specify an ifname= argument for all
    interfaces used in ip= or fcoe= arguments.

I think it is out-of-date? In my case, "ip=eth0.2:dhcp ifname=eth0:XXX", eth0.2
appears in ip= but does not have to be in ifname=, as you suggested.

What's more, how about bridge and bonding cases? Do we have to specify
the slave device in ifname= instead of the master device??

Thanks!

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2012-05-24  4:50 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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   ` [RFC PATCH 1/3] Add vlan support in network module Harald Hoyer
     [not found]     ` <4FBA094B.5040303-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-05-21  9:26       ` Cong Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.