[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: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 14241ad..fa5f938 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -859,7 +859,6 @@
int min_len;
int family;
int type;
- int err;
type = nlh->nlmsg_type;
if (type > RTM_MAX)
@@ -888,10 +887,7 @@
if (dumpit == NULL)
return -EINVAL;
- err = netlink_dump_start(rtnl, skb, nlh, dumpit, NULL);
- if (err == 0)
- err = -EINTR;
- return err;
+ return netlink_dump_start(rtnl, skb, nlh, dumpit, NULL);
}
memset(rta_buf, 0, (rtattr_max * sizeof(struct rtattr *)));
diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c
index 7dd97c5..0148f0e 100644
--- a/net/ipv4/inet_diag.c
+++ b/net/ipv4/inet_diag.c
@@ -818,8 +818,6 @@
return -ENOENT;
if (nlh->nlmsg_flags & NLM_F_DUMP) {
- int err;
-
if (nlmsg_attrlen(nlh, hdrlen)) {
struct nlattr *attr;
@@ -831,11 +829,8 @@
return -EINVAL;
}
- err = netlink_dump_start(idiagnl, skb, nlh,
- inet_diag_dump, NULL);
- if (err == 0)
- err = -EINTR;
- return err;
+ return netlink_dump_start(idiagnl, skb, nlh,
+ inet_diag_dump, NULL);
}
return inet_diag_get_exact(skb, nlh);
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index 443ba77..e526730 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -724,11 +724,8 @@
if (NFNL_MSG_TYPE(nlh->nlmsg_type) == IPCTNL_MSG_CT_GET_CTRZERO)
return -ENOTSUPP;
#endif
- err = netlink_dump_start(ctnl, skb, nlh, ctnetlink_dump_table,
- ctnetlink_done);
- if (err == 0)
- err = -EINTR;
- return err;
+ return netlink_dump_start(ctnl, skb, nlh, ctnetlink_dump_table,
+ ctnetlink_done);
}
if (nfattr_bad_size(cda, CTA_MAX, cta_min))
@@ -1266,12 +1263,9 @@
return -EINVAL;
if (nlh->nlmsg_flags & NLM_F_DUMP) {
- err = netlink_dump_start(ctnl, skb, nlh,
- ctnetlink_exp_dump_table,
- ctnetlink_done);
- if (err == 0)
- err = -EINTR;
- return err;
+ return netlink_dump_start(ctnl, skb, nlh,
+ ctnetlink_exp_dump_table,
+ ctnetlink_done);
}
if (cda[CTA_EXPECT_MASTER-1])
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 1823b7c..2cbf168 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -1426,7 +1426,12 @@
netlink_dump(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)
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
index 1b897bc..fac2e7a 100644
--- a/net/netlink/genetlink.c
+++ b/net/netlink/genetlink.c
@@ -323,11 +323,8 @@
if (ops->dumpit == NULL)
return -EOPNOTSUPP;
- err = netlink_dump_start(genl_sock, skb, nlh,
- ops->dumpit, ops->done);
- if (err == 0)
- err = -EINTR;
- return err;
+ return netlink_dump_start(genl_sock, skb, nlh,
+ ops->dumpit, ops->done);
}
if (ops->doit == NULL)
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index 5e52d62..2ff9683 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -1856,7 +1856,7 @@
{
struct rtattr *xfrma[XFRMA_MAX];
struct xfrm_link *link;
- int type, min_len, err;
+ int type, min_len;
type = nlh->nlmsg_type;
if (type > XFRM_MSG_MAX)
@@ -1875,10 +1875,7 @@
if (link->dump == NULL)
return -EINVAL;
- err = netlink_dump_start(xfrm_nl, skb, nlh, link->dump, NULL);
- if (err == 0)
- err = -EINTR;
- return err;
+ return netlink_dump_start(xfrm_nl, skb, nlh, link->dump, NULL);
}
memset(xfrma, 0, sizeof(xfrma));