virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: netdev@vger.kernel.org, davem@davemloft.net,
	virtualization@lists.linux-foundation.org
Subject: Re: [PATCH net-next] net: virtio: use eth_hw_addr_set()
Date: Wed, 27 Oct 2021 10:55:20 -0400	[thread overview]
Message-ID: <20211027105137-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20211027062640.5d32d7be@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>

On Wed, Oct 27, 2021 at 06:26:40AM -0700, Jakub Kicinski wrote:
> On Wed, 27 Oct 2021 03:23:17 -0400 Michael S. Tsirkin wrote:
> > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> > > index c501b5974aee..b7f35aff8e82 100644
> > > --- a/drivers/net/virtio_net.c
> > > +++ b/drivers/net/virtio_net.c
> > > @@ -3177,12 +3177,16 @@ static int virtnet_probe(struct virtio_device *vdev)
> > >  	dev->max_mtu = MAX_MTU;
> > >  
> > >  	/* Configuration may specify what MAC to use.  Otherwise random. */
> > > -	if (virtio_has_feature(vdev, VIRTIO_NET_F_MAC))
> > > +	if (virtio_has_feature(vdev, VIRTIO_NET_F_MAC)) {
> > > +		u8 addr[MAX_ADDR_LEN];
> > > +
> > >  		virtio_cread_bytes(vdev,
> > >  				   offsetof(struct virtio_net_config, mac),
> > > -				   dev->dev_addr, dev->addr_len);
> > > -	else
> > > +				   addr, dev->addr_len);  
> > 
> > Maybe BUG_ON(dev->addr_len > sizeof addr);
> > 
> > here just to make sure we don't overflow addr silently?
> 
> Since I need to post a v2 and we're talking... can I just use
> eth_hw_addr_set() instead? AFAICT netdev is always allocated with 
> alloc_etherdev_mq() and ->addr_len never changed. Plus there is 
> a number of Ethernet address helpers used so ETH_ALEN is kind of 
> already assumed.


Right. Sure, just document this in the commit log pls.

> > > +		dev_addr_set(dev, addr);
> > > +	} else {
> > >  		eth_hw_addr_random(dev);
> > > +	}
> > >  
> > >  	/* Set up our device-specific information */
> > >  	vi = netdev_priv(dev);

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

      parent reply	other threads:[~2021-10-27 14:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20211026175634.3198477-1-kuba@kernel.org>
2021-10-27  2:45 ` [PATCH net-next] net: virtio: use eth_hw_addr_set() Jason Wang
2021-10-27  7:24   ` Jason Wang
2021-10-27  7:40     ` Michael S. Tsirkin
2021-10-27  7:23 ` Michael S. Tsirkin
     [not found]   ` <20211027062640.5d32d7be@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>
2021-10-27 14:55     ` Michael S. Tsirkin [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=20211027105137-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=virtualization@lists.linux-foundation.org \
    /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;
as well as URLs for NNTP newsgroup(s).