Skip to contentSkip to conversation

mlx5 fixes 2020-11-03

GIT PULL Superseded Saeed Mahameed 3 participants 14 messages Nov 3, 2020 – Nov 5, 2020

Subsystems (5)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Saeed Mahameed

author maintainer
#0 lore raw

Hi Jakub,

This series introduces some fixes to mlx5 driver.
For more information please see tag log below.

Please pull and let me know if there is any problem.

For -stable v5.1
('net/mlx5: Fix deletion of duplicate rules')

For -stable v5.4
('net/mlx5e: Fix modify header actions memory leak')

For -stable v5.8
('net/mlx5e: Protect encap route dev from concurrent release')

For -stable v5.9
('net/mlx5e: Fix VXLAN synchronization after function reload') ('net/mlx5e: Fix refcount leak on kTLS RX resync') ('net/mlx5e: Use spin_lock_bh for async_icosq_lock') ('net/mlx5e: Fix incorrect access of RCU-protected xdp_prog') ('net/mlx5: E-switch, Avoid extack error log for disabled vport')

Thanks,
Saeed.

---
The following changes since commit 9621618130bf7e83635367c13b9a6ee53935bb37:

sfp: Fix error handing in sfp_probe() (2020-11-02 17:19:59 -0800)

are available in the Git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git tags/mlx5-fixes-2020-11-03

for you to fetch changes up to 9166a02a7b1c21de2155c91e3b69c805e2448267:

net/mlx5e: Fix incorrect access of RCU-protected xdp_prog (2020-11-03 11:11:53 -0800)

----------------------------------------------------------------
mlx5-fixes-2020-11-03

----------------------------------------------------------------
Aya Levin (1):
net/mlx5e: Fix VXLAN synchronization after function reload

Jianbo Liu (1):
net/mlx5e: E-Switch, Offload all chain 0 priorities when modify header and forward action is not supported

Maor Dickman (1):
net/mlx5e: Fix modify header actions memory leak

Maor Gottlieb (1):
net/mlx5: Fix deletion of duplicate rules

Maxim Mikityanskiy (3):
net/mlx5e: Use spin_lock_bh for async_icosq_lock net/mlx5e: Fix refcount leak on kTLS RX resync net/mlx5e: Fix incorrect access of RCU-protected xdp_prog

Parav Pandit (1):
net/mlx5: E-switch, Avoid extack error log for disabled vport

Vlad Buslov (1):
net/mlx5e: Protect encap route dev from concurrent release

 .../net/ethernet/mellanox/mlx5/core/en/rep/tc.c    |  6 +-
 .../net/ethernet/mellanox/mlx5/core/en/tc_tun.c    | 72 ++++++++++++++--------
 .../net/ethernet/mellanox/mlx5/core/en/xsk/setup.c |  4 +-
 .../net/ethernet/mellanox/mlx5/core/en/xsk/tx.c    |  4 +-
 .../ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c | 27 ++++----
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c  |  1 +
 drivers/net/ethernet/mellanox/mlx5/core/en_rep.h   |  2 +-
 drivers/net/ethernet/mellanox/mlx5/core/en_rx.c    |  2 +-
 drivers/net/ethernet/mellanox/mlx5/core/en_tc.c    |  8 +--
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.c  |  2 -
 drivers/net/ethernet/mellanox/mlx5/core/fs_core.c  |  7 ++-
 .../ethernet/mellanox/mlx5/core/lib/fs_chains.c    |  3 -
 .../net/ethernet/mellanox/mlx5/core/lib/vxlan.c    | 23 +++++--
 .../net/ethernet/mellanox/mlx5/core/lib/vxlan.h    |  2 +
 14 files changed, 98 insertions(+), 65 deletions(-)
author maintainer
#1 lore raw

PATCH 1/9 net/mlx5e: Fix modify header actions memory leak

From: Maor Dickman <[email protected]>

Modify header actions are allocated during parse tc actions and only freed during the flow creation, however, on error flow the allocated memory is wrongly unfreed.

Fix this by calling dealloc_mod_hdr_actions in __mlx5e_add_fdb_flow and mlx5e_add_nic_flow error flow.

