netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][Generic netlink]: dont send empty operational attributes
@ 2006-11-19 19:17 jamal
       [not found] ` <4466a10611191122r2bd16dbdmc35991c13dc9c92f@mail.gmail.com>
  0 siblings, 1 reply; 6+ messages in thread
From: jamal @ 2006-11-19 19:17 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Thomas Graf

This is probably 2.6.19 material (a little annoyance)
I am testing using a new mailer - if this patch doesnt look right let me know.

cheers,
jamal

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH][Generic netlink]: dont send empty operational attributes
       [not found] ` <4466a10611191122r2bd16dbdmc35991c13dc9c92f@mail.gmail.com>
@ 2006-11-19 19:54   ` Thomas Graf
  2006-11-22  1:35     ` David Miller
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Graf @ 2006-11-19 19:54 UTC (permalink / raw)
  To: jamal; +Cc: David Miller, netdev

* jamal <hadi@cyberus.ca> 2006-11-19 14:22
> On 11/19/06, jamal <hadi@cyberus.ca> wrote:
> >This is probably 2.6.19 material (a little annoyance)
> >I am testing using a new mailer - if this patch doesnt look right let me
> know.
> 
> Seems like i failed. Ok, heres the patch again..

HTML mail and application/octet-stream for the patch? :-)
Probably never made it to netdev. The patch (enclosed again)
is fine though.

Dont add operations attribute headers when the family doesnt have
any (gets annoying to see the header upon first registration
before the commands are registered)

signed-off-by: J Hadi Salim

---
commit 0dc22b960a081832e6c05b59eeefbce564354b94
tree 0659cc668f40fbe383c8d63eaa3adbec72668244
parent e030f8294a5b9f8179dae10cdbf9dcf32aa64110
author J Hadi Salim hadi@cyberus.ca <hadi@cyberus.ca> Sun, 19 Nov 2006 14:00:04 -0500
committer J Hadi Salim hadi@cyberus.ca <hadi@lilsol.(none)> Sun, 19 Nov 2006 14:00:04 -0500

 net/netlink/genetlink.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
index 49bc2db..9e33d5f 100644
--- a/net/netlink/genetlink.c
+++ b/net/netlink/genetlink.c
@@ -403,6 +403,9 @@ static int ctrl_fill_info(struct genl_fa
 	NLA_PUT_U32(skb, CTRL_ATTR_HDRSIZE, family->hdrsize);
 	NLA_PUT_U32(skb, CTRL_ATTR_MAXATTR, family->maxattr);
 
+	if (list_empty(&family->ops_list))
+		goto ctrl_fill_done;
+
 	nla_ops = nla_nest_start(skb, CTRL_ATTR_OPS);
 	if (nla_ops == NULL)
 		goto nla_put_failure;
@@ -429,6 +432,7 @@ static int ctrl_fill_info(struct genl_fa
 		nla_nest_end(skb, nest);
 	}
 
+ctrl_fill_done:
 	nla_nest_end(skb, nla_ops);
 
 	return genlmsg_end(skb, hdr);

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH][Generic netlink]: dont send empty operational attributes
  2006-11-19 19:54   ` Thomas Graf
@ 2006-11-22  1:35     ` David Miller
  2006-11-22  1:40       ` David Miller
  0 siblings, 1 reply; 6+ messages in thread
From: David Miller @ 2006-11-22  1:35 UTC (permalink / raw)
  To: tgraf; +Cc: hadi, netdev

From: Thomas Graf <tgraf@suug.ch>
Date: Sun, 19 Nov 2006 20:54:02 +0100

> * jamal <hadi@cyberus.ca> 2006-11-19 14:22
> > On 11/19/06, jamal <hadi@cyberus.ca> wrote:
> > >This is probably 2.6.19 material (a little annoyance)
> > >I am testing using a new mailer - if this patch doesnt look right let me
> > know.
> > 
> > Seems like i failed. Ok, heres the patch again..
> 
> HTML mail and application/octet-stream for the patch? :-)
> Probably never made it to netdev. The patch (enclosed again)
> is fine though.
> 
> Dont add operations attribute headers when the family doesnt have
> any (gets annoying to see the header upon first registration
> before the commands are registered)
> 
> signed-off-by: J Hadi Salim

Applied, thanks guys.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH][Generic netlink]: dont send empty operational attributes
  2006-11-22  1:35     ` David Miller
@ 2006-11-22  1:40       ` David Miller
  2006-11-23 13:47         ` [GENETLINK] ctrl: Avoid empty CTRL_ATTR_OPS attribute when dumping Thomas Graf
  0 siblings, 1 reply; 6+ messages in thread
From: David Miller @ 2006-11-22  1:40 UTC (permalink / raw)
  To: tgraf; +Cc: hadi, netdev

From: David Miller <davem@davemloft.net>
Date: Tue, 21 Nov 2006 17:35:56 -0800 (PST)

> From: Thomas Graf <tgraf@suug.ch>
> Date: Sun, 19 Nov 2006 20:54:02 +0100
> 
> > * jamal <hadi@cyberus.ca> 2006-11-19 14:22
> > > On 11/19/06, jamal <hadi@cyberus.ca> wrote:
> > > >This is probably 2.6.19 material (a little annoyance)
> > > >I am testing using a new mailer - if this patch doesnt look right let me
> > > know.
> > > 
> > > Seems like i failed. Ok, heres the patch again..
> > 
> > HTML mail and application/octet-stream for the patch? :-)
> > Probably never made it to netdev. The patch (enclosed again)
> > is fine though.
> > 
> > Dont add operations attribute headers when the family doesnt have
> > any (gets annoying to see the header upon first registration
> > before the commands are registered)
> > 
> > signed-off-by: J Hadi Salim
> 
> Applied, thanks guys.

