All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch net-next] virtio_net: allow to change mac when iface is running
@ 2012-06-27 15:27 Jiri Pirko
  2012-06-28  4:30 ` David Miller
  0 siblings, 1 reply; 5+ messages in thread
From: Jiri Pirko @ 2012-06-27 15:27 UTC (permalink / raw)
  To: netdev; +Cc: davem, rusty, mst, virtualization, brouer

Signed-off-by: Jiri Pirko <jpirko@redhat.com>
---
 drivers/net/virtio_net.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index f18149a..36a16d5 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -679,11 +679,12 @@ static int virtnet_set_mac_address(struct net_device *dev, void *p)
 {
 	struct virtnet_info *vi = netdev_priv(dev);
 	struct virtio_device *vdev = vi->vdev;
-	int ret;
+	struct sockaddr *addr = p;
 
-	ret = eth_mac_addr(dev, p);
-	if (ret)
-		return ret;
+	if (!is_valid_ether_addr(addr->sa_data))
+		return -EADDRNOTAVAIL;
+	memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
+	dev->addr_assign_type &= ~NET_ADDR_RANDOM;
 
 	if (virtio_has_feature(vdev, VIRTIO_NET_F_MAC))
 		vdev->config->set(vdev, offsetof(struct virtio_net_config, mac),
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [patch net-next] virtio_net: allow to change mac when iface is running
  2012-06-27 15:27 [patch net-next] virtio_net: allow to change mac when iface is running Jiri Pirko
@ 2012-06-28  4:30 ` David Miller
  2012-06-28  6:35   ` Jiri Pirko
  0 siblings, 1 reply; 5+ messages in thread
From: David Miller @ 2012-06-28  4:30 UTC (permalink / raw)
  To: jpirko; +Cc: netdev, virtualization, brouer, mst

From: Jiri Pirko <jpirko@redhat.com>
Date: Wed, 27 Jun 2012 17:27:46 +0200

> Signed-off-by: Jiri Pirko <jpirko@redhat.com>

Applied, but this seriously makes eth_mac_addr() completely useless.

Technically, every eth_mac_addr() user in a software/virtual device
should behave the way virtio_net does now.

It therefore probably makes sense to add a boolean arg which when true
elides the netif_running() check then fixup and audit every caller.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [patch net-next] virtio_net: allow to change mac when iface is running
  2012-06-28  4:30 ` David Miller
@ 2012-06-28  6:35   ` Jiri Pirko
  2012-06-28  8:30     ` David Miller
  0 siblings, 1 reply; 5+ messages in thread
From: Jiri Pirko @ 2012-06-28  6:35 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, virtualization, brouer, mst

Thu, Jun 28, 2012 at 06:30:46AM CEST, davem@davemloft.net wrote:
>From: Jiri Pirko <jpirko@redhat.com>
>Date: Wed, 27 Jun 2012 17:27:46 +0200
>
>> Signed-off-by: Jiri Pirko <jpirko@redhat.com>
>
>Applied, but this seriously makes eth_mac_addr() completely useless.
>
>Technically, every eth_mac_addr() user in a software/virtual device
>should behave the way virtio_net does now.

I guess to. But for some HW devices eth_mac_addr() is needed (when they
does not support "life" mac change")

>
>It therefore probably makes sense to add a boolean arg which when true
>elides the netif_running() check then fixup and audit every caller.

I was thinking about this. Maybe probably __eth_mac_addr() which does
not have netif_running() check and eth_mac_addr() calling
netif_running() check and __eth_mac_addr() after that.

What do you think?

Jirka

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [patch net-next] virtio_net: allow to change mac when iface is running
  2012-06-28  6:35   ` Jiri Pirko
@ 2012-06-28  8:30     ` David Miller
  0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2012-06-28  8:30 UTC (permalink / raw)
  To: jpirko; +Cc: netdev, virtualization, brouer, mst

From: Jiri Pirko <jpirko@redhat.com>
Date: Thu, 28 Jun 2012 08:35:25 +0200

> Thu, Jun 28, 2012 at 06:30:46AM CEST, davem@davemloft.net wrote:
>>It therefore probably makes sense to add a boolean arg which when true
>>elides the netif_running() check then fixup and audit every caller.
> 
> I was thinking about this. Maybe probably __eth_mac_addr() which does
> not have netif_running() check and eth_mac_addr() calling
> netif_running() check and __eth_mac_addr() after that.
> 
> What do you think?

Yes, sounds good.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [patch net-next] virtio_net: allow to change mac when iface is running
@ 2012-06-27 15:27 Jiri Pirko
  0 siblings, 0 replies; 5+ messages in thread
From: Jiri Pirko @ 2012-06-27 15:27 UTC (permalink / raw)
  To: netdev; +Cc: brouer, virtualization, davem, mst

Signed-off-by: Jiri Pirko <jpirko@redhat.com>
---
 drivers/net/virtio_net.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index f18149a..36a16d5 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -679,11 +679,12 @@ static int virtnet_set_mac_address(struct net_device *dev, void *p)
 {
 	struct virtnet_info *vi = netdev_priv(dev);
 	struct virtio_device *vdev = vi->vdev;
-	int ret;
+	struct sockaddr *addr = p;
 
-	ret = eth_mac_addr(dev, p);
-	if (ret)
-		return ret;
+	if (!is_valid_ether_addr(addr->sa_data))
+		return -EADDRNOTAVAIL;
+	memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
+	dev->addr_assign_type &= ~NET_ADDR_RANDOM;
 
 	if (virtio_has_feature(vdev, VIRTIO_NET_F_MAC))
 		vdev->config->set(vdev, offsetof(struct virtio_net_config, mac),
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-06-28  8:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-27 15:27 [patch net-next] virtio_net: allow to change mac when iface is running Jiri Pirko
2012-06-28  4:30 ` David Miller
2012-06-28  6:35   ` Jiri Pirko
2012-06-28  8:30     ` David Miller
2012-06-27 15:27 Jiri Pirko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.