Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 682854 - net-misc/netifrc-0.5.1 iproute2 module _get_mac_address incorrectly emits ALL interfaces' MAC addresses
Summary: net-misc/netifrc-0.5.1 iproute2 module _get_mac_address incorrectly emits ALL...
Status: RESOLVED NEEDINFO
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: netifrc (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: netifrc Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-04-08 00:34 UTC by Stuart Longland
Modified: 2019-07-16 11:50 UTC (History)
1 user (show)

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


Attachments
/etc/conf.d/net (net,721 bytes, text/plain)
2019-07-16 00:26 UTC, Stuart Longland
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Stuart Longland 2019-04-08 00:34:35 UTC
For the better part of a YEAR now, I've put up with the following error message, unable to trace its origin:

# /etc/init.d/net.home restart
 * Caching service dependencies ...                                                                                                                                                  [ ok ]
 * Bringing down interface home
 *   Destroying bridge home ...                                                                                                                                                      [ ok ]
 * Bringing up interface home
 *   Creating bridge home ...
 *   Adding ports to home
 *     home-tap ...                                                                                                                                                                  [ ok ]
/etc/init.d/net.home: line 186: 309C23006431: command not found
/etc/init.d/net.home: line 186: 309C23006431: command not found
/etc/init.d/net.home: line 186: 309C23006431: command not found
/etc/init.d/net.home: line 186: 309C23006431: command not found
/etc/init.d/net.home: line 186: 309C23006431: command not found
/etc/init.d/net.home: line 186: 309C23006431: command not found
/etc/init.d/net.home: line 186: 309C23006431: command not found
/etc/init.d/net.home: line 186: 309C23006431: command not found
/etc/init.d/net.home: line 186: 309C23006431: command not found
/etc/init.d/net.home: line 186: 309C23006431: command not found
/etc/init.d/net.home: line 186: 309C23006431: command not found
/etc/init.d/net.home: line 186: 309C23006431: command not found
/etc/init.d/net.home: line 186: 309C23006431: command not found
/etc/init.d/net.home: line 186: 309C23006431: command not found
/etc/init.d/net.home: line 186: 309C23006431: command not found
/etc/init.d/net.home: line 186: 309C23006431: command not found
/etc/init.d/net.home: line 186: 309C23006431: command not found
/etc/init.d/net.home: line 186: 309C23006431: command not found
/etc/init.d/net.home: line 186: 309C23006431: command not found
/etc/init.d/net.home: line 186: 309C23006431: command not found
/etc/init.d/net.home: line 186: 309C23006431: command not found
/etc/init.d/net.home: line 186: 309C23006431: command not found
/etc/init.d/net.home: line 186: 309C23006431: command not found
/etc/init.d/net.home: line 186: 309C23006431: command not found
/etc/init.d/net.home: line 186: 309C23006431: command not found
/etc/init.d/net.home: line 186: 309C23006431: command not found
/etc/init.d/net.home: line 186: 309C23006431: command not found
/etc/init.d/net.home: line 186: 309C23006431: command not found
/etc/init.d/net.home: line 186: 309C23006431: command not found
/etc/init.d/net.home: line 186: 309C23006431: command not found
/etc/init.d/net.home: line 186: 309C23006431: command not found
/etc/init.d/net.home: line 186: 309C23006431: command not found
/etc/init.d/net.home: line 186: 309C23006431: command not found
/etc/init.d/net.home: line 186: 309C23006431: command not found
/etc/init.d/net.home: line 186: 309C23006431: command not found
 *   2001:44b8:21ac:7053:1000::1/64 ...                                                                                                                                              [ ok ]
 *   192.168.64.48/23 ...                                                                                                                                                            [ ok ]
 *   Adding routes
 *     172.31.128.0/17 via 192.168.64.1 ...                                                                                                                                          [ ok ]
 *     192.168.64.0/23 dev home ...                                                                                                                                                  [ ok ]
 *     2001:44b8:21ac:7053::/64 dev home ...                                                                                                                                         [ ok ]
 *   Waiting for IPv6 addresses (5 seconds) ..                                                                                                                                       [ ok ]

Some sleuthing revealed that the netifrc script, when it asks for the MAC address of my bridge (home), it instead of returning just ONE MAC address, it returns the MAC address of EVERY interface on my system:

# /etc/init.d/net.home -d restart
+ for module in ${MODULES}
++ command -v macnet_pre_start
+ '[' macnet_pre_start = macnet_pre_start ']'
+ macnet_pre_start
++ _get_mac_address
+ local 'mac=00:00:00:00:00:00
30:9C:23:00:64:31
F8:1A:67:00:48:35
F8:1A:67:00:48:35
F8:1A:67:00:48:35
1A:97:02:C7:E0:8C
F8:1A:67:00:48:35
F8:1A:67:00:48:35
30:9C:23:00:64:31
F8:1A:67:00:48:35
02:42:86:DF:C3:65
02:42:DB:17:B5:38
02:42:38:D2:F4:5C
52:54:00:0B:EE:D2
52:54:00:0B:EE:D2
FE:54:00:CB:8B:88
1A:97:02:C7:E0:8C'

The offending code is /lib64/netifrc/net/iproute2.sh line 526, it runs:

LC_ALL=C ip link show "${IFACE}" | sed -n \
                -e 'y/abcdef/ABCDEF/' \
                -e '/link\// s/^.*\<\(..:..:..:..:..:..\)\>.*/\1/p'

which returns the above list of MAC addresses -- the MAC address of *EVERY* Ethernet interface on my computer (including virtual ones).

That command should be:

LC_ALL=C ip link show dev "${IFACE}" | sed -n \
                -e 'y/abcdef/ABCDEF/' \
                -e '/link\// s/^.*\<\(..:..:..:..:..:..\)\>.*/\1/p'

The word "dev" tells `iproute2` *WHICH* interface is of interest.
Comment 1 Ben Kohler gentoo-dev 2019-07-10 15:10:16 UTC
I'm not able to reproduce this problem, what iproute2 version are you using?  I get the same output with or without the "dev" word.

Your report sounds like what would happen if ${IFACE} is somehow unset.
Comment 2 dwfreed 2019-07-10 15:54:20 UTC
Both iproute2 and busybox that are stable as of this writing (4.17.0-r1 and 1.29.3, respectively) support "ip link show <interface>" to only show that interface, and will throw errors if the interface provided does not exactly match an interface on the system.

Please provide the output of the following commands:

ip -V
LC_ALL=C ip link show home # obviously after the interface has been created
sed --version
LC_ALL=C ip link show home | sed -n -e 'y/abcdef/ABCDEF/' -e '/link\// s/^.*\<\(..:..:..:..:..:..\)\>.*/\1/p'
Comment 3 dwfreed 2019-07-10 16:01:18 UTC
Also your /etc/conf.d/net would be helpful (attach it).
Comment 4 Stuart Longland 2019-07-15 23:58:42 UTC
I'll have to dig up a back-up, as I now have Ubuntu 18.04 running on the affected machine.
Comment 5 Stuart Longland 2019-07-16 00:26:15 UTC
The following is while chrooted into the back-up:

vk4msl-ws / # ip -V
ip utility, iproute2-ss180608
vk4msl-ws / # LC_ALL=C ip link show home
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp30s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master vrtoffice state UP mode DEFAULT group default qlen 1000
    link/ether 30:9c:23:00:64:31 brd ff:ff:ff:ff:ff:ff
3: enp33s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
    link/ether f8:1a:67:00:48:35 brd ff:ff:ff:ff:ff:ff
4: vrtproj-phy@enp33s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master vrtproj state UP mode DEFAULT group default qlen 1000
    link/ether f8:1a:67:00:48:35 brd ff:ff:ff:ff:ff:ff
5: vrtproj: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether f8:1a:67:00:48:35 brd ff:ff:ff:ff:ff:ff
6: vrtoffice: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether 30:9c:23:00:64:31 brd ff:ff:ff:ff:ff:ff
7: home: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether ea:0f:39:bc:30:08 brd ff:ff:ff:ff:ff:ff
8: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default qlen 1000
    link/ether 52:54:00:89:98:be brd ff:ff:ff:ff:ff:ff
9: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel master virbr0 state DOWN mode DEFAULT group default qlen 1000
    link/ether 52:54:00:89:98:be brd ff:ff:ff:ff:ff:ff
10: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default 
    link/ether 02:42:3d:21:07:3a brd ff:ff:ff:ff:ff:ff
24: home-tap: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master home state UNKNOWN mode DEFAULT group default qlen 100
    link/ether ea:0f:39:bc:30:08 brd ff:ff:ff:ff:ff:ff
vk4msl-ws / # sed --version
sed (GNU sed) 4.5
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Jay Fenlason, Tom Lord, Ken Pizzini,
and Paolo Bonzini.
GNU sed home page: <https://www.gnu.org/software/sed/>.
General help using GNU software: <https://www.gnu.org/gethelp/>.
E-mail bug reports to: <bug-sed@gnu.org>.
vk4msl-ws / # LC_ALL=C ip link show home | sed -n -e 'y/abcdef/ABCDEF/' -e '/link\// s/^.*\<\(..:..:..:..:..:..\)\>.*/\1/p'
00:00:00:00:00:00
30:9C:23:00:64:31
F8:1A:67:00:48:35
F8:1A:67:00:48:35
F8:1A:67:00:48:35
30:9C:23:00:64:31
EA:0F:39:BC:30:08
52:54:00:89:98:BE
52:54:00:89:98:BE
02:42:3D:21:07:3A
EA:0F:39:BC:30:08

Now, adding that keyword in, I get:

vk4msl-ws / # LC_ALL=C ip link show dev home
7: home: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether ea:0f:39:bc:30:08 brd ff:ff:ff:ff:ff:ff
Comment 6 Stuart Longland 2019-07-16 00:26:46 UTC
Created attachment 582956 [details]
/etc/conf.d/net
Comment 7 Ben Kohler gentoo-dev 2019-07-16 11:50:48 UTC
Can you share "emerge -pvO iproute2" output?