I've recently added a new NIC to my system and have enabled virtual functions on it. Unfortunately, running /etc/init.d/net.<interface> start will always spam a ton of errors at me as said device will not have its MAC address discovered properly. Reproducible: Always Steps to Reproduce: 1. Have a device that returns multiple a MAC addresses in an ip link show command 2. Run anything that calls _get_mac_address() in net/iproute2.sh Actual Results: ip link show enp37s0 returns: 4: enp37s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000 link/ether 00:1b:21:bc:0a:87 brd ff:ff:ff:ff:ff:ff vf 0 link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff, spoof checking on, link-state auto, trust off, query_rss off vf 1 link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff, spoof checking on, link-state auto, trust off, query_rss off vf 2 link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff, spoof checking on, link-state auto, trust off, query_rss off vf 3 link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff, spoof checking on, link-state auto, trust off, query_rss off Therefore, the variable mac will be set as, in my example: 00:1B:21:BC:0A:87 FF:FF:FF:FF:FF:FF FF:FF:FF:FF:FF:FF FF:FF:FF:FF:FF:FF FF:FF:FF:FF:FF:FF Expected Results: Variable mac should be 00:1B:21:BC:0A:87 Tracked down to the setting of mac in _get_mac_address() in net/iproute2.sh.
(In reply to gentoo from comment #0) > Tracked down to the setting of mac in _get_mac_address() in net/iproute2.sh. Please try the impending patch.
Created attachment 684285 [details, diff] netifrc-use-sysfs-to-obtain-the-mac-address.patch
Created attachment 684291 [details, diff] netifrc-use-sysfs-to-obtain-the-mac-address-r1.patch No behavioural change from the previously attached patch. The only difference is that it employs a more terse method of transliterating the hex characters to upper case, looking slightly neater overall.
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=6632c348cce8be19c7a960cabb2f6f41ec4c6d51 commit 6632c348cce8be19c7a960cabb2f6f41ec4c6d51 Author: Kerin Millar <kfm@plushkava.net> AuthorDate: 2021-01-24 02:49:43 +0000 Commit: Lars Wendler <polynomial-c@gentoo.org> CommitDate: 2021-01-24 10:21:20 +0000 Use sysfs to obtain the MAC address in net/iproute2.sh Dispense with the hideous ip-link(8) parser. Instead, collect the MAC address by reading from the relevant sysfs file. While at it, tidy up the remainder of the function so that the control flow is easier to ascertain at a glance. Note that the address will be rendered in upper case, just as it was before. Signed-off-by: Kerin Millar <kfm@plushkava.net> Closes: https://bugs.gentoo.org/766758 Signed-off-by: Lars Wendler <polynomial-c@gentoo.org> net/iproute2.sh | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
I realise that very few Linux users will be using the ifconfig.sh module at this point but, still, I wonder whether the ifconfig parser is also affected. OP, if it is not too much trouble, please attach the output of "ifconfig enp37s0" so that it can be determined whether anything needs to be done for that particular module. Thanks.
Thanks for the fix, it works for me. My ifconfig output is: $ ifconfig enp37s0 enp37s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 10.0.0.13 netmask 255.0.0.0 broadcast 10.255.255.255 inet6 fe80::ddbb:b3aa:f3c7:21dc prefixlen 64 scopeid 0x20<link> ether 00:1b:21:bc:0a:87 txqueuelen 1000 (Ethernet) RX packets 265464326 bytes 224348828808 (208.9 GiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 203344434 bytes 214929531141 (200.1 GiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
So it only prints a single "ether" address. Good. Thanks.