summaryrefslogtreecommitdiff
path: root/ctdb
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2015-07-08 21:23:48 +1000
committerAmitay Isaacs <amitay@samba.org>2015-07-14 09:57:16 +0200
commitbc71251433ce618c95c674d7cbe75b01a94adad9 (patch)
treeeda403b958541d12173a305b84206fefe6e943ff /ctdb
parent87c5c96b767aa317dd620f89ac3e11bb40dae70f (diff)
downloadsamba-bc71251433ce618c95c674d7cbe75b01a94adad9.tar.gz
ctdb-scripts: Support monitoring of interestingly named VLANs on bonds
VLAN interfaces on bonds with a name other than <iface>.<id>@<iface> are not currently supported. That is, where the VLAN name isn't based on the underlying bond name. Such VLAN interfaces can be created with the "ip link" command, as opposed to the "vconfig" command, or by renaming a VLAN interface. This is improved by determining the underlying interface name for a VLAN from the output of "ip link". No serious attempt is made to support VLANs with '@' in their name, although this seems to be legal. Why would you do that? Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb')
-rwxr-xr-xctdb/config/events.d/10.interface28
1 files changed, 26 insertions, 2 deletions
diff --git a/ctdb/config/events.d/10.interface b/ctdb/config/events.d/10.interface
index 69da2106b39..acc0fc82ddc 100755
--- a/ctdb/config/events.d/10.interface
+++ b/ctdb/config/events.d/10.interface
@@ -52,6 +52,30 @@ get_all_interfaces ()
all_interfaces=$(echo $all_interfaces $ctdb_ifaces | tr ' ' '\n' | sort -u)
}
+get_real_iface ()
+{
+ # Output of "ip link show <iface>"
+ _iface_info="$1"
+
+ # Extract the full interface description to see if it is a VLAN
+ _t=$(echo "$_iface_info" |
+ awk 'NR == 1 { iface = $2; sub(":$", "", iface) ; \
+ print iface }')
+ case "$_t" in
+ *@*)
+ # VLAN: use the underlying interface, after the '@'
+ echo "${_t##*@}"
+ ;;
+ *)
+ # Not a regular VLAN. For backward compatibility, assume
+ # there is some other sort of VLAN that doesn't have the
+ # '@' in the output and only use what is before a '.'. If
+ # there is no '.' then this will be the whole interface
+ # name.
+ echo "${_t%%.*}"
+ esac
+}
+
monitor_interfaces()
{
get_all_interfaces
@@ -65,7 +89,7 @@ monitor_interfaces()
# problem with an interface then set fail=true and continue.
for iface in $all_interfaces ; do
- ip link show $iface 2>/dev/null >/dev/null || {
+ _iface_info=$(ip link show $iface 2>&1) || {
echo "ERROR: Interface $iface does not exist but it is used by public addresses."
mark_down $iface
continue
@@ -74,7 +98,7 @@ monitor_interfaces()
# These interfaces are sometimes bond devices
# When we use VLANs for bond interfaces, there will only
# be an entry in /proc for the underlying real interface
- realiface=`echo $iface |sed -e 's/\..*$//'`
+ realiface=$(get_real_iface "$_iface_info")
bi=$(get_proc "net/bonding/$realiface" 2>/dev/null) && {
echo "$bi" | grep -q 'Currently Active Slave: None' && {
echo "ERROR: No active slaves for bond device $realiface"