[NETLINK]: Remove error pointer from netlink message handler
The error pointer argument in netlink message handlers is used to signal the special case where processing has to be interrupted because a dump was started but no error happened. Instead it is simpler and more clear to return -EINTR and have netlink_run_queue() deal with getting the queue right. nfnetlink passed on this error pointer to its subsystem handlers but only uses it to signal the start of a netlink dump. Therefore it can be removed there as well. This patch also cleans up the error handling in the affected message handlers to be consistent since it had to be touched anyway. Signed-off-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
45e7ae7f71
commit
1d00a4eb42
@@ -295,60 +295,49 @@ int genl_unregister_family(struct genl_family *family)
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
static int genl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh,
|
||||
int *errp)
|
||||
static int genl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
|
||||
{
|
||||
struct genl_ops *ops;
|
||||
struct genl_family *family;
|
||||
struct genl_info info;
|
||||
struct genlmsghdr *hdr = nlmsg_data(nlh);
|
||||
int hdrlen, err = -EINVAL;
|
||||
int hdrlen, err;
|
||||
|
||||
family = genl_family_find_byid(nlh->nlmsg_type);
|
||||
if (family == NULL) {
|
||||
err = -ENOENT;
|
||||
goto errout;
|
||||
}
|
||||
if (family == NULL)
|
||||
return -ENOENT;
|
||||
|
||||
hdrlen = GENL_HDRLEN + family->hdrsize;
|
||||
if (nlh->nlmsg_len < nlmsg_msg_size(hdrlen))
|
||||
goto errout;
|
||||
return -EINVAL;
|
||||
|
||||
ops = genl_get_cmd(hdr->cmd, family);
|
||||
if (ops == NULL) {
|
||||
err = -EOPNOTSUPP;
|
||||
goto errout;
|
||||
}
|
||||
if (ops == NULL)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
if ((ops->flags & GENL_ADMIN_PERM) && security_netlink_recv(skb, CAP_NET_ADMIN)) {
|
||||
err = -EPERM;
|
||||
goto errout;
|
||||
}
|
||||
if ((ops->flags & GENL_ADMIN_PERM) &&
|
||||
security_netlink_recv(skb, CAP_NET_ADMIN))
|
||||
return -EPERM;
|
||||
|
||||
if (nlh->nlmsg_flags & NLM_F_DUMP) {
|
||||
if (ops->dumpit == NULL) {
|
||||
err = -EOPNOTSUPP;
|
||||
goto errout;
|
||||
}
|
||||
if (ops->dumpit == NULL)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
*errp = err = netlink_dump_start(genl_sock, skb, nlh,
|
||||
ops->dumpit, ops->done);
|
||||
err = netlink_dump_start(genl_sock, skb, nlh,
|
||||
ops->dumpit, ops->done);
|
||||
if (err == 0)
|
||||
skb_pull(skb, min(NLMSG_ALIGN(nlh->nlmsg_len),
|
||||
skb->len));
|
||||
return -1;
|
||||
err = -EINTR;
|
||||
return err;
|
||||
}
|
||||
|
||||
if (ops->doit == NULL) {
|
||||
err = -EOPNOTSUPP;
|
||||
goto errout;
|
||||
}
|
||||
if (ops->doit == NULL)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
if (family->attrbuf) {
|
||||
err = nlmsg_parse(nlh, hdrlen, family->attrbuf, family->maxattr,
|
||||
ops->policy);
|
||||
if (err < 0)
|
||||
goto errout;
|
||||
return err;
|
||||
}
|
||||
|
||||
info.snd_seq = nlh->nlmsg_seq;
|
||||
@@ -358,12 +347,7 @@ static int genl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh,
|
||||
info.userhdr = nlmsg_data(nlh) + GENL_HDRLEN;
|
||||
info.attrs = family->attrbuf;
|
||||
|
||||
*errp = err = ops->doit(skb, &info);
|
||||
return err;
|
||||
|
||||
errout:
|
||||
*errp = err;
|
||||
return -1;
|
||||
return ops->doit(skb, &info);
|
||||
}
|
||||
|
||||
static void genl_rcv(struct sock *sk, int len)
|
||||
|
Reference in New Issue
Block a user