summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2007-11-01 22:25:53 +0000
committerRoy Marples <roy@marples.name>2007-11-01 22:25:53 +0000
commit80124a050c626584f19fbac917276946224bcde7 (patch)
treec94990be30f3bf00785a8577fb7ef7cf1bd46f21
parenta1f80bc7a74b5b3b899eadeb63ccfbdec6d860d0 (diff)
downloadopenrc-80124a050c626584f19fbac917276946224bcde7.tar.gz
openrc-80124a050c626584f19fbac917276946224bcde7.tar.bz2
openrc-80124a050c626584f19fbac917276946224bcde7.tar.xz
Work cleanly with bridges on kernels without TCP, #197791.
-rw-r--r--ChangeLog1
-rw-r--r--net.Linux/bridge.sh26
-rw-r--r--net.Linux/ifconfig.sh4
-rw-r--r--net.Linux/iproute2.sh12
-rwxr-xr-xsh/net.sh8
5 files changed, 36 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index 334fa4c..8898854 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@
01 Nov 2007; Roy Marples <uberlord@gentoo.org>:
+ Work cleanly with bridges on kernels without TCP, #197791.
Fix fallback, #197788.
* baselayout-2.0.0_rc6 (31 Oct 2007)
diff --git a/net.Linux/bridge.sh b/net.Linux/bridge.sh
index b1d4cfc..301b1fa 100644
--- a/net.Linux/bridge.sh
+++ b/net.Linux/bridge.sh
@@ -33,7 +33,7 @@ bridge_pre_start() {
if ! _is_bridge; then
ebegin "Creating bridge ${IFACE}"
- if ! brctl addbr "${IFACE}" ; then
+ if ! brctl addbr "${IFACE}"; then
eend 1
return 1
fi
@@ -50,15 +50,18 @@ bridge_pre_start() {
done
unset IFS
- if [ -n "${ports}" ] ; then
+ if [ -n "${ports}" ]; then
einfo "Adding ports to ${IFACE}"
eindent
+ local OIFACE="${IFACE}"
for x in ${ports}; do
ebegin "${x}"
- ifconfig "${x}" promisc up
- if ! brctl addif "${IFACE}" "${x}" ; then
- ifconfig "${x}" -promisc 2>/dev/null
+ local IFACE="${x}"
+ _set_flag promisc
+ _up
+ if ! brctl addif "${OIFACE}" "${x}"; then
+ _set_flag -promisc
eend 1
return 1
fi
@@ -78,7 +81,7 @@ bridge_post_stop() {
if _is_bridge ; then
ebegin "Destroying bridge ${IFACE}"
_down
- ports="$( brctl show 2>/dev/null | \
+ ports="$(brctl show 2>/dev/null | \
sed -n -e '/^'"${IFACE}"'[[:space:]]/,/^\S/ { /^\('"${IFACE}"'[[:space:]]\|\t\)/s/^.*\t//p }')"
delete=true
iface=${IFACE}
@@ -87,9 +90,9 @@ bridge_post_stop() {
# Work out if we're added to a bridge for removal or not
eval set -- $(brctl show 2>/dev/null | sed -e "s/'/'\\\\''/g" -e "s/$/'/g" -e "s/^/'/g")
local line=
- for line in "$@" ; do
+ for line in "$@"; do
set -- ${line}
- if [ "$3" = "${IFACE}" ] ; then
+ if [ "$3" = "${IFACE}" ]; then
iface=$1
break
fi
@@ -98,14 +101,15 @@ bridge_post_stop() {
extra=" from ${iface}"
fi
- for port in ${ports} ; do
+ for port in ${ports}; do
ebegin "Removing port ${port}${extra}"
- ifconfig "${port}" -promisc
+ local IFACE="${port}"
+ _set_flag -promisc
brctl delif "${iface}" "${port}"
eend $?
done
- if ${delete} ; then
+ if ${delete}; then
eoutdent
brctl delbr "${iface}"
eend $?
diff --git a/net.Linux/ifconfig.sh b/net.Linux/ifconfig.sh
index bc04cdb..4051ef5 100644
--- a/net.Linux/ifconfig.sh
+++ b/net.Linux/ifconfig.sh
@@ -42,6 +42,10 @@ _is_wireless() {
grep -Eq "^[[:space:]]*${IFACE}:" /proc/net/wireless
}
+_set_flag() {
+ ifconfig "${IFACE}" "$1"
+}
+
_get_mac_address() {
local mac=$(LC_ALL=C ifconfig "${IFACE}" | \
sed -n -e 's/.* HWaddr \(..:..:..:..:..:..\).*/\1/p')
diff --git a/net.Linux/iproute2.sh b/net.Linux/iproute2.sh
index e6652c0..8357f25 100644
--- a/net.Linux/iproute2.sh
+++ b/net.Linux/iproute2.sh
@@ -43,6 +43,15 @@ _is_wireless() {
grep -Eq "^[[:space:]]*${IFACE}:" /proc/net/wireless
}
+_set_flag() {
+ local flag=$1 opt="on"
+ if [ "${flag#-}" != "${flag}" ]; then
+ flag=${flag#-}
+ opt="off"
+ fi
+ ip link set "${IFACE}" "${flag}" "${opt}"
+}
+
_get_mac_address() {
local mac=$(LC_ALL=C ip link show "${IFACE}" | sed -n \
-e 'y/abcdef/ABCDEF/' \
@@ -181,7 +190,8 @@ iproute2_pre_start() {
}
iproute2_post_start() {
- ip route flush table cache dev "${IFACE}"
+ # Kernel may not have tcp built in
+ [ -e /proc/net/route ] && ip route flush table cache dev "${IFACE}"
}
iproute2_post_stop() {
diff --git a/sh/net.sh b/sh/net.sh
index 6c9dd6d..71017bf 100755
--- a/sh/net.sh
+++ b/sh/net.sh
@@ -349,7 +349,7 @@ _load_config() {
local fallback="$(_get_array fallback_${IFVAR})"
if [ "${IFACE}" = "lo" -o "${IFACE}" = "lo0" ] ; then
- config="127.0.0.1/8
+ [ "${config}" != "null" ] && config="127.0.0.1/8
${config}"
else
if [ -z "${config}" ] ; then
@@ -495,9 +495,11 @@ start() {
local hidefirstroute=false first=true
local routes="$(_get_array "routes_${IFVAR}")"
if [ "${IFACE}" = "lo" -o "${IFACE}" = "lo0" ] ; then
- routes="127.0.0.0/8 via 127.0.0.1
+ if [ "${config_0}" != "null" ]; then
+ routes="127.0.0.0/8 via 127.0.0.1
${routes}"
- hidefirstroute=true
+ hidefirstroute=true
+ fi
fi
local IFS="$__IFS"
for cmd in ${routes}; do