All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch net-next 0/4] net: introduce and use IFF_LIFE_ADDR_CHANGE
@ 2012-06-28 14:10 Jiri Pirko
  2012-06-28 14:10 ` [patch net-next 1/4] net: introduce new priv_flag indicating iface capable of change mac when running Jiri Pirko
                   ` (6 more replies)
  0 siblings, 7 replies; 14+ messages in thread
From: Jiri Pirko @ 2012-06-28 14:10 UTC (permalink / raw)
  To: netdev
  Cc: mst, shimoda.hiroaki, virtualization, danny.kukawka, edumazet, davem

three drivers updated, but this can be used in many others.

Jiri Pirko (4):
  net: introduce new priv_flag indicating iface capable of change mac
    when running
  virtio_net: use IFF_LIFE_ADDR_CHANGE priv_flag
  team: use IFF_LIFE_ADDR_CHANGE priv_flag
  dummy: use IFF_LIFE_ADDR_CHANGE priv_flag

 drivers/net/dummy.c      |   15 ++-------------
 drivers/net/team/team.c  |    9 +++++----
 drivers/net/virtio_net.c |   11 +++++------
 include/linux/if.h       |    2 ++
 net/ethernet/eth.c       |    2 +-
 5 files changed, 15 insertions(+), 24 deletions(-)

-- 
1.7.10.4

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

* [patch net-next 1/4] net: introduce new priv_flag indicating iface capable of change mac when running
  2012-06-28 14:10 [patch net-next 0/4] net: introduce and use IFF_LIFE_ADDR_CHANGE Jiri Pirko
@ 2012-06-28 14:10 ` Jiri Pirko
  2012-06-28 15:24   ` Eric Dumazet
  2012-06-28 22:17   ` Ben Hutchings
  2012-06-28 14:10 ` [patch net-next 2/4] virtio_net: use IFF_LIFE_ADDR_CHANGE priv_flag Jiri Pirko
                   ` (5 subsequent siblings)
  6 siblings, 2 replies; 14+ messages in thread
From: Jiri Pirko @ 2012-06-28 14:10 UTC (permalink / raw)
  To: netdev
  Cc: mst, shimoda.hiroaki, virtualization, danny.kukawka, edumazet, davem

Introduce IFF_LIFE_ADDR_CHANGE priv_flag and use it to disable
netif_running() check in eth_mac_addr()

Signed-off-by: Jiri Pirko <jpirko@redhat.com>
---
 include/linux/if.h |    2 ++
 net/ethernet/eth.c |    2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/linux/if.h b/include/linux/if.h
index f995c66..fd9ee7c 100644
--- a/include/linux/if.h
+++ b/include/linux/if.h
@@ -81,6 +81,8 @@
 #define IFF_UNICAST_FLT	0x20000		/* Supports unicast filtering	*/
 #define IFF_TEAM_PORT	0x40000		/* device used as team port */
 #define IFF_SUPP_NOFCS	0x80000		/* device supports sending custom FCS */
+#define IFF_LIFE_ADDR_CHANGE 0x100000	/* device supports hardware address
+					 * change when it's running */
 
 
 #define IF_GET_IFACE	0x0001		/* for querying only */
diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c
index 36e5880..8f8ded4 100644
--- a/net/ethernet/eth.c
+++ b/net/ethernet/eth.c
@@ -283,7 +283,7 @@ int eth_mac_addr(struct net_device *dev, void *p)
 {
 	struct sockaddr *addr = p;
 
-	if (netif_running(dev))
+	if (!(dev->priv_flags & IFF_LIFE_ADDR_CHANGE) && netif_running(dev))
 		return -EBUSY;
 	if (!is_valid_ether_addr(addr->sa_data))
 		return -EADDRNOTAVAIL;
-- 
1.7.10.4

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

* [patch net-next 2/4] virtio_net: use IFF_LIFE_ADDR_CHANGE priv_flag
  2012-06-28 14:10 [patch net-next 0/4] net: introduce and use IFF_LIFE_ADDR_CHANGE Jiri Pirko
  2012-06-28 14:10 ` [patch net-next 1/4] net: introduce new priv_flag indicating iface capable of change mac when running Jiri Pirko
