Gentoo Archives: gentoo-commits

From: Patrick McLean <chutzpah@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/netifrc:master commit in: net/
Date: Wed, 31 Mar 2021 01:11:12
Message-Id: 1617153063.4143e26dd4a56c08fbb99e18913eaafaf2a04f32.chutzpah@OpenRC
1 commit: 4143e26dd4a56c08fbb99e18913eaafaf2a04f32
2 Author: Patrick McLean <chutzpah <AT> gentoo <DOT> org>
3 AuthorDate: Wed Mar 31 01:07:57 2021 +0000
4 Commit: Patrick McLean <chutzpah <AT> gentoo <DOT> org>
5 CommitDate: Wed Mar 31 01:11:03 2021 +0000
6 URL: https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=4143e26d
7
8 net/iproute2.sh: in _get_mac_address, don't return multiple addresses
9
10 Currently if a device has virtual functions configured, ip will list the mac
11 addresses for the virtual functions on a device as well as the device itself.
12 This makes _get_mac_address return these addresses as well, causing functions
13 that consume this output to fail in "interesting" ways. This makes sure it only
14 returns 1 address.
15
16 Also don't set the mac variable to the address of the interface from sysfs, then
17 proceed to overwrite it with a call to "ip".
18
19 Signed-off-by: Patrick McLean <chutzpah <AT> gentoo.org>
20
21 net/iproute2.sh | 5 ++---
22 1 file changed, 2 insertions(+), 3 deletions(-)
23
24 diff --git a/net/iproute2.sh b/net/iproute2.sh
25 index 46f0e48..bd7333e 100644
26 --- a/net/iproute2.sh
27 +++ b/net/iproute2.sh
28 @@ -91,10 +91,9 @@ _set_flag()
29 _get_mac_address()
30 {
31 local mac=
32 - read -r mac < /sys/class/net/"${IFACE}"/address || return 1
33 - local mac=$(LC_ALL=C _ip link show "${IFACE}" | sed -n \
34 + mac=$(LC_ALL=C _ip link show "${IFACE}" | sed -n \
35 -e 'y/abcdef/ABCDEF/' \
36 - -e '/link\// s/^.*\<\(..:..:..:..:..:..\)\>.*/\1/p')
37 + -e '/link\// s/^.*\<\(..:..:..:..:..:..\)\>.*/\1/p' | head -n1)
38
39 case "${mac}" in
40 00:00:00:00:00:00) return 1 ;;