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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id DC02315800F for ; Thu, 19 Jan 2023 18:50:18 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 352DEE08A8; Thu, 19 Jan 2023 18:50:18 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 215BFE08A8 for ; Thu, 19 Jan 2023 18:50:18 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 55B74340B77 for ; Thu, 19 Jan 2023 18:50:17 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id B0E5584D for ; Thu, 19 Jan 2023 18:50:15 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1674154165.46f8a90fef9d9bff21760dab52124bfbbb62e064.sam@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: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: 46f8a90fef9d9bff21760dab52124bfbbb62e064 X-VCS-Branch: master Date: Thu, 19 Jan 2023 18:50:15 +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: 4cbed85f-1575-4725-8ce6-d0b9252d0f9b X-Archives-Hash: 5994018de61814f49cee30809efaed09 commit: 46f8a90fef9d9bff21760dab52124bfbbb62e064 Author: Kerin Millar plushkava net> AuthorDate: Sat Jul 17 09:53:36 2021 +0000 Commit: Sam James gentoo org> CommitDate: Thu Jan 19 18:49:25 2023 +0000 URL: https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=46f8a90f net/iproute2.sh: Fix two regressions in _get_mac_address Commit 4143e26 re-introduced the ip(8) parser in the course of adding network namespace support. In doing so, it also introduced two regressions. Firstly, in the case that no MAC address is successfully discerned, the function will return 0. Secondly, FF:FF:FF:FF:FF:FF is no longer handled as a special case. This patch, once again, does away with the ip(8) parser and, instead, collects the address from sysfs. The _netns function is used to ensure that the procedure is carried out within the applicable network namespace, if necessary. In the event that the address file cannot be read, or that it contains nothing, the function will now return 1, which addresses the first issue. The second issue is addressed by uppercasing the applicable case pattern. As an aside, this patch also addresses an issue whereby sed(1) was used to match against a pattern containing \< and \>, which are GNU-specific extensions. Fixes: 4143e26dd4a56c08fbb99e18913eaafaf2a04f32 Signed-off-by: Kerin Millar plushkava.net> Signed-off-by: Sam James gentoo.org> net/iproute2.sh | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/net/iproute2.sh b/net/iproute2.sh index bd7333e..ea0a6f7 100644 --- a/net/iproute2.sh +++ b/net/iproute2.sh @@ -91,17 +91,15 @@ _set_flag() _get_mac_address() { local mac= - mac=$(LC_ALL=C _ip link show "${IFACE}" | sed -n \ - -e 'y/abcdef/ABCDEF/' \ - -e '/link\// s/^.*\<\(..:..:..:..:..:..\)\>.*/\1/p' | head -n1) + mac=$(_netns sed -e 'y/abcdef/ABCDEF/;q' /sys/class/net/"${IFACE}"/address) || return case "${mac}" in - 00:00:00:00:00:00) return 1 ;; - 44:44:44:44:44:44) return 1 ;; - ff:ff:ff:ff:ff:ff) return 1 ;; - esac - - printf '%s\n' "${mac}" | LC_ALL=C tr '[:lower:]' '[:upper:]' + '') false ;; + 00:00:00:00:00:00) false ;; + 44:44:44:44:44:44) false ;; + FF:FF:FF:FF:FF:FF) false ;; + esac && + printf '%s\n' "${mac}" } _set_mac_address()