Skip to contentSkip to conversation

mlxsw: Couple of fixes

PATCH In review Jiri Pirko 2 participants 5 messages Nov 11, 2016 – Nov 13, 2016

Subsystems (3)
lore
Share & tools
lore

Jiri Pirko

author
#0 lore raw

v2 cover mlxsw: Couple of fixes

From: Jiri Pirko <[email protected]>

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(-)
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH v2 1/2 mlxsw: spectrum: Fix refcount bug on span entries

From: Yotam Gigi <[email protected]>

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

---
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(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +3 -1
index 1ec0a4c..dda5761 100644
@@ -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;
Signature · 1 line
2.7.4
author
#2 lore raw

PATCH v2 2/2 mlxsw: spectrum_router: Correctly dump neighbour activity

In reply to Jiri Pirko

From: Arkadi Sharshevsky <[email protected]>

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

---
v1->v2:
- remove an extra space
- fix the description

---
 .../net/ethernet/mellanox/mlxsw/spectrum_router.c  | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +21 -1
index 040737e..cbeeddd 100644
@@ -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);
Signature · 1 line
2.7.4
author
#4 lore raw
Quoted 9 lines · Sun, Nov 13, 2016 at 06:51:33PM CET, [email protected] wrote:

From: Jiri Pirko <[email protected]>
Date: Fri, 11 Nov 2016 16:34:24 +0100

Quoted 3 lines

From: Jiri Pirko <[email protected]>

Please, queue-up both for stable. Thanks!

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

Good. Thanks!