Skip to content

Commit

Permalink
Merge pull request #222 from ptalbert/net_master_fix
Browse files Browse the repository at this point in the history
[ip_addr] Match on a substring of interface name when looking for mas…
  • Loading branch information
ptalbert authored Apr 4, 2019
2 parents 0b693d5 + 23ea312 commit 22fcbb0
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions xsos
Original file line number Diff line number Diff line change
Expand Up @@ -2223,7 +2223,7 @@ IPADDR() {
fi

# Local vars:
local ip_a_input brctl_show_input ipdevs bridge interface i n ipaddr scope alias
local ip_a_input brctl_show_input ipdevs bridge interface i i_substr n ipaddr scope alias

# Declare our 7 associative arrays:
local -A lookup_bridge iface_input slaveof state ipv4 ipv4_alias mtu mac
Expand Down Expand Up @@ -2277,12 +2277,15 @@ IPADDR() {
# Pull out input for specific interface and save to interface key in array
iface_input[$i]=$(gawk "BEGIN {RS=\"\n\n\"} /^[0-9]+: ${i}:/" <<<"${ip_a_input}")

# Figure out if $i is a slave of some bond / bridge device
# Store a substr of $i with any @<master> removed
i_substr=$(expr match "$i" '\([^@]*\)')

# Figure out if $i_substr is a slave of some bond / bridge device
slaveof[$i]=$(
if egrep -q 'SLAVE|master' <<<"${iface_input[$i]}"; then
egrep -o 'master [[:graph:]]+' <<<"${iface_input[$i]}" | gawk '{print $2}'
elif [[ -n $brctl_show_input && -n ${lookup_bridge[$i]} ]]; then
echo ${lookup_bridge[$i]}
elif [[ -n $brctl_show_input && -n ${lookup_bridge[$i_substr]} ]]; then
echo ${lookup_bridge[$i_substr]}
else
echo "-"
fi
Expand Down

0 comments on commit 22fcbb0

Please sign in to comment.