diff mbox series

usb: gadget: u_ether: use eth_hw_addr_set()

Message ID 20211019172124.1413620-1-kuba@kernel.org (mailing list archive)
State Accepted
Commit 99984b081f99ca30bbbebe5490a8328b0a212931
Headers show
Series usb: gadget: u_ether: use eth_hw_addr_set() | expand

Commit Message

Jakub Kicinski Oct. 19, 2021, 5:21 p.m. UTC
Commit 406f42fa0d3c ("net-next: When a bond have a massive amount
of VLANs...") introduced a rbtree for faster Ethernet address look
up. To maintain netdev->dev_addr in this tree we need to make all
the writes to it got through appropriate helpers.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: balbi@kernel.org
CC: gregkh@linuxfoundation.org
CC: lorenzo@google.com
CC: manish.narani@xilinx.com
CC: maze@google.com
CC: linux-usb@vger.kernel.org
---
 drivers/usb/gadget/function/u_ether.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Maciej Żenczykowski Oct. 19, 2021, 6:02 p.m. UTC | #1
On Tue, Oct 19, 2021 at 10:21 AM Jakub Kicinski <kuba@kernel.org> wrote:
>
> Commit 406f42fa0d3c ("net-next: When a bond have a massive amount
> of VLANs...") introduced a rbtree for faster Ethernet address look
> up. To maintain netdev->dev_addr in this tree we need to make all
> the writes to it got through appropriate helpers.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
> CC: balbi@kernel.org
> CC: gregkh@linuxfoundation.org
> CC: lorenzo@google.com
> CC: manish.narani@xilinx.com
> CC: maze@google.com
> CC: linux-usb@vger.kernel.org
> ---
>  drivers/usb/gadget/function/u_ether.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c
> index 85a3f6d4b5af..e0ad5aed6ac9 100644
> --- a/drivers/usb/gadget/function/u_ether.c
> +++ b/drivers/usb/gadget/function/u_ether.c
> @@ -754,6 +754,7 @@ struct eth_dev *gether_setup_name(struct usb_gadget *g,
>         struct eth_dev          *dev;
>         struct net_device       *net;
>         int                     status;
> +       u8                      addr[ETH_ALEN];
>
>         net = alloc_etherdev(sizeof *dev);
>         if (!net)
> @@ -773,9 +774,10 @@ 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, net->dev_addr))
> +       if (get_ether_addr(dev_addr, addr))
>                 dev_warn(&g->dev,
>                         "using random %s ethernet address\n", "self");
> +       eth_hw_addr_set(net, addr);
>         if (get_ether_addr(host_addr, dev->host_mac))
>                 dev_warn(&g->dev,
>                         "using random %s ethernet address\n", "host");
> --
> 2.31.1
>
Reviewed-by: Maciej Żenczykowski <maze@google.com>
diff mbox series

Patch

diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c
index 85a3f6d4b5af..e0ad5aed6ac9 100644
--- a/drivers/usb/gadget/function/u_ether.c
+++ b/drivers/usb/gadget/function/u_ether.c
@@ -754,6 +754,7 @@  struct eth_dev *gether_setup_name(struct usb_gadget *g,
 	struct eth_dev		*dev;
 	struct net_device	*net;
 	int			status;
+	u8			addr[ETH_ALEN];
 
 	net = alloc_etherdev(sizeof *dev);
 	if (!net)
@@ -773,9 +774,10 @@  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, net->dev_addr))
+	if (get_ether_addr(dev_addr, addr))
 		dev_warn(&g->dev,
 			"using random %s ethernet address\n", "self");
+	eth_hw_addr_set(net, addr);
 	if (get_ether_addr(host_addr, dev->host_mac))
 		dev_warn(&g->dev,
 			"using random %s ethernet address\n", "host");