All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: petrm@nvidia.com
Cc: Jakub Kicinski <kuba@kernel.org>,
	netdev@vger.kernel.org, edumazet@google.com, horms@kernel.org,
	davem@davemloft.net, pabeni@redhat.com
Subject: Re: [net-next,5/8] net: core: neighbour: Inline neigh_update_notify() calls
Date: Sat, 17 Jan 2026 18:26:30 -0800	[thread overview]
Message-ID: <20260118022629.1105469-2-kuba@kernel.org> (raw)
In-Reply-To: <e1528224375ebd8789994668a286fb3105dbb2c4.1768225160.git.petrm@nvidia.com>

I'm a bit behind so I haven't validated this myself TBH,
but in the interest of time perhaps you can TAL?

This is an AI-generated review of your patch.
For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
net: core: neighbour: Make another netlink notification atomically

This commit moves the netlink notification call in neigh_timer_handler()
earlier, into the critical section before neigh_probe() releases the lock,
to fix a race where notifications could reflect stale state.

> diff --git a/net/core/neighbour.c b/net/core/neighbour.c
> index 635d71c6420f..5512dd7035b1 100644
> --- a/net/core/neighbour.c
> +++ b/net/core/neighbour.c

[ ... ]

Earlier in the function, when max probes are exhausted, there is this code:

        if ((neigh->nud_state & (NUD_INCOMPLETE | NUD_PROBE)) &&
            atomic_read(&neigh->probes) >= neigh_max_probes(neigh)) {
                ...
                notify = 1;
                goto out;
        }

Then the new code places __neigh_notify() here:

> @@ -1180,6 +1180,10 @@ static void neigh_timer_handler(struct timer_list *t)
>  		if (!mod_timer(&neigh->timer, next))
>  			neigh_hold(neigh);
>  	}
> +
> +	if (notify)
> +		__neigh_notify(neigh, RTM_NEWNEIGH, 0, 0);
> +
>  	if (neigh->nud_state & (NUD_INCOMPLETE | NUD_PROBE)) {
>  		neigh_probe(neigh);
>  	} else {
> @@ -1187,10 +1191,8 @@ static void neigh_timer_handler(struct timer_list *t)
> out:
>  		write_unlock(&neigh->lock);
>  	}
> -
> -	if (notify) {
> -		neigh_notify(neigh, RTM_NEWNEIGH, 0, 0);
> +	if (notify)
>  		call_netevent_notifiers(NETEVENT_NEIGH_UPDATE, neigh);
> -	}

When the neighbor exhausts max probes and transitions to NUD_FAILED or
NUD_STALE, the code sets notify = 1 and then does goto out. This jumps
directly to the out: label, skipping the new __neigh_notify() call.

The old code called neigh_notify() after the out: label, so the netlink
notification was always sent when notify was set. With this change, the
goto out path no longer sends the netlink notification to userspace,
though it still calls call_netevent_notifiers() for kernel-internal
listeners.

Is this an oversight? Should the __neigh_notify() call be placed before the
goto out, or should the goto out path have its own __neigh_notify() call?

  reply	other threads:[~2026-01-18  2:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-14  9:54 [PATCH net-next 0/8] net: neighbour: Notify changes atomically Petr Machata
2026-01-14  9:54 ` [PATCH net-next 1/8] net: core: neighbour: Add a neigh_fill_info() helper for when lock not held Petr Machata
2026-01-16  7:22   ` Kuniyuki Iwashima
2026-01-16 12:01     ` Petr Machata
2026-01-19 12:25       ` Petr Machata
2026-01-14  9:54 ` [PATCH net-next 2/8] net: core: neighbour: Call __neigh_notify() under a lock Petr Machata
2026-01-14  9:54 ` [PATCH net-next 3/8] net: core: neighbour: Extract ARP queue processing to a helper function Petr Machata
2026-01-14  9:54 ` [PATCH net-next 4/8] net: core: neighbour: Process ARP queue later Petr Machata
2026-01-14  9:54 ` [PATCH net-next 5/8] net: core: neighbour: Inline neigh_update_notify() calls Petr Machata
2026-01-18  2:26   ` Jakub Kicinski [this message]
2026-01-19  8:51     ` [net-next,5/8] " Petr Machata
2026-01-14  9:54 ` [PATCH net-next 6/8] net: core: neighbour: Reorder netlink & internal notification Petr Machata
2026-01-14  9:54 ` [PATCH net-next 7/8] net: core: neighbour: Make one netlink notification atomically Petr Machata
2026-01-14  9:54 ` [PATCH net-next 8/8] net: core: neighbour: Make another " Petr Machata

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=20260118022629.1105469-2-kuba@kernel.org \
    --to=kuba@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=petrm@nvidia.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.