Netdev List
 help / color / mirror / Atom feed
From: Jianbo Liu <jianbol@nvidia.com>
To: netdev-bot+sashiko@kernel.org, tariqt@nvidia.com
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
	kuba@kernel.org, netdev@vger.kernel.org, pabeni@redhat.com,
	willemb@google.com, parri.andrea@gmail.com, borisp@nvidia.com,
	cratiu@nvidia.com, eedmunds@nvidia.com, gal@nvidia.com,
	jmassar@nvidia.com, kuniyu@google.com, leon@kernel.org,
	linux-rdma@vger.kernel.org, mbloch@nvidia.com,
	phaddad@nvidia.com, raeds@nvidia.com, saeedm@nvidia.com,
	horms@kernel.org, sridhar.samudrala@intel.com,
	steffen.klassert@secunet.com
Subject: Re: [PATCH net 05/10] net/mlx5e: Drop IPsec tunnel traffic if the neigh cannot be created
Date: Mon, 30 Nov 2026 15:40:51 +0800	[thread overview]
Message-ID: <922daa79-0cc7-49a0-80f4-095c8c5d99fb@nvidia.com> (raw)
In-Reply-To: <179581873325.3135.13078869091632134545@kernel.org>



On 11/28/2026 6:32 AM, netdev-bot+sashiko@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 3 potential
> issue(s) to consider.
> 
> Critical: 0 · High: 0 · Medium: 3 · Low: 0
> 
> If you believe none of the issues are legitimate, please reply to each
> issue of Medium severity or higher and explain why the AI is wrong.
> If any of them are legitimate and you plan to respin, please let patchwork
> know by including "pw-bot: cr" as a separate line at the end of your reply
> (one such reply per series is enough).
> 
> - [Medium] The patch only covers the case where neighbour creation fails.
> - [Medium] Setting attrs->drop = true when the neighbour cannot be
>    created permanently stops the SA's software lifetime worker.
> - [Medium] The new 'attrs->drop = true' on neighbour-creation failure in
>    mlx5e_ipsec_init_macs() (ipsec.c:371) is not limited to the TX…
> 
> --
> 
> net/mlx5e: Drop IPsec tunnel traffic if the neigh cannot be created
> 
> This patch moves the attrs->drop assignment in mlx5e_ipsec_init_macs() so
> it happens before the IS_ERR() check on the result of ipv4_neigh_create().
> When the peer neighbour cannot be created, the tunnel packet offload SA
> is now installed as a drop rule. Before, it forwarded traffic with an
> all-zero destination MAC.
> 
>> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c
>> index ea7a1ae2056fa..4daad648460fe 100644
>> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c
>> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c
>> @@ -368,10 +368,10 @@ static void mlx5e_ipsec_init_macs(struct mlx5e_ipsec_sa_entry *sa_entry,
>>  	n = ipv4_neigh_lookup(netdev, pkey);
>>  	if (!n) {
>>  		n = ipv4_neigh_create(netdev, pkey);
>> +		attrs->drop = true;
>>  		if (IS_ERR(n))
>>  			return;
> 
> [Severity: Medium]
> Should this drop be limited to XFRM_DEV_OFFLOAD_OUT?
> 
> For an inbound SA, mlx5e_ipsec_init_macs() sets src = attrs->dmac (the
> netdev's own MAC) and dst = attrs->smac (the peer MAC). The unresolved
> peer MAC only becomes the source MAC of the L2 header that
> setup_pkt_reformat() adds to the decrypted inner frame:
> 
> drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c:setup_pkt_reformat() {
>      ...
> 	ether_addr_copy(eth_hdr->h_dest, attrs->dmac);
> 	ether_addr_copy(eth_hdr->h_source, attrs->smac);
>      ...
> }
> 
> Before this patch, an RX SA in this state still delivered decrypted
> traffic to the host, with h_source set to 00:00:00:00:00:00. With drop
> set, rx_add_rule() now installs CRYPTO_DECRYPT|DROP:
> 
> drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c:rx_add_rule() {
>      ...
> 	if (attrs->drop) {
> 		flow_act.action |= MLX5_FLOW_CONTEXT_ACTION_DROP;
> 		rule = mlx5_add_flow_rules(rx->ft.sa, spec, &flow_act, NULL, 0);
>      ...
> }
> 
> n is an ERR_PTR here, so neigh_event_send() is never called and no
> resolution starts.
> 
> Could inbound traffic for this SA stay blackholed until some unrelated
> event creates and validates the neighbour? That can't happen while the
> table is still full.
> 
> The commit message only describes the TX case ("add the TX SA ...").
> 

The drop in this path is not limited to TX. Commit 4c24272b4e2b
added it for the IN case as well as the OUT case, and the code
before this patch drops both directions for a neighbour that this
path has just created. The patch makes a failed create do the same.

Right, no probe is sent in this branch, there is no neighbour to
probe. mlx5e_ipsec_netevent_event() still finds the SA, and it is
switched to forward when a neighbour entry for the peer address
becomes valid. Until then the SA drops, and no such entry is learned
while the table is full. A created neighbour that gets no answer to
the probe leaves the SA in the same state today.

> [Severity: Medium]
> Does setting drop here permanently stop the software lifetime worker for
> this SA?
> 
> mlx5e_xfrm_add_state() queues sa_entry->dwork once, MLX5_IPSEC_RESCHED
> after install. mlx5e_ipsec_handle_sw_limits() returns early when drop is
> set and only re-queues itself at the end:
> 
> mlx5e_ipsec_handle_sw_limits() {
> 	...
> 	if (sa_entry->attrs.drop)
> 		return;
> 	...
> 	xfrm_state_check_expire(x);
> 	spin_unlock_bh(&x->lock);
> 
> 	queue_delayed_work(sa_entry->ipsec->wq, &dwork->dwork,
> 			   MLX5_IPSEC_RESCHED);
> }
> 
> This IS_ERR() branch sends no probe. Drop is therefore almost certainly
> still set when the worker first runs, and the worker is never queued
> again.
> 
> If the neighbour resolves later, mlx5e_ipsec_handle_netdev_event()
> clears the flag and reprograms the rules to forward:
> 
> 	attrs->drop = false;
> 	mlx5e_accel_ipsec_fs_modify(sa_entry);
> 
> It does not re-arm the dwork. Would the SA then forward traffic without
> any xfrm_state_check_expire() calls, so the soft and hard byte limits
> are never enforced?
> 
> Before this patch, the IS_ERR() branch left drop false and the worker
> kept running. The root cause seems to be that attrs->drop means both
> "expired" and "neighbour unresolved".
> 
> A later commit in the series, "net/mlx5e: Copy back only replay_esn
> after an IPsec ESN update", fixes the ESN rebuild variant of this
> problem. At the end of the series, the early return in
> mlx5e_ipsec_handle_sw_limits() and the missing re-arm in
> mlx5e_ipsec_handle_netdev_event() are both still there.
> 
>>  		neigh_event_send(n, NULL);
>> -		attrs->drop = true;
>>  	} else {
>>  		neigh_ha_snapshot(addr, n, netdev);
>>  		ether_addr_copy(dst, addr);
> 

Yes, the work returns when it finds the SA in the drop state and is
not queued again. It is an existing problem, which needs a seperate fix, 
as I said in the reply to patch 2.

> [Severity: Medium]
> The commit message says this makes creation failure behave "as for a
> created but still unresolved neigh". Does that hold outside the create
> branch of the fallback path?
> 
> In this else branch, ipv4_neigh_lookup() can return an existing
> neighbour that is INCOMPLETE or FAILED. Its zero ha is copied into dmac,
> drop stays false, and no probe is sent.
> 
> The route path earlier in mlx5e_ipsec_init_macs() shows the same
> symptom. dst_neigh_lookup() goes through
> ipv4_dst_neigh_lookup()->ip_neigh_gw4(), which calls __neigh_create()
> on a miss. It returns a new unresolved neighbour instead of NULL, so the
> fallback is never reached:
> 
> 	n = dst_neigh_lookup(rt_dst_entry, pkey);
> 	...
> 	neigh_ha_snapshot(addr, n, netdev);
> 	ether_addr_copy(dst, addr);
> 	if (attrs->dir == XFRM_DEV_OFFLOAD_OUT &&
> 	    is_zero_ether_addr(addr))
> 		neigh_event_send(n, NULL);
> 
> attrs->drop is never set on that path, and tx_add_rule() chooses the
> action from attrs->drop alone:
> 
> drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c:tx_add_rule() {
>      ...
> 	if (attrs->drop)
> 		flow_act.action |= MLX5_FLOW_CONTEXT_ACTION_DROP;
> 	else
> 		flow_act.action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
>      ...
> }
> 
> Suppose a route to the peer exists but the next hop is not resolved yet,
> for example the first SA toward a new peer. Won't the TX SA still be
> installed with dmac 00:00:00:00:00:00 and forwarding enabled? That is
> the symptom this commit describes.
> 
> Commit 9ab89bde13e5 describes this route path case ("the hardware rule
> is programmed with an all-zero destination MAC address") but only adds a
> probe, not a drop. The route path still has no drop at the end of the
> series.
> 
> A later commit in the series, "net/mlx5e: Validate neighbour events
> before updating IPsec SAs", fixes the related problem that gateway
> neighbour updates were never matched.
> 

It seems irrelevant. This patch is only about the failed create.


  reply	other threads:[~2026-11-30  7:41 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26 21:56 [PATCH net 00/10] net/mlx5e: Fix IPsec SA races and neighbour handling Tariq Toukan
2026-11-26 21:56 ` [PATCH net 01/10] net/mlx5e: Initialize IPsec XArrays with XA_FLAGS_LOCK_BH Tariq Toukan
2026-11-27 22:32   ` netdev-bot+sashiko
2026-11-26 21:56 ` [PATCH net 02/10] net/mlx5e: Stop counting packets dropped by IPsec RX SA rules Tariq Toukan
2026-11-27 22:32   ` netdev-bot+sashiko
2026-11-30  6:57     ` Jianbo Liu
2026-11-26 21:56 ` [PATCH net 03/10] net/mlx5e: Fix IPsec SA modify/stats update race Tariq Toukan
2026-11-27 22:32   ` netdev-bot+sashiko
2026-11-30  7:14     ` Jianbo Liu
2026-11-26 21:56 ` [PATCH net 04/10] net/mlx5e: Drain pending hardware event work before freeing IPsec SA Tariq Toukan
2026-11-27 22:32   ` netdev-bot+sashiko
2026-11-26 21:56 ` [PATCH net 05/10] net/mlx5e: Drop IPsec tunnel traffic if the neigh cannot be created Tariq Toukan
2026-11-27 22:32   ` netdev-bot+sashiko
2026-11-30  7:40     ` Jianbo Liu [this message]
2026-11-26 21:56 ` [PATCH net 07/10] net/mlx5e: Copy back only replay_esn after an IPsec ESN update Tariq Toukan
2026-11-26 21:56 ` [PATCH net 08/10] net/mlx5e: Validate neighbour events before updating IPsec SAs Tariq Toukan
2026-11-27 22:32   ` netdev-bot+sashiko
2026-11-26 21:56 ` [PATCH net 09/10] net/mlx5e: Serialize IPsec netevent MAC snapshots Tariq Toukan
2026-11-26 21:56 ` [PATCH net 10/10] net/mlx5e: Create IPsec flow counters once per SA Tariq Toukan
2026-11-27 22:32   ` netdev-bot+sashiko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=922daa79-0cc7-49a0-80f4-095c8c5d99fb@nvidia.com \
    --to=jianbol@nvidia.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=borisp@nvidia.com \
    --cc=cratiu@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=eedmunds@nvidia.com \
    --cc=gal@nvidia.com \
    --cc=horms@kernel.org \
    --cc=jmassar@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=mbloch@nvidia.com \
    --cc=netdev-bot+sashiko@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=parri.andrea@gmail.com \
    --cc=phaddad@nvidia.com \
    --cc=raeds@nvidia.com \
    --cc=saeedm@nvidia.com \
    --cc=sridhar.samudrala@intel.com \
    --cc=steffen.klassert@secunet.com \
    --cc=tariqt@nvidia.com \
    --cc=willemb@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox