Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 450326
Collapse All | Expand All

(-)a/doc/net.example.Linux.in (+35 lines)
Lines 473-478 Link Here
473
# use any of them.
473
# use any of them.
474
474
475
#-----------------------------------------------------------------------------
475
#-----------------------------------------------------------------------------
476
# DHCPv6
477
# DHCPv6 can be provided by dhclient
478
#
479
# dhclient: emerge net-misc/dhcp
480
#
481
# If you have more than one DHCP client installed, you should probably
482
# explicitly use 'dhclient' to use dhclient for both DHCP and DHCPv6,
483
# otherwise the default DHCP client will be used.  dhcpcd has some stateless
484
# IPv6 autoconfiguration support which may clash with DHCPv6.
485
#modules="dhclient" # to select dhclient over dhcpcd
486
487
# Regardless of which DHCP client you prefer, you configure them the
488
# same way using one of following depending on which interface modules
489
# you're using.
490
#config_eth0="dhcpv6"
491
492
# You can also use both DHCP and DHCPv6 on a dual-stack network:
493
#config_eth0="dhcp
494
#dhcpv6"
495
496
# To pass runtime arguments to dhclient for DHCPv6, you do it similarly to
497
# setting runtime arguments for DHCP.  Note that you can set options for
498
# DHCPv6 separately or in addition the dhclient arguments for DHCP.
499
#dhclientv6_eth0="..." # options for DHCPv6 only
500
#dhclient_eth0='..."   # options for DHCP (also for DHCPv6 when no
501
#                      # dhclientv6_eth0 is defined)
502
503
# GENERIC DHCPv6 OPTIONS
504
# Set generic DHCPv6 options just as with generic DHCP options.
505
#dhcpv6_eth0="release nodns nontp nonis nogateway nosendhost"
506
507
# If no generic DHCPv6 options are set, the default is to fall back to the
508
# DHCP generic options.
509
510
#-----------------------------------------------------------------------------
476
# For APIPA support, emerge net-misc/iputils or net-analyzer/arping
511
# For APIPA support, emerge net-misc/iputils or net-analyzer/arping
477
512
478
# APIPA is a module that tries to find a free address in the range
513
# APIPA is a module that tries to find a free address in the range
(-)a/init.d/net.lo.in (+5 lines)
Lines 214-219 _show_address() Link Here
214
	einfo "received address $(_get_inet_address "${IFACE}")"
214
	einfo "received address $(_get_inet_address "${IFACE}")"
215
}
215
}
216
216
217
_show_address6()
218
{
219
	einfo "received address $(_get_inet6_address "${IFACE}")"
220
}
221
217
# Basically sorts our modules into order and saves the list
222
# Basically sorts our modules into order and saves the list
218
_gen_module_list()
223
_gen_module_list()
219
{
224
{
(-)a/net/Makefile (-1 / +1 lines)
Lines 13-19 SRCS-Linux= iwconfig.sh.in Link Here
13
INC-Linux=	adsl.sh apipa.sh arping.sh bonding.sh br2684ctl.sh bridge.sh \
13
INC-Linux=	adsl.sh apipa.sh arping.sh bonding.sh br2684ctl.sh bridge.sh \
14
		ccwgroup.sh clip.sh ethtool.sh iproute2.sh ifplugd.sh ip6to4.sh \
14
		ccwgroup.sh clip.sh ethtool.sh iproute2.sh ifplugd.sh ip6to4.sh \
15
		ipppd.sh iwconfig.sh netplugd.sh pppd.sh pump.sh tuntap.sh udhcpc.sh \
15
		ipppd.sh iwconfig.sh netplugd.sh pppd.sh pump.sh tuntap.sh udhcpc.sh \
16
		vlan.sh macvlan.sh ip6rd.sh firewalld.sh
16
		vlan.sh macvlan.sh ip6rd.sh firewalld.sh dhclientv6.sh
17
17
18
SRCS-NetBSD=
18
SRCS-NetBSD=
19
INC-NetBSD=	ifwatchd.sh
19
INC-NetBSD=	ifwatchd.sh
(-)a/net/dhclientv6.sh (+82 lines)
Line 0 Link Here
1
# Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
2
# Released under the 2-clause BSD license.
3
4
dhclientv6_depend()
5
{
6
	after interface
7
	program start /sbin/dhclient
8
	provide dhcpv6
9
}
10
11
_config_vars="$_config_vars dhcp dhclient dhcpv6 dhclientv6"
12
13
dhclientv6_start()
14
{
15
	local args= opt= opts= pidfile="/var/run/dhclientv6-${IFACE}.pid"
16
	local sendhost=true dconf=
17
18
	# Get our options
19
	# These options only work in Gentoo, and maybe RedHat
20
	eval args=\$dhclientv6_${IFVAR}
21
	[ -z "${args}" ] && eval args=\$dhclient_${IFVAR}
22
	eval opts=\$dhcpv6_${IFVAR}
23
	[ -z "${opts}" ] && opts=${dhcpv6}
24
	[ -z "${opts}" ] && eval opts=\$dhcp_${IFVAR}
25
	[ -z "${opts}" ] && opts=${dhcp}
26
27
	for opt in ${opts}; do
28
		case "${opt}" in
29
			nodns) args="${args} -e PEER_DNS=no";;
30
			nontp) args="${args} -e PEER_NTP=no";;
31
			nogateway) args="${args} -e PEER_ROUTERS=no";;
32
			nosendhost) sendhost=false;;
33
		esac
34
	done
35
36
	# Add our route metric
