1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-08 04:58:40 +03:00

Eventscripts - add facility to 10.interface to delete unmanaged IPs

For a number of reasons (delip failure, admin stupidity, ...) an
interface that hosts public addresses can also contain spurious,
unmanaged addresses.

Add functionality to 10.interfaces, controlled by new configuration
variable CTDB_DELETE_UNEXPECTED_IPS, to delete these addresses when
encountered as part of a monitor event.

Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit 88f88d86b0d08240f749fb721b8c401c2eeb1099)
This commit is contained in:
Martin Schwenke 2011-11-17 16:47:00 +11:00
parent ba5e5f51cf
commit 162ac70f9e

View File

@ -49,10 +49,39 @@ get_all_interfaces ()
all_interfaces=$(echo $all_interfaces $ctdb_ifaces | tr ' ' '\n' | sort -u)
}
delete_unexpected_ips ()
{
[ "$CTDB_DELETE_UNEXPECTED_IPS" = "yes" ] || return
for _i in $all_interfaces ; do
# Get the IPs actually on this interface
_ips=$(ip addr show dev "$_i" | \
sed -n -e 's@.*inet[[:space:]]*\([^[:space:]]*\).*scope global.*@\1@p')
for _ip in $_ips ; do
# The NATGW address is OK
if [ "$CTDB_NATGW_PUBLIC_IP" = "$_ip" -a \
"$CTDB_NATGW_PUBLIC_IFACE" = "$_i" ] ; then
continue
fi
# If CTDB knows about the address then it is OK
if ctdb ipinfo "${_ip%/*}" >/dev/null 2>&1 ; then
continue
fi
echo "WARNING: Removing unmanaged IP address $_ip from interface $_i"
delete_ip_from_iface "$_i" "${_ip%/*}" "${_ip#*/}"
done
done
}
monitor_interfaces()
{
get_all_interfaces
delete_unexpected_ips
fail=false
up_interfaces_found=false