Skip to content

Commit dc5e014

Browse files
idoschkuba-moo
authored andcommitted
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 <[email protected]> Reviewed-by: David Ahern <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 5f20e6a commit dc5e014

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
@@ -3230,10 +3230,12 @@ static int nh_valid_get_del_req(const struct nlmsghdr *nlh,
32303230
return -EINVAL;
32313231
}
32323232

3233-
if (tb[NHA_OP_FLAGS])
3234-
*op_flags = nla_get_u32(tb[NHA_OP_FLAGS]);
3235-
else
3236-
*op_flags = 0;
3233+
if (op_flags) {
3234+
if (tb[NHA_OP_FLAGS])
3235+
*op_flags = nla_get_u32(tb[NHA_OP_FLAGS]);
3236+
else
3237+
*op_flags = 0;
3238+
}
32373239

32383240
return 0;
32393241
}
@@ -3250,7 +3252,6 @@ static int rtm_del_nexthop(struct sk_buff *skb, struct nlmsghdr *nlh,
32503252
.portid = NETLINK_CB(skb).portid,
32513253
};
32523254
struct nexthop *nh;
3253-
u32 op_flags;
32543255
int err;
32553256
u32 id;
32563257

@@ -3259,7 +3260,7 @@ static int rtm_del_nexthop(struct sk_buff *skb, struct nlmsghdr *nlh,
32593260
if (err < 0)
32603261
return err;
32613262

3262-
err = nh_valid_get_del_req(nlh, tb, &id, &op_flags, extack);
3263+
err = nh_valid_get_del_req(nlh, tb, &id, NULL, extack);
32633264
if (err)
32643265
return err;
32653266

@@ -3716,15 +3717,14 @@ static int nh_valid_get_bucket_req(const struct nlmsghdr *nlh,
37163717
struct netlink_ext_ack *extack)
37173718
{
37183719
struct nlattr *tb[NHA_MAX + 1];
3719-
u32 op_flags;
37203720
int err;
37213721

37223722
err = nlmsg_parse(nlh, sizeof(struct nhmsg), tb, NHA_MAX,
37233723
rtm_nh_policy_get_bucket, extack);
37243724
if (err < 0)
37253725
return err;
37263726

3727-
err = nh_valid_get_del_req(nlh, tb, id, &op_flags, extack);
3727+
err = nh_valid_get_del_req(nlh, tb, id, NULL, extack);
37283728
if (err)
37293729
return err;
37303730

0 commit comments

Comments
 (0)