From: Maximilian Senftleben <kernel@mail.msdigital.de>
To: Marian Postevca <posteuca@mutex.one>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: PROBLEM: No static MAC address for usb gadget ethernet via kernel parameter any more.
Date: Tue, 31 May 2022 10:38:21 +0200 [thread overview]
Message-ID: <689d5b9d-3d1e-75be-ea0d-250e16b6d85c@mail.msdigital.de> (raw)
In-Reply-To: <87tu9cpyv6.fsf@mutex.one>
Just tested, the fix works for me.
Am 26.05.2022 um 08:54 schrieb Marian Postevca:
> Could you test if this patch fixes the issue for you?
> Should apply without problems on kernel 5.17.
> ---
> drivers/usb/gadget/function/u_ether.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c
> index 6f5d45ef2e39a..b5bf51cdc3c8f 100644
> --- a/drivers/usb/gadget/function/u_ether.c
> +++ b/drivers/usb/gadget/function/u_ether.c
> @@ -775,9 +775,14 @@ struct eth_dev *gether_setup_name(struct usb_gadget *g,
> dev->qmult = qmult;
> snprintf(net->name, sizeof(net->name), "%s%%d", netname);
>
> - if (get_ether_addr(dev_addr, addr))
> + if (get_ether_addr(dev_addr, addr)) {
> + net->addr_assign_type = NET_ADDR_RANDOM;
> dev_warn(&g->dev,
> "using random %s ethernet address\n", "self");
> + }
> + else {
> + net->addr_assign_type = NET_ADDR_SET;
> + }
> eth_hw_addr_set(net, addr);
> if (get_ether_addr(host_addr, dev->host_mac))
> dev_warn(&g->dev,
> @@ -835,6 +840,9 @@ struct net_device *gether_setup_name_default(const char *netname)
> INIT_LIST_HEAD(&dev->tx_reqs);
> INIT_LIST_HEAD(&dev->rx_reqs);
>
> + /* by default we always have a random MAC address */
> + net->addr_assign_type = NET_ADDR_RANDOM;
> +
> skb_queue_head_init(&dev->rx_frames);
>
> /* network device setup */
> @@ -871,7 +879,6 @@ int gether_register_netdev(struct net_device *net)
> dev = netdev_priv(net);
> g = dev->gadget;
>
> - net->addr_assign_type = NET_ADDR_RANDOM;
> eth_hw_addr_set(net, dev->dev_mac);
>
> status = register_netdev(net);
> @@ -912,6 +919,7 @@ int gether_set_dev_addr(struct net_device *net, const char *dev_addr)
> if (get_ether_addr(dev_addr, new_addr))
> return -EINVAL;
> memcpy(dev->dev_mac, new_addr, ETH_ALEN);
> + net->addr_assign_type = NET_ADDR_SET;
> return 0;
> }
> EXPORT_SYMBOL_GPL(gether_set_dev_addr);
prev parent reply other threads:[~2022-05-31 8:38 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-12 13:38 Maximilian Senftleben
2022-05-12 21:34 ` Marian Postevca
2022-05-17 18:55 ` Marian Postevca
2022-05-18 10:00 ` Maximilian Senftleben
[not found] ` <83b013eb-b320-f397-0ecc-f4824f3f45b9@msdigital.de>
2022-05-22 20:17 ` Marian Postevca
2022-05-23 14:36 ` Maximilian Senftleben
2022-05-26 6:54 ` Marian Postevca
2022-05-31 8:38 ` Maximilian Senftleben [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=689d5b9d-3d1e-75be-ea0d-250e16b6d85c@mail.msdigital.de \
--to=kernel@mail.msdigital.de \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=posteuca@mutex.one \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®