1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-26 10:04:02 +03:00
Andrew Tridgell 8d76f55bfc we need an additional gratuitous arp before the NFS tickles
(This used to be ctdb commit f7a70a5f9043b1d7293a515abf5b5228365693da)
2008-08-01 14:23:15 +10:00

76 lines
1.5 KiB
Bash
Executable File

#!/bin/sh
# ctdb event script for NFS tickle acks
PATH=/bin:/usr/bin:$PATH
. $CTDB_BASE/functions
loadconfig ctdb
loadconfig nfs
cmd="$1"
shift
[ "$CTDB_MANAGES_NFS" = "yes" ] || exit 0
[ -z "$NFS_TICKLE_SHARED_DIRECTORY" ] && exit 0
case $cmd in
startup)
mkdir -p $CTDB_BASE/state/nfstickle
mkdir -p $NFS_TICKLE_SHARED_DIRECTORY/`hostname`
# we rely on fast tcp wait1 recycling
echo 1 > /proc/sys/net/ipv4/tcp_tw_recycle
exit 0
;;
takeip)
iface=$1
ip=$2
shopt -s nullglob
# first send a grat arp, to ensure the client knows the updated
# mac address for this IP
ctdb gratiousarp $ip $iface
# send tickle acks for all the connections the old server had
for f in $NFS_TICKLE_SHARED_DIRECTORY/*/$ip; do
cat $f | while read dest; do
dip=`echo $dest | cut -d: -f1`
dport=`echo $dest | cut -d: -f2`
# send three, in case of lost packets
echo "Sending NFS tickle ack for $ip to $dip:$dport"
for i in `seq 1 3`; do
ctdb tickle $dip:$dport $ip:2049
done
done
done
exit 0
;;
releaseip)
exit 0
;;
recovered)
exit 0
;;
shutdown)
exit 0
;;
monitor)
mydir=$NFS_TICKLE_SHARED_DIRECTORY/`hostname`
rm -f $mydir/*
# record our connections to shared storage
netstat -tn |egrep '^tcp[[:space:]]+[0-9]+[[:space:]]+[0-9]+[[:space:]]+[0-9\.]+:2049.*ESTABLISHED' |
awk '{print $4" "$5}' |
while read dest src; do
ip=`echo $dest | cut -d: -f1`
echo $src >> $mydir/$ip
done
exit 0
;;
esac
# ignore unknown commands
exit 0