Message ID | ba50a38cbf211cc98bdbebfda53226a1785f73e7.1722519021.git.petrm@nvidia.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | net: nexthop: Increase weight to u16 | expand |
On Thu, 1 Aug 2024 18:23:57 +0200 Petr Machata wrote: > diff --git a/include/uapi/linux/nexthop.h b/include/uapi/linux/nexthop.h > index dd8787f9cf39..2ed643207847 100644 > --- a/include/uapi/linux/nexthop.h > +++ b/include/uapi/linux/nexthop.h > @@ -33,6 +33,9 @@ enum { > #define NHA_OP_FLAG_DUMP_STATS BIT(0) > #define NHA_OP_FLAG_DUMP_HW_STATS BIT(1) > > +/* Response OP_FLAGS. */ > +#define NHA_OP_FLAG_RESP_GRP_RESVD_0 BIT(0) I guess these are op flags, so nobody should have a need to store them, but having bits mean different things in and out make decoding and binding generation much harder. Let's not do this unless absolutely necessary. Perhaps you can start defining response flags from the "other end", i.e. bit 31? Chances are the two sides will never "meet".
Jakub Kicinski <kuba@kernel.org> writes: > On Thu, 1 Aug 2024 18:23:57 +0200 Petr Machata wrote: >> diff --git a/include/uapi/linux/nexthop.h b/include/uapi/linux/nexthop.h >> index dd8787f9cf39..2ed643207847 100644 >> --- a/include/uapi/linux/nexthop.h >> +++ b/include/uapi/linux/nexthop.h >> @@ -33,6 +33,9 @@ enum { >> #define NHA_OP_FLAG_DUMP_STATS BIT(0) >> #define NHA_OP_FLAG_DUMP_HW_STATS BIT(1) >> >> +/* Response OP_FLAGS. */ >> +#define NHA_OP_FLAG_RESP_GRP_RESVD_0 BIT(0) > > I guess these are op flags, so nobody should have a need to store them, > but having bits mean different things in and out make decoding and > binding generation much harder. Let's not do this unless absolutely > necessary. Perhaps you can start defining response flags from the > "other end", i.e. bit 31? Chances are the two sides will never "meet". OK.
diff --git a/include/uapi/linux/nexthop.h b/include/uapi/linux/nexthop.h index dd8787f9cf39..2ed643207847 100644 --- a/include/uapi/linux/nexthop.h +++ b/include/uapi/linux/nexthop.h @@ -33,6 +33,9 @@ enum { #define NHA_OP_FLAG_DUMP_STATS BIT(0) #define NHA_OP_FLAG_DUMP_HW_STATS BIT(1) +/* Response OP_FLAGS. */ +#define NHA_OP_FLAG_RESP_GRP_RESVD_0 BIT(0) + enum { NHA_UNSPEC, NHA_ID, /* u32; id for nexthop. id == 0 means auto-assign */ diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c index 6b9787ee8601..23caa13bf24d 100644 --- a/net/ipv4/nexthop.c +++ b/net/ipv4/nexthop.c @@ -865,7 +865,7 @@ static int nla_put_nh_group_stats(struct sk_buff *skb, struct nexthop *nh, } static int nla_put_nh_group(struct sk_buff *skb, struct nexthop *nh, - u32 op_flags) + u32 op_flags, u32 *resp_op_flags) { struct nh_group *nhg = rtnl_dereference(nh->nh_grp); struct nexthop_grp *p; @@ -874,6 +874,8 @@ static int nla_put_nh_group(struct sk_buff *skb, struct nexthop *nh, u16 group_type = 0; int i; + *resp_op_flags |= NHA_OP_FLAG_RESP_GRP_RESVD_0; + if (nhg->hash_threshold) group_type = NEXTHOP_GRP_TYPE_MPATH; else if (nhg->resilient) @@ -934,10 +936,12 @@ static int nh_fill_node(struct sk_buff *skb, struct nexthop *nh, if (nh->is_group) { struct nh_group *nhg = rtnl_dereference(nh->nh_grp); + u32 resp_op_flags = 0; if (nhg->fdb_nh && nla_put_flag(skb, NHA_FDB)) goto nla_put_failure; - if (nla_put_nh_group(skb, nh, op_flags)) + if (nla_put_nh_group(skb, nh, op_flags, &resp_op_flags) || + nla_put_u32(skb, NHA_OP_FLAGS, resp_op_flags)) goto nla_put_failure; goto out; } @@ -1050,7 +1054,9 @@ static size_t nh_nlmsg_size(struct nexthop *nh) sz += nla_total_size(4); /* NHA_ID */ if (nh->is_group) - sz += nh_nlmsg_size_grp(nh); + sz += nh_nlmsg_size_grp(nh) + + nla_total_size(4) + /* NHA_OP_FLAGS */ + 0; else sz += nh_nlmsg_size_single(nh);