@@ -43,6 +43,10 @@ static const struct nla_policy rtm_nh_policy_get[] = {
43
43
[NHA_ID ] = { .type = NLA_U32 },
44
44
};
45
45
46
+ static const struct nla_policy rtm_nh_policy_del [] = {
47
+ [NHA_ID ] = { .type = NLA_U32 },
48
+ };
49
+
46
50
static const struct nla_policy rtm_nh_policy_dump [] = {
47
51
[NHA_OIF ] = { .type = NLA_U32 },
48
52
[NHA_GROUPS ] = { .type = NLA_FLAG },
@@ -2966,9 +2970,9 @@ static int rtm_new_nexthop(struct sk_buff *skb, struct nlmsghdr *nlh,
2966
2970
return err ;
2967
2971
}
2968
2972
2969
- static int __nh_valid_get_del_req (const struct nlmsghdr * nlh ,
2970
- struct nlattr * * tb , u32 * id ,
2971
- struct netlink_ext_ack * extack )
2973
+ static int nh_valid_get_del_req (const struct nlmsghdr * nlh ,
2974
+ struct nlattr * * tb , u32 * id ,
2975
+ struct netlink_ext_ack * extack )
2972
2976
{
2973
2977
struct nhmsg * nhm = nlmsg_data (nlh );
2974
2978
@@ -2991,26 +2995,12 @@ static int __nh_valid_get_del_req(const struct nlmsghdr *nlh,
2991
2995
return 0 ;
2992
2996
}
2993
2997
2994
- static int nh_valid_get_del_req (const struct nlmsghdr * nlh , u32 * id ,
2995
- struct netlink_ext_ack * extack )
2996
- {
2997
- struct nlattr * tb [ARRAY_SIZE (rtm_nh_policy_get )];
2998
- int err ;
2999
-
3000
- err = nlmsg_parse (nlh , sizeof (struct nhmsg ), tb ,
3001
- ARRAY_SIZE (rtm_nh_policy_get ) - 1 ,
3002
- rtm_nh_policy_get , extack );
3003
- if (err < 0 )
3004
- return err ;
3005
-
3006
- return __nh_valid_get_del_req (nlh , tb , id , extack );
3007
- }
3008
-
3009
2998
/* rtnl */
3010
2999
static int rtm_del_nexthop (struct sk_buff * skb , struct nlmsghdr * nlh ,
3011
3000
struct netlink_ext_ack * extack )
3012
3001
{
3013
3002
struct net * net = sock_net (skb -> sk );
3003
+ struct nlattr * tb [NHA_MAX + 1 ];
3014
3004
struct nl_info nlinfo = {
3015
3005
.nlh = nlh ,
3016
3006
.nl_net = net ,
@@ -3020,7 +3010,12 @@ static int rtm_del_nexthop(struct sk_buff *skb, struct nlmsghdr *nlh,
3020
3010
int err ;
3021
3011
u32 id ;
3022
3012
3023
- err = nh_valid_get_del_req (nlh , & id , extack );
3013
+ err = nlmsg_parse (nlh , sizeof (struct nhmsg ), tb , NHA_MAX ,
3014
+ rtm_nh_policy_del , extack );
3015
+ if (err < 0 )
3016
+ return err ;
3017
+
3018
+ err = nh_valid_get_del_req (nlh , tb , & id , extack );
3024
3019
if (err )
3025
3020
return err ;
3026
3021
@@ -3038,12 +3033,18 @@ static int rtm_get_nexthop(struct sk_buff *in_skb, struct nlmsghdr *nlh,
3038
3033
struct netlink_ext_ack * extack )
3039
3034
{
3040
3035
struct net * net = sock_net (in_skb -> sk );
3036
+ struct nlattr * tb [NHA_MAX + 1 ];
3041
3037
struct sk_buff * skb = NULL ;
3042
3038
struct nexthop * nh ;
3043
3039
int err ;
3044
3040
u32 id ;
3045
3041
3046
- err = nh_valid_get_del_req (nlh , & id , extack );
3042
+ err = nlmsg_parse (nlh , sizeof (struct nhmsg ), tb , NHA_MAX ,
3043
+ rtm_nh_policy_get , extack );
3044
+ if (err < 0 )
3045
+ return err ;
3046
+
3047
+ err = nh_valid_get_del_req (nlh , tb , & id , extack );
3047
3048
if (err )
3048
3049
return err ;
3049
3050
@@ -3157,11 +3158,10 @@ static int nh_valid_dump_req(const struct nlmsghdr *nlh,
3157
3158
struct nh_dump_filter * filter ,
3158
3159
struct netlink_callback * cb )
3159
3160
{
3160
- struct nlattr * tb [ARRAY_SIZE ( rtm_nh_policy_dump ) ];
3161
+ struct nlattr * tb [NHA_MAX + 1 ];
3161
3162
int err ;
3162
3163
3163
- err = nlmsg_parse (nlh , sizeof (struct nhmsg ), tb ,
3164
- ARRAY_SIZE (rtm_nh_policy_dump ) - 1 ,
3164
+ err = nlmsg_parse (nlh , sizeof (struct nhmsg ), tb , NHA_MAX ,
3165
3165
rtm_nh_policy_dump , cb -> extack );
3166
3166
if (err < 0 )
3167
3167
return err ;
@@ -3300,11 +3300,10 @@ static int nh_valid_dump_bucket_req(const struct nlmsghdr *nlh,
3300
3300
struct netlink_callback * cb )
3301
3301
{
3302
3302
struct nlattr * res_tb [ARRAY_SIZE (rtm_nh_res_bucket_policy_dump )];
3303
- struct nlattr * tb [ARRAY_SIZE ( rtm_nh_policy_dump_bucket ) ];
3303
+ struct nlattr * tb [NHA_MAX + 1 ];
3304
3304
int err ;
3305
3305
3306
- err = nlmsg_parse (nlh , sizeof (struct nhmsg ), tb ,
3307
- ARRAY_SIZE (rtm_nh_policy_dump_bucket ) - 1 ,
3306
+ err = nlmsg_parse (nlh , sizeof (struct nhmsg ), tb , NHA_MAX ,
3308
3307
rtm_nh_policy_dump_bucket , NULL );
3309
3308
if (err < 0 )
3310
3309
return err ;
@@ -3474,16 +3473,15 @@ static int nh_valid_get_bucket_req(const struct nlmsghdr *nlh,
3474
3473
u32 * id , u16 * bucket_index ,
3475
3474
struct netlink_ext_ack * extack )
3476
3475
{
3477
- struct nlattr * tb [ARRAY_SIZE ( rtm_nh_policy_get_bucket ) ];
3476
+ struct nlattr * tb [NHA_MAX + 1 ];
3478
3477
int err ;
3479
3478
3480
- err = nlmsg_parse (nlh , sizeof (struct nhmsg ), tb ,
3481
- ARRAY_SIZE (rtm_nh_policy_get_bucket ) - 1 ,
3479
+ err = nlmsg_parse (nlh , sizeof (struct nhmsg ), tb , NHA_MAX ,
3482
3480
rtm_nh_policy_get_bucket , extack );
3483
3481
if (err < 0 )
3484
3482
return err ;
3485
3483
3486
- err = __nh_valid_get_del_req (nlh , tb , id , extack );
3484
+ err = nh_valid_get_del_req (nlh , tb , id , extack );
3487
3485
if (err )
3488
3486
return err ;
3489
3487
0 commit comments