From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netdev@vger.kernel.org
Cc: kaber@trash.net, davem@davemloft.net
Subject: Re: [PATCH 1/3] netlink: fix NETLINK_RECV_NO_ENOBUFS in netlink_set_err()
Date: Wed, 17 Mar 2010 01:04:20 +0100 [thread overview]
Message-ID: <4BA01C84.2040701@netfilter.org> (raw)
In-Reply-To: <20100316232957.4185.46217.stgit@decadence>
[-- Attachment #1: Type: text/plain, Size: 77 bytes --]
The previous patch was broken, sorry. Please, take this one instead. Thanks!
[-- Attachment #2: netlink.patch --]
[-- Type: text/x-patch, Size: 2806 bytes --]
netlink: fix NETLINK_RECV_NO_ENOBUFS in netlink_set_err()
Currently, ENOBUFS errors are reported to the socket via
netlink_set_err() even if NETLINK_RECV_NO_ENOBUFS is set. However,
that should not happen. This fixes this problem and it changes the
prototype of netlink_set_err() to return the number of sockets whose
error has been set. This allows to know if any error has been set.
This return value is used in the next patch in these bugfix series.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
include/linux/netlink.h | 2 +-
net/netlink/af_netlink.c | 13 +++++++++++--
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/include/linux/netlink.h b/include/linux/netlink.h
index fde27c0..6eaca5e 100644
--- a/include/linux/netlink.h
+++ b/include/linux/netlink.h
@@ -188,7 +188,7 @@ extern int netlink_has_listeners(struct sock *sk, unsigned int group);
extern int netlink_unicast(struct sock *ssk, struct sk_buff *skb, __u32 pid, int nonblock);
extern int netlink_broadcast(struct sock *ssk, struct sk_buff *skb, __u32 pid,
__u32 group, gfp_t allocation);
-extern void netlink_set_err(struct sock *ssk, __u32 pid, __u32 group, int code);
+extern int netlink_set_err(struct sock *ssk, __u32 pid, __u32 group, int code);
extern int netlink_register_notifier(struct notifier_block *nb);
extern int netlink_unregister_notifier(struct notifier_block *nb);
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 4c5972b..4ae2e8f 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -1104,8 +1104,12 @@ static inline int do_one_set_err(struct sock *sk,
!test_bit(p->group - 1, nlk->groups))
goto out;
+ if (p->code == ENOBUFS && nlk->flags & NETLINK_RECV_NO_ENOBUFS)
+ goto out;
+
sk->sk_err = p->code;
sk->sk_error_report(sk);
+ return 1;
out:
return 0;
}
@@ -1116,12 +1120,16 @@ out:
* @pid: the PID of a process that we want to skip (if any)
* @groups: the broadcast group that will notice the error
* @code: error code, must be negative (as usual in kernelspace)
+ *
+ * This function returns the number of broadcast listeners whose error code
+ * has been set.
*/
-void netlink_set_err(struct sock *ssk, u32 pid, u32 group, int code)
+int netlink_set_err(struct sock *ssk, u32 pid, u32 group, int code)
{
struct netlink_set_err_data info;
struct hlist_node *node;
struct sock *sk;
+ int ret = 0;
info.exclude_sk = ssk;
info.pid = pid;
@@ -1132,9 +1140,10 @@ void netlink_set_err(struct sock *ssk, u32 pid, u32 group, int code)
read_lock(&nl_table_lock);
sk_for_each_bound(sk, node, &nl_table[ssk->sk_protocol].mc_list)
- do_one_set_err(sk, &info);
+ ret += do_one_set_err(sk, &info);
read_unlock(&nl_table_lock);
+ return ret;
}
EXPORT_SYMBOL(netlink_set_err);
next prev parent reply other threads:[~2010-03-17 0:04 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-16 23:29 [PATCH 0/3] several minor Netlink fixes Pablo Neira Ayuso
2010-03-16 23:29 ` [PATCH 1/3] netlink: fix NETLINK_RECV_NO_ENOBUFS in netlink_set_err() Pablo Neira Ayuso
2010-03-17 0:04 ` Pablo Neira Ayuso [this message]
2010-03-17 15:26 ` Patrick McHardy
2010-03-17 16:17 ` Pablo Neira Ayuso
2010-03-18 13:02 ` Patrick McHardy
2010-03-18 16:34 ` Pablo Neira Ayuso
2010-03-18 16:46 ` Patrick McHardy
2010-03-18 17:01 ` Pablo Neira Ayuso
2010-03-18 17:22 ` Patrick McHardy
2010-03-19 0:24 ` Pablo Neira Ayuso
2010-03-20 21:30 ` David Miller
2010-03-22 15:38 ` Patrick McHardy
2010-03-16 23:30 ` [PATCH 2/3] netfilter: ctnetlink: fix reliable event delivery if message building fails Pablo Neira Ayuso
2010-03-16 23:30 ` [PATCH 3/3] netlink: fix unaligned access in nla_get_be64() Pablo Neira Ayuso
2010-03-20 5:44 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4BA01C84.2040701@netfilter.org \
--to=pablo@netfilter.org \
--cc=davem@davemloft.net \
--cc=kaber@trash.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).