diff options
author | Martin Schwenke <martin@meltin.net> | 2022-08-17 11:38:44 +1000 |
---|---|---|
committer | Amitay Isaacs <amitay@samba.org> | 2022-09-16 03:36:32 +0000 |
commit | a31fb7e5ab8439349bc2670b3fde1020ba2c48b5 (patch) | |
tree | 25d3d85238e22bb93c4d4e05553b0f1b22b5aef8 /ctdb | |
parent | 5abaec499275bc47fb596e6bf2fa9fe98a891e79 (diff) | |
download | samba-a31fb7e5ab8439349bc2670b3fde1020ba2c48b5.tar.gz |
ctdb-scripts: Simplify determination of real interface
This can now be made trivial.
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb')
-rwxr-xr-x | ctdb/config/functions | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/ctdb/config/functions b/ctdb/config/functions index 518bc201f7b..dcb04ebb5ef 100755 --- a/ctdb/config/functions +++ b/ctdb/config/functions @@ -631,21 +631,11 @@ flush_route_cache () # underlying interface interface_get_real () { - # 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##*@}" - ;; - *) - echo "$_t" - esac + _iface="$1" + + # If $_iface is a VLAN (i.e. contains an '@') then strip every + # before the '@', otherwise print the whole interface + echo "${_iface##*@}" } # Check whether an interface is operational @@ -653,7 +643,7 @@ interface_monitor () { _iface="$1" - _iface_info=$(ip link show "$_iface" 2>&1) || { + _iface_info=$(ip -br link show "$_iface" 2>&1) || { echo "ERROR: Monitored interface ${_iface} does not exist" return 1 } @@ -661,7 +651,7 @@ interface_monitor () # If the interface is a virtual one (e.g. VLAN) then get the # underlying interface. - _realiface=$(interface_get_real "$_iface_info") + _realiface=$(interface_get_real "${_iface_info%% *}") if _bi=$(get_proc "net/bonding/${_realiface}" 2>/dev/null) ; then # This is a bond: various monitoring strategies |