diff mbox series

[5.10,03/29] vdpa_sim: store parsed MAC address in a buffer

Message ID 20210222121020.153222666@linuxfoundation.org
State New
Headers show
Series None | expand

Commit Message

Greg KH Feb. 22, 2021, 12:12 p.m. UTC
From: Stefano Garzarella <sgarzare@redhat.com>

commit cf1a3b35382c10ce315c32bd2b3d7789897fbe13 upstream.

As preparation for the next patches, we store the MAC address,
parsed during the vdpasim_create(), in a buffer that will be used
to fill 'config' together with other configurations.

Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Link: https://lore.kernel.org/r/20201215144256.155342-11-sgarzare@redhat.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/vdpa/vdpa_sim/vdpa_sim.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Comments

Pavel Machek Feb. 22, 2021, 7:54 p.m. UTC | #1
Hi!

> From: Stefano Garzarella <sgarzare@redhat.com>
> 
> commit cf1a3b35382c10ce315c32bd2b3d7789897fbe13 upstream.
> 
> As preparation for the next patches, we store the MAC address,
> parsed during the vdpasim_create(), in a buffer that will be used
> to fill 'config' together with other configurations.

I'm not sure why this series is in stable. It is not documented to fix
anything bad. 

> +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c
> @@ -42,6 +42,8 @@ static char *macaddr;
>  module_param(macaddr, charp, 0);
>  MODULE_PARM_DESC(macaddr, "Ethernet MAC address");
>  
> +u8 macaddr_buf[ETH_ALEN];
> +

Should this be static?

Best regards,
								Pavel
Greg KH Feb. 23, 2021, 4:49 a.m. UTC | #2
On Mon, Feb 22, 2021 at 08:54:15PM +0100, Pavel Machek wrote:
> Hi!

> 

> > From: Stefano Garzarella <sgarzare@redhat.com>

> > 

> > commit cf1a3b35382c10ce315c32bd2b3d7789897fbe13 upstream.

> > 

> > As preparation for the next patches, we store the MAC address,

> > parsed during the vdpasim_create(), in a buffer that will be used

> > to fill 'config' together with other configurations.

> 

> I'm not sure why this series is in stable. It is not documented to fix

> anything bad. 


Please see https://lore.kernel.org/r/20210211162519.215418-1-sgarzare@redhat.com
Stefano Garzarella Feb. 23, 2021, 8:06 a.m. UTC | #3
On Mon, Feb 22, 2021 at 08:54:15PM +0100, Pavel Machek wrote:
>Hi!

>

>> From: Stefano Garzarella <sgarzare@redhat.com>

>>

>> commit cf1a3b35382c10ce315c32bd2b3d7789897fbe13 upstream.

>>

>> As preparation for the next patches, we store the MAC address,

>> parsed during the vdpasim_create(), in a buffer that will be used

>> to fill 'config' together with other configurations.

>

>I'm not sure why this series is in stable. It is not documented to fix

>anything bad.

>

>> +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c

>> @@ -42,6 +42,8 @@ static char *macaddr;

>>  module_param(macaddr, charp, 0);

>>  MODULE_PARM_DESC(macaddr, "Ethernet MAC address");

>>

>> +u8 macaddr_buf[ETH_ALEN];

>> +

>

>Should this be static?


Yes, there is already a patch [1] queued by Michael but not yet 
upstream. When it will be merged upstream I will make sure it will be 
backported.

Thanks,
Stefano

[1] 
https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git/commit/?h=linux-next&id=8c0bea4adac9f1f9ac827210fa8862be4bde6290
Pavel Machek Feb. 24, 2021, 8:29 a.m. UTC | #4
Hi!

> >>+++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c

> >>@@ -42,6 +42,8 @@ static char *macaddr;

> >> module_param(macaddr, charp, 0);

> >> MODULE_PARM_DESC(macaddr, "Ethernet MAC address");

> >>

> >>+u8 macaddr_buf[ETH_ALEN];

> >>+

> >

> >Should this be static?

> 

> Yes, there is already a patch [1] queued by Michael but not yet upstream.

> When it will be merged upstream I will make sure it will be backported.


Having it in mainline is enough, I don't really think it causes
anything user-visible, so it does not need to be in stable.

Best regards,
								Pavel
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Stefano Garzarella Feb. 24, 2021, 8:36 a.m. UTC | #5
On Wed, Feb 24, 2021 at 09:29:54AM +0100, Pavel Machek wrote:
>Hi!

>

>> >>+++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c

>> >>@@ -42,6 +42,8 @@ static char *macaddr;

>> >> module_param(macaddr, charp, 0);

>> >> MODULE_PARM_DESC(macaddr, "Ethernet MAC address");

>> >>

>> >>+u8 macaddr_buf[ETH_ALEN];

>> >>+

>> >

>> >Should this be static?

>>

>> Yes, there is already a patch [1] queued by Michael but not yet upstream.

>> When it will be merged upstream I will make sure it will be backported.

>

>Having it in mainline is enough, I don't really think it causes

>anything user-visible, so it does not need to be in stable.


Got it.

Thanks,
Stefano
diff mbox series

Patch

--- a/drivers/vdpa/vdpa_sim/vdpa_sim.c
+++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c
@@ -42,6 +42,8 @@  static char *macaddr;
 module_param(macaddr, charp, 0);
 MODULE_PARM_DESC(macaddr, "Ethernet MAC address");
 
+u8 macaddr_buf[ETH_ALEN];
+
 struct vdpasim_virtqueue {
 	struct vringh vring;
 	struct vringh_kiov iov;
@@ -392,13 +394,13 @@  static struct vdpasim *vdpasim_create(st
 		goto err_iommu;
 
 	if (macaddr) {
-		mac_pton(macaddr, vdpasim->config.mac);
-		if (!is_valid_ether_addr(vdpasim->config.mac)) {
+		mac_pton(macaddr, macaddr_buf);
+		if (!is_valid_ether_addr(macaddr_buf)) {
 			ret = -EADDRNOTAVAIL;
 			goto err_iommu;
 		}
 	} else {
-		eth_random_addr(vdpasim->config.mac);
+		eth_random_addr(macaddr_buf);
 	}
 
 	for (i = 0; i < dev_attr->nvqs; i++)
@@ -532,6 +534,8 @@  static int vdpasim_set_features(struct v
 
 	config->mtu = cpu_to_vdpasim16(vdpasim, 1500);
 	config->status = cpu_to_vdpasim16(vdpasim, VIRTIO_NET_S_LINK_UP);
+	memcpy(config->mac, macaddr_buf, ETH_ALEN);
+
 	return 0;
 }