From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id DBB9513835A for ; Wed, 31 Mar 2021 01:11:12 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id A607FE081E; Wed, 31 Mar 2021 01:11:11 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 48924E0814 for ; Wed, 31 Mar 2021 01:11:11 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id C2055335CEE for ; Wed, 31 Mar 2021 01:11:09 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 1A54D633 for ; Wed, 31 Mar 2021 01:11:08 +0000 (UTC) From: "Patrick McLean" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Patrick McLean" Message-ID: <1617153063.4143e26dd4a56c08fbb99e18913eaafaf2a04f32.chutzpah@OpenRC> Subject: [gentoo-commits] proj/netifrc:master commit in: net/ X-VCS-Repository: proj/netifrc X-VCS-Files: net/iproute2.sh X-VCS-Directories: net/ X-VCS-Committer: chutzpah X-VCS-Committer-Name: Patrick McLean X-VCS-Revision: 4143e26dd4a56c08fbb99e18913eaafaf2a04f32 X-VCS-Branch: master Date: Wed, 31 Mar 2021 01:11:08 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 131c9e5e-d0b7-4a4a-8ab7-6ae756fd2610 X-Archives-Hash: 7ce872755785133b0aab600166a2ee89 commit: 4143e26dd4a56c08fbb99e18913eaafaf2a04f32 Author: Patrick McLean gentoo org> AuthorDate: Wed Mar 31 01:07:57 2021 +0000 Commit: Patrick McLean gentoo org> CommitDate: Wed Mar 31 01:11:03 2021 +0000 URL: https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=4143e26d 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 gentoo.org> net/iproute2.sh | 5 ++--- 1 file 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 ;;