aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick McLean <chutzpah@gentoo.org>2021-03-30 18:07:57 -0700
committerPatrick McLean <chutzpah@gentoo.org>2021-03-30 18:11:03 -0700
commit4143e26dd4a56c08fbb99e18913eaafaf2a04f32 (patch)
tree51ea90422328980b7f61370ead9a48b2f2bdd61d
parentnet.lo.in: quote variables in _configure_variables (diff)
downloadnetifrc-4143e26dd4a56c08fbb99e18913eaafaf2a04f32.tar.gz
netifrc-4143e26dd4a56c08fbb99e18913eaafaf2a04f32.tar.bz2
netifrc-4143e26dd4a56c08fbb99e18913eaafaf2a04f32.zip
net/iproute2.sh: in _get_mac_address, don't return multiple addresses
Currently if a device has virtual functions configured, ip will list the mac addresses for the virtual functions on a device as well as the device itself. This makes _get_mac_address return these addresses as well, causing functions that consume this output to fail in "interesting" ways. This makes sure it only returns 1 address. Also don't set the mac variable to the address of the interface from sysfs, then proceed to overwrite it with a call to "ip". Signed-off-by: Patrick McLean <chutzpah@gentoo.org>
-rw-r--r--net/iproute2.sh5
1 files changed, 2 insertions, 3 deletions
diff --git a/net/iproute2.sh b/net/iproute2.sh
index 46f0e48..bd7333e 100644
--- a/net/iproute2.sh
+++ b/net/iproute2.sh
@@ -91,10 +91,9 @@ _set_flag()
_get_mac_address()
{
local mac=
- read -r mac < /sys/class/net/"${IFACE}"/address || return 1
- local mac=$(LC_ALL=C _ip link show "${IFACE}" | sed -n \
+ mac=$(LC_ALL=C _ip link show "${IFACE}" | sed -n \
-e 'y/abcdef/ABCDEF/' \
- -e '/link\// s/^.*\<\(..:..:..:..:..:..\)\>.*/\1/p')
+ -e '/link\// s/^.*\<\(..:..:..:..:..:..\)\>.*/\1/p' | head -n1)
case "${mac}" in
00:00:00:00:00:00) return 1 ;;