Actually, this patch is completely bogus.

You're branching to ctrl_fill_done without initializing nla_ops
or doing nla_nest_start() at all, and that code path does:

ctrl_fill_done:
	nla_nest_end(skb, nla_ops);

	return genlmsg_end(skb, hdr);

The compiler even warns when you try to build genetlink.o
with this change installed, please don't send garbage like
this to me. :-)

I'm reverting...


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [GENETLINK] ctrl: Avoid empty CTRL_ATTR_OPS attribute when dumping
  2006-11-22  1:40       ` David Miller
@ 2006-11-23 13:47         ` Thomas Graf
  2006-11-23 19:45           ` David Miller
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Graf @ 2006-11-23 13:47 UTC (permalink / raw)
  To: David Miller; +Cc: hadi, netdev


Based on Jamal's patch but compiled and even tested. :-)

Signed-off-by: Thomas Graf <tgraf@suug.ch>

Index: net-2.6.20/net/netlink/genetlink.c
===================================================================
--- net-2.6.20.orig/net/netlink/genetlink.c	2006-11-23 14:37:54.000000000 +0100
+++ net-2.6.20/net/netlink/genetlink.c	2006-11-23 14:39:42.000000000 +0100
@@ -394,10 +394,7 @@
 static int ctrl_fill_info(struct genl_family *family, u32 pid, u32 seq,
 			  u32 flags, struct sk_buff *skb, u8 cmd)
 {
-	struct nlattr *nla_ops;
-	struct genl_ops *ops;
 	void *hdr;
-	int idx = 1;
 
 	hdr = genlmsg_put(skb, pid, seq, &genl_ctrl, flags, cmd);
 	if (hdr == NULL)
@@ -409,33 +406,39 @@
 	NLA_PUT_U32(skb, CTRL_ATTR_HDRSIZE, family->hdrsize);
 	NLA_PUT_U32(skb, CTRL_ATTR_MAXATTR, family->maxattr);
 
-	nla_ops = nla_nest_start(skb, CTRL_ATTR_OPS);
-	if (nla_ops == NULL)
-		goto nla_put_failure;
+	if (!list_empty(&family->ops_list)) {
+		struct nlattr *nla_ops;
+		struct genl_ops *ops;
+		int idx = 1;
 
-	list_for_each_entry(ops, &family->ops_list, ops_list) {
-		struct nlattr *nest;
-
-		nest = nla_nest_start(skb, idx++);
-		if (nest == NULL)
+		nla_ops = nla_nest_start(skb, CTRL_ATTR_OPS);
+		if (nla_ops == NULL)
 			goto nla_put_failure;
 
-		NLA_PUT_U32(skb, CTRL_ATTR_OP_ID, ops->cmd);
-		NLA_PUT_U32(skb, CTRL_ATTR_OP_FLAGS, ops->flags);
+		list_for_each_entry(ops, &family->ops_list, ops_list) {
+			struct nlattr *nest;
 
-		if (ops->policy)
-			NLA_PUT_FLAG(skb, CTRL_ATTR_OP_POLICY);
+			nest = nla_nest_start(skb, idx++);
+			if (nest == NULL)
+				goto nla_put_failure;
 
-		if (ops->doit)
-			NLA_PUT_FLAG(skb, CTRL_ATTR_OP_DOIT);
+			NLA_PUT_U32(skb, CTRL_ATTR_OP_ID, ops->cmd);
+			NLA_PUT_U32(skb, CTRL_ATTR_OP_FLAGS, ops->flags);
 
-		if (ops->dumpit)
-			NLA_PUT_FLAG(skb, CTRL_ATTR_OP_DUMPIT);
+			if (ops->policy)
+				NLA_PUT_FLAG(skb, CTRL_ATTR_OP_POLICY);
 
-		nla_nest_end(skb, nest);
-	}
+			if (ops->doit)
+				NLA_PUT_FLAG(skb, CTRL_ATTR_OP_DOIT);
+
+			if (ops->dumpit)
+				NLA_PUT_FLAG(skb, CTRL_ATTR_OP_DUMPIT);
 
-	nla_nest_end(skb, nla_ops);
+			nla_nest_end(skb, nest);
+		}
+
+		nla_nest_end(skb, nla_ops);
+	}
 
 	return genlmsg_end(skb, hdr);
 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [GENETLINK] ctrl: Avoid empty CTRL_ATTR_OPS attribute when dumping
  2006-11-23 13:47         ` [GENETLINK] ctrl: Avoid empty CTRL_ATTR_OPS attribute when dumping Thomas Graf
@ 2006-11-23 19:45           ` David Miller
  0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2006-11-23 19:45 UTC (permalink / raw)
  To: tgraf; +Cc: hadi, netdev

From: Thomas Graf <tgraf@suug.ch>
Date: Thu, 23 Nov 2006 14:47:54 +0100

> Based on Jamal's patch but compiled and even tested. :-)
> 
> Signed-off-by: Thomas Graf <tgraf@suug.ch>

Applied to net-2.6.20, thanks!

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-11-23 19:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-19 19:17 [PATCH][Generic netlink]: dont send empty operational attributes jamal
     [not found] ` <4466a10611191122r2bd16dbdmc35991c13dc9c92f@mail.gmail.com>
2006-11-19 19:54   ` Thomas Graf
2006-11-22  1:35     ` David Miller
2006-11-22  1:40       ` David Miller
2006-11-23 13:47         ` [GENETLINK] ctrl: Avoid empty CTRL_ATTR_OPS attribute when dumping Thomas Graf
2006-11-23 19:45           ` David Miller

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).