Skip to content

Commit 4d44bcb

Browse files
committed
nexthop: Only parse NHA_OP_FLAGS for get messages that require it
JIRA: https://issues.redhat.com/browse/RHEL-59118 commit dc5e014 Author: Ido Schimmel <idosch@nvidia.com> Date: Mon Mar 11 18:23:04 2024 +0200 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> Signed-off-by: Ivan Vecera <ivecera@redhat.com>
1 parent e0f34c7 commit 4d44bcb

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

net/ipv4/nexthop.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3228,10 +3228,12 @@ static int nh_valid_get_del_req(const struct nlmsghdr *nlh,
32283228
return -EINVAL;
32293229
}
32303230

3231-
if (tb[NHA_OP_FLAGS])
3232-
*op_flags = nla_get_u32(tb[NHA_OP_FLAGS]);
3233-
else
3234-
*op_flags = 0;
3231+
if (op_flags) {
3232+
if (tb[NHA_OP_FLAGS])
3233+
*op_flags = nla_get_u32(tb[NHA_OP_FLAGS]);
3234+
else
3235+
*op_flags = 0;
3236+
}
32353237

32363238
return 0;
32373239
}
@@ -3248,7 +3250,6 @@ static int rtm_del_nexthop(struct sk_buff *skb, struct nlmsghdr *nlh,
32483250
.portid = NETLINK_CB(skb).portid,
32493251
};
32503252
struct nexthop *nh;
3251-
u32 op_flags;
32523253
int err;
32533254
u32 id;
32543255

@@ -3257,7 +3258,7 @@ static int rtm_del_nexthop(struct sk_buff *skb, struct nlmsghdr *nlh,
32573258
if (err < 0)
32583259
return err;
32593260

3260-
err = nh_valid_get_del_req(nlh, tb, &id, &op_flags, extack);
3261+
err = nh_valid_get_del_req(nlh, tb, &id, NULL, extack);
32613262
if (err)
32623263
return err;
32633264

@@ -3729,15 +3730,14 @@ static int nh_valid_get_bucket_req(const struct nlmsghdr *nlh,
37293730
struct netlink_ext_ack *extack)
37303731
{
37313732
struct nlattr *tb[NHA_MAX + 1];
3732-
u32 op_flags;
37333733
int err;
37343734

37353735
err = nlmsg_parse(nlh, sizeof(struct nhmsg), tb, NHA_MAX,
37363736
rtm_nh_policy_get_bucket, extack);
37373737
if (err < 0)
37383738
return err;
37393739

3740-
err = nh_valid_get_del_req(nlh, tb, id, &op_flags, extack);
3740+
err = nh_valid_get_del_req(nlh, tb, id, NULL, extack);
37413741
if (err)
37423742
return err;
37433743

0 commit comments

Comments
 (0)