Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 346365 | Differences between
and this patch

Collapse All | Expand All

(-)a/doc/net.example.Linux.in (-7 / +13 lines)
Lines 527-533 Link Here
527
527
528
#-----------------------------------------------------------------------------
528
#-----------------------------------------------------------------------------
529
# VLAN (802.1q support)
529
# VLAN (802.1q support)
530
# For VLAN support, emerge net-misc/vconfig
530
# For VLAN support, emerge sys-apps/iproute2
531
531
532
# Specify the VLAN numbers for the interface like so
532
# Specify the VLAN numbers for the interface like so
533
# Please ensure your VLAN IDs are NOT zero-padded
533
# Please ensure your VLAN IDs are NOT zero-padded
Lines 537-546 Link Here
537
# need it up.
537
# need it up.
538
#config_eth0="null"
538
#config_eth0="null"
539
539
540
# You can also configure the VLAN - see for vconfig man page for more details
540
# You can also configure the VLAN - see for ip man page for more details
541
#vconfig_eth0="set_name_type VLAN_PLUS_VID_NO_PAD"
541
# To change the vlan interface name. If not set, the standard "iface.vlanid"
542
#vconfig_vlan1="set_flag 1
542
# will be used
543
#set_egress_map 2 6"
543
#vlan_1_name="vlan1"
544
#vlan_2_name="eth0.2"
545
# Set the vlan flags
546
#vlan_1_flags="reorder_hdr off gvrp on loose_binding on"
547
# Configure in/egress maps
548
#vlan_1_ingress="2:6 3:5"
549
#vlan_1_egress="1:2"
550
544
#config_vlan1="172.16.3.1/23"
551
#config_vlan1="172.16.3.1/23"
545
#config_vlan2="172.16.2.1/23"
552
#config_vlan2="172.16.2.1/23"
546
553
Lines 553-560 Link Here
553
# This means you do not need to create init scripts in /etc/init.d for each
560
# This means you do not need to create init scripts in /etc/init.d for each
554
# vlan, you must need to create one for the physical interface.
561
# vlan, you must need to create one for the physical interface.
555
# If you wish to control the configuration of each vlan through a separate
562
# If you wish to control the configuration of each vlan through a separate
556
# script, or wish to rename the vlan interface to something that vconfig
563
# script then you need to do this.
557
# cannot then you need to do this.
558
#vlan_start_eth0="no"
564
#vlan_start_eth0="no"
559
565
560
# If you do the above then you may want to depend on eth0 like so
566
# If you do the above then you may want to depend on eth0 like so
(-)a/net/vlan.sh (-33 / +25 lines)
Lines 1-9 Link Here
1
# Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
1
# Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
2
# All rights reserved. Released under the 2-clause BSD license.
2
# All rights reserved. Released under the 2-clause BSD license.
3
3
4
_ip()
5
{
6
	if [ -x /bin/ip ]; then
7
		echo /bin/ip
8
	else
9
		echo /sbin/ip
10
	fi
11
}
12
4
vlan_depend()
13
vlan_depend()
5
{
14
{
6
	program /sbin/vconfig
15
	program $(_ip)
7
	after interface
16
	after interface
8
	before dhcp
17
	before dhcp
9
}
18
}
Lines 34-68 _check_vlan() Link Here
34
	fi
43
	fi
35
}
44
}
36
45
37
vlan_pre_start()
38
{
39
	local vc="$(_get_array "vconfig_${IFVAR}")"
40
	[ -z "${vc}" ] && return 0
41
42
	_check_vlan || return 1
43
	_exists || return 1
44
45
	local v= x= e=
46
	local IFS="$__IFS"
47
	for v in ${vc}; do
48
		unset IFS
49
		case "${v}" in
50
			set_name_type" "*) x=${v};;
51
			*)
52
				set -- ${v}
53
				x="$1 ${IFACE}"
54
				shift
55
				x="${x} $@"
56
				;;
57
		esac
58
59
		e="$(vconfig ${x} 2>&1 1>/dev/null)"
60
		[ -z "${e}" ] && continue
61
		eerror "${e}"
62
		return 1
63
	done
64
}
65
66
vlan_post_start()
46
vlan_post_start()
67
{
47
{
68
	local vlans=
48
	local vlans=
Lines 72-81 vlan_post_start() Link Here
72
	_check_vlan || return 1
52
	_check_vlan || return 1
73
	_exists || return 1
53
	_exists || return 1
74
54
75
	local vlan= e= s=
55
	local vlan= e= s= vname= vflags= vingress= vegress=
76
	for vlan in ${vlans}; do
56
	for vlan in ${vlans}; do
77
		einfo "Adding VLAN ${vlan} to ${IFACE}"
57
		einfo "Adding VLAN ${vlan} to ${IFACE}"
78
		e="$(vconfig add "${IFACE}" "${vlan}" 2>&1 1>/dev/null)"
58
		# We need to gather all interface configuration options
59
		# 1) naming. Default to the standard "${IFACE}.${vlan}" but it can be anything
60
		eval vname=\$vlan_${vlan}_name
61
		[ -z "${vname}" ] && vname="${IFACE}.${vlan}"
62
		# 2) flags
63
		eval vflags=\$vlan_${vlan}_flags
64
		# 3) ingress/egress map
65
		eval vingress=\$vlan_${vlan}_ingress
66
		[ -z "${vingress}" ] || vingress="ingress-qos-map ${vingress}"
67
		eval vegress=\$vlan_${vlan}_egress
68
		[ -z "${vegress}" ] || vegress="egress-qos-map ${vegress}"
69
70
		e="$(ip link add link "${IFACE}" name "${vname}" type vlan id "${vlan}" ${vflags} ${vingress} ${vegress} 2>&1 1>/dev/null)"
79
		if [ -n "${e}" ]; then
71
		if [ -n "${e}" ]; then
80
			eend 1 "${e}"
72
			eend 1 "${e}"
81
			continue
73
			continue
Lines 110-116 vlan_post_stop() Link Here
110
			stop
102
			stop
111
		) && {
103
		) && {
112
			mark_service_stopped "net.${vlan}"
104
			mark_service_stopped "net.${vlan}"
113
			vconfig rem "${vlan}" >/dev/null
105
			ip link delete "${vlan}" type vlan >/dev/null
114
		}
106
		}
115
	done
107
	done
116
108

Return to bug 346365