Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 8 Jun 2016 11:44:36 +0200 (CEST)
From:      Arnaud YSMAL <arnaud.ysmal@stormshield.eu>
To:        freebsd-net@freebsd.org
Subject:   [Patch] Changing mac address does not always work
Message-ID:  <494678734.3111275.1465379076220.JavaMail.zimbra@stormshield.eu>

next in thread | raw e-mail | index | archive | help
------=_Part_3111273_1322850569.1465379076220
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

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
------=_Part_3111273_1322850569.1465379076220
Content-Type: text/x-patch; name=down_iface.patch
Content-Disposition: attachment; filename=down_iface.patch
Content-Transfer-Encoding: base64

ZGlmZiAtLWdpdCBzeXMvbmV0L2lmLmMgc3lzL25ldC9pZi5jCmluZGV4IDRkNDc1ZDkuLjI1MTU5
MjcgMTAwNjQ0Ci0tLSBzeXMvbmV0L2lmLmMKKysrIHN5cy9uZXQvaWYuYwpAQCAtMzM5NCw2ICsz
Mzk0LDcgQEAgaWZfc2V0bGxhZGRyKHN0cnVjdCBpZm5ldCAqaWZwLCBjb25zdCB1X2NoYXIgKmxs
Y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KKwkJaWZyLmlmcl9mbGFnc2hp
Z2ggPSBpZnAtPmlmX2ZsYWdzID4+IDE2OworCQkoKmlmcC0+aWZfaW9jdGwpKGlmcCwgU0lPQ1NJ
RkZMQUdTLCAoY2FkZHJfdCkmaWZyKTsKKwkJaWYgKGlzX3VwKSB7CiAJCQlpZnAtPmlmX2ZsYWdz
IHw9IElGRl9VUDsKIAkJCWlmci5pZnJfZmxhZ3MgPSBpZnAtPmlmX2ZsYWdzICYgMHhmZmZmOwog
CQkJaWZyLmlmcl9mbGFnc2hpZ2ggPSBpZnAtPmlmX2ZsYWdzID4+IDE2Owo=
------=_Part_3111273_1322850569.1465379076220--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?494678734.3111275.1465379076220.JavaMail.zimbra>