Jiri Pirko
2012-Jun-28 14:10 UTC
[patch net-next 0/4] net: introduce and use IFF_LIFE_ADDR_CHANGE
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
Jiri Pirko
2012-Jun-28 14:10 UTC
[patch net-next 1/4] net: introduce new priv_flag indicating iface capable of change mac when running
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 at 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
Jiri Pirko
2012-Jun-28 14:10 UTC
[patch net-next 2/4] virtio_net: use IFF_LIFE_ADDR_CHANGE priv_flag
Signed-off-by: Jiri Pirko <jpirko at 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
Jiri Pirko
2012-Jun-28 14:10 UTC
[patch net-next 3/4] team: use IFF_LIFE_ADDR_CHANGE priv_flag
Signed-off-by: Jiri Pirko <jpirko at 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
Jiri Pirko
2012-Jun-28 14:10 UTC
[patch net-next 4/4] dummy: use IFF_LIFE_ADDR_CHANGE priv_flag
Signed-off-by: Jiri Pirko <jpirko at 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
Richard Cochran
2012-Jun-28 15:15 UTC
[patch net-next 0/4] net: introduce and use IFF_LIFE_ADDR_CHANGE
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_flagI 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 at vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html
Jiri Pirko
2012-Jun-28 15:41 UTC
[patch net-next 0/4] net: introduce and use IFF_LIFE_ADDR_CHANGE
Thu, Jun 28, 2012 at 05:15:07PM CEST, richardcochran at 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 at vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html
Michael S. Tsirkin
2012-Jun-28 19:21 UTC
[patch net-next 2/4] virtio_net: use IFF_LIFE_ADDR_CHANGE priv_flag
On Thu, Jun 28, 2012 at 04:10:37PM +0200, Jiri Pirko wrote:> Signed-off-by: Jiri Pirko <jpirko at redhat.com>FWIW Acked-by: Michael S. Tsirkin <mst at 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
Seemingly Similar Threads
- [patch net-next 0/4] net: introduce and use IFF_LIFE_ADDR_CHANGE
- [patch net-next v2 0/4] net: introduce and use IFF_LIFE_ADDR_CHANGE
- [patch net-next v2 0/4] net: introduce and use IFF_LIFE_ADDR_CHANGE
- [RESEND][PATCH v2 0/2] Part 2: handle addr_assign_type for random addresses
- [RESEND][PATCH v2 0/2] Part 2: handle addr_assign_type for random addresses