Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 766758 - net-misc/netifrc: Interface returning multiple MAC addresses errors out
Summary: net-misc/netifrc: Interface returning multiple MAC addresses errors out
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: netifrc (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: netifrc Team
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2021-01-23 22:02 UTC by son
Modified: 2021-01-27 18:33 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
netifrc-use-sysfs-to-obtain-the-mac-address.patch (netifrc-use-sysfs-to-obtain-the-mac-address.patch,1.32 KB, patch)
2021-01-24 03:06 UTC, kfm
Details | Diff
netifrc-use-sysfs-to-obtain-the-mac-address-r1.patch (netifrc-use-sysfs-to-obtain-the-mac-address-r1.patch,1.31 KB, patch)
2021-01-24 08:35 UTC, kfm
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description son 2021-01-23 22:02:04 UTC
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.
Comment 1 kfm 2021-01-24 03:02:35 UTC
(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.
Comment 2 kfm 2021-01-24 03:06:46 UTC
Created attachment 684285 [details, diff]
netifrc-use-sysfs-to-obtain-the-mac-address.patch
Comment 3 kfm 2021-01-24 08:35:34 UTC
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.
Comment 4 Larry the Git Cow gentoo-dev 2021-01-24 10:37:24 UTC
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(-)
Comment 5 kfm 2021-01-27 17:51:26 UTC
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.
Comment 6 son 2021-01-27 18:32:39 UTC
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
Comment 7 kfm 2021-01-27 18:33:58 UTC
So it only prints a single "ether" address. Good. Thanks.