37
	[ "${metric:-0}" != "0" ] && args="${args} -e IF_METRIC=${metric}"
38
39
	if ${sendhost}; then
40
		local hname="$(hostname)"
41
		if [ "${hname}" != "(none)" -a "${hname}" != "localhost" ]; then
42
			dhconf="${dhconf} interface \"${IFACE}\" {"
43
			dhconf="${dhconf} send fqdn.fqdn \"${hname}\";"
44
			dhconf="${dhconf} send fqdn.encoded on;"
45
			dhconf="${dhconf} send fqdn.server-update on;"
46
			dhconf="${dhconf} send fqdn.no-client-update on;"
47
			dhconf="${dhconf}}"
48
		fi
49
	fi
50
51
	# Bring up DHCP for this interface
52
	ebegin "Running dhclient -6"
53
	echo "${dhconf}" | start-stop-daemon --start --exec /sbin/dhclient \
54
		--pidfile "${pidfile}" \
55
		-- -6 ${args} -q -1 -pf "${pidfile}" "${IFACE}"
56
	eend $? || return 1
57
58
	_show_address6
59
	return 0
60
}
61
62
dhclientv6_stop()
63
{
64
	local pidfile="/var/run/dhclientv6-${IFACE}.pid" opts=
65
	[ ! -f "${pidfile}" ] && return 0
66
67
	# Get our options
68
	if [ -x /sbin/dhclient ]; then
69
		eval opts=\$dhcp_${IFVAR}
70
		[ -z "${opts}" ] && opts=${dhcp}
71
	fi
72
73
	ebegin "Stopping dhclient -6 on ${IFACE}"
74
	case " ${opts} " in
75
		*" release "*) dhclient -6 -q -r -pf "${pidfile}" "${IFACE}";;
76
		*)
77
			start-stop-daemon --stop --quiet \
78
				--exec /sbin/dhclient --pidfile "${pidfile}"
79
			;;
80
	esac
81
	eend $?
82
}
(-)a/net/ifconfig.sh.Linux.in (-3 / +23 lines)
Lines 86-106 _get_inet_address() Link Here
86
	echo "/$(_netmask2cidr "$1")"
86
	echo "/$(_netmask2cidr "$1")"
87
}
87
}
88
88
89
_get_inet_addresses()
89
_get_inet6_address()
90
{
91
	set -- $(LC_ALL=C ifconfig "${IFACE}" |
92
	sed -n -e 's/.*\(inet6 addr:\|inet6\) \([^ /]*\)\(\/\| *prefixlen \)\([^ ]*\).*/\2\/\4/p')
93
	[ -z "$1" ] && return 1
94
95
	echo -n "$1"
96
}
97
98
_get_addresses_fn()
90
{
99
{
100
	local fn="$1"
91
	local iface=${IFACE} i=0
101
	local iface=${IFACE} i=0
92
	local addrs="$(_get_inet_address)"
102
	local addrs="$($fn)"
93
103
94
	while true; do
104
	while true; do
95
		local IFACE="${iface}:${i}"
105
		local IFACE="${iface}:${i}"
96
		_exists || break
106
		_exists || break
97
		local addr="$(_get_inet_address)"
107
		local addr="$($fn)"
98
		[ -n "${addr}" ] && addrs="${addrs}${addrs:+ }${addr}"
108
		[ -n "${addr}" ] && addrs="${addrs}${addrs:+ }${addr}"
99
		: $(( i += 1 ))
109
		: $(( i += 1 ))
100
	done
110
	done
101
	echo "${addrs}"
111
	echo "${addrs}"
102
}
112
}
103
113
114
_get_inet_addresses()
115
{
116
	_get_addresses_fn _get_inet_address
117
}
118
119
_get_inet6_addresses()
120
{
121
	_get_addresses_fn _get_inet6_address
122
}
123
104
_cidr2netmask()
124
_cidr2netmask()
105
{
125
{
106
	local cidr="$1" netmask="" done=0 i=0 sum=0 cur=128
126
	local cidr="$1" netmask="" done=0 i=0 sum=0 cur=128
(-)a/net/iproute2.sh (-3 / +17 lines)
Lines 84-91 _set_mac_address() Link Here
84
84
85
_get_inet_addresses()
85
_get_inet_addresses()
86
{
86
{
87
	LC_ALL=C ip -family inet addr show "${IFACE}" | \
87
	local family="$1";
88
	sed -n -e 's/.*inet \([^ ]*\).*/\1/p'
88
	if [ -z "$family" ]; then
89
		family="inet"
90
	fi
91
	LC_ALL=C ip -family $family addr show "${IFACE}" | \
92
	sed -n -e 's/.*inet6\? \([^ ]*\).*/\1/p'
93
}
94
95
_get_inet6_addresses() {
96
	_get_inet_addresses "inet6"
89
}
97
}
90
98
91
_get_inet_address()
99
_get_inet_address()
Lines 95-100 _get_inet_address() Link Here
95
	echo "$1"
103
	echo "$1"
96
}
104
}
97
105
106
_get_inet6_address()
107
{
108
	set -- $(_get_inet6_addresses)
109
	[ $# = "0" ] && return 1
110
	echo "$1"
111
}
112
98
_add_address()
113
_add_address()
99
{
114
{
100
	if [ "$1" = "127.0.0.1/8" -a "${IFACE}" = "lo" ]; then
115
	if [ "$1" = "127.0.0.1/8" -a "${IFACE}" = "lo" ]; then
101
- 

Return to bug 450326