1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-12 09:18:10 +03:00
samba-mirror/ctdb/config/events.d/90.ipmux
Ronnie Sahlberg e4ec6e9d6b flush the route cache when we have added the single public ip to the
node

cleanup and remove everything when we do a shutdown event

(This used to be ctdb commit 221432f45073bc7624803058c8bbf18838e7ceeb)
2007-10-18 14:13:48 +10:00

88 lines
2.4 KiB
Bash
Executable File

#!/bin/sh
# script to manage the ip multiplexer for a single public address cluster
. $CTDB_BASE/functions
loadconfig ctdb
[ -z "$CTDB_SINGLE_PUBLIC_IP" ] && exit 0
[ -z "$CTDB_PUBLIC_INTERFACE" ] && exit 0
cmd="$1"
shift
PATH=/usr/bin:/bin:/usr/sbin:/sbin:$PATH
case $cmd in
startup)
modprobe ip_queue
ip addr add $CTDB_SINGLE_PUBLIC_IP/32 dev lo scope host >/dev/null 2>/dev/null
# do not respond to ARPs that are for ip addresses with scope 'host'
echo 3 > /proc/sys/net/ipv4/conf/all/arp_ignore
;;
shutdown)
# remove the ip
ip addr del $CTDB_SINGLE_PUBLIC_IP/32 dev lo >/dev/null 2>/dev/null
# remove any iptables rules
/sbin/iptables -D INPUT -i $CTDB_PUBLIC_INTERFACE -d $CTDB_SINGLE_PUBLIC_IP -j DROP 2> /dev/null
# kill off any ipmux processes
killall -9 ctdb_ipmux >/dev/null 2>/dev/null
# flush our route cache
echo 1 > /proc/sys/net/ipv4/route/flush
;;
takeip)
;;
releaseip)
;;
recovered)
# remove any previous rule for queueing
iptables -D INPUT -d $CTDB_SINGLE_PUBLIC_IP -i $CTDB_PUBLIC_INTERFACE -j QUEUE >/dev/null 2>/dev/null
# kill off any ipmux processes
killall -9 ctdb_ipmux >/dev/null 2>/dev/null
# kill off any tcp connections
/sbin/iptables -D INPUT -i $CTDB_PUBLIC_INTERFACE -d $CTDB_SINGLE_PUBLIC_IP -j DROP 2> /dev/null
/sbin/iptables -I INPUT -i $CTDB_PUBLIC_INTERFACE -d $CTDB_SINGLE_PUBLIC_IP -j DROP
kill_tcp_connections $CTDB_SINGLE_PUBLIC_IP
/sbin/iptables -D INPUT -i $CTDB_PUBLIC_INTERFACE -d $CTDB_SINGLE_PUBLIC_IP -j DROP 2> /dev/null
# are we the recmaster ?
ctdb isnotrecmaster >/dev/null 2>/dev/null || {
# change the ip address to have scope host so we wont respond
# to arps
ip addr del $CTDB_SINGLE_PUBLIC_IP/32 dev lo >/dev/null 2>/dev/null
ip addr add $CTDB_SINGLE_PUBLIC_IP/32 dev lo scope host >/dev/null 2>/dev/null
exit 0
}
# change the scope so we start responding to arps
ip addr del $CTDB_SINGLE_PUBLIC_IP/32 dev lo >/dev/null 2>/dev/null
ip addr add $CTDB_SINGLE_PUBLIC_IP/32 dev lo >/dev/null 2>/dev/null
# send out a gratious arp so our peers will update their arp tables
ctdb gratiousarp $CTDB_SINGLE_PUBLIC_IP $CTDB_PUBLIC_INTERFACE >/dev/null 2>/dev/null
# mark all these for queueing
iptables -I INPUT 1 -d $CTDB_SINGLE_PUBLIC_IP -i $CTDB_PUBLIC_INTERFACE -j QUEUE >/dev/null 2>/dev/null
ctdb_ipmux &
# flush our route cache
echo 1 > /proc/sys/net/ipv4/route/flush
;;
monitor)
;;
esac
exit 0