diff options
author | Ido Schimmel <idosch@nvidia.com> | 2024-03-11 17:23:04 +0100 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2024-03-12 04:35:20 +0100 |
commit | dc5e0141ff19439bfe8d54fce6d6b834bdf1efe0 (patch) | |
tree | 976dabc449949a2d5b2fcca620f820c6ffed4995 /net/ipv4/nexthop.c | |
parent | Merge tag 'for-netdev' of https://git.kernel.org/pub/scm/linux/kernel/git/bpf... (diff) | |
download | linux-dc5e0141ff19439bfe8d54fce6d6b834bdf1efe0.tar.xz linux-dc5e0141ff19439bfe8d54fce6d6b834bdf1efe0.zip |
nexthop: Only parse NHA_OP_FLAGS for get messages that require it
The attribute is parsed into 'op_flags' in nh_valid_get_del_req() which
is called from the handlers of three message types: RTM_DELNEXTHOP,
RTM_GETNEXTHOPBUCKET and RTM_GETNEXTHOP. The attribute is only used by
the latter and rejected by the policies of the other two.
Pass 'op_flags' as NULL from the handlers of the other two and only
parse the attribute when the argument is not NULL.
This is a preparation for a subsequent patch.
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Link: https://lore.kernel.org/r/20240311162307.545385-2-idosch@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net/ipv4/nexthop.c')
-rw-r--r-- | net/ipv4/nexthop.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c index 73b849be6504..6901fa390651 100644 --- a/net/ipv4/nexthop.c +++ b/net/ipv4/nexthop.c @@ -3230,10 +3230,12 @@ static int nh_valid_get_del_req(const struct nlmsghdr *nlh, return -EINVAL; } - if (tb[NHA_OP_FLAGS]) - *op_flags = nla_get_u32(tb[NHA_OP_FLAGS]); - else - *op_flags = 0; + if (op_flags) { + if (tb[NHA_OP_FLAGS]) + *op_flags = nla_get_u32(tb[NHA_OP_FLAGS]); + else + *op_flags = 0; + } return 0; } @@ -3250,7 +3252,6 @@ static int rtm_del_nexthop(struct sk_buff *skb, struct nlmsghdr *nlh, .portid = NETLINK_CB(skb).portid, }; struct nexthop *nh; - u32 op_flags; int err; u32 id; @@ -3259,7 +3260,7 @@ static int rtm_del_nexthop(struct sk_buff *skb, struct nlmsghdr *nlh, if (err < 0) return err; - err = nh_valid_get_del_req(nlh, tb, &id, &op_flags, extack); + err = nh_valid_get_del_req(nlh, tb, &id, NULL, extack); if (err) return err; @@ -3716,7 +3717,6 @@ static int nh_valid_get_bucket_req(const struct nlmsghdr *nlh, struct netlink_ext_ack *extack) { struct nlattr *tb[NHA_MAX + 1]; - u32 op_flags; int err; err = nlmsg_parse(nlh, sizeof(struct nhmsg), tb, NHA_MAX, @@ -3724,7 +3724,7 @@ static int nh_valid_get_bucket_req(const struct nlmsghdr *nlh, if (err < 0) return err; - err = nh_valid_get_del_req(nlh, tb, id, &op_flags, extack); + err = nh_valid_get_del_req(nlh, tb, id, NULL, extack); if (err) return err; |