virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [patch net-next v2 0/4] net: introduce and use IFF_LIFE_ADDR_CHANGE
@ 2012-06-29 15:10 Jiri Pirko
  2012-06-29 15:10 ` [patch net-next v2 1/4] net: introduce new priv_flag indicating iface capable of change mac when running Jiri Pirko
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Jiri Pirko @ 2012-06-29 15: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.

v1->v2:
%s/LIFE/LIVE

Jiri Pirko (4):
  net: introduce new priv_flag indicating iface capable of change mac
    when running
  virtio_net: use IFF_LIVE_ADDR_CHANGE priv_flag
  team: use IFF_LIVE_ADDR_CHANGE priv_flag
  dummy: use IFF_LIVE_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] 6+ messages in thread

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

Introduce IFF_LIVE_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..1ec407b 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_LIVE_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..db6a6c1 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_LIVE_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] 6+ messages in thread

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

Acked-by: Michael S. Tsirkin <mst@redhat.com>
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..1db445b 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_LIVE_ADDR_CHANGE;
 	dev->netdev_ops = &virtnet_netdev;
 	dev->features = NETIF_F_HIGHDMA;
 
-- 
1.7.10.4

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

* [patch net-next v2 3/4] team: use IFF_LIVE_ADDR_CHANGE priv_flag
  2012-06-29 15:10 [patch net-next v2 0/4] net: introduce and use IFF_LIFE_ADDR_CHANGE Jiri Pirko
  2012-06-29 15:10 ` [patch net-next v2 1/4] net: introduce new priv_flag indicating iface capable of change mac when running Jiri Pirko
  2012-06-29 15:10 ` [patch net-next v2 2/4] virtio_net: use IFF_LIVE_ADDR_CHANGE priv_flag Jiri Pirko
@ 2012-06-29 15:10 ` Jiri Pirko
  2012-06-29 15:10 ` [patch net-next v2 4/4] dummy: " Jiri Pirko
  2012-06-30  8:08 ` [patch net-next v2 0/4] net: introduce and use IFF_LIFE_ADDR_CHANGE David Miller
  4 siblings, 0 replies; 6+ messages in thread
From: Jiri Pirko @ 2012-06-29 15: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 89853c3..9b94f53 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_LIVE_ADDR_CHANGE;
 
 	dev->features |= NETIF_F_LLTX;
 	dev->features |= NETIF_F_GRO;
-- 
1.7.10.4

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

* [patch net-next v2 4/4] dummy: use IFF_LIVE_ADDR_CHANGE priv_flag
  2012-06-29 15:10 [patch net-next v2 0/4] net: introduce and use IFF_LIFE_ADDR_CHANGE Jiri Pirko
                   ` (2 preceding siblings ...)
  2012-06-29 15:10 ` [patch net-next v2 3/4] team: " Jiri Pirko
@ 2012-06-29 15:10 ` Jiri Pirko
  2012-06-30  8:08 ` [patch net-next v2 0/4] net: introduce and use IFF_LIFE_ADDR_CHANGE David Miller
  4 siblings, 0 replies; 6+ messages in thread
From: Jiri Pirko @ 2012-06-29 15: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..9d6a067 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_LIVE_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] 6+ messages in thread

* Re: [patch net-next v2 0/4] net: introduce and use IFF_LIFE_ADDR_CHANGE
  2012-06-29 15:10 [patch net-next v2 0/4] net: introduce and use IFF_LIFE_ADDR_CHANGE Jiri Pirko
                   ` (3 preceding siblings ...)
  2012-06-29 15:10 ` [patch net-next v2 4/4] dummy: " Jiri Pirko
@ 2012-06-30  8:08 ` David Miller
  4 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2012-06-30  8:08 UTC (permalink / raw)
  To: jpirko
  Cc: mst, netdev, shimoda.hiroaki, virtualization, danny.kukawka,
	edumazet

From: Jiri Pirko <jpirko@redhat.com>
Date: Fri, 29 Jun 2012 17:10:04 +0200

> three drivers updated, but this can be used in many others.
> 
> v1->v2:
> %s/LIFE/LIVE
> 
> Jiri Pirko (4):
>   net: introduce new priv_flag indicating iface capable of change mac
>     when running
>   virtio_net: use IFF_LIVE_ADDR_CHANGE priv_flag
>   team: use IFF_LIVE_ADDR_CHANGE priv_flag
>   dummy: use IFF_LIVE_ADDR_CHANGE priv_flag

Applied, thanks Jiri.

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

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

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-29 15:10 [patch net-next v2 0/4] net: introduce and use IFF_LIFE_ADDR_CHANGE Jiri Pirko
2012-06-29 15:10 ` [patch net-next v2 1/4] net: introduce new priv_flag indicating iface capable of change mac when running Jiri Pirko
2012-06-29 15:10 ` [patch net-next v2 2/4] virtio_net: use IFF_LIVE_ADDR_CHANGE priv_flag Jiri Pirko
2012-06-29 15:10 ` [patch net-next v2 3/4] team: " Jiri Pirko
2012-06-29 15:10 ` [patch net-next v2 4/4] dummy: " Jiri Pirko
2012-06-30  8:08 ` [patch net-next v2 0/4] net: introduce and use IFF_LIFE_ADDR_CHANGE David Miller

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).