List Archive: gentoo-dev
1.1 |
On Wed, Apr 23, 2008 at 04:21:27PM +0100, Roy Marples wrote:
> OK, it seems that hard lines in multipart configs seem to be an issue, so I'm
> doing this now.
>
> For a summary of why we're using hard lines you can read this thread
> http://thread.gmane.org/gmane.linux.gentoo.devel/45756/focus=45765
Do you plan to reimplement parsing of the complete ip syntax for
addresses and routes?
See my attached example from work, we use a lot of the various options
on stuff.
--
Robin Hugh Johnson
Gentoo Linux Developer & Infra Guy
E-Mail : robbat2@g.o
GnuPG FP : 11AC BA4F 4778 E3F6 E4ED F38E B27B 944E 3488 4E85
|
1.2 |
# Prefer iproute2 over ifconfig
modules=( "iproute2" )
ext="AAA.BBB.CCC" #REMOVED-FOR-PRIVACY
oob="DDD.EEE.FFF" #REMOVED-FOR-PRIVACY
int="GGG.HHH.III" #REMOVED-FOR-PRIVACY
RC_NEED_bond0="net.eth2 net.eth3"
# Primary IP must come first
config_bond0=( "${int}.51/24" "${int}.22/24" "${int}.23/24" )
slaves_bond0="eth2 eth3"
mtu_bond0="9000"
#slaves_bond0="eth3"
config_eth0=( "${oob}.145/27" )
config_eth1=(
"${ext}.51/24" # REMOVED
"${ext}.20/24" # REMOVED
"${ext}.21/24" # REMOVED
"${ext}.22/24" # REMOVED
"${ext}.23/24" # REMOVED
"${ext}.37/24" # REMOVED
"${ext}.71/24" # REMOVED
)
mtu_eth1="9000"
config_eth2=( "null" )
#config_eth2=( "${ext}.51/24" )
config_eth3=( "null" )
config_lo=(
"${ext}.30/32 broadcast - scope host"
"${ext}.31/32 broadcast - scope host"
"${ext}.32/32 broadcast - scope host"
"${ext}.33/32 broadcast - scope host"
"${ext}.34/32 broadcast - scope host"
"${ext}.35/32 broadcast - scope host"
"${ext}.36/32 broadcast - scope host"
"${ext}.37/32 broadcast - scope host"
"${ext}.38/32 broadcast - scope host"
)
# Routing
routes_eth0=(
"${oob}.128/27 dev eth0 table oob scope link"
"default via ${oob}.129 table oob"
)
routes_eth1=( # was eth1
"${ext}.0/24 dev eth1 table external scope link"
"default via ${ext}.10 dev eth1"
)
routes_bond0=(
"${int}.0/8 dev bond0 table internal scope link"
"${int}.192/27 dev bond0 mtu 1500 table internal scope link"
"default via ${int}.2 bond0 table internal"
)
rules_bond0=(
"from ${int}.0/24 table internal priority 700 dev bond0"
"to ${int}.0/24 table internal priority 750 dev bond0"
)
rules_eth0=(
"from ${oob}.128/27 table oob priority 500"
"to ${oob}.128/27 table oob priority 550"
)
rules_eth1=( # was eth1
"from ${ext}.0/24 table external priority 400"
"to ${ext}.0/24 table external priority 450"
)
# Now some fun functionality.
# This flushes the Linux route cache
# It is important on failover to do this
# otherwise traffic might try an old route for a while.
flush_route_cache() {
ebegin "Flushing route cache for ${IFACE}"
ip route flush cache dev ${IFACE}
ret=$?
eend $ret
return $ret
}
# This will take a rules array, and process it.
ip_rule_runner() {
cmd="$1"
rules_iface=rules_${IFACE}[@]
rules=( "${!rules_iface}" )
max=$((${#rules[@]} - 1))
cmd="ip rule ${cmd}"
for ln in `seq 0 $max`; do
ebegin " ${cmd} ${rules[$ln]}"
${cmd} ${rules[$ln]}
eend $?
done
}
postup() {
einfo "Adding rules"
ip_rule_runner add
flush_route_cache
}
predown() {
einfo "Removing rules"
ip_rule_runner del
flush_route_cache
}
check_link() {
ethtool "${IFACE}" | grep -q 'Link detected: yes'
}
preup() {
case $IFACE in
ppp*|ippp*|isdn*|plip*|lo*|irda*|dummy*|ipsec*|tun*|tap*)
;;
bond*)
;;
eth*)
# Try to force link up first, for e1000 special case
i=0
while [ $i -lt 5 ] && ! check_link; do
[ $i -gt 0 ] && sleep 0.2
ip link set ${IFACE} up
i=$(($i+1))
done
if ! check_link; then
ewarn "No link on ${IFACE}, aborting configuration"
ip link set $IFACE down
# commented out for the moment, we need to check if we are in a bond
#return 1
fi
;;
esac
return 0
}
# Do not use the metric calculation code
# It is slow with lots of routes.
metric=0
metric_eth0=0
metric_eth1=0
metric_eth2=0
metric_eth3=0
metric_eth4=0
metric_eth5=0
metric_bond0=0
|
|