@ 2012-06-28 14:10 ` Jiri Pirko
  2012-06-28 19:21   ` Michael S. Tsirkin
  2012-06-28 14:10 ` [patch net-next 3/4] team: " Jiri Pirko
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Jiri Pirko @ 2012-06-28 14:10 UTC (permalink / raw)
  To: netdev
  Cc: mst, shimoda.hiroaki, virtualization, danny.kukawka, edumazet, davem

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

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 36a16d5..6a0f526 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -679,12 +679,11 @@ 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;
-	struct sockaddr *addr = p;
+	int 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;
+	ret = eth_mac_addr(dev, p);
+	if (ret)
+		return ret;
 
 	if (virtio_has_feature(vdev, VIRTIO_NET_F_MAC))
 		vdev->config->set(vdev, offsetof(struct virtio_net_config, mac),
@@ -1063,7 +1062,7 @@ static int virtnet_probe(struct virtio_device *vdev)
 		return -ENOMEM;
 
 	/* Set up network device as normal. */
-	dev->priv_flags |= IFF_UNICAST_FLT;
+	dev->priv_flags |= IFF_UNICAST_FLT | IFF_LIFE_ADDR_CHANGE;
 	dev->netdev_ops = &virtnet_netdev;
 	dev->features = NETIF_F_HIGHDMA;
 
-- 
1.7.10.4

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

* [patch net-next 3/4] team: use IFF_LIFE_ADDR_CHANGE priv_flag
  2012-06-28 14:10 [patch net-next 0/4] net: introduce and use IFF_LIFE_ADDR_CHANGE Jiri Pirko
  2012-06-28 14:10 ` [patch net-next 1/4] net: introduce new priv_flag indicating iface capable of change mac when running Jiri Pirko
  2012-06-28 14:10 ` [patch net-next 2/4] virtio_net: use IFF_LIFE_ADDR_CHANGE priv_flag Jiri Pirko
@ 2012-06-28 14:10 ` Jiri Pirko
  2012-06-28 14:10 ` [patch net-next 4/4] dummy: " Jiri Pirko
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 14+ messages in thread
From: Jiri Pirko @ 2012-06-28 14:10 UTC (permalink / raw)
  To: netdev
  Cc: mst, shimoda.hiroaki, virtualization, danny.kukawka, edumazet, davem

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

diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
index 5350eea..019d658 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -1188,10 +1188,11 @@ static int team_set_mac_address(struct net_device *dev, void *p)
 {
 	struct team *team = netdev_priv(dev);
 	struct team_port *port;
-	struct sockaddr *addr = p;
+	int err;
 
-	dev->addr_assign_type &= ~NET_ADDR_RANDOM;
-	memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
+	err = eth_mac_addr(dev, p);
+	if (err)
+		return err;
 	rcu_read_lock();
 	list_for_each_entry_rcu(port, &team->port_list, list)
 		if (team->ops.port_change_mac)
@@ -1393,7 +1394,7 @@ static void team_setup(struct net_device *dev)
 	 * bring us to promisc mode in case a unicast addr is added.
 	 * Let this up to underlay drivers.
 	 */
-	dev->priv_flags |= IFF_UNICAST_FLT;
+	dev->priv_flags |= IFF_UNICAST_FLT | IFF_LIFE_ADDR_CHANGE;
 
 	dev->features |= NETIF_F_LLTX;
 	dev->features |= NETIF_F_GRO;
-- 
1.7.10.4

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

* [patch net-next 4/4] dummy: use IFF_LIFE_ADDR_CHANGE priv_flag
  2012-06-28 14:10 [patch net-next 0/4] net: introduce and use IFF_LIFE_ADDR_CHANGE Jiri Pirko
                   ` (3 preceding siblings ...)
  2012-06-28 14:10 ` [patch net-next 4/4] dummy: " Jiri Pirko
@ 2012-06-28 14:10 ` Jiri Pirko
  2012-06-28 15:15 ` [patch net-next 0/4] net: introduce and use IFF_LIFE_ADDR_CHANGE Richard Cochran
  2012-06-28 15:15 ` Richard Cochran
  6 siblings, 0 replies; 14+ messages in thread
