]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: core: neighbour: Inline neigh_update_notify() calls
authorPetr Machata <petrm@nvidia.com>
Wed, 21 Jan 2026 16:43:39 +0000 (17:43 +0100)
committerJakub Kicinski <kuba@kernel.org>
Sun, 25 Jan 2026 22:57:37 +0000 (14:57 -0800)
The obvious idea behind the helper is to keep together the two bits that
should be done either both or neither: the internal notifier chain message,
and the netlink notification.

To make sure that the notification sent reflects the change being made, the
netlink message needs to be send inside the critical section where the
neighbor is changed. But for the notifier chain, there is no such need: the
listeners do not assume lock, and often in fact just schedule a delayed
work to act on the neighbor later. At least one in fact also takes the
neighbor lock. Therefore these two items have each different locking needs.

Now we could unlock inside the helper, but I find that error prone, and the
fact that the notification is conditional in the first place does not help
to make the call site obvious.

So in this patch, the helper is instead removed and the body, which is just
these two calls, inlined. That way we can use each notifier independently.

Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/e65dce5882bc6f4aa2530b8a4877d0e003071a1a.1769012464.git.petrm@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/core/neighbour.c

index 3d969f0190a196f42b73d70edc27ae6722584a95..0fbdaae7df99f8e378b305d6037f8b55305a5a53 100644 (file)
@@ -52,7 +52,6 @@ do {                                          \
 
 static void neigh_timer_handler(struct timer_list *t);
 static void neigh_notify(struct neighbour *n, int type, int flags, u32 pid);
-static void neigh_update_notify(struct neighbour *neigh, u32 nlmsg_pid);
 static void pneigh_ifdown(struct neigh_table *tbl, struct net_device *dev,
                          bool skip_perm);
 
@@ -1187,8 +1186,10 @@ out:
                write_unlock(&neigh->lock);
        }
 
-       if (notify)
-               neigh_update_notify(neigh, 0);
+       if (notify) {
+               call_netevent_notifiers(NETEVENT_NEIGH_UPDATE, neigh);
+               neigh_notify(neigh, RTM_NEWNEIGH, 0, 0);
+       }
 
        trace_neigh_timer_handler(neigh, 0);
 
@@ -1520,8 +1521,12 @@ out:
                neigh_update_gc_list(neigh);
        if (managed_update)
                neigh_update_managed_list(neigh);
-       if (notify)
-               neigh_update_notify(neigh, nlmsg_pid);
+
+       if (notify) {
+               call_netevent_notifiers(NETEVENT_NEIGH_UPDATE, neigh);
+               neigh_notify(neigh, RTM_NEWNEIGH, 0, nlmsg_pid);
+       }
+
        trace_neigh_update_done(neigh, err);
        return err;
 }
@@ -2750,12 +2755,6 @@ nla_put_failure:
        return -EMSGSIZE;
 }
 
-static void neigh_update_notify(struct neighbour *neigh, u32 nlmsg_pid)
-{
-       call_netevent_notifiers(NETEVENT_NEIGH_UPDATE, neigh);
-       neigh_notify(neigh, RTM_NEWNEIGH, 0, nlmsg_pid);
-}
-
 static bool neigh_master_filtered(struct net_device *dev, int master_idx)
 {
        struct net_device *master;