@@ -2910,10 +2910,9 @@ static int neigh_dump_info(struct sk_buff *skb, struct netlink_callback *cb)
2910
2910
return err ;
2911
2911
}
2912
2912
2913
- static int neigh_valid_get_req (const struct nlmsghdr * nlh ,
2914
- struct neigh_table * * tbl ,
2915
- void * * dst , int * dev_idx , u8 * ndm_flags ,
2916
- struct netlink_ext_ack * extack )
2913
+ static struct ndmsg * neigh_valid_get_req (const struct nlmsghdr * nlh ,
2914
+ struct neigh_table * * tbl , void * * dst ,
2915
+ struct netlink_ext_ack * extack )
2917
2916
{
2918
2917
struct nlattr * tb [NDA_MAX + 1 ];
2919
2918
struct ndmsg * ndm ;
@@ -2922,31 +2921,29 @@ static int neigh_valid_get_req(const struct nlmsghdr *nlh,
2922
2921
ndm = nlmsg_payload (nlh , sizeof (* ndm ));
2923
2922
if (!ndm ) {
2924
2923
NL_SET_ERR_MSG (extack , "Invalid header for neighbor get request" );
2925
- return - EINVAL ;
2924
+ return ERR_PTR ( - EINVAL ) ;
2926
2925
}
2927
2926
2928
2927
if (ndm -> ndm_pad1 || ndm -> ndm_pad2 || ndm -> ndm_state ||
2929
2928
ndm -> ndm_type ) {
2930
2929
NL_SET_ERR_MSG (extack , "Invalid values in header for neighbor get request" );
2931
- return - EINVAL ;
2930
+ return ERR_PTR ( - EINVAL ) ;
2932
2931
}
2933
2932
2934
2933
if (ndm -> ndm_flags & ~NTF_PROXY ) {
2935
2934
NL_SET_ERR_MSG (extack , "Invalid flags in header for neighbor get request" );
2936
- return - EINVAL ;
2935
+ return ERR_PTR ( - EINVAL ) ;
2937
2936
}
2938
2937
2939
2938
err = nlmsg_parse_deprecated_strict (nlh , sizeof (struct ndmsg ), tb ,
2940
2939
NDA_MAX , nda_policy , extack );
2941
2940
if (err < 0 )
2942
- return err ;
2941
+ return ERR_PTR ( err ) ;
2943
2942
2944
- * ndm_flags = ndm -> ndm_flags ;
2945
- * dev_idx = ndm -> ndm_ifindex ;
2946
2943
* tbl = neigh_find_table (ndm -> ndm_family );
2947
- if (* tbl == NULL ) {
2944
+ if (! * tbl ) {
2948
2945
NL_SET_ERR_MSG (extack , "Unsupported family in header for neighbor get request" );
2949
- return - EAFNOSUPPORT ;
2946
+ return ERR_PTR ( - EAFNOSUPPORT ) ;
2950
2947
}
2951
2948
2952
2949
for (i = 0 ; i <= NDA_MAX ; ++ i ) {
@@ -2957,17 +2954,17 @@ static int neigh_valid_get_req(const struct nlmsghdr *nlh,
2957
2954
case NDA_DST :
2958
2955
if (nla_len (tb [i ]) != (int )(* tbl )-> key_len ) {
2959
2956
NL_SET_ERR_MSG (extack , "Invalid network address in neighbor get request" );
2960
- return - EINVAL ;
2957
+ return ERR_PTR ( - EINVAL ) ;
2961
2958
}
2962
2959
* dst = nla_data (tb [i ]);
2963
2960
break ;
2964
2961
default :
2965
2962
NL_SET_ERR_MSG (extack , "Unsupported attribute in neighbor get request" );
2966
- return - EINVAL ;
2963
+ return ERR_PTR ( - EINVAL ) ;
2967
2964
}
2968
2965
}
2969
2966
2970
- return 0 ;
2967
+ return ndm ;
2971
2968
}
2972
2969
2973
2970
static inline size_t neigh_nlmsg_size (void )
@@ -3038,18 +3035,16 @@ static int neigh_get(struct sk_buff *in_skb, struct nlmsghdr *nlh,
3038
3035
struct net_device * dev = NULL ;
3039
3036
struct neigh_table * tbl = NULL ;
3040
3037
struct neighbour * neigh ;
3038
+ struct ndmsg * ndm ;
3041
3039
void * dst = NULL ;
3042
- u8 ndm_flags = 0 ;
3043
- int dev_idx = 0 ;
3044
3040
int err ;
3045
3041
3046
- err = neigh_valid_get_req (nlh , & tbl , & dst , & dev_idx , & ndm_flags ,
3047
- extack );
3048
- if (err < 0 )
3049
- return err ;
3042
+ ndm = neigh_valid_get_req (nlh , & tbl , & dst , extack );
3043
+ if (IS_ERR (ndm ))
3044
+ return PTR_ERR (ndm );
3050
3045
3051
- if (dev_idx ) {
3052
- dev = __dev_get_by_index (net , dev_idx );
3046
+ if (ndm -> ndm_ifindex ) {
3047
+ dev = __dev_get_by_index (net , ndm -> ndm_ifindex );
3053
3048
if (!dev ) {
3054
3049
NL_SET_ERR_MSG (extack , "Unknown device ifindex" );
3055
3050
return - ENODEV ;
@@ -3061,7 +3056,7 @@ static int neigh_get(struct sk_buff *in_skb, struct nlmsghdr *nlh,
3061
3056
return - EINVAL ;
3062
3057
}
3063
3058
3064
- if (ndm_flags & NTF_PROXY ) {
3059
+ if (ndm -> ndm_flags & NTF_PROXY ) {
3065
3060
struct pneigh_entry * pn ;
3066
3061
3067
3062
pn = pneigh_lookup (tbl , net , dst , dev , 0 );
0 commit comments