netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/4] vrf: a few simplifications and cleanups
@ 2015-08-18 17:28 Nikolay Aleksandrov
  2015-08-18 17:28 ` [PATCH net-next 1/4] vrf: drop unnecessary dev refcnt changes Nikolay Aleksandrov
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Nikolay Aleksandrov @ 2015-08-18 17:28 UTC (permalink / raw)
  To: netdev; +Cc: dsa, shm, davem, Nikolay Aleksandrov

From: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>

Hi,
These patches remove some unnecessary checks (patches 3, 4), unnecessary
num_slaves member and refcnt manipulations which are already done by the
upper functions.

Cheers,
 Nik

Nikolay Aleksandrov (4):
  vrf: drop unnecessary dev refcnt changes
  vrf: drop unused num_slaves member
  vrf: don't check for dstats and rth in uninit path
  vrf: simplify the netdev notifier function

 drivers/net/vrf.c | 15 ++++-----------
 include/net/vrf.h |  1 -
 2 files changed, 4 insertions(+), 12 deletions(-)

-- 
2.4.3

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

* [PATCH net-next 1/4] vrf: drop unnecessary dev refcnt changes
  2015-08-18 17:28 [PATCH net-next 0/4] vrf: a few simplifications and cleanups Nikolay Aleksandrov
@ 2015-08-18 17:28 ` Nikolay Aleksandrov
  2015-08-18 17:28 ` [PATCH net-next 2/4] vrf: drop unused num_slaves member Nikolay Aleksandrov
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Nikolay Aleksandrov @ 2015-08-18 17:28 UTC (permalink / raw)
  To: netdev; +Cc: dsa, shm, davem, Nikolay Aleksandrov

From: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>

netdev_master_upper_dev_link/unlink already do a dev_hold/put on the
devices being linked, so no need to take another reference.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
---
 drivers/net/vrf.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
index 95097cb79354..cd4bc77f2e04 100644
--- a/drivers/net/vrf.c
+++ b/drivers/net/vrf.c
@@ -334,14 +334,12 @@ static struct slave *__vrf_find_slave_dev(struct slave_queue *queue,
 /* inverse of __vrf_insert_slave */
 static void __vrf_remove_slave(struct slave_queue *queue, struct slave *slave)
 {
-	dev_put(slave->dev);
 	list_del(&slave->list);
 	queue->num_slaves--;
 }
 
 static void __vrf_insert_slave(struct slave_queue *queue, struct slave *slave)
 {
-	dev_hold(slave->dev);
 	list_add(&slave->list, &queue->all_slaves);
 	queue->num_slaves++;
 }
-- 
2.4.3

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

* [PATCH net-next 2/4] vrf: drop unused num_slaves member
  2015-08-18 17:28 [PATCH net-next 0/4] vrf: a few simplifications and cleanups Nikolay Aleksandrov
  2015-08-18 17:28 ` [PATCH net-next 1/4] vrf: drop unnecessary dev refcnt changes Nikolay Aleksandrov
@ 2015-08-18 17:28 ` Nikolay Aleksandrov
  2015-08-18 17:28 ` [PATCH net-next 3/4] vrf: don't check for dstats and rth in uninit path Nikolay Aleksandrov
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Nikolay Aleksandrov @ 2015-08-18 17:28 UTC (permalink / raw)
  To: netdev; +Cc: dsa, shm, davem, Nikolay Aleksandrov

From: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>

slave_queue has a num_slaves member which is unused, drop it.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
---
 drivers/net/vrf.c | 2 --
 include/net/vrf.h | 1 -
 2 files changed, 3 deletions(-)

diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
index cd4bc77f2e04..3d7da0c6f827 100644
--- a/drivers/net/vrf.c
+++ b/drivers/net/vrf.c
@@ -335,13 +335,11 @@ static struct slave *__vrf_find_slave_dev(struct slave_queue *queue,
 static void __vrf_remove_slave(struct slave_queue *queue, struct slave *slave)
 {
 	list_del(&slave->list);
-	queue->num_slaves--;
 }
 
 static void __vrf_insert_slave(struct slave_queue *queue, struct slave *slave)
 {
 	list_add(&slave->list, &queue->all_slaves);
-	queue->num_slaves++;
 }
 
 static int do_vrf_add_slave(struct net_device *dev, struct net_device *port_dev)
diff --git a/include/net/vrf.h b/include/net/vrf.h
index 40e3793c7a05..3bb4af462ed6 100644
--- a/include/net/vrf.h
+++ b/include/net/vrf.h
@@ -24,7 +24,6 @@ struct slave {
 
 struct slave_queue {
 	struct list_head	all_slaves;
-	int			num_slaves;
 };
 
 struct net_vrf {
-- 
2.4.3

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

* [PATCH net-next 3/4] vrf: don't check for dstats and rth in uninit path
  2015-08-18 17:28 [PATCH net-next 0/4] vrf: a few simplifications and cleanups Nikolay Aleksandrov
  2015-08-18 17:28 ` [PATCH net-next 1/4] vrf: drop unnecessary dev refcnt changes Nikolay Aleksandrov
  2015-08-18 17:28 ` [PATCH net-next 2/4] vrf: drop unused num_slaves member Nikolay Aleksandrov
@ 2015-08-18 17:28 ` Nikolay Aleksandrov
  2015-08-18 17:28 ` [PATCH net-next 4/4] vrf: simplify the netdev notifier function Nikolay Aleksandrov
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Nikolay Aleksandrov @ 2015-08-18 17:28 UTC (permalink / raw)
  To: netdev; +Cc: dsa, shm, davem, Nikolay Aleksandrov

From: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>

dstats and rth are always present because we fail the device registration
if they can't be allocated in vrf_init() (ndo_init) so drop the unnecessary
checks.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
---
 drivers/net/vrf.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
index 3d7da0c6f827..97605eab14ae 100644
--- a/drivers/net/vrf.c
+++ b/drivers/net/vrf.c
@@ -265,8 +265,7 @@ static void vrf_rtable_destroy(struct net_vrf *vrf)
 {
 	struct dst_entry *dst = (struct dst_entry *)vrf->rth;
 
-	if (dst)
-		dst_destroy(dst);
+	dst_destroy(dst);
 	vrf->rth = NULL;
 }
 
@@ -455,8 +454,7 @@ static void vrf_dev_uninit(struct net_device *dev)
 	list_for_each_entry_safe(slave, next, head, list)
 		vrf_del_slave(dev, slave->dev);
 
-	if (dev->dstats)
-		free_percpu(dev->dstats);
+	free_percpu(dev->dstats);
 	dev->dstats = NULL;
 }
 
-- 
2.4.3

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

* [PATCH net-next 4/4] vrf: simplify the netdev notifier function
  2015-08-18 17:28 [PATCH net-next 0/4] vrf: a few simplifications and cleanups Nikolay Aleksandrov
                   ` (2 preceding siblings ...)
  2015-08-18 17:28 ` [PATCH net-next 3/4] vrf: don't check for dstats and rth in uninit path Nikolay Aleksandrov
@ 2015-08-18 17:28 ` Nikolay Aleksandrov
  2015-08-18 19:38 ` [PATCH net-next 0/4] vrf: a few simplifications and cleanups David Ahern
  2015-08-19  3:17 ` David Miller
  5 siblings, 0 replies; 7+ messages in thread
From: Nikolay Aleksandrov @ 2015-08-18 17:28 UTC (permalink / raw)
  To: netdev; +Cc: dsa, shm, davem, Nikolay Aleksandrov

From: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>

We can drop the check because if vrf_ptr is present then we must have
the vrf device as a master and since we're running with rtnl it can't go
away.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
---
 drivers/net/vrf.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
index 97605eab14ae..ed208317cbb5 100644
--- a/drivers/net/vrf.c
+++ b/drivers/net/vrf.c
@@ -624,9 +624,8 @@ static int vrf_device_event(struct notifier_block *unused,
 		if (!vrf_ptr || netif_is_vrf(dev))
 			goto out;
 
-		vrf_dev = __dev_get_by_index(dev_net(dev), vrf_ptr->ifindex);
-		if (vrf_dev)
-			vrf_del_slave(vrf_dev, dev);
+		vrf_dev = netdev_master_upper_dev_get(dev);
+		vrf_del_slave(vrf_dev, dev);
 	}
 out:
 	return NOTIFY_DONE;
-- 
2.4.3

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

* Re: [PATCH net-next 0/4] vrf: a few simplifications and cleanups
  2015-08-18 17:28 [PATCH net-next 0/4] vrf: a few simplifications and cleanups Nikolay Aleksandrov
                   ` (3 preceding siblings ...)
  2015-08-18 17:28 ` [PATCH net-next 4/4] vrf: simplify the netdev notifier function Nikolay Aleksandrov
@ 2015-08-18 19:38 ` David Ahern
  2015-08-19  3:17 ` David Miller
  5 siblings, 0 replies; 7+ messages in thread
From: David Ahern @ 2015-08-18 19:38 UTC (permalink / raw)
  To: Nikolay Aleksandrov, netdev; +Cc: shm, davem, Nikolay Aleksandrov

On 8/18/15 11:28 AM, Nikolay Aleksandrov wrote:
> From: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
>
> Hi,
> These patches remove some unnecessary checks (patches 3, 4), unnecessary
> num_slaves member and refcnt manipulations which are already done by the
> upper functions.
>
> Cheers,
>   Nik
>
> Nikolay Aleksandrov (4):
>    vrf: drop unnecessary dev refcnt changes
>    vrf: drop unused num_slaves member
>    vrf: don't check for dstats and rth in uninit path
>    vrf: simplify the netdev notifier function
>
>   drivers/net/vrf.c | 15 ++++-----------
>   include/net/vrf.h |  1 -
>   2 files changed, 4 insertions(+), 12 deletions(-)
>

Looks good to me. Thanks, Nikolay.

Acked-by: David Ahern <dsa@cumulusnetworks.com>

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

* Re: [PATCH net-next 0/4] vrf: a few simplifications and cleanups
  2015-08-18 17:28 [PATCH net-next 0/4] vrf: a few simplifications and cleanups Nikolay Aleksandrov
                   ` (4 preceding siblings ...)
  2015-08-18 19:38 ` [PATCH net-next 0/4] vrf: a few simplifications and cleanups David Ahern
@ 2015-08-19  3:17 ` David Miller
  5 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2015-08-19  3:17 UTC (permalink / raw)
  To: razor; +Cc: netdev, dsa, shm, nikolay

From: Nikolay Aleksandrov <razor@blackwall.org>
Date: Tue, 18 Aug 2015 20:28:00 +0300

> These patches remove some unnecessary checks (patches 3, 4), unnecessary
> num_slaves member and refcnt manipulations which are already done by the
> upper functions.

Series applied, thanks.

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

end of thread, other threads:[~2015-08-19  3:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-18 17:28 [PATCH net-next 0/4] vrf: a few simplifications and cleanups Nikolay Aleksandrov
2015-08-18 17:28 ` [PATCH net-next 1/4] vrf: drop unnecessary dev refcnt changes Nikolay Aleksandrov
2015-08-18 17:28 ` [PATCH net-next 2/4] vrf: drop unused num_slaves member Nikolay Aleksandrov
2015-08-18 17:28 ` [PATCH net-next 3/4] vrf: don't check for dstats and rth in uninit path Nikolay Aleksandrov
2015-08-18 17:28 ` [PATCH net-next 4/4] vrf: simplify the netdev notifier function Nikolay Aleksandrov
2015-08-18 19:38 ` [PATCH net-next 0/4] vrf: a few simplifications and cleanups David Ahern
2015-08-19  3:17 ` 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).