netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch net v2 0/2] mlxsw: Couple of fixes
@ 2016-11-11 15:34 Jiri Pirko
  2016-11-11 15:34 ` [patch net v2 1/2] mlxsw: spectrum: Fix refcount bug on span entries Jiri Pirko
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Jiri Pirko @ 2016-11-11 15:34 UTC (permalink / raw)
  To: netdev; +Cc: davem, yotamg, arkadis, idosch, eladr, nogahf, ogerlitz

From: Jiri Pirko <jiri@mellanox.com>

Please, queue-up both for stable. Thanks!

---
v1->v2:
- patch 1:
 - fix this rather by initializing refcount to 1
 - fix typo in description
- patch 2:
 - remove an extra space
 - fix the description

Arkadi Sharshevsky (1):
  mlxsw: spectrum_router: Correctly dump neighbour activity

Yotam Gigi (1):
  mlxsw: spectrum: Fix refcount bug on span entries

 drivers/net/ethernet/mellanox/mlxsw/spectrum.c     |  4 +++-
 .../net/ethernet/mellanox/mlxsw/spectrum_router.c  | 22 +++++++++++++++++++++-
 2 files changed, 24 insertions(+), 2 deletions(-)

-- 
2.7.4

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

* [patch net v2 1/2] mlxsw: spectrum: Fix refcount bug on span entries
  2016-11-11 15:34 [patch net v2 0/2] mlxsw: Couple of fixes Jiri Pirko
@ 2016-11-11 15:34 ` Jiri Pirko
  2016-11-11 15:34 ` [patch net v2 2/2] mlxsw: spectrum_router: Correctly dump neighbour activity Jiri Pirko
  2016-11-13 17:51 ` [patch net v2 0/2] mlxsw: Couple of fixes David Miller
  2 siblings, 0 replies; 5+ messages in thread
From: Jiri Pirko @ 2016-11-11 15:34 UTC (permalink / raw)
  To: netdev; +Cc: davem, yotamg, arkadis, idosch, eladr, nogahf, ogerlitz

From: Yotam Gigi <yotamg@mellanox.com>

When binding port to a newly created span entry, its refcount is
initialized to zero even though it has a bound port. That leads
to unexpected behaviour when the user tries to delete that port
from the span entry.

Fix this by initializing the reference count to 1.

Also add a warning to put function.

Fixes: 763b4b70afcd ("mlxsw: spectrum: Add support in matchall mirror TC offloading")
Signed-off-by: Yotam Gigi <yotamg@mellanox.com>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
v1->v2:
- fix this rather by initializing refcount to 1
- fix typo in description
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
index 1ec0a4c..dda5761 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
@@ -231,7 +231,7 @@ mlxsw_sp_span_entry_create(struct mlxsw_sp_port *port)
 
 	span_entry->used = true;
 	span_entry->id = index;
-	span_entry->ref_count = 0;
+	span_entry->ref_count = 1;
 	span_entry->local_port = local_port;
 	return span_entry;
 }
@@ -270,6 +270,7 @@ static struct mlxsw_sp_span_entry
 
 	span_entry = mlxsw_sp_span_entry_find(port);
 	if (span_entry) {
+		/* Already exists, just take a reference */
 		span_entry->ref_count++;
 		return span_entry;
 	}