From: Jiri Pirko @ 2012-06-28 14:10 UTC (permalink / raw)
  To: netdev
  Cc: davem, rusty, mst, virtualization, edumazet, danny.kukawka,
	shimoda.hiroaki

Signed-off-by: Jiri Pirko <jpirko@redhat.com>
---
 drivers/net/dummy.c |   15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/drivers/net/dummy.c b/drivers/net/dummy.c
index bab0158..0352246 100644
--- a/drivers/net/dummy.c
+++ b/drivers/net/dummy.c
@@ -40,18 +40,6 @@
 
 static int numdummies = 1;
 
-static int dummy_set_address(struct net_device *dev, void *p)
-{
-	struct sockaddr *sa = p;
-
-	if (!is_valid_ether_addr(sa->sa_data))
-		return -EADDRNOTAVAIL;
-
-	dev->addr_assign_type &= ~NET_ADDR_RANDOM;
-	memcpy(dev->dev_addr, sa->sa_data, ETH_ALEN);
-	return 0;
-}
-
 /* fake multicast ability */
 static void set_multicast_list(struct net_device *dev)
 {
@@ -118,7 +106,7 @@ static const struct net_device_ops dummy_netdev_ops = {
 	.ndo_start_xmit		= dummy_xmit,
 	.ndo_validate_addr	= eth_validate_addr,
 	.ndo_set_rx_mode	= set_multicast_list,
-	.ndo_set_mac_address	= dummy_set_address,
+	.ndo_set_mac_address	= eth_mac_addr,
 	.ndo_get_stats64	= dummy_get_stats64,
 };
 
@@ -134,6 +122,7 @@ static void dummy_setup(struct net_device *dev)
 	dev->tx_queue_len = 0;
 	dev->flags |= IFF_NOARP;
 	dev->flags &= ~IFF_MULTICAST;
+	dev->priv_flags |= IFF_LIFE_ADDR_CHANGE;
 	dev->features	|= NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_TSO;
 	dev->features	|= NETIF_F_HW_CSUM | NETIF_F_HIGHDMA | NETIF_F_LLTX;
 	eth_hw_addr_random(dev);
-- 
1.7.10.4

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

* [patch net-next 4/4] dummy: use IFF_LIFE_ADDR_CHANGE priv_flag
  2012-06-28 14:10 [patch net-next 0/4] net: introduce and use IFF_LIFE_ADDR_CHANGE Jiri Pirko
                   ` (2 preceding siblings ...)
  2012-06-28 14:10 ` [patch net-next 3/4] team: " Jiri Pirko
@ 2012-06-28 14:10 ` Jiri Pirko
  2012-06-28 14:10 ` Jiri Pirko
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 14+ messages in thread
From: Jiri Pirko @ 2012-06-28 14:10 UTC (permalink / raw)
  To: netdev
  Cc: mst, shimoda.hiroaki, virtualization, danny.kukawka, edumazet, davem

Signed-off-by: Jiri Pirko <jpirko@redhat.com>
---
 drivers/net/dummy.c |   15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/drivers/net/dummy.c b/drivers/net/dummy.c
index bab0158..0352246 100644
--- a/drivers/net/dummy.c
+++ b/drivers/net/dummy.c
@@ -40,18 +40,6 @@
 
 static int numdummies = 1;
 
-static int dummy_set_address(struct net_device *dev, void *p)
-{
-	struct sockaddr *sa = p;
-
-	if (!is_valid_ether_addr(sa->sa_data))
-		return -EADDRNOTAVAIL;
-
-	dev->addr_assign_type &= ~NET_ADDR_RANDOM;
-	memcpy(dev->dev_addr, sa->sa_data, ETH_ALEN);
-	return 0;
-}
-
 /* fake multicast ability */
 static void set_multicast_list(struct net_device *dev)
 {
@@ -118,7 +106,7 @@ static const struct net_device_ops dummy_netdev_ops = {
 	.ndo_start_xmit		= dummy_xmit,
 	.ndo_validate_addr	= eth_validate_addr,
 	.ndo_set_rx_mode	= set_multicast_list,
-	.ndo_set_mac_address	= dummy_set_address,
+	.ndo_set_mac_address	= eth_mac_addr,
 	.ndo_get_stats64	= dummy_get_stats64,
 };
 
@@ -134,6 +122,7 @@ static void dummy_setup(struct net_device *dev)
 	dev->tx_queue_len = 0;
 	dev->flags |= IFF_NOARP;
 	dev->flags &= ~IFF_MULTICAST;
+	dev->priv_flags |= IFF_LIFE_ADDR_CHANGE;
 	dev->features	|= NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_TSO;
 	dev->features	|= NETIF_F_HW_CSUM | NETIF_F_HIGHDMA | NETIF_F_LLTX;
 	eth_hw_addr_random(dev);
-- 
1.7.10.4

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

* Re: [patch net-next 0/4] net: introduce and use IFF_LIFE_ADDR_CHANGE
  2012-06-28 14:10 [patch net-next 0/4] net: introduce and use IFF_LIFE_ADDR_CHANGE Jiri Pirko
                   ` (4 preceding siblings ...)
  2012-06-28 14:10 ` Jiri Pirko
@ 2012-06-28 15:15 ` Richard Cochran
  2012-06-28 15:41   ` Jiri Pirko
  2012-06-28 15:15 ` Richard Cochran
  6 siblings, 1 reply; 14+ messages in thread
From: Richard Cochran @ 2012-06-28 15:15 UTC (permalink / raw)
  To: Jiri Pirko
  Cc: netdev, davem, rusty, mst, virtualization, edumazet,
	danny.kukawka, shimoda.hiroaki

On Thu, Jun 28, 2012 at 04:10:35PM +0200, Jiri Pirko wrote:
> three drivers updated, but this can be used in many others.
> 
> Jiri Pirko (4):
>   net: introduce new priv_flag indicating iface capable of change mac
>     when running
>   virtio_net: use IFF_LIFE_ADDR_CHANGE priv_flag
>   team: use IFF_LIFE_ADDR_CHANGE priv_flag
>   dummy: use IFF_LIFE_ADDR_CHANGE priv_flag

I think you must mean LIVE and not LIFE...

Thanks,
Richard


> 
>  drivers/net/dummy.c      |   15 ++-------------
>  drivers/net/team/team.c  |    9 +++++----
>  drivers/net/virtio_net.c |   11 +++++------
>  include/linux/if.h       |    2 ++
>  net/ethernet/eth.c       |    2 +-
>  5 files changed, 15 insertions(+), 24 deletions(-)
> 
> -- 
> 1.7.10.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [patch net-next 0/4] net: introduce and use IFF_LIFE_ADDR_CHANGE
  2012-06-28 14:10 [patch net-next 0/4] net: introduce and use IFF_LIFE_ADDR_CHANGE Jiri Pirko
                   ` (5 preceding siblings ...)
  2012-06-28 15:15 ` [patch net-next 0/4] net: introduce and use IFF_LIFE_ADDR_CHANGE Richard Cochran
@ 2012-06-28 15:15 ` Richard Cochran
  6 siblings, 0 replies; 14+ messages in thread
From: Richard Cochran @ 2012-06-28 15:15 UTC (permalink / raw)
  To: Jiri Pirko
  Cc: mst, netdev, shimoda.hiroaki, virtualization, danny.kukawka,
	edumazet, davem

On Thu, Jun 28, 2012 at 04:10:35PM +0200, Jiri Pirko wrote:
> three drivers updated, but this can be used in many others.
> 
> Jiri Pirko (4):
>   net: introduce new priv_flag indicating iface capable of change mac
>     when running
>   virtio_net: use IFF_LIFE_ADDR_CHANGE priv_flag
>   team: use IFF_LIFE_ADDR_CHANGE priv_flag
>   dummy: use IFF_LIFE_ADDR_CHANGE priv_flag

I think you must mean LIVE and not LIFE...

Thanks,
Richard


> 
>  drivers/net/dummy.c      |   15 ++-------------
>  drivers/net/team/team.c  |    9 +++++----
>  drivers/net/virtio_net.c |   11 +++++------
>  include/linux/if.h       |    2 ++
>  net/ethernet/eth.c       |    2 +-
>  5 files changed, 15 insertions(+), 24 deletions(-)
> 
> -- 
> 1.7.10.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [patch net-next 1/4] net: introduce new priv_flag indicating iface capable of change mac when running
  2012-06-28 14:10 ` [patch net-next 1/4] net: introduce new priv_flag indicating iface capable of change mac when running Jiri Pirko
@ 2012-06-28 15:24   ` Eric Dumazet
  2012-06-28 20:32     ` Michael S. Tsirkin
  2012-06-28 22:17   ` Ben Hutchings
  1 sibling, 1 reply; 14+ messages in thread
From: Eric Dumazet @ 2012-06-28 15:24 UTC (permalink / raw)
  To: Jiri Pirko
  Cc: mst, netdev, shimoda.hiroaki, virtualization, danny.kukawka,
	edumazet, davem

On Thu, 2012-06-28 at 16:10 +0200, Jiri Pirko wrote:
> Introduce IFF_LIFE_ADDR_CHANGE priv_flag and use it to disable
> netif_running() check in eth_mac_addr()
> 
> Signed-off-by: Jiri Pirko <jpirko@redhat.com>
> ---
>  include/linux/if.h |    2 ++
>  net/ethernet/eth.c |    2 +-
>  2 files changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/if.h b/include/linux/if.h
> index f995c66..fd9ee7c 100644
> --- a/include/linux/if.h
> +++ b/include/linux/if.h
> @@ -81,6 +81,8 @@
>  #define IFF_UNICAST_FLT	0x20000		/* Supports unicast filtering	*/
>  #define IFF_TEAM_PORT	0x40000		/* device used as team port */
>  #define IFF_SUPP_NOFCS	0x80000		/* device supports sending custom FCS */
> +#define IFF_LIFE_ADDR_CHANGE 0x100000	/* device supports hardware address
> +					 * change when it's running */
>  
> 
>  #define IF_GET_IFACE	0x0001		/* for querying only */
> diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c
> index 36e5880..8f8ded4 100644
> --- a/net/ethernet/eth.c
> +++ b/net/ethernet/eth.c
> @@ -283,7 +283,7 @@ int eth_mac_addr(struct net_device *dev, void *p)
>  {
>  	struct sockaddr *addr = p;
>  
> -	if (netif_running(dev))
> +	if (!(dev->priv_flags & IFF_LIFE_ADDR_CHANGE) && netif_running(dev))
>  		return -EBUSY;
>  	if (!is_valid_ether_addr(addr->sa_data))
>  		return -EADDRNOTAVAIL;

Since the memcpy() is not atomic, there is a small window where a reader
could get a half-changed mac address. I guess its a detail.

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

* Re: [patch net-next 0/4] net: introduce and use IFF_LIFE_ADDR_CHANGE
  2012-06-28 15:15 ` [patch net-next 0/4] net: introduce and use IFF_LIFE_ADDR_CHANGE Richard Cochran
@ 2012-06-28 15:41   ` Jiri Pirko
  0 siblings, 0 replies; 14+ messages in thread
From: Jiri Pirko @ 2012-06-28 15:41 UTC (permalink / raw)
  To: Richard Cochran
  Cc: mst, netdev, shimoda.hiroaki, virtualization, danny.kukawka,
	edumazet, davem

Thu, Jun 28, 2012 at 05:15:07PM CEST, richardcochran@gmail.com wrote:
>On Thu, Jun 28, 2012 at 04:10:35PM +0200, Jiri Pirko wrote:
>> three drivers updated, but this can be used in many others.
>> 
>> Jiri Pirko (4):
>>   net: introduce new priv_flag indicating iface capable of change mac
>>     when running
>>   virtio_net: use IFF_LIFE_ADDR_CHANGE priv_flag
>>   team: use IFF_LIFE_ADDR_CHANGE priv_flag
>>   dummy: use IFF_LIFE_ADDR_CHANGE priv_flag
>
>I think you must mean LIVE and not LIFE...

Good point. I will change it and repost, but I will give it some time so
people can express themselves.

Thanks!

Jirka
>
>Thanks,
>Richard
>
>
>> 
>>  drivers/net/dummy.c      |   15 ++-------------
>>  drivers/net/team/team.c  |    9 +++++----
>>  drivers/net/virtio_net.c |   11 +++++------
>>  include/linux/if.h       |    2 ++
>>  net/ethernet/eth.c       |    2 +-
>>  5 files changed, 15 insertions(+), 24 deletions(-)
>> 
>> -- 
>> 1.7.10.4
>> 
>> --
>> To unsubscribe from this list: send the line "unsubscribe netdev" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [patch net-next 2/4] virtio_net: use IFF_LIFE_ADDR_CHANGE priv_flag
  2012-06-28 14:10 ` [patch net-next 2/4] virtio_net: use IFF_LIFE_ADDR_CHANGE priv_flag Jiri Pirko
@ 2012-06-28 19:21   ` Michael S. Tsirkin
  0 siblings, 0 replies; 14+ messages in thread
From: Michael S. Tsirkin @ 2012-06-28 19:21 UTC (permalink / raw)
  To: Jiri Pirko
  Cc: netdev, shimoda.hiroaki, virtualization, danny.kukawka, edumazet, davem

On Thu, Jun 28, 2012 at 04:10:37PM +0200, Jiri Pirko wrote:
> Signed-off-by: Jiri Pirko <jpirko@redhat.com>

FWIW

Acked-by: Michael S. Tsirkin <mst@redhat.com>

> ---
>  drivers/net/virtio_net.c |   11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 36a16d5..6a0f526 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -679,12 +679,11 @@ 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;
> -	struct sockaddr *addr = p;
> +	int 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;
> +	ret = eth_mac_addr(dev, p);
> +	if (ret)
> +		return ret;
>  
>  	if (virtio_has_feature(vdev, VIRTIO_NET_F_MAC))
>  		vdev->config->set(vdev, offsetof(struct virtio_net_config, mac),
> @@ -1063,7 +1062,7 @@ static int virtnet_probe(struct virtio_device *vdev)
>  		return -ENOMEM;
>  
>  	/* Set up network device as normal. */
> -	dev->priv_flags |= IFF_UNICAST_FLT;
> +	dev->priv_flags |= IFF_UNICAST_FLT | IFF_LIFE_ADDR_CHANGE;
>  	dev->netdev_ops = &virtnet_netdev;
>  	dev->features = NETIF_F_HIGHDMA;
>  
> -- 
> 1.7.10.4

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

* Re: [patch net-next 1/4] net: introduce new priv_flag indicating iface capable of change mac when running
  2012-06-28 15:24   ` Eric Dumazet
@ 2012-06-28 20:32     ` Michael S. Tsirkin
  0 siblings, 0 replies; 14+ messages in thread
From: Michael S. Tsirkin @ 2012-06-28 20:32 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: Jiri Pirko, netdev, shimoda.hiroaki, virtualization,
	danny.kukawka, edumazet, davem

On Thu, Jun 28, 2012 at 05:24:52PM +0200, Eric Dumazet wrote:
> On Thu, 2012-06-28 at 16:10 +0200, Jiri Pirko wrote:
> > Introduce IFF_LIFE_ADDR_CHANGE priv_flag and use it to disable
> > netif_running() check in eth_mac_addr()
> > 
> > Signed-off-by: Jiri Pirko <jpirko@redhat.com>
> > ---
> >  include/linux/if.h |    2 ++
> >  net/ethernet/eth.c |    2 +-
> >  2 files changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/include/linux/if.h b/include/linux/if.h
> > index f995c66..fd9ee7c 100644
> > --- a/include/linux/if.h
> > +++ b/include/linux/if.h
> > @@ -81,6 +81,8 @@
> >  #define IFF_UNICAST_FLT	0x20000		/* Supports unicast filtering	*/
> >  #define IFF_TEAM_PORT	0x40000		/* device used as team port */
> >  #define IFF_SUPP_NOFCS	0x80000		/* device supports sending custom FCS */
> > +#define IFF_LIFE_ADDR_CHANGE 0x100000	/* device supports hardware address
> > +					 * change when it's running */
> >  
> > 
> >  #define IF_GET_IFACE	0x0001		/* for querying only */
> > diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c
> > index 36e5880..8f8ded4 100644
> > --- a/net/ethernet/eth.c
> > +++ b/net/ethernet/eth.c
> > @@ -283,7 +283,7 @@ int eth_mac_addr(struct net_device *dev, void *p)
> >  {
> >  	struct sockaddr *addr = p;
> >  
> > -	if (netif_running(dev))
> > +	if (!(dev->priv_flags & IFF_LIFE_ADDR_CHANGE) && netif_running(dev))
> >  		return -EBUSY;
> >  	if (!is_valid_ether_addr(addr->sa_data))
> >  		return -EADDRNOTAVAIL;
> 
> Since the memcpy() is not atomic, there is a small window where a reader
> could get a half-changed mac address. I guess its a detail.
> 

At least for virtio nothing changes - we had this bug forever.
How'd you fix this?

-- 
MST

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

* Re: [patch net-next 1/4] net: introduce new priv_flag indicating iface capable of change mac when running
  2012-06-28 14:10 ` [patch net-next 1/4] net: introduce new priv_flag indicating iface capable of change mac when running Jiri Pirko
  2012-06-28 15:24   ` Eric Dumazet
@ 2012-06-28 22:17   ` Ben Hutchings
  2012-06-29  6:41     ` Jiri Pirko
  1 sibling, 1 reply; 14+ messages in thread
From: Ben Hutchings @ 2012-06-28 22:17 UTC (permalink / raw)
  To: Jiri Pirko
  Cc: mst, netdev, shimoda.hiroaki, virtualization, danny.kukawka,
	edumazet, davem

On Thu, 2012-06-28 at 16:10 +0200, Jiri Pirko wrote:
> Introduce IFF_LIFE_ADDR_CHANGE priv_flag and use it to disable
> netif_running() check in eth_mac_addr()
>
> Signed-off-by: Jiri Pirko <jpirko@redhat.com>
> ---
>  include/linux/if.h |    2 ++
>  net/ethernet/eth.c |    2 +-
>  2 files changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/if.h b/include/linux/if.h
> index f995c66..fd9ee7c 100644
> --- a/include/linux/if.h
> +++ b/include/linux/if.h
> @@ -81,6 +81,8 @@
>  #define IFF_UNICAST_FLT	0x20000		/* Supports unicast filtering	*/
>  #define IFF_TEAM_PORT	0x40000		/* device used as team port */
>  #define IFF_SUPP_NOFCS	0x80000		/* device supports sending custom FCS */
> +#define IFF_LIFE_ADDR_CHANGE 0x100000	/* device supports hardware address
> +					 * change when it's running */
[...]

Any device that has IFF_UNICAST_FLT can update the unicast MAC filter
while it's running; doesn't that go hand-in-hand with being able to
handle changes to the primary MAC address?  Is the new flag really
necessary at all?

Ben.

-- 
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.

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

* Re: [patch net-next 1/4] net: introduce new priv_flag indicating iface capable of change mac when running
  2012-06-28 22:17   ` Ben Hutchings
@ 2012-06-29  6:41     ` Jiri Pirko
  0 siblings, 0 replies; 14+ messages in thread
From: Jiri Pirko @ 2012-06-29  6:41 UTC (permalink / raw)
  To: Ben Hutchings
  Cc: mst, netdev, shimoda.hiroaki, virtualization, danny.kukawka,
	edumazet, davem

Fri, Jun 29, 2012 at 12:17:34AM CEST, bhutchings@solarflare.com wrote:
>On Thu, 2012-06-28 at 16:10 +0200, Jiri Pirko wrote:
>> Introduce IFF_LIFE_ADDR_CHANGE priv_flag and use it to disable
>> netif_running() check in eth_mac_addr()
>>
>> Signed-off-by: Jiri Pirko <jpirko@redhat.com>
>> ---
>>  include/linux/if.h |    2 ++
>>  net/ethernet/eth.c |    2 +-
>>  2 files changed, 3 insertions(+), 1 deletion(-)
>> 
>> diff --git a/include/linux/if.h b/include/linux/if.h
>> index f995c66..fd9ee7c 100644
>> --- a/include/linux/if.h
>> +++ b/include/linux/if.h
>> @@ -81,6 +81,8 @@
>>  #define IFF_UNICAST_FLT	0x20000		/* Supports unicast filtering	*/
>>  #define IFF_TEAM_PORT	0x40000		/* device used as team port */
>>  #define IFF_SUPP_NOFCS	0x80000		/* device supports sending custom FCS */
>> +#define IFF_LIFE_ADDR_CHANGE 0x100000	/* device supports hardware address
>> +					 * change when it's running */
>[...]
>
>Any device that has IFF_UNICAST_FLT can update the unicast MAC filter
>while it's running; doesn't that go hand-in-hand with being able to
>handle changes to the primary MAC address?  Is the new flag really
>necessary at all?

Hmm, this makes sense. But, can you guarantee that all devices behave like this?

Also, there are many devices that does not support unicast filtering
and yet they support updating mac adress while running.

Jirka

>
>Ben.
>
>-- 
>Ben Hutchings, Staff Engineer, Solarflare
>Not speaking for my employer; that's the marketing department's job.
>They asked us to note that Solarflare product names are trademarked.
>

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

end of thread, other threads:[~2012-06-29  6:41 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-28 14:10 [patch net-next 0/4] net: introduce and use IFF_LIFE_ADDR_CHANGE Jiri Pirko
2012-06-28 14:10 ` [patch net-next 1/4] net: introduce new priv_flag indicating iface capable of change mac when running Jiri Pirko
2012-06-28 15:24   ` Eric Dumazet
2012-06-28 20:32     ` Michael S. Tsirkin
2012-06-28 22:17   ` Ben Hutchings
2012-06-29  6:41     ` Jiri Pirko
2012-06-28 14:10 ` [patch net-next 2/4] virtio_net: use IFF_LIFE_ADDR_CHANGE priv_flag Jiri Pirko
2012-06-28 19:21   ` Michael S. Tsirkin
2012-06-28 14:10 ` [patch net-next 3/4] team: " Jiri Pirko
2012-06-28 14:10 ` [patch net-next 4/4] dummy: " Jiri Pirko
2012-06-28 14:10 ` Jiri Pirko
2012-06-28 15:15 ` [patch net-next 0/4] net: introduce and use IFF_LIFE_ADDR_CHANGE Richard Cochran
2012-06-28 15:41   ` Jiri Pirko
2012-06-28 15:15 ` Richard Cochran

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.