Work cleanly with bridges on kernels without TCP, #197791.

This commit is contained in:
Roy Marples
2007-11-01 22:25:53 +00:00
parent a1f80bc7a7
commit 80124a050c
5 changed files with 36 additions and 15 deletions

View File

@@ -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)

View File

@@ -54,11 +54,14 @@ bridge_pre_start() {
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
@@ -100,7 +103,8 @@ bridge_post_stop() {
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

View File

@@ -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')

View File

@@ -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() {

View File

@@ -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,10 +495,12 @@ start() {
local hidefirstroute=false first=true
local routes="$(_get_array "routes_${IFVAR}")"
if [ "${IFACE}" = "lo" -o "${IFACE}" = "lo0" ] ; then
if [ "${config_0}" != "null" ]; then
routes="127.0.0.0/8 via 127.0.0.1
${routes}"
hidefirstroute=true
fi
fi
local IFS="$__IFS"
for cmd in ${routes}; do
unset IFS