summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Heim <phreak@gentoo.org>2006-01-19 17:13:13 +0000
committerChristian Heim <phreak@gentoo.org>2006-01-19 17:13:13 +0000
commit2fc04a041525a0215e9eb3ca54e4617c1be7b4f7 (patch)
tree2d0c6f0239789614db2400bdd742d6aa96c1c201 /net-scripts
parentMerging r1828 (diff)
downloadbaselayout-vserver-2fc04a041525a0215e9eb3ca54e4617c1be7b4f7.tar.gz
baselayout-vserver-2fc04a041525a0215e9eb3ca54e4617c1be7b4f7.tar.bz2
baselayout-vserver-2fc04a041525a0215e9eb3ca54e4617c1be7b4f7.zip
Merging r1832
svn path=/baselayout-vserver/trunk/; revision=212
Diffstat (limited to 'net-scripts')
-rwxr-xr-xnet-scripts/init.d/net.lo29
-rw-r--r--net-scripts/net.modules.d/ifconfig8
-rw-r--r--net-scripts/net.modules.d/iproute29
3 files changed, 33 insertions, 13 deletions
diff --git a/net-scripts/init.d/net.lo b/net-scripts/init.d/net.lo
index b9c2352..43bfd46 100755
--- a/net-scripts/init.d/net.lo
+++ b/net-scripts/init.d/net.lo
@@ -16,7 +16,7 @@ depend() {
# Load any custom depend functions for the given interface
# For example, br0 may need eth0 and eth1
- local iface="${myservice##*.}"
+ local iface="${myservice#*.}"
[[ $(type -t "depend_${iface}") == "function" ]] && depend_${iface}
return 0
@@ -25,10 +25,7 @@ depend() {
# Define where our modules are
MODULES_DIR="${svclib}/net.modules.d"
-# Some defaults
-background="${background:-no}"
-
-# Load some functions shared between ourselves and our dhcp helpers
+# Load some functions shared between ourselves and our DHCP helpers
source "${MODULES_DIR}/helpers.d/functions"
# Make some wrappers to fudge after/before/need/use depend flags.
@@ -571,12 +568,11 @@ iface_start() {
# Otherwise a default of NULL
if [[ -z ${config} ]]; then
# if [[ ${RC_AUTO_INTERFACE} == "yes" ]]; then
+ ewarn "Configuration not set for ${iface} - assuming DHCP"
if is_function "dhcp_start" ; then
config=( "dhcp" )
- ewarn "Configuration not set for ${iface} - assuming dhcp"
else
- eerror "Cannot default to dhcp as there is no dhcp module loaded"
- eerror "No configuration for ${iface}"
+ eerror "No DHCP client installed"
return 1
fi
# else
@@ -621,7 +617,11 @@ iface_start() {
[[ ${x} == "0" ]] && interface_add_address "${iface}" ${conf[@]}; x="$?"
eend "${x}" && config_worked=true && continue
else
- eerror "No loaded modules provide \"${conf[0]}\" (${conf[0]}_start)"
+ if [[ ${conf[0]} == "dhcp" ]] ; then
+ eerror "No DHCP client installed"
+ else
+ eerror "No loaded modules provide \"${conf[0]}\" (${conf[0]}_start)"
+ fi
fi
if [[ -n ${fallback[config_counter]} ]]; then
@@ -855,11 +855,8 @@ run() {
local -a MODULES mods
local IN_BACKGROUND="${IN_BACKGROUND}"
- # No point in backgrounding if we're already there ...
- # This is also required so we can select the "best" interface
if [[ ${IN_BACKGROUND} == "true" || ${IN_BACKGROUND} == "1" ]]; then
IN_BACKGROUND=true
- background=false
else
IN_BACKGROUND=false
fi
@@ -885,6 +882,14 @@ run() {
run_stop "${iface}" && r=0
remove_state "${iface}"
else
+ # Only hotplug on ethernet interfaces
+ if [[ ${IN_HOTPLUG} == 1 ]] ; then
+ if ! interface_is_ethernet "${iface}" ; then
+ eerror "We only hotplug for ethernet interfaces"
+ return 1
+ fi
+ fi
+
run_start "${iface}" && r=0
fi
fi
diff --git a/net-scripts/net.modules.d/ifconfig b/net-scripts/net.modules.d/ifconfig
index 05ef95a..eacbd57 100644
--- a/net-scripts/net.modules.d/ifconfig
+++ b/net-scripts/net.modules.d/ifconfig
@@ -97,6 +97,14 @@ ifconfig_get_address() {
[[ -n ${x[0]} ]] && echo "${x[0]}/${x[1]}"
}
+# bool ifconfig_is_ethernet(char *interface)
+#
+# Return 0 if the link is ethernet, otherwise 1.
+ifconfig_is_ethernet() {
+ ifconfig "$1" | grep -q "^$1[[:space:]]*Link encap:Ethernet[[:space:]]"
+}
+
+
# void ifconfig_get_mac_address(char *interface)
#
# Fetch the mac address assingned to the network card
diff --git a/net-scripts/net.modules.d/iproute2 b/net-scripts/net.modules.d/iproute2
index 8b6a9a7..09fcfa5 100644
--- a/net-scripts/net.modules.d/iproute2
+++ b/net-scripts/net.modules.d/iproute2
@@ -97,12 +97,19 @@ iproute2_get_address() {
| sed -n -e 's/.*inet \([^ ]*\).*/\1/p'
}
+# bool iproute2_is_ethernet(char *interface)
+#
+# Return 0 if the link is ethernet, otherwise 1.
+iproute2_is_ethernet() {
+ ip link show "$1" | grep -q "^[[:space:]]*link/ether[[:space:]]*"
+}
+
# void iproute2_get_mac_address(char *interface)
#
# Fetch the mac address assingned to the network card
iproute2_get_mac_address() {
local mac=$( ip link show "$1" | sed -n -e \
- 's/^.*\<\(..:..:..:..:..:..\)\>.*/\U\1/p' )
+ '/link\// s/^.*\<\(..:..:..:..:..:..\)\>.*/\U\1/p' )
[[ ${mac} != '00:00:00:00:00:00' \
&& ${mac} != '44:44:44:44:44:44' \
&& ${mac} != 'FF:FF:FF:FF:FF:FF' ]] \