Fixes d7e75a325cb2 ("net/mlx5e: Add offloading of E-Switch TC pedit (header re-write) action"')
Fixes 2f4fe4cab073 ("net/mlx5e: Add offloading of NIC TC pedit (header re-write) actions")
---
 drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +2 -0
index e3a968e9e2a0..2e2fa0440032 100644
@@ -4658,6 +4658,7 @@ __mlx5e_add_fdb_flow(struct mlx5e_priv *priv,
 	return flow;
 
 err_free:
+	dealloc_mod_hdr_actions(&parse_attr->mod_hdr_acts);
 	mlx5e_flow_put(priv, flow);
 out:
 	return ERR_PTR(err);
@@ -4802,6 +4803,7 @@ mlx5e_add_nic_flow(struct mlx5e_priv *priv,
 	return 0;
 
 err_free:
+	dealloc_mod_hdr_actions(&parse_attr->mod_hdr_acts);
 	mlx5e_flow_put(priv, flow);
 out:
 	return err;
Signature · 1 line
2.26.2
author maintainer
#3 lore raw

PATCH 2/9 net/mlx5e: Protect encap route dev from concurrent release

In reply to Saeed Mahameed

From: Vlad Buslov <[email protected]>

In functions mlx5e_route_lookup_ipv{4|6}() route_dev can be arbitrary net device and not necessary mlx5 eswitch port representor. As such, in order to ensure that route_dev is not destroyed concurrent the code needs either explicitly take reference to the device before releasing reference to rtable instance or ensure that caller holds rtnl lock. First approach is chosen as a fix since rtnl lock dependency was intentionally removed from mlx5 TC layer.

To prevent unprotected usage of route_dev in encap code take a reference to the device before releasing rt. Don't save direct pointer to the device in mlx5_encap_entry structure and use ifindex instead. Modify users of route_dev pointer to properly obtain the net device instance from its ifindex.

Fixes 61086f391044 ("net/mlx5e: Protect encap hash table with mutex")
Fixes 6707f74be862 ("net/mlx5e: Update hw flows when encap source mac changed")
---
 .../ethernet/mellanox/mlx5/core/en/rep/tc.c   |  6 +-
 .../ethernet/mellanox/mlx5/core/en/tc_tun.c   | 72 ++++++++++++-------
 .../net/ethernet/mellanox/mlx5/core/en_rep.h  |  2 +-
 3 files changed, 52 insertions(+), 28 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c +5 -1
index e36e505d38ad..d29af7b9c695 100644
@@ -107,12 +107,16 @@ void mlx5e_rep_update_flows(struct mlx5e_priv *priv,
 		mlx5e_tc_encap_flows_del(priv, e, &flow_list);
 
 	if (neigh_connected && !(e->flags & MLX5_ENCAP_ENTRY_VALID)) {
+		struct net_device *route_dev;
+
 		ether_addr_copy(e->h_dest, ha);
 		ether_addr_copy(eth->h_dest, ha);
 		/* Update the encap source mac, in case that we delete
 		 * the flows when encap source mac changed.
 		 */
-		ether_addr_copy(eth->h_source, e->route_dev->dev_addr);
+		route_dev = __dev_get_by_index(dev_net(priv->netdev), e->route_dev_ifindex);
+		if (route_dev)
+			ether_addr_copy(eth->h_source, route_dev->dev_addr);
 
 		mlx5e_tc_encap_flows_add(priv, e, &flow_list);
 	}
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c +46 -26

161 lines not on this page · raw message

drivers/net/ethernet/mellanox/mlx5/core/en_rep.h +1 -1
index 9020d1419bcf..8932c387d46a 100644
@@ -186,7 +186,7 @@ struct mlx5e_encap_entry {
 	unsigned char h_dest[ETH_ALEN];	/* destination eth addr	*/
 
 	struct net_device *out_dev;
-	struct net_device *route_dev;
+	int route_dev_ifindex;
 	struct mlx5e_tc_tunnel *tunnel;
 	int reformat_type;
 	u8 flags;
Signature · 1 line
2.26.2
author maintainer
#8 lore raw

PATCH 5/9 net/mlx5: Fix deletion of duplicate rules

In reply to Saeed Mahameed

From: Maor Gottlieb <[email protected]>

When a rule is duplicated, the refcount of the rule is increased so only the second deletion of the rule should cause destruction of the FTE. Currently, the FTE will be destroyed in the first deletion of rule since the modify_mask will be 0.
Fix it and call to destroy FTE only if all the rules (FTE's children) have been removed.

Fixes 718ce4d601db ("net/mlx5: Consolidate update FTE for all removal changes")
---
 drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c +4 -3
index 16091838bfcf..325a5b0d6829 100644
@@ -2010,10 +2010,11 @@ void mlx5_del_flow_rules(struct mlx5_flow_handle *handle)
 	down_write_ref_node(&fte->node, false);
 	for (i = handle->num_rules - 1; i >= 0; i--)
 		tree_remove_node(&handle->rule[i]->node, true);
-	if (fte->modify_mask && fte->dests_size) {
-		modify_fte(fte);
+	if (fte->dests_size) {
+		if (fte->modify_mask)
+			modify_fte(fte);
 		up_write_ref_node(&fte->node, false);
-	} else {
+	} else if (list_empty(&fte->node.children)) {
 		del_hw_fte(&fte->node);
 		/* Avoid double call to del_hw_fte */
 		fte->node.del_hw_func = NULL;
Signature · 1 line
2.26.2
author maintainer
#11 lore raw

PATCH 7/9 net/mlx5: E-switch, Avoid extack error log for disabled vport

In reply to Saeed Mahameed

From: Parav Pandit <[email protected]>

When E-switch vport is disabled, querying its hardware address is unsupported.
Avoid setting extack error log message in such case.

Fixes f099fde16db3 ("net/mlx5: E-switch, Support querying port function mac address")
---
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 2 --
 1 file changed, 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +0 -2
index 6e6a9a563992..e8e6294c7cca 100644
@@ -1902,8 +1902,6 @@ int mlx5_devlink_port_function_hw_addr_get(struct devlink *devlink,
 		ether_addr_copy(hw_addr, vport->info.mac);
 		*hw_addr_len = ETH_ALEN;
 		err = 0;
-	} else {
-		NL_SET_ERR_MSG_MOD(extack, "Eswitch vport is disabled");
 	}
 	mutex_unlock(&esw->state_lock);
 	return err;
Signature · 1 line
2.26.2
author maintainer
#9 lore raw

PATCH 6/9 net/mlx5e: E-Switch, Offload all chain 0 priorities when modify header and forward action is not supported

In reply to Saeed Mahameed

From: Jianbo Liu <[email protected]>

Miss path handling of tc multi chain filters (i.e. filters that are defined on chain > 0) requires the hardware to communicate to the driver the last chain that was processed. This is possible only when the hardware is capable of performing the combination of modify header and forward to table actions. Currently, if the hardware is missing this capability then the driver only offloads rules that are defined on tc chain 0 prio 1. However, this restriction can be relaxed because packets that miss from chain 0 are processed through all the priorities by tc software.

Allow the offload of all the supported priorities for chain 0 even when the hardware is not capable to perform modify header and goto table actions.

Fixes 0b3a8b6b5340 ("net/mlx5: E-Switch: Fix using fwd and modify when firmware doesn't support it")
---
 drivers/net/ethernet/mellanox/mlx5/core/en_tc.c         | 6 ------
 drivers/net/ethernet/mellanox/mlx5/core/lib/fs_chains.c | 3 ---
 2 files changed, 9 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +0 -6
index 2e2fa0440032..17d9ba4ac95f 100644
@@ -1319,12 +1319,6 @@ mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv,
 	int err = 0;
 	int out_index;
 
-	if (!mlx5_chains_prios_supported(esw_chains(esw)) && attr->prio != 1) {
-		NL_SET_ERR_MSG_MOD(extack,
-				   "E-switch priorities unsupported, upgrade FW");
-		return -EOPNOTSUPP;
-	}
-
 	/* We check chain range only for tc flows.
 	 * For ft flows, we checked attr->chain was originally 0 and set it to
 	 * FDB_FT_CHAIN which is outside tc range.
drivers/net/ethernet/mellanox/mlx5/core/lib/fs_chains.c +0 -3
index 947f346bdc2d..fa61d305990c 100644
@@ -141,9 +141,6 @@ u32 mlx5_chains_get_nf_ft_chain(struct mlx5_fs_chains *chains)
 
 u32 mlx5_chains_get_prio_range(struct mlx5_fs_chains *chains)
 {
-	if (!mlx5_chains_prios_supported(chains))
-		return 1;
-
 	if (mlx5_chains_ignore_flow_level_supported(chains))
 		return UINT_MAX;
 
Signature · 1 line
2.26.2
author maintainer
#5 lore raw

PATCH 4/9 net/mlx5e: Fix refcount leak on kTLS RX resync

In reply to Saeed Mahameed

From: Maxim Mikityanskiy <[email protected]>

On resync, the driver calls inet_lookup_established (__inet6_lookup_established) that increases sk_refcnt of the socket. To decrease it, the driver set skb->destructor to sock_edemux. However, it didn't work well, because the TCP stack also sets this destructor for early demux, and the refcount gets decreased only once, while increased two times (in mlx5e and in the TCP stack). It leads to a socket leak, a TLS context leak, which in the end leads to calling tls_dev_del twice:
on socket close and on driver unload, which in turn leads to a crash.

This commit fixes the refcount leak by calling sock_gen_put right away after using the socket, thus fixing all the subsequent issues.

Fixes 0419d8c9d8f8 ("net/mlx5e: kTLS, Add kTLS RX resync support")
---
 .../ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c  | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c +8 -5
index 7f6221b8b1f7..6a1d82503ef8 100644
@@ -476,19 +476,22 @@ static void resync_update_sn(struct mlx5e_rq *rq, struct sk_buff *skb)
 
 	depth += sizeof(struct tcphdr);
 
-	if (unlikely(!sk || sk->sk_state == TCP_TIME_WAIT))
+	if (unlikely(!sk))
 		return;
 
-	if (unlikely(!resync_queue_get_psv(sk)))
-		return;
+	if (unlikely(sk->sk_state == TCP_TIME_WAIT))
+		goto unref;
 
-	skb->sk = sk;
-	skb->destructor = sock_edemux;
+	if (unlikely(!resync_queue_get_psv(sk)))
+		goto unref;
 
 	seq = th->seq;
 	datalen = skb->len - depth;
 	tls_offload_rx_resync_async_request_start(sk, seq, datalen);
 	rq->stats->tls_resync_req_start++;
+
+unref:
+	sock_gen_put(sk);
 }
 
 void mlx5e_ktls_rx_resync(struct net_device *netdev, struct sock *sk,
Signature · 1 line
2.26.2
author maintainer
#13 lore raw

PATCH 9/9 net/mlx5e: Fix incorrect access of RCU-protected xdp_prog

In reply to Saeed Mahameed

From: Maxim Mikityanskiy <[email protected]>

rq->xdp_prog is RCU-protected and should be accessed only with rcu_access_pointer for the NULL check in mlx5e_poll_rx_cq.

rq->xdp_prog may change on the fly only from one non-NULL value to another non-NULL value, so the checks in mlx5e_xdp_handle and mlx5e_poll_rx_cq will have the same result during one NAPI cycle, meaning that no additional synchronization is needed.

Fixes fe45386a2082 ("net/mlx5e: Use RCU to protect rq->xdp_prog")
---
 drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +1 -1
index 599f5b5ebc97..6628a0197b4e 100644
@@ -1584,7 +1584,7 @@ int mlx5e_poll_rx_cq(struct mlx5e_cq *cq, int budget)
 	} while ((++work_done < budget) && (cqe = mlx5_cqwq_get_cqe(cqwq)));
 
 out:
-	if (rq->xdp_prog)
+	if (rcu_access_pointer(rq->xdp_prog))
 		mlx5e_xdp_rx_poll_complete(rq);
 
 	mlx5_cqwq_update_db_record(cqwq);
Signature · 1 line
2.26.2
author maintainer
#4 lore raw

PATCH 3/9 net/mlx5e: Use spin_lock_bh for async_icosq_lock

In reply to Saeed Mahameed

From: Maxim Mikityanskiy <[email protected]>

async_icosq_lock may be taken from softirq and non-softirq contexts. It requires protection with spin_lock_bh, otherwise a softirq may be triggered in the middle of the critical section, and it may deadlock if it tries to take the same lock. This patch fixes such a scenario by using spin_lock_bh to disable softirqs on that CPU while inside the critical section.

Fixes 8d94b590f1e4 ("net/mlx5e: Turn XSK ICOSQ into a general asynchronous one")
---
 .../net/ethernet/mellanox/mlx5/core/en/xsk/setup.c |  4 ++--
 .../net/ethernet/mellanox/mlx5/core/en/xsk/tx.c    |  4 ++--
 .../ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c | 14 +++++++-------
 3 files changed, 11 insertions(+), 11 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c +2 -2
index 4e574ac73019..be3465ba38ca 100644
@@ -122,9 +122,9 @@ void mlx5e_activate_xsk(struct mlx5e_channel *c)
 	set_bit(MLX5E_RQ_STATE_ENABLED, &c->xskrq.state);
 	/* TX queue is created active. */
 
-	spin_lock(&c->async_icosq_lock);
+	spin_lock_bh(&c->async_icosq_lock);
 	mlx5e_trigger_irq(&c->async_icosq);
-	spin_unlock(&c->async_icosq_lock);
+	spin_unlock_bh(&c->async_icosq_lock);
 }
 
 void mlx5e_deactivate_xsk(struct mlx5e_channel *c)
drivers/net/ethernet/mellanox/mlx5/core/en/xsk/tx.c +2 -2
index fb671a457129..8e96260fce1d 100644
@@ -36,9 +36,9 @@ int mlx5e_xsk_wakeup(struct net_device *dev, u32 qid, u32 flags)
 		if (test_and_set_bit(MLX5E_SQ_STATE_PENDING_XSK_TX, &c->async_icosq.state))
 			return 0;
 
-		spin_lock(&c->async_icosq_lock);
+		spin_lock_bh(&c->async_icosq_lock);
 		mlx5e_trigger_irq(&c->async_icosq);
-		spin_unlock(&c->async_icosq_lock);
+		spin_unlock_bh(&c->async_icosq_lock);
 	}
 
 	return 0;
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c +7 -7
index ccaccb9fc2f7..7f6221b8b1f7 100644
@@ -188,7 +188,7 @@ static int post_rx_param_wqes(struct mlx5e_channel *c,
 
 	err = 0;
 	sq = &c->async_icosq;
-	spin_lock(&c->async_icosq_lock);
+	spin_lock_bh(&c->async_icosq_lock);
 
 	cseg = post_static_params(sq, priv_rx);
 	if (IS_ERR(cseg))
@@ -199,7 +199,7 @@ static int post_rx_param_wqes(struct mlx5e_channel *c,
 
 	mlx5e_notify_hw(&sq->wq, sq->pc, sq->uar_map, cseg);
 unlock:
-	spin_unlock(&c->async_icosq_lock);
+	spin_unlock_bh(&c->async_icosq_lock);
 
 	return err;
 
@@ -265,10 +265,10 @@ resync_post_get_progress_params(struct mlx5e_icosq *sq,
 
 	BUILD_BUG_ON(MLX5E_KTLS_GET_PROGRESS_WQEBBS != 1);
 
-	spin_lock(&sq->channel->async_icosq_lock);
+	spin_lock_bh(&sq->channel->async_icosq_lock);
 
 	if (unlikely(!mlx5e_wqc_has_room_for(&sq->wq, sq->cc, sq->pc, 1))) {
-		spin_unlock(&sq->channel->async_icosq_lock);
+		spin_unlock_bh(&sq->channel->async_icosq_lock);
 		err = -ENOSPC;
 		goto err_dma_unmap;
 	}
@@ -299,7 +299,7 @@ resync_post_get_progress_params(struct mlx5e_icosq *sq,
 	icosq_fill_wi(sq, pi, &wi);
 	sq->pc++;
 	mlx5e_notify_hw(&sq->wq, sq->pc, sq->uar_map, cseg);
-	spin_unlock(&sq->channel->async_icosq_lock);
+	spin_unlock_bh(&sq->channel->async_icosq_lock);
 
 	return 0;
 
@@ -360,7 +360,7 @@ static int resync_handle_seq_match(struct mlx5e_ktls_offload_context_rx *priv_rx
 	err = 0;
 
 	sq = &c->async_icosq;
-	spin_lock(&c->async_icosq_lock);
+	spin_lock_bh(&c->async_icosq_lock);
 
 	cseg = post_static_params(sq, priv_rx);
 	if (IS_ERR(cseg)) {
@@ -372,7 +372,7 @@ static int resync_handle_seq_match(struct mlx5e_ktls_offload_context_rx *priv_rx
 	mlx5e_notify_hw(&sq->wq, sq->pc, sq->uar_map, cseg);
 	priv_rx->stats->tls_resync_res_ok++;
 unlock:
-	spin_unlock(&c->async_icosq_lock);
+	spin_unlock_bh(&c->async_icosq_lock);
 
 	return err;
 }
Signature · 1 line
2.26.2
author maintainer
#12 lore raw

PATCH 8/9 net/mlx5e: Fix VXLAN synchronization after function reload

In reply to Saeed Mahameed

From: Aya Levin <[email protected]>

During driver reload, perform firmware tear-down which results in firmware losing the configured VXLAN ports. These ports are still available in the driver's database. Fix this by cleaning up driver's VXLAN database in the nic unload flow, before firmware tear-down. With that, minimize mlx5_vxlan_destroy() to remove only what was added in mlx5_vxlan_create() and warn on leftover UDP ports.

Fixes 18a2b7f969c9 ("net/mlx5: convert to new udp_tunnel infrastructure")
---
 .../net/ethernet/mellanox/mlx5/core/en_main.c |  1 +
 .../ethernet/mellanox/mlx5/core/lib/vxlan.c   | 23 ++++++++++++++-----
 .../ethernet/mellanox/mlx5/core/lib/vxlan.h   |  2 ++
 3 files changed, 20 insertions(+), 6 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +1 -0
index b3f02aac7f26..ebce97921e03 100644
@@ -5253,6 +5253,7 @@ static void mlx5e_nic_disable(struct mlx5e_priv *priv)
 
 	mlx5e_disable_async_events(priv);
 	mlx5_lag_remove(mdev);
+	mlx5_vxlan_reset_to_default(mdev->vxlan);
 }
 
 int mlx5e_update_nic_rx(struct mlx5e_priv *priv)
drivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.c +17 -6
index 3315afe2f8dc..38084400ee8f 100644
@@ -167,6 +167,17 @@ struct mlx5_vxlan *mlx5_vxlan_create(struct mlx5_core_dev *mdev)
 }
 
 void mlx5_vxlan_destroy(struct mlx5_vxlan *vxlan)
+{
+	if (!mlx5_vxlan_allowed(vxlan))
+		return;
+
+	mlx5_vxlan_del_port(vxlan, IANA_VXLAN_UDP_PORT);
+	WARN_ON(!hash_empty(vxlan->htable));
+
+	kfree(vxlan);
+}
+
+void mlx5_vxlan_reset_to_default(struct mlx5_vxlan *vxlan)
 {
 	struct mlx5_vxlan_port *vxlanp;
 	struct hlist_node *tmp;
@@ -175,12 +186,12 @@ void mlx5_vxlan_destroy(struct mlx5_vxlan *vxlan)
 	if (!mlx5_vxlan_allowed(vxlan))
 		return;
 
-	/* Lockless since we are the only hash table consumers*/
 	hash_for_each_safe(vxlan->htable, bkt, tmp, vxlanp, hlist) {
-		hash_del(&vxlanp->hlist);
-		mlx5_vxlan_core_del_port_cmd(vxlan->mdev, vxlanp->udp_port);
-		kfree(vxlanp);
+		/* Don't delete default UDP port added by the HW.
+		 * Remove only user configured ports
+		 */
+		if (vxlanp->udp_port == IANA_VXLAN_UDP_PORT)
+			continue;
+		mlx5_vxlan_del_port(vxlan, vxlanp->udp_port);
 	}
-
-	kfree(vxlan);
 }
drivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.h +2 -0
index ec766529f49b..34ef662da35e 100644
@@ -56,6 +56,7 @@ void mlx5_vxlan_destroy(struct mlx5_vxlan *vxlan);
 int mlx5_vxlan_add_port(struct mlx5_vxlan *vxlan, u16 port);
 int mlx5_vxlan_del_port(struct mlx5_vxlan *vxlan, u16 port);
 bool mlx5_vxlan_lookup_port(struct mlx5_vxlan *vxlan, u16 port);
+void mlx5_vxlan_reset_to_default(struct mlx5_vxlan *vxlan);
 #else
 static inline struct mlx5_vxlan*
 mlx5_vxlan_create(struct mlx5_core_dev *mdev) { return ERR_PTR(-EOPNOTSUPP); }
@@ -63,6 +64,7 @@ static inline void mlx5_vxlan_destroy(struct mlx5_vxlan *vxlan) { return; }
 static inline int mlx5_vxlan_add_port(struct mlx5_vxlan *vxlan, u16 port) { return -EOPNOTSUPP; }
 static inline int mlx5_vxlan_del_port(struct mlx5_vxlan *vxlan, u16 port) { return -EOPNOTSUPP; }
 static inline bool mlx5_vxlan_lookup_port(struct mlx5_vxlan *vxlan, u16 port) { return false; }
+static inline void mlx5_vxlan_reset_to_default(struct mlx5_vxlan *vxlan) { return; }
 #endif
 
 #endif /* __MLX5_VXLAN_H__ */
Signature · 1 line
2.26.2
maintainer
#2 lore raw

Re: [net 1/9] net/mlx5e: Fix modify header actions memory leak

In reply to Saeed Mahameed
Quoted 6 lines · On Tue, 3 Nov 2020 11:18:22 -0800 Saeed Mahameed wrote:

From: Maor Dickman <[email protected]>

Modify header actions are allocated during parse tc actions and only freed during the flow creation, however, on error flow the allocated memory is wrongly unfreed.

Quoted 8 lines

Fix this by calling dealloc_mod_hdr_actions in __mlx5e_add_fdb_flow and mlx5e_add_nic_flow error flow.

Fixes d7e75a325cb2 ("net/mlx5e: Add offloading of E-Switch TC pedit (header re-write) action"')
Fixes 2f4fe4cab073 ("net/mlx5e: Add offloading of NIC TC pedit (header re-write) actions")

Sorry, I didn't look at the warnings for you patches yesterday.

Fixes tag: Fixes: d7e75a325cb2 ("net/mlx5e: Add offloading of E-Switch TC pedit (header re-write) action"') Has these problem(s):
- Subject has leading but no trailing quotes
- Subject does not match target commit subject
Just use
git log -1 --format='Fixes: %h ("%s")'

maintainer
#6 lore raw

Re: [net 4/9] net/mlx5e: Fix refcount leak on kTLS RX resync

In reply to Saeed Mahameed
Quoted 7 lines · On Tue, 3 Nov 2020 11:18:25 -0800 Saeed Mahameed wrote:

From: Maxim Mikityanskiy <[email protected]>

On resync, the driver calls inet_lookup_established (__inet6_lookup_established) that increases sk_refcnt of the socket. To decrease it, the driver set skb->destructor to sock_edemux. However, it didn't work well, because the TCP stack also sets this destructor for early demux, and the refcount gets decreased only once

Why is the stack doing early_demux if there is already a socket assigned? Or is it not early_demux but something else? Can you point us at the code?

IPv4:

	if (net->ipv4.sysctl_ip_early_demux &&
	    !skb_dst(skb) &&
	    !skb->sk &&                              <============
	    !ip_is_fragment(iph)) {
		const struct net_protocol *ipprot;
		int protocol = iph->protocol;

		ipprot = rcu_dereference(inet_protos[protocol]);
		if (ipprot && (edemux = READ_ONCE(ipprot->early_demux))) {
			err = INDIRECT_CALL_2(edemux, tcp_v4_early_demux,
					      udp_v4_early_demux, skb);
			if (unlikely(err))
				goto drop_error;
			/* must reload iph, skb->head might have changed */
			iph = ip_hdr(skb);
		}
	}

IPv6:

	if (net->ipv4.sysctl_ip_early_demux && !skb_dst(skb) && skb->sk == NULL) {
                                                                ~~~~~~~~~~~~~~~
		const struct inet6_protocol *ipprot;

		ipprot = rcu_dereference(inet6_protos[ipv6_hdr(skb)->nexthdr]);
		if (ipprot && (edemux = READ_ONCE(ipprot->early_demux)))
			INDIRECT_CALL_2(edemux, tcp_v6_early_demux,
					udp_v6_early_demux, skb);
	}
maintainer
#10 lore raw

Re: [net 6/9] net/mlx5e: E-Switch, Offload all chain 0 priorities when modify header and forward action is not supported

In reply to Saeed Mahameed
Quoted 16 lines · On Tue, 3 Nov 2020 11:18:27 -0800 Saeed Mahameed wrote:

From: Jianbo Liu <[email protected]>

Miss path handling of tc multi chain filters (i.e. filters that are defined on chain > 0) requires the hardware to communicate to the driver the last chain that was processed. This is possible only when the hardware is capable of performing the combination of modify header and forward to table actions. Currently, if the hardware is missing this capability then the driver only offloads rules that are defined on tc chain 0 prio 1. However, this restriction can be relaxed because packets that miss from chain 0 are processed through all the priorities by tc software.

Allow the offload of all the supported priorities for chain 0 even when the hardware is not capable to perform modify header and goto table actions.

Quoted 6 lines
Fixes 0b3a8b6b5340 ("net/mlx5: E-Switch: Fix using fwd and modify when firmware doesn't support it")

Sounds like a feature TBH.

#7 lore raw

Re: [net 4/9] net/mlx5e: Fix refcount leak on kTLS RX resync

In reply to Jakub Kicinski
Quoted 9 lines · Jakub Kicinski
Quoted 7 lines · On Tue, 3 Nov 2020 11:18:25 -0800 Saeed Mahameed wrote:

From: Maxim Mikityanskiy <[email protected]>

On resync, the driver calls inet_lookup_established (__inet6_lookup_established) that increases sk_refcnt of the socket. To decrease it, the driver set skb->destructor to sock_edemux. However, it didn't work well, because the TCP stack also sets this destructor for early demux, and the refcount gets decreased only once

Quoted 3 lines

Why is the stack doing early_demux if there is already a socket assigned? Or is it not early_demux but something else? Can you point us at the code?

I thought this was the code that was in conflict with setting skb->destructor in the driver:

void skb_set_owner_w(struct sk_buff *skb, struct sock *sk)

{
        skb_orphan(skb);
        skb->sk = sk;
#ifdef CONFIG_INET
        if (unlikely(!sk_fullsock(sk))) {
                skb->destructor = sock_edemux;
                sock_hold(sk);
                return;
        }

#endif

However, after taking another look, it seems that the root cause is somewhere else. This piece of code actually calls skb_orphan before reassigning the destructor.

I'll debug it further to try to find where the destructor is replaced or just not called.

Quoted 30 lines

IPv4:

	if (net->ipv4.sysctl_ip_early_demux &&
	    !skb_dst(skb) &&
	    !skb->sk &&                              <============
	    !ip_is_fragment(iph)) {
		const struct net_protocol *ipprot;
		int protocol = iph->protocol;

		ipprot = rcu_dereference(inet_protos[protocol]);
		if (ipprot && (edemux = READ_ONCE(ipprot->early_demux))) {
			err = INDIRECT_CALL_2(edemux, tcp_v4_early_demux,
					      udp_v4_early_demux, skb);
			if (unlikely(err))
				goto drop_error;
			/* must reload iph, skb->head might have changed */
			iph = ip_hdr(skb);
		}
	}

IPv6:

	if (net->ipv4.sysctl_ip_early_demux && !skb_dst(skb) && skb->sk == NULL) {
                                                                 ~~~~~~~~~~~~~~~
		const struct inet6_protocol *ipprot;

		ipprot = rcu_dereference(inet6_protos[ipv6_hdr(skb)->nexthdr]);
		if (ipprot && (edemux = READ_ONCE(ipprot->early_demux)))
			INDIRECT_CALL_2(edemux, tcp_v6_early_demux,
					udp_v6_early_demux, skb);
	}