Commit c702e804 authored by Thomas Graf's avatar Thomas Graf Committed by David S. Miller

[NETLINK]: Directly return -EINTR from netlink_dump_start()

Now that all users of netlink_dump_start() use netlink_run_queue()
to process the receive queue, it is possible to return -EINTR from
netlink_dump_start() directly, therefore simplying the callers.
Signed-off-by: default avatarThomas Graf <tgraf@suug.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ead592ba
...@@ -859,7 +859,6 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) ...@@ -859,7 +859,6 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
int min_len; int min_len;
int family; int family;
int type; int type;
int err;
type = nlh->nlmsg_type; type = nlh->nlmsg_type;
if (type > RTM_MAX) if (type > RTM_MAX)
...@@ -888,10 +887,7 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) ...@@ -888,10 +887,7 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
if (dumpit == NULL) if (dumpit == NULL)
return -EINVAL; return -EINVAL;
err = netlink_dump_start(rtnl, skb, nlh, dumpit, NULL); return netlink_dump_start(rtnl, skb, nlh, dumpit, NULL);
if (err == 0)
err = -EINTR;
return err;
} }
memset(rta_buf, 0, (rtattr_max * sizeof(struct rtattr *))); memset(rta_buf, 0, (rtattr_max * sizeof(struct rtattr *)));
......
...@@ -818,8 +818,6 @@ static int inet_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) ...@@ -818,8 +818,6 @@ static int inet_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
return -ENOENT; return -ENOENT;
if (nlh->nlmsg_flags & NLM_F_DUMP) { if (nlh->nlmsg_flags & NLM_F_DUMP) {
int err;
if (nlmsg_attrlen(nlh, hdrlen)) { if (nlmsg_attrlen(nlh, hdrlen)) {
struct nlattr *attr; struct nlattr *attr;
...@@ -831,11 +829,8 @@ static int inet_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) ...@@ -831,11 +829,8 @@ static int inet_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
return -EINVAL; return -EINVAL;
} }
err = netlink_dump_start(idiagnl, skb, nlh, return netlink_dump_start(idiagnl, skb, nlh,
inet_diag_dump, NULL); inet_diag_dump, NULL);
if (err == 0)
err = -EINTR;
return err;
} }
return inet_diag_get_exact(skb, nlh); return inet_diag_get_exact(skb, nlh);
......
...@@ -724,11 +724,8 @@ ctnetlink_get_conntrack(struct sock *ctnl, struct sk_buff *skb, ...@@ -724,11 +724,8 @@ ctnetlink_get_conntrack(struct sock *ctnl, struct sk_buff *skb,
if (NFNL_MSG_TYPE(nlh->nlmsg_type) == IPCTNL_MSG_CT_GET_CTRZERO) if (NFNL_MSG_TYPE(nlh->nlmsg_type) == IPCTNL_MSG_CT_GET_CTRZERO)
return -ENOTSUPP; return -ENOTSUPP;
#endif #endif
err = netlink_dump_start(ctnl, skb, nlh, ctnetlink_dump_table, return netlink_dump_start(ctnl, skb, nlh, ctnetlink_dump_table,
ctnetlink_done); ctnetlink_done);
if (err == 0)
err = -EINTR;
return err;
} }
if (nfattr_bad_size(cda, CTA_MAX, cta_min)) if (nfattr_bad_size(cda, CTA_MAX, cta_min))
...@@ -1266,12 +1263,9 @@ ctnetlink_get_expect(struct sock *ctnl, struct sk_buff *skb, ...@@ -1266,12 +1263,9 @@ ctnetlink_get_expect(struct sock *ctnl, struct sk_buff *skb,
return -EINVAL; return -EINVAL;
if (nlh->nlmsg_flags & NLM_F_DUMP) { if (nlh->nlmsg_flags & NLM_F_DUMP) {
err = netlink_dump_start(ctnl, skb, nlh, return netlink_dump_start(ctnl, skb, nlh,
ctnetlink_exp_dump_table, ctnetlink_exp_dump_table,
ctnetlink_done); ctnetlink_done);
if (err == 0)
err = -EINTR;
return err;
} }
if (cda[CTA_EXPECT_MASTER-1]) if (cda[CTA_EXPECT_MASTER-1])
......
...@@ -1426,7 +1426,12 @@ int netlink_dump_start(struct sock *ssk, struct sk_buff *skb, ...@@ -1426,7 +1426,12 @@ int netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
netlink_dump(sk); netlink_dump(sk);
sock_put(sk); sock_put(sk);
return 0;
/* We successfully started a dump, by returning -EINTR we
* signal the queue mangement to interrupt processing of
* any netlink messages so userspace gets a chance to read
* the results. */
return -EINTR;
} }
void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err) void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err)
......
...@@ -323,11 +323,8 @@ static int genl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) ...@@ -323,11 +323,8 @@ static int genl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
if (ops->dumpit == NULL) if (ops->dumpit == NULL)
return -EOPNOTSUPP; return -EOPNOTSUPP;
err = netlink_dump_start(genl_sock, skb, nlh, return netlink_dump_start(genl_sock, skb, nlh,
ops->dumpit, ops->done); ops->dumpit, ops->done);
if (err == 0)
err = -EINTR;
return err;
} }
if (ops->doit == NULL) if (ops->doit == NULL)
......
...@@ -1856,7 +1856,7 @@ static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) ...@@ -1856,7 +1856,7 @@ static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
{ {
struct rtattr *xfrma[XFRMA_MAX]; struct rtattr *xfrma[XFRMA_MAX];
struct xfrm_link *link; struct xfrm_link *link;
int type, min_len, err; int type, min_len;
type = nlh->nlmsg_type; type = nlh->nlmsg_type;
if (type > XFRM_MSG_MAX) if (type > XFRM_MSG_MAX)
...@@ -1875,10 +1875,7 @@ static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) ...@@ -1875,10 +1875,7 @@ static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
if (link->dump == NULL) if (link->dump == NULL)
return -EINVAL; return -EINVAL;
err = netlink_dump_start(xfrm_nl, skb, nlh, link->dump, NULL); return netlink_dump_start(xfrm_nl, skb, nlh, link->dump, NULL);
if (err == 0)
err = -EINTR;
return err;
} }
memset(xfrma, 0, sizeof(xfrma)); memset(xfrma, 0, sizeof(xfrma));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment