Skip to contentSkip to conversation

several minor Netlink fixes

PATCH Applied Pablo Neira Ayuso 3 participants 16 messages Mar 16, 2010 – Mar 22, 2010

Subsystems (3)
lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

cover several minor Netlink fixes

Hi!

This patchset contains a couple of fixes for Netlink related stuff. More relevantly, a path that allows to set ENOBUFS when NETLINK_NO_ENOBUFS is set (that should not happen). It follows the corresponding fix for ctnetlink. This patchset closes with one fix for a unaligned access.

Please apply! Thanks!

---

Pablo Neira Ayuso (3):
netlink: fix NETLINK_RECV_NO_ENOBUFS in netlink_set_err()
netfilter: ctnetlink: fix reliable event delivery if message building fails
netlink: fix unaligned access in nla_get_be64()

 include/linux/netfilter/nfnetlink.h  |    2 +-
 include/linux/netlink.h              |    2 +-
 include/net/netlink.h                |    6 +++++-
 net/netfilter/nf_conntrack_netlink.c |    4 +++-
 net/netfilter/nfnetlink.c            |    4 ++--
 net/netlink/af_netlink.c             |   13 +++++++++++--
 6 files changed, 23 insertions(+), 8 deletions(-)
author maintainer
#1 lore raw

PATCH 1/3 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.

---
 include/linux/netlink.h  |    2 +-
 net/netlink/af_netlink.c |   13 +++++++++++--
 2 files changed, 12 insertions(+), 3 deletions(-)
include/linux/netlink.h +1 -1
index fde27c0..6eaca5e 100644
@@ -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);
 
net/netlink/af_netlink.c +11 -2
index 4c5972b..24ec840 100644
@@ -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);
 
author maintainer
#13 lore raw

PATCH 2/3 netfilter: ctnetlink: fix reliable event delivery if message building fails

In reply to Pablo Neira Ayuso

This patch fixes a bug that allows to lose events when reliable event delivery mode is used, ie. if NETLINK_BROADCAST_SEND_ERROR and NETLINK_RECV_NO_ENOBUFS socket options are set.

---
 include/linux/netfilter/nfnetlink.h  |    2 +-
 net/netfilter/nf_conntrack_netlink.c |    4 +++-
 net/netfilter/nfnetlink.c            |    4 ++--
 3 files changed, 6 insertions(+), 4 deletions(-)
include/linux/netfilter/nfnetlink.h +1 -1
index 5392386..361d6b5 100644
@@ -76,7 +76,7 @@ extern int nfnetlink_subsys_unregister(const struct nfnetlink_subsystem *n);
 extern int nfnetlink_has_listeners(struct net *net, unsigned int group);
 extern int nfnetlink_send(struct sk_buff *skb, struct net *net, u32 pid, unsigned group,
 			  int echo, gfp_t flags);
-extern void nfnetlink_set_err(struct net *net, u32 pid, u32 group, int error);
+extern int nfnetlink_set_err(struct net *net, u32 pid, u32 group, int error);
 extern int nfnetlink_unicast(struct sk_buff *skb, struct net *net, u_int32_t pid, int flags);
 
 extern void nfnl_lock(void);
net/netfilter/nf_conntrack_netlink.c +3 -1
index 8b05f36..00016e0 100644
@@ -582,7 +582,9 @@ nla_put_failure:
 nlmsg_failure:
 	kfree_skb(skb);
 errout:
-	nfnetlink_set_err(net, 0, group, -ENOBUFS);
+	if (nfnetlink_set_err(net, 0, group, -ENOBUFS) > 0)
+		return -ENOBUFS;
+
 	return 0;
 }
 #endif /* CONFIG_NF_CONNTRACK_EVENTS */
net/netfilter/nfnetlink.c +2 -2
index 8eb0cc2..6afa3d5 100644
@@ -113,9 +113,9 @@ int nfnetlink_send(struct sk_buff *skb, struct net *net, u32 pid,
 }
 EXPORT_SYMBOL_GPL(nfnetlink_send);
 
-void nfnetlink_set_err(struct net *net, u32 pid, u32 group, int error)
+int nfnetlink_set_err(struct net *net, u32 pid, u32 group, int error)
 {
-	netlink_set_err(net->nfnl, pid, group, error);
+	return netlink_set_err(net->nfnl, pid, group, error);
 }
 EXPORT_SYMBOL_GPL(nfnetlink_set_err);
 
author maintainer
#14 lore raw

PATCH 3/3 netlink: fix unaligned access in nla_get_be64()

In reply to Pablo Neira Ayuso

