]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
rtnetlink: Add RTNH_F_TRAP flag
authorIdo Schimmel <idosch@nvidia.com>
Wed, 4 Nov 2020 13:30:27 +0000 (15:30 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 2 Oct 2025 11:35:46 +0000 (13:35 +0200)
[ Upstream commit 968a83f8cf6fd5a107289c57ee3197a52c72f02c ]

The flag indicates to user space that the nexthop is not programmed to
forward packets in hardware, but rather to trap them to the CPU. This is
needed, for example, when the MAC of the nexthop neighbour is not
resolved and packets should reach the CPU to trigger neighbour
resolution.

The flag will be used in subsequent patches by netdevsim to test nexthop
objects programming to device drivers and in the future by mlxsw as
well.

Changes since RFC:
* Reword commit message

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: David Ahern <dsahern@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Stable-dep-of: 390b3a300d78 ("nexthop: Forbid FDB status change while nexthop is in a group")
Signed-off-by: Sasha Levin <sashal@kernel.org>
include/uapi/linux/rtnetlink.h
net/ipv4/fib_semantics.c

index 31be7345e0c2e801ba1b9193a5e52bbc15c56790..5fb40c0c57ffda4390ad39108d0c8ee644f78bd9 100644 (file)
@@ -396,11 +396,13 @@ struct rtnexthop {
 #define RTNH_F_DEAD            1       /* Nexthop is dead (used by multipath)  */
 #define RTNH_F_PERVASIVE       2       /* Do recursive gateway lookup  */
 #define RTNH_F_ONLINK          4       /* Gateway is forced on link    */
-#define RTNH_F_OFFLOAD         8       /* offloaded route */
+#define RTNH_F_OFFLOAD         8       /* Nexthop is offloaded */
 #define RTNH_F_LINKDOWN                16      /* carrier-down on nexthop */
 #define RTNH_F_UNRESOLVED      32      /* The entry is unresolved (ipmr) */
+#define RTNH_F_TRAP            64      /* Nexthop is trapping packets */
 
-#define RTNH_COMPARE_MASK      (RTNH_F_DEAD | RTNH_F_LINKDOWN | RTNH_F_OFFLOAD)
+#define RTNH_COMPARE_MASK      (RTNH_F_DEAD | RTNH_F_LINKDOWN | \
+                                RTNH_F_OFFLOAD | RTNH_F_TRAP)
 
 /* Macros to handle hexthops */
 
index a308d3f0f845ca805e80fdc8c8c4802774b66ec3..48516a403a9bbd77fc9a503e247d7456847315e6 100644 (file)
@@ -1705,6 +1705,8 @@ int fib_nexthop_info(struct sk_buff *skb, const struct fib_nh_common *nhc,
        *flags |= (nhc->nhc_flags & RTNH_F_ONLINK);
        if (nhc->nhc_flags & RTNH_F_OFFLOAD)
                *flags |= RTNH_F_OFFLOAD;
+       if (nhc->nhc_flags & RTNH_F_TRAP)
+               *flags |= RTNH_F_TRAP;
 
        if (!skip_oif && nhc->nhc_dev &&
            nla_put_u32(skb, RTA_OIF, nhc->nhc_dev->ifindex))