Message ID | 20201104133040.1125369-6-idosch@idosch.org |
---|---|
State | New |
Headers | show |
Series | nexthop: Add support for nexthop objects offload | expand |
On Wed, 4 Nov 2020 15:30:27 +0200 Ido Schimmel wrote: > *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; Out of curiosity - why use this if construct like OFFLOAD rather than the more concise mask like ONLINK does? In fact looks like the mask could just be extended there instead?
On Fri, Nov 06, 2020 at 11:12:21AM -0800, Jakub Kicinski wrote: > On Wed, 4 Nov 2020 15:30:27 +0200 Ido Schimmel wrote: > > *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; > > Out of curiosity - why use this if construct like OFFLOAD rather than > the more concise mask like ONLINK does? Good question :) > In fact looks like the mask could just be extended there instead? Yes, good suggestion. Will do that.
diff --git a/include/uapi/linux/rtnetlink.h b/include/uapi/linux/rtnetlink.h index fdd408f6a5d2..a0d3363c6bd3 100644 --- a/include/uapi/linux/rtnetlink.h +++ b/include/uapi/linux/rtnetlink.h @@ -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 */ diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c index 1f75dc686b6b..f70b9a0c4957 100644 --- a/net/ipv4/fib_semantics.c +++ b/net/ipv4/fib_semantics.c @@ -1644,6 +1644,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))