@@ -280,6 +281,7 @@ static struct mlxsw_sp_span_entry
 static int mlxsw_sp_span_entry_put(struct mlxsw_sp *mlxsw_sp,
 				   struct mlxsw_sp_span_entry *span_entry)
 {
+	WARN_ON(!span_entry->ref_count);
 	if (--span_entry->ref_count == 0)
 		mlxsw_sp_span_entry_destroy(mlxsw_sp, span_entry);
 	return 0;
-- 
2.7.4

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

* [patch net v2 2/2] mlxsw: spectrum_router: Correctly dump neighbour activity
  2016-11-11 15:34 [patch net v2 0/2] mlxsw: Couple of fixes Jiri Pirko
  2016-11-11 15:34 ` [patch net v2 1/2] mlxsw: spectrum: Fix refcount bug on span entries Jiri Pirko
@ 2016-11-11 15:34 ` Jiri Pirko
  2016-11-13 17:51 ` [patch net v2 0/2] mlxsw: Couple of fixes David Miller
  2 siblings, 0 replies; 5+ messages in thread
From: Jiri Pirko @ 2016-11-11 15:34 UTC (permalink / raw)
  To: netdev; +Cc: davem, yotamg, arkadis, idosch, eladr, nogahf, ogerlitz

From: Arkadi Sharshevsky <arkadis@mellanox.com>

The device's neighbour table is periodically dumped in order to update
the kernel about active neighbours. A single dump session may span
multiple queries, until the response carries less records than requested
or when a record (can contain up to four neighbour entries) is not full.
Current code stops the session when the number of returned records is
zero, which can result in infinite loop in case of high packet rate.

Fix this by stopping the session according to the above logic.

Fixes: c723c735fa6b ("mlxsw: spectrum_router: Periodically update the kernel's neigh table")
Signed-off-by: Arkadi Sharshevsky <arkadis@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
v1->v2:
- remove an extra space
- fix the description
---
 .../net/ethernet/mellanox/mlxsw/spectrum_router.c  | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
index 040737e..cbeeddd 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
@@ -800,6 +800,26 @@ static void mlxsw_sp_router_neigh_rec_process(struct mlxsw_sp *mlxsw_sp,
 	}
 }
 
+static bool mlxsw_sp_router_rauhtd_is_full(char *rauhtd_pl)
+{
+	u8 num_rec, last_rec_index, num_entries;
+
+	num_rec = mlxsw_reg_rauhtd_num_rec_get(rauhtd_pl);
+	last_rec_index = num_rec - 1;
+
+	if (num_rec < MLXSW_REG_RAUHTD_REC_MAX_NUM)
+		return false;
+	if (mlxsw_reg_rauhtd_rec_type_get(rauhtd_pl, last_rec_index) ==
+	    MLXSW_REG_RAUHTD_TYPE_IPV6)
+		return true;
+
+	num_entries = mlxsw_reg_rauhtd_ipv4_rec_num_entries_get(rauhtd_pl,
+								last_rec_index);
+	if (++num_entries == MLXSW_REG_RAUHTD_IPV4_ENT_PER_REC)
+		return true;
+	return false;
+}
+
 static int mlxsw_sp_router_neighs_update_rauhtd(struct mlxsw_sp *mlxsw_sp)
 {
 	char *rauhtd_pl;
@@ -826,7 +846,7 @@ static int mlxsw_sp_router_neighs_update_rauhtd(struct mlxsw_sp *mlxsw_sp)
 		for (i = 0; i < num_rec; i++)
 			mlxsw_sp_router_neigh_rec_process(mlxsw_sp, rauhtd_pl,
 							  i);
-	} while (num_rec);
+	} while (mlxsw_sp_router_rauhtd_is_full(rauhtd_pl));
 	rtnl_unlock();
 
 	kfree(rauhtd_pl);
-- 
2.7.4

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

* Re: [patch net v2 0/2] mlxsw: Couple of fixes
  2016-11-11 15:34 [patch net v2 0/2] mlxsw: Couple of fixes Jiri Pirko
  2016-11-11 15:34 ` [patch net v2 1/2] mlxsw: spectrum: Fix refcount bug on span entries Jiri Pirko
  2016-11-11 15:34 ` [patch net v2 2/2] mlxsw: spectrum_router: Correctly dump neighbour activity Jiri Pirko
@ 2016-11-13 17:51 ` David Miller
  2016-11-13 20:00   ` Jiri Pirko
  2 siblings, 1 reply; 5+ messages in thread
From: David Miller @ 2016-11-13 17:51 UTC (permalink / raw)
  To: jiri; +Cc: netdev, yotamg, arkadis, idosch, eladr, nogahf, ogerlitz

From: Jiri Pirko <jiri@resnulli.us>
Date: Fri, 11 Nov 2016 16:34:24 +0100

> From: Jiri Pirko <jiri@mellanox.com>
> 
> Please, queue-up both for stable. Thanks!

Just to be clear I did make sure to take v2 rather than
v1.

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

* Re: [patch net v2 0/2] mlxsw: Couple of fixes
  2016-11-13 17:51 ` [patch net v2 0/2] mlxsw: Couple of fixes David Miller
@ 2016-11-13 20:00   ` Jiri Pirko
  0 siblings, 0 replies; 5+ messages in thread
From: Jiri Pirko @ 2016-11-13 20:00 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, yotamg, arkadis, idosch, eladr, nogahf, ogerlitz

Sun, Nov 13, 2016 at 06:51:33PM CET, davem@davemloft.net wrote:
>From: Jiri Pirko <jiri@resnulli.us>
>Date: Fri, 11 Nov 2016 16:34:24 +0100
>
>> From: Jiri Pirko <jiri@mellanox.com>
>> 
>> Please, queue-up both for stable. Thanks!
>
>Just to be clear I did make sure to take v2 rather than
>v1.

Good. Thanks!

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

end of thread, other threads:[~2016-11-13 20:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-11 15:34 [patch net v2 0/2] mlxsw: Couple of fixes Jiri Pirko
2016-11-11 15:34 ` [patch net v2 1/2] mlxsw: spectrum: Fix refcount bug on span entries Jiri Pirko
2016-11-11 15:34 ` [patch net v2 2/2] mlxsw: spectrum_router: Correctly dump neighbour activity Jiri Pirko
2016-11-13 17:51 ` [patch net v2 0/2] mlxsw: Couple of fixes David Miller
2016-11-13 20:00   ` Jiri Pirko

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