[Patch] Changing mac address does not always work

Arnaud YSMAL arnaud.ysmal at stormshield.eu
Wed Jun 8 09:47:27 UTC 2016


Hi,

Configuring the network card with the following commands (in this specific order) does not work.
# ifconfig em0 down
# ifconfig em0 mtu 1500
# ifconfig em0 ether 12:34:56:12:34:56
# ifconfig em0 192.168.1.1/24
# ifconfig em0 up

I was able to reproduce this issue on 10.3-RELEASE and HEAD with ix and em drivers.

>From what I understand:
- When setting the mtu, the driver calls the init of the interface which sets the IFF_DRV_RUNNING flag
- When setting the mac address, if_setlladdr (from if.c) copy the mac address but does nothing else (the interface is not up)
- When setting the ip address, the driver does not call the init as the IFF_DRV_RUNNING is already set.
- When setting the up flag, same as above, the IFF_DRV_RUNNING is already set.

In this case the network card does not work as the mac address filter is not up to date.

The enclosed path fixes this issue,
It changes if_setlladdr in if.c to call the ifp->if_ioctl function with the IFF_UP flag clear even when the interface is not up.
The driver will then call its stop function which clear the IFF_DRV_RUNNING.
The init will be called when setting the ip address or the up flag.

Do you have any advice regarding this patch?

Arnaud
-------------- next part --------------
A non-text attachment was scrubbed...
Name: down_iface.patch
Type: text/x-patch
Size: 1184 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-net/attachments/20160608/1cc762bc/attachment.bin>


More information about the freebsd-net mailing list