1 |
commit: 683a21b0a0e52ad756366a9527f509761214e971 |
2 |
Author: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon Feb 21 09:41:48 2011 +0000 |
4 |
Commit: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Feb 21 09:41:48 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=683a21b0 |
7 |
|
8 |
net/vlan: update to use modern iproute2 interface |
9 |
|
10 |
This replaces the vlan setup code that previously used the old vconfig |
11 |
binary with a new implementation using the iproute2 interface. |
12 |
|
13 |
vconfig does not handle many of the newer setups. No automatic migration |
14 |
path is provided, as altering the configuration is non-trivial. |
15 |
|
16 |
Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org> |
17 |
Written-by: Guillaume Castagnino <casta <AT> xwing.info> |
18 |
X-Gentoo-Bug: 346365 |
19 |
|
20 |
--- |
21 |
doc/net.example.Linux.in | 21 +++++++++++----- |
22 |
net/vlan.sh | 58 +++++++++++++++++++++++---------------------- |
23 |
2 files changed, 44 insertions(+), 35 deletions(-) |
24 |
|
25 |
diff --git a/doc/net.example.Linux.in b/doc/net.example.Linux.in |
26 |
index 2d1a7dc..d3b97c5 100644 |
27 |
--- a/doc/net.example.Linux.in |
28 |
+++ b/doc/net.example.Linux.in |
29 |
@@ -527,7 +527,8 @@ |
30 |
|
31 |
#----------------------------------------------------------------------------- |
32 |
# VLAN (802.1q support) |
33 |
-# For VLAN support, emerge net-misc/vconfig |
34 |
+# For VLAN support, emerge sys-apps/iproute2 |
35 |
+# The old vconfig based VLAN support is no longer available. |
36 |
|
37 |
# Specify the VLAN numbers for the interface like so |
38 |
# Please ensure your VLAN IDs are NOT zero-padded |
39 |
@@ -537,10 +538,17 @@ |
40 |
# need it up. |
41 |
#config_eth0="null" |
42 |
|
43 |
-# You can also configure the VLAN - see for vconfig man page for more details |
44 |
-#vconfig_eth0="set_name_type VLAN_PLUS_VID_NO_PAD" |
45 |
-#vconfig_vlan1="set_flag 1 |
46 |
-#set_egress_map 2 6" |
47 |
+# You can also configure the VLAN - see for ip man page for more details |
48 |
+# To change the vlan interface name. If not set, the standard "iface.vlanid" |
49 |
+# will be used |
50 |
+#vlan1_name="vlan1" |
51 |
+#vlan2_name="eth0.2" |
52 |
+# Set the vlan flags |
53 |
+#vlan1_flags="reorder_hdr off gvrp on loose_binding on" |
54 |
+# Configure in/egress maps |
55 |
+#vlan1_ingress="2:6 3:5" |
56 |
+#vlan1_egress="1:2" |
57 |
+ |
58 |
#config_vlan1="172.16.3.1/23" |
59 |
#config_vlan2="172.16.2.1/23" |
60 |
|
61 |
@@ -553,8 +561,7 @@ |
62 |
# This means you do not need to create init scripts in /etc/init.d for each |
63 |
# vlan, you must need to create one for the physical interface. |
64 |
# If you wish to control the configuration of each vlan through a separate |
65 |
-# script, or wish to rename the vlan interface to something that vconfig |
66 |
-# cannot then you need to do this. |
67 |
+# script then you need to do this. |
68 |
#vlan_start_eth0="no" |
69 |
|
70 |
# If you do the above then you may want to depend on eth0 like so |
71 |
|
72 |
diff --git a/net/vlan.sh b/net/vlan.sh |
73 |
index 5cd4957..1d50d4f 100644 |
74 |
--- a/net/vlan.sh |
75 |
+++ b/net/vlan.sh |
76 |
@@ -1,9 +1,18 @@ |
77 |
# Copyright (c) 2007-2008 Roy Marples <roy@×××××××.name> |
78 |
# All rights reserved. Released under the 2-clause BSD license. |
79 |
|
80 |
+_ip() |
81 |
+{ |
82 |
+ if [ -x /bin/ip ]; then |
83 |
+ echo /bin/ip |
84 |
+ else |
85 |
+ echo /sbin/ip |
86 |
+ fi |
87 |
+} |
88 |
+ |
89 |
vlan_depend() |
90 |
{ |
91 |
- program /sbin/vconfig |
92 |
+ program $(_ip) |
93 |
after interface |
94 |
before dhcp |
95 |
} |
96 |
@@ -36,31 +45,12 @@ _check_vlan() |
97 |
|
98 |
vlan_pre_start() |
99 |
{ |
100 |
- local vc="$(_get_array "vconfig_${IFVAR}")" |
101 |
- [ -z "${vc}" ] && return 0 |
102 |
- |
103 |
- _check_vlan || return 1 |
104 |
- _exists || return 1 |
105 |
- |
106 |
- local v= x= e= |
107 |
- local IFS="$__IFS" |
108 |
- for v in ${vc}; do |
109 |
- unset IFS |
110 |
- case "${v}" in |
111 |
- set_name_type" "*) x=${v};; |
112 |
- *) |
113 |
- set -- ${v} |
114 |
- x="$1 ${IFACE}" |
115 |
- shift |
116 |
- x="${x} $@" |
117 |
- ;; |
118 |
- esac |
119 |
- |
120 |
- e="$(vconfig ${x} 2>&1 1>/dev/null)" |
121 |
- [ -z "${e}" ] && continue |
122 |
- eerror "${e}" |
123 |
+ local vconfig |
124 |
+ eval vconfig=\$vconfig_${IFVAR} |
125 |
+ if [ -n "${vconfig}" ]; then |
126 |
+ eerror "You must convert your vconfig_ VLAN entries to vlan${N} entries." |
127 |
return 1 |
128 |
- done |
129 |
+ fi |
130 |
} |
131 |
|
132 |
vlan_post_start() |
133 |
@@ -72,10 +62,22 @@ vlan_post_start() |
134 |
_check_vlan || return 1 |
135 |
_exists || return 1 |
136 |
|
137 |
- local vlan= e= s= |
138 |
+ local vlan= e= s= vname= vflags= vingress= vegress= |
139 |
for vlan in ${vlans}; do |
140 |
einfo "Adding VLAN ${vlan} to ${IFACE}" |
141 |
- e="$(vconfig add "${IFACE}" "${vlan}" 2>&1 1>/dev/null)" |
142 |
+ # We need to gather all interface configuration options |
143 |
+ # 1) naming. Default to the standard "${IFACE}.${vlan}" but it can be anything |
144 |
+ eval vname=\$vlan${vlan}_name |
145 |
+ [ -z "${vname}" ] && vname="${IFACE}.${vlan}" |
146 |
+ # 2) flags |
147 |
+ eval vflags=\$vlan${vlan}_flags |
148 |
+ # 3) ingress/egress map |
149 |
+ eval vingress=\$vlan${vlan}_ingress |
150 |
+ [ -z "${vingress}" ] || vingress="ingress-qos-map ${vingress}" |
151 |
+ eval vegress=\$vlan${vlan}_egress |
152 |
+ [ -z "${vegress}" ] || vegress="egress-qos-map ${vegress}" |
153 |
+ |
154 |
+ e="$(ip link add link "${IFACE}" name "${vname}" type vlan id "${vlan}" ${vflags} ${vingress} ${vegress} 2>&1 1>/dev/null)" |
155 |
if [ -n "${e}" ]; then |
156 |
eend 1 "${e}" |
157 |
continue |
158 |
@@ -110,7 +112,7 @@ vlan_post_stop() |
159 |
stop |
160 |
) && { |
161 |
mark_service_stopped "net.${vlan}" |
162 |
- vconfig rem "${vlan}" >/dev/null |
163 |
+ ip link delete "${vlan}" type vlan >/dev/null |
164 |
} |
165 |
done |