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

Collapse All | Expand All

(-)/lib/rcscripts.conf.d/env_whitelist (-2 / +5 lines)
Lines 8-17 Link Here
8
# NB: Do not modify below this line if you do not know what you are doing!!
8
# NB: Do not modify below this line if you do not know what you are doing!!
9
#
9
#
10
10
11
# Hotplug ?
11
# Hotplug
12
IN_BACKGROUND
13
IN_HOTPLUG
12
IN_HOTPLUG
14
13
14
# RC network script support
15
IN_BACKGROUND
16
RC_INTERFACE_KEEP_CONFIG
17
15
# Default shell stuff
18
# Default shell stuff
16
SHELL
19
SHELL
17
USER
20
USER
(-)/lib/rcscripts/net.modules.d/arping (+5 lines)
Lines 87-92 Link Here
87
			eoutdent
87
			eoutdent
88
			veinfo "Configuring ${iface} for ${x}"
88
			veinfo "Configuring ${iface} for ${x}"
89
			configure_variables "${iface}" "${conf}"
89
			configure_variables "${iface}" "${conf}"
90
91
			# Call the system module as we've aleady passed it by ....
92
			# And it *has* to be pre_start for other things to work correctly
93
			system_pre_start "${iface}"
94
			
90
			eval config=( \"\$\{config_${ifvar}\[@\]\}\" )
95
			eval config=( \"\$\{config_${ifvar}\[@\]\}\" )
91
			eval fallback_config=( \"\$\{fallback_config_${ifvar}\[@\]\}\" )
96
			eval fallback_config=( \"\$\{fallback_config_${ifvar}\[@\]\}\" )
92
			eval fallback_route=( \"\$\{fallback_route_${ifvar}\[@\]\}\" )
97
			eval fallback_route=( \"\$\{fallback_route_${ifvar}\[@\]\}\" )
(-)/lib/rcscripts/net.modules.d/system (-2 / +3 lines)
Lines 6-12 Link Here
6
#
6
#
7
# Sets up the dependancies for the module
7
# Sets up the dependancies for the module
8
system_depend() {
8
system_depend() {
9
	after interface dhcp
9
	after interface
10
	before dhcp
10
	variables dns_servers dns_domain dns_options dns_search dns_sortlist \
11
	variables dns_servers dns_domain dns_options dns_search dns_sortlist \
11
		ntp_servers nis_domain nis_servers
12
		ntp_servers nis_domain nis_servers
12
}
13
}
Lines 122-128 Link Here
122
#
123
#
123
# Configures the host system for dns, ntp and nis information
124
# Configures the host system for dns, ntp and nis information
124
# Always returns 0
125
# Always returns 0
125
system_post_start() {
126
system_pre_start() {
126
	local iface="$1"
127
	local iface="$1"
127
128
128
	system_dns "${iface}"
129
	system_dns "${iface}"
(-)/lib/rcscripts/net.modules.d/ifconfig (+18 lines)
Lines 394-399 Link Here
394
	return ${r}
394
	return ${r}
395
}
395
}
396
396
397
# void ifconfig_route_metric(char* interface, int metric)
398
#
399
# Change all routes for an interface to a given metric
400
ifconfig_route_metric() {
401
	local dest gateway mask flags metric ref use
402
	route -n | grep " $1$" | {
403
		while read dest gateway mask flags metric ref use ; do
404
			if [[ ${gateway} != "0.0.0.0" ]]; then
405
				gateway="gw ${gateway}"
406
			else
407
				unset gateway
408
			fi
409
			route del ${dest}
410
			route add -net ${dest} netmask ${mask} ${gateway} metric "$2" dev "$1"
411
		done
412
	}
413
}
414
397
# void ifconfig_default_route(char* interface, char* gateway_ip, int metric)
415
# void ifconfig_default_route(char* interface, char* gateway_ip, int metric)
398
#
416
#
399
# Force default route to the specified gateway
417
# Force default route to the specified gateway
(-)/lib/rcscripts/net.modules.d/helpers.d/pppd-wrapper (+42 lines)
Line 0 Link Here
1
#!/bin/bash
2
# Copyright (c) 2005 Gentoo Foundation
3
# Distributed under the terms of the GNU General Public License v2
4
5
# Contributed by Roy Marples (uberlord@gentoo.org)
6
7
action="$1"
8
interface="$2"
9
export IN_BACKGROUND="true"
10
. /lib/rcscripts/net.modules.d/helpers.d/module-loader
11
resolv="${statedir}/${interface}/resolv.conf"
12
13
if [[ ${action} == "up" ]]; then
14
	if [[ -n ${DNS1} || -n ${DNS2} ]]; then
15
	    echo "# Generated by pppd for interface $1" > "${resolv}"
16
	    chmod 0644 "${resolv}"
17
	    [ -n ${DNS1} ] && echo "nameserver ${DNS1}" >> "${resolv}"
18
	    [ -n ${DNS2} ] && echo "nameserver ${DNS2}" >> "${resolv}"
19
	fi
20
	
21
	# Calculate the metric for our routes
22
	ifvar=$( bash_variable "${interface}" )
23
	eval metric=\"\$\{metric_${ifvar}\}\"
24
	if [[ -z ${metric} ]]; then
25
		if [[ ${RC_AUTO_INTERFACE} == "yes" ]]; then
26
			metric=$( calculate_metric "${interface}" )
27
		else
28
			metric="0"
29
		fi
30
		eval metric_${ifvar}="${metric}"
31
	fi
32
33
	[[ ${metric} != "0" ]] && interface_route_metric "${interface}" "${metric}"
34
35
	export RC_INTERFACE_KEEP_CONFIG="yes"
36
	/etc/init.d/net."${interface}" start
37
else
38
	rm -f "${resolv}"
39
	/etc/init.d/net."${interface}" stop
40
fi
41
42
# vim:ts=4
0
  + *
43
  + *
(-)/lib/rcscripts/net.modules.d/helpers.d/functions (-13 / +11 lines)
Lines 96-116 Link Here
96
# (ie a state dir exists)
96
# (ie a state dir exists)
97
# require_gateway defaults to false
97
# require_gateway defaults to false
98
order_interfaces() {
98
order_interfaces() {
99
	local ifaces
99
	local ifaces extra
100
	
100
101
	if [[ ${1:-false} == "true" ]]; then
101
	${1:-false} && extra=' && $2=="00000000"'
102
		ifaces=$(awk '$2!="Gateway" { print $7, $1 }' /proc/net/route \
102
	ifaces=$(awk '{if (NR>1 && $1!="lo"'"${extra}"') print $7, $1}' /proc/net/route \
103
		| sort -n | cut -d' ' -f2 | uniq)
103
		| sort -n | cut -d' ' -f2 | uniq)
104
	else
105
		ifaces=$(awk '$2=="00000000" { print $7, $1 }' /proc/net/route \
106
		| sort -n | cut -d' ' -f2 )
107
	fi
108
104
109
	# Append lo if it's up
105
	# Append lo if it's up
110
	if grep -q "^lo[ \t]*" /proc/net/route ; then
106
	if ! ${1:-false} ; then
111
		ifaces="${ifaces} lo"
107
		if grep -q "^lo[ \t]*" /proc/net/route ; then
108
			ifaces="${ifaces} lo"
109
		fi
112
	fi
110
	fi
113
	
111
114
	local i order
112
	local i order
115
	for i in ${ifaces}; do
113
	for i in ${ifaces}; do
116
		[[ -d "${statedir}/${i}" ]] && order="${order}${i} "
114
		[[ -d "${statedir}/${i}" ]] && order="${order}${i} "
Lines 132-138 Link Here
132
		[[ ! -e "${statedir}/${ifaces[i]}/resolv.conf" ]] && unset ifaces[i]
131
		[[ ! -e "${statedir}/${ifaces[i]}/resolv.conf" ]] && unset ifaces[i]
133
	done
132
	done
134
	ifaces=( "${ifaces[@]}" )
133
	ifaces=( "${ifaces[@]}" )
135
	
134
136
	# No point merging unless there are two or more interfaces
135
	# No point merging unless there are two or more interfaces
137
	[[ ${#ifaces[@]} -lt 2 ]] && return
136
	[[ ${#ifaces[@]} -lt 2 ]] && return
138
137
Lines 151-157 Link Here
151
		opts[i]=$( sed -n -e 's/^[ \t]*options[ \t]*\([^#]*\).*/\1#/p;' "${f}" | xargs )
150
		opts[i]=$( sed -n -e 's/^[ \t]*options[ \t]*\([^#]*\).*/\1#/p;' "${f}" | xargs )
152
		sortlist[i]=$( sed -n -e 's/^[ \t]*sortlist[ \t]*\([^#]*\).*/\1/p' "${f}" )
151
		sortlist[i]=$( sed -n -e 's/^[ \t]*sortlist[ \t]*\([^#]*\).*/\1/p' "${f}" )
153
		
152
		
154
		if [[ -z ${srvs[i]} && -z ${opts[i]} && -z ${sortlist[i]} ]]; then
153
		if [[ -z ${srvs[i]} && -z ${opts[i]} && -z ${sortlist[i]} && -z ${search[i]} ]]; then
155
			unset srvs[i]
154
			unset srvs[i]
156
			unset search[i]
155
			unset search[i]
157
			unset opts[i]
156
			unset opts[i]
(-)/lib/rcscripts/net.modules.d/pppd (-2 / +9 lines)
Lines 101-106 Link Here
101
#
101
#
102
# Returns 0 (true) when successful, otherwise 1
102
# Returns 0 (true) when successful, otherwise 1
103
pppd_start() {
103
pppd_start() {
104
    ${IN_BACKGROUND} && return 0
105
    
104
    local iface="$1" ifvar=$( bash_variable "$1" ) opts="" link
106
    local iface="$1" ifvar=$( bash_variable "$1" ) opts="" link
105
    if [[ ${iface%%[0-9]*} != "ppp" ]]; then
107
    if [[ ${iface%%[0-9]*} != "ppp" ]]; then
106
        eerror "PPP can only be invoked from net.ppp[0-9]"
108
        eerror "PPP can only be invoked from net.ppp[0-9]"
Lines 142-149 Link Here
142
    # Load any commandline options
144
    # Load any commandline options
143
    eval opts=\"\$\{pppd_${ifvar}\[@\]}\"
145
    eval opts=\"\$\{pppd_${ifvar}\[@\]}\"
144
146
145
    # We don't work if unit, no detach or linkname is set.
147
    # We don't work with these options set by the user
146
    for i in unit nodetach linkname ; do
148
    for i in unit nodetach linkname maxfail persist ; do
147
        if [[ " ${opts} " == *" ${i} "* ]]; then
149
        if [[ " ${opts} " == *" ${i} "* ]]; then
148
            eerror "The option \"${i}\" is not allowed"
150
            eerror "The option \"${i}\" is not allowed"
149
            return 1
151
            return 1
Lines 228-239 Link Here
228
    [[ ${insert_link_in_opts} -eq 0 ]] || opts="${link} ${opts}"
230
    [[ ${insert_link_in_opts} -eq 0 ]] || opts="${link} ${opts}"
229
    
231
    
230
    ebegin "Running pppd"
232
    ebegin "Running pppd"
233
    [[ " ${opts} " != *" updetatch "* ]] && mark_service_inactive "net.${iface}"
231
    i=$( eval /usr/sbin/pppd ${opts} 2>&1 )
234
    i=$( eval /usr/sbin/pppd ${opts} 2>&1 )
232
    eend $? "${i}" || return 1
235
    eend $? "${i}" || return 1
233
236
234
    if [[ " ${opts} " == *" updetach "* ]]; then
237
    if [[ " ${opts} " == *" updetach "* ]]; then
235
        local addr=$( interface_get_address "${iface}" )
238
        local addr=$( interface_get_address "${iface}" )
236
        einfo "${iface} received address ${addr}"
239
        einfo "${iface} received address ${addr}"
240
    else
241
	einfo "Backgrounding ..."
242
	exit 0
237
    fi
243
    fi
238
}
244
}
239
245
Lines 244-249 Link Here
244
# Returns 0 (true) if no process to kill or it terminates successfully,
250
# Returns 0 (true) if no process to kill or it terminates successfully,
245
# otherwise non-zero (false)
251
# otherwise non-zero (false)
246
pppd_stop() {
252
pppd_stop() {
253
    ${IN_BACKGROUND} && return 0
247
    local iface="$1" pidfile="/var/run/ppp-$1.pid"
254
    local iface="$1" pidfile="/var/run/ppp-$1.pid"
248
255
249
    [[ ! -s ${pidfile} ]] && return 0 
256
    [[ ! -s ${pidfile} ]] && return 0 
(-)/lib/rcscripts/net.modules.d/iproute2 (-3 / +16 lines)
Lines 309-317 Link Here
309
309
310
		# Support net-tools routing too
310
		# Support net-tools routing too
311
		x="${x//gw/via}"
311
		x="${x//gw/via}"
312
		x="${x//-A inet6}"
312
		x="${x//-A inet6/}"
313
		x="${x//-net}"
313
		x="${x//-net/}"
314
		[[ " ${x} " == *" -host "* ]] && x="${x//-host} scope host"
314
		[[ " ${x} " == *" -host "* ]] && x="${x//-host/} scope host"
315
315
316
		# Attempt to support net-tools route netmask option
316
		# Attempt to support net-tools route netmask option
317
		netmask="${x##* netmask }"
317
		netmask="${x##* netmask }"
Lines 334-339 Link Here
334
	return 0
334
	return 0
335
}
335
}
336
336
337
# void iproute2_route_metric(char* interface, int metric)
338
#
339
# Change all routes for an interface to a given metric
340
iproute2_route_metric() {
341
	local route
342
	ip route | grep " dev $1" | {
343
		while read route ; do
344
			ip route del ${route}
345
			ip route add ${route} metric "$2"
346
		done
347
	}
348
}
349
337
# void iproute2_default_route(char* interface, char* gateway_ip, int metric)
350
# void iproute2_default_route(char* interface, char* gateway_ip, int metric)
338
#
351
#
339
# Force default route to the specified gateway, optionally on
352
# Force default route to the specified gateway, optionally on

Return to bug 112049