This patch fixes a unaligned access in nla_get_be64() that was introduced by myself in a17c859849402315613a0015ac8fbf101acf0cc1.

---
 include/net/netlink.h |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
include/net/netlink.h +5 -1
index a63b219..668ad04 100644
@@ -945,7 +945,11 @@ static inline u64 nla_get_u64(const struct nlattr *nla)
  */
 static inline __be64 nla_get_be64(const struct nlattr *nla)
 {
-	return *(__be64 *) nla_data(nla);
+	__be64 tmp;
+
+	nla_memcpy(&tmp, nla, sizeof(tmp));
+
+	return tmp;
 }
 
 /**
author maintainer
#2 lore raw

Re: [PATCH 1/3] netlink: fix NETLINK_RECV_NO_ENOBUFS in netlink_set_err()

In reply to Pablo Neira Ayuso

The previous patch was broken, sorry. Please, take this one instead. Thanks!

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.

---
 include/linux/netlink.h  |    2 +-
 net/netlink/af_netlink.c |   13 +++++++++++--
 2 files changed, 12 insertions(+), 3 deletions(-)
include/linux/netlink.h +1 -1
index fde27c0..6eaca5e 100644
@@ -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);
 
net/netlink/af_netlink.c +11 -2
index 4c5972b..4ae2e8f 100644
@@ -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);
 
#3 lore raw

Re: [PATCH 1/3] netlink: fix NETLINK_RECV_NO_ENOBUFS in netlink_set_err()

In reply to Pablo Neira Ayuso
Quoted 6 lines · Pablo Neira Ayuso

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.

But that only happens if we have a message allocate error, which is a different situation than rcvqueue overrun, which I thought the original patch was supposed to handle (disable netlink congestion control).

Is there any problem with these errors?

author maintainer
#4 lore raw

Re: [PATCH 1/3] netlink: fix NETLINK_RECV_NO_ENOBUFS in netlink_set_err()

Quoted 8 lines · Patrick McHardy
Quoted 6 lines · Pablo Neira Ayuso

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.

Quoted 4 lines

But that only happens if we have a message allocate error, which is a different situation than rcvqueue overrun, which I thought the original patch was supposed to handle (disable netlink congestion control).

Yes, allocation is a different situation but we still report ENOBUFS to user-space. I think that NETLINK_RECV_NO_ENOBUFS is there to a) disable ENOBUFS reports to user-space and b) disable Netlink congestion.

Quoted 1 line

Is there any problem with these errors?

Specifically in ctnetlink, if we fail to allocate a message in ctnetlink and NETLINK_RECV_NO_ENOBUFS is set, we still lose an event and that should not happen.

#5 lore raw

Re: [PATCH 1/3] netlink: fix NETLINK_RECV_NO_ENOBUFS in netlink_set_err()

Quoted 17 lines · Pablo Neira Ayuso
Quoted 11 lines · Patrick McHardy
Quoted 6 lines · Pablo Neira Ayuso

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.

But that only happens if we have a message allocate error, which is a different situation than rcvqueue overrun, which I thought the original patch was supposed to handle (disable netlink congestion control).

Yes, allocation is a different situation but we still report ENOBUFS to user-space. I think that NETLINK_RECV_NO_ENOBUFS is there to a) disable ENOBUFS reports to user-space and b) disable Netlink congestion.

Quoted 5 lines
Quoted 1 line

Is there any problem with these errors?

Specifically in ctnetlink, if we fail to allocate a message in ctnetlink and NETLINK_RECV_NO_ENOBUFS is set, we still lose an event and that should not happen.

I assume you mean "not set"? Otherwise I fail to follow :)

#7 lore raw

Re: [PATCH 1/3] netlink: fix NETLINK_RECV_NO_ENOBUFS in netlink_set_err()

In reply to Pablo Neira Ayuso
Quoted 12 lines · Pablo Neira Ayuso
Quoted 10 lines · Patrick McHardy
Quoted 8 lines · Pablo Neira Ayuso

Yes, allocation is a different situation but we still report ENOBUFS to user-space. I think that NETLINK_RECV_NO_ENOBUFS is there to a) disable ENOBUFS reports to user-space and b) disable Netlink congestion.

Quoted 1 line

Is there any problem with these errors?

Specifically in ctnetlink, if we fail to allocate a message in ctnetlink and NETLINK_RECV_NO_ENOBUFS is set, we still lose an event and that should not happen.

I assume you mean "not set"? Otherwise I fail to follow :)

Quoted 8 lines

OK, I'll try again :-)

Currently, no matter if NETLINK_RECV_NO_ENOBUFS is set or not: if we fail to allocate the netlink message, then ctnetlink_conntrack_event() returns 0. Thus, we report ENOBUFS to user-space and we lose the event.

With my patches, if NETLINK_RECV_NO_ENOBUFS is set and we fail to allocate the message, we don't report ENOBUFS and we don't lose the event.

That last part is what keeps confusing me. With your patch, if the ENOBUFS options is set, we don't report the error to userspace and therefore don't return it to conntrack, thus we *do* loose the event. Which is correct however.

Did I get it right this time? :)

#9 lore raw

Re: [PATCH 1/3] netlink: fix NETLINK_RECV_NO_ENOBUFS in netlink_set_err()

In reply to Pablo Neira Ayuso
Quoted 12 lines · Pablo Neira Ayuso
Quoted 10 lines · Patrick McHardy
Quoted 6 lines

Currently, no matter if NETLINK_RECV_NO_ENOBUFS is set or not: if we fail to allocate the netlink message, then ctnetlink_conntrack_event() returns 0. Thus, we report ENOBUFS to user-space and we lose the event.

With my patches, if NETLINK_RECV_NO_ENOBUFS is set and we fail to allocate the message, we don't report ENOBUFS and we don't lose the event.

That last part is what keeps confusing me. With your patch, if the ENOBUFS options is set, we don't report the error to userspace and therefore don't return it to conntrack, thus we *do* loose the event. Which is correct however.

Quoted 5 lines

Sorry, I'm being a bit imprecise myself: we do lose the event anyway. However, with my patch, if the NO_ENOBUFS option is set, we keep the event in the ctevent cache, so we can try to deliver it again with the next packet (this is what I initially meant with "we don't lose the event", yes, confusing...).

That still doesn't make sense. The NO_ENOBUFS option *surpresses* errors, so conntrack assumes success and we *don't* keep it in the cache. Look:

Patch 1:

Review static inline int do_one_set_err(struct sock *sk, · line 1115

Quoted 13 lines
(quoted diff) +4 -0
@@ -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;
 }

=> return 0 for NO_ENOBUFS option

Patch 2:

Review

Quoted 5 lines
(quoted diff) +3 -0
+	if (nfnetlink_set_err(net, 0, group, -ENOBUFS) > 0)
+		return -ENOBUFS;
+
 	return 0;
 }

=> return 0 to conntrack. Therefore nf_conntrack_eventmask_report() assumes success. So if the NO_ENOBUFS option is indeed used for reliable delivery, this won't work.

Generally the logic seems inverted, you should return an error to conntrack if userspace wasn't notified of the error.

author maintainer
#8 lore raw

Re: [PATCH 1/3] netlink: fix NETLINK_RECV_NO_ENOBUFS in netlink_set_err()

In reply to Patrick McHardy
Quoted 18 lines · Patrick McHardy
Quoted 17 lines · Pablo Neira Ayuso
Quoted 10 lines · Patrick McHardy
Quoted 8 lines · Pablo Neira Ayuso

Yes, allocation is a different situation but we still report ENOBUFS to user-space. I think that NETLINK_RECV_NO_ENOBUFS is there to a) disable ENOBUFS reports to user-space and b) disable Netlink congestion.

Quoted 1 line

Is there any problem with these errors?

Specifically in ctnetlink, if we fail to allocate a message in ctnetlink and NETLINK_RECV_NO_ENOBUFS is set, we still lose an event and that should not happen.

I assume you mean "not set"? Otherwise I fail to follow :)

OK, I'll try again :-)

Currently, no matter if NETLINK_RECV_NO_ENOBUFS is set or not: if we fail to allocate the netlink message, then ctnetlink_conntrack_event() returns 0. Thus, we report ENOBUFS to user-space and we lose the event.

Quoted 7 lines
Quoted 2 lines

With my patches, if NETLINK_RECV_NO_ENOBUFS is set and we fail to allocate the message, we don't report ENOBUFS and we don't lose the event.

That last part is what keeps confusing me. With your patch, if the ENOBUFS options is set, we don't report the error to userspace and therefore don't return it to conntrack, thus we *do* loose the event. Which is correct however.

Sorry, I'm being a bit imprecise myself: we do lose the event anyway. However, with my patch, if the NO_ENOBUFS option is set, we keep the event in the ctevent cache, so we can try to deliver it again with the next packet (this is what I initially meant with "we don't lose the event", yes, confusing...).

Quoted 1 line

Did I get it right this time? :)

I think so! :-)

author maintainer
#6 lore raw

Re: [PATCH 1/3] netlink: fix NETLINK_RECV_NO_ENOBUFS in netlink_set_err()

In reply to Patrick McHardy
Quoted 17 lines · Patrick McHardy
Quoted 16 lines · Pablo Neira Ayuso
Quoted 11 lines · Patrick McHardy
Quoted 6 lines · Pablo Neira Ayuso

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.

But that only happens if we have a message allocate error, which is a different situation than rcvqueue overrun, which I thought the original patch was supposed to handle (disable netlink congestion control).

Yes, allocation is a different situation but we still report ENOBUFS to user-space. I think that NETLINK_RECV_NO_ENOBUFS is there to a) disable ENOBUFS reports to user-space and b) disable Netlink congestion.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Is there any problem with these errors?

Specifically in ctnetlink, if we fail to allocate a message in ctnetlink and NETLINK_RECV_NO_ENOBUFS is set, we still lose an event and that should not happen.

I assume you mean "not set"? Otherwise I fail to follow :)

OK, I'll try again :-)

Currently, no matter if NETLINK_RECV_NO_ENOBUFS is set or not: if we fail to allocate the netlink message, then ctnetlink_conntrack_event() returns 0. Thus, we report ENOBUFS to user-space and we lose the event.

With my patches, if NETLINK_RECV_NO_ENOBUFS is set and we fail to allocate the message, we don't report ENOBUFS and we don't lose the event.

author maintainer
#10 lore raw

Re: [PATCH 1/3] netlink: fix NETLINK_RECV_NO_ENOBUFS in netlink_set_err()

In reply to Patrick McHardy
Quoted 2 lines · Patrick McHardy

Generally the logic seems inverted, you should return an error to conntrack if userspace wasn't notified of the error.

Indeed, thanks. Are you OK with this patch instead?

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 that have set the NETLINK_RECV_NO_ENOBUFS socket option. This return value is used in the next patch in these bugfix series.

---
 include/linux/netlink.h  |    2 +-
 net/netlink/af_netlink.c |   17 ++++++++++++++---
 2 files changed, 15 insertions(+), 4 deletions(-)
include/linux/netlink.h +1 -1
index fde27c0..6eaca5e 100644
@@ -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);
 
net/netlink/af_netlink.c +14 -3
index 4c5972b..0052d3c 100644
@@ -1093,6 +1093,7 @@ static inline int do_one_set_err(struct sock *sk,
 				 struct netlink_set_err_data *p)
 {
 	struct netlink_sock *nlk = nlk_sk(sk);
+	int ret = 0;
 
 	if (sk == p->exclude_sk)
 		goto out;
@@ -1104,10 +1105,15 @@ 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) {
+		ret = 1;
+		goto out;
+	}
+
 	sk->sk_err = p->code;
 	sk->sk_error_report(sk);
 out:
-	return 0;
+	return ret;
 }
 
 /**
@@ -1116,12 +1122,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 that have set the
+ * NETLINK_RECV_NO_ENOBUFS socket option.
  */
-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 +1142,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);
 
maintainer
#11 lore raw

Re: [PATCH 1/3] netlink: fix NETLINK_RECV_NO_ENOBUFS in netlink_set_err()

In reply to Pablo Neira Ayuso

From: Pablo Neira Ayuso <[email protected]>
Date: Fri, 19 Mar 2010 01:24:42 +0100

Quoted 5 lines
Quoted 2 lines · Patrick McHardy

Generally the logic seems inverted, you should return an error to conntrack if userspace wasn't notified of the error.

Indeed, thanks. Are you OK with this patch instead?

I went over all of this and now the patches #1 and #2 look correct to me, so I've applied them to net-2.6

Patrick let me know if you think any follow-on tidy ups are still necessary and we can add them.

Thanks Pablo!

#12 lore raw

Re: [PATCH 1/3] netlink: fix NETLINK_RECV_NO_ENOBUFS in netlink_set_err()

Quoted 9 lines · David Miller

From: Pablo Neira Ayuso <[email protected]>
Date: Fri, 19 Mar 2010 01:24:42 +0100

Quoted 5 lines
Quoted 3 lines · Patrick McHardy

Generally the logic seems inverted, you should return an error to conntrack if userspace wasn't notified of the error.

Quoted 8 lines
Quoted 2 lines

Indeed, thanks. Are you OK with this patch instead?

I went over all of this and now the patches #1 and #2 look correct to me, so I've applied them to net-2.6

Patrick let me know if you think any follow-on tidy ups are still necessary and we can add them.

The patch looks fine to me as well, thanks Dave.