Skip to contentSkip to conversation

move command capabilities to flags

RFC In review jamal 3 participants 9 messages Dec 2, 2006 – Dec 5, 2006

Subsystems (2)
lore
Share & tools
lore

jamal

author
#0 lore raw

RFC 1/1 move command capabilities to flags

Dave,
If there is no objections on this approach, please apply this patch. Against net-2.6.20

cheers,
jamal

This patch moves command capabilities to command flags. Other than being cleaner, saves several bytes.

---
commit b6ac8f41bdd2edd9d215e376efa47261e9b118a1
tree fec2a968aad15264b30e2d550cb0c6f7939d4c93
parent 4bacaeb2cea3c6684f9b3acc54f71958bb2c25c5
author Jamal Hadi Salim <[email protected]> Sat, 02 Dec 2006 06:54:55 -0500 committer Jamal Hadi Salim <[email protected]> Sat, 02 Dec 2006 06:54:55 -0500

 include/linux/genetlink.h |    3 +++
 net/netlink/genetlink.c   |   16 +++++++---------
 2 files changed, 10 insertions(+), 9 deletions(-)
include/linux/genetlink.h +3 -0
index 9049dc6..3bd75c2 100644
@@ -17,6 +17,9 @@ struct genlmsghdr {
 #define GENL_HDRLEN	NLMSG_ALIGN(sizeof(struct genlmsghdr))
 
 #define GENL_ADMIN_PERM		0x01
+#define GENL_CMD_CAP_DO		0x02
+#define GENL_CMD_CAP_DUMP	0x04
+#define GENL_CMD_CAP_HASPOL	0x08
 
 /*
  * List of reserved static generic netlink identifiers:
net/netlink/genetlink.c +7 -9
index cc874f0..adfc203 100644
@@ -143,6 +143,13 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
 		goto errout;
 	}
 
+	if (ops->dumpit)
+		ops->flags |= GENL_CMD_CAP_DO;
+	if (ops->doit)
+		ops->flags |= GENL_CMD_CAP_DUMP;
+	if (ops->policy)
+		ops->flags |= GENL_CMD_CAP_HASPOL;
+
 	genl_lock();
 	list_add_tail(&ops->ops_list, &family->ops_list);
 	genl_unlock();
@@ -425,15 +432,6 @@ static int ctrl_fill_info(struct genl_family *family, u32 pid, u32 seq,
 			NLA_PUT_U32(skb, CTRL_ATTR_OP_ID, ops->cmd);
 			NLA_PUT_U32(skb, CTRL_ATTR_OP_FLAGS, ops->flags);
 
-			if (ops->policy)
-				NLA_PUT_FLAG(skb, CTRL_ATTR_OP_POLICY);
-
-			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, nest);
 		}
 
#1 lore raw

* jamal <[email protected]> 2006-12-02 06:56

Quoted 10 lines

Dave,
If there is no objections on this approach, please apply this patch. Against net-2.6.20

cheers,
jamal

This patch moves command capabilities to command flags. Other than being cleaner, saves several bytes.

Is it worth to save these 12 bytes by breaking compatibility? If you really want to do it, remove the obsoleted attribute types, I don't like dead bodies laying around :-)

author
#2 lore raw
Quoted 6 lines · Thomas Graf

* jamal <[email protected]> 2006-12-02 06:56

Quoted 5 lines

Dave,
If there is no objections on this approach, please apply this patch. Against net-2.6.20

Quoted 7 lines
Quoted 5 lines

cheers,
jamal

This patch moves command capabilities to command flags. Other than being cleaner, saves several bytes.

Is it worth to save these 12 bytes by breaking compatibility?

The savings bytes is one aspect; the other is the cleanliness. transfering a boolean in that many bits is a little of overkill. I think it is better to fix it now than later.
I know you mentioned libnl uses it. But that is something you can change on your side. I dont know of any other app that uses it.

Quoted 3 lines

If you
really want to do it, remove the obsoleted attribute types, I don't like dead bodies laying around :-)

I could resend the patch getting rid of those definitions.

cheers,
jamal

#3 lore raw

* jamal <[email protected]> 2006-12-04 08:01

Quoted 5 lines

The savings bytes is one aspect; the other is the cleanliness. transfering a boolean in that many bits is a little of overkill. I think it is better to fix it now than later.
I know you mentioned libnl uses it. But that is something you can change on your side. I dont know of any other app that uses it.

Right but if some distro is based on exactly 2.6.19 the specific libnl parts won't work at all for a long time.

Quoted 5 lines
Quoted 3 lines

If you
really want to do it, remove the obsoleted attribute types, I don't like dead bodies laying around :-)

I could resend the patch getting rid of those definitions.

OK, I can live with it, I don't care for the breakage much.

author
#4 lore raw
Quoted 10 lines · Thomas Graf

* jamal <[email protected]> 2006-12-04 08:01

Quoted 5 lines

The savings bytes is one aspect; the other is the cleanliness. transfering a boolean in that many bits is a little of overkill. I think it is better to fix it now than later.
I know you mentioned libnl uses it. But that is something you can change on your side. I dont know of any other app that uses it.

Right but if some distro is based on exactly 2.6.19 the specific libnl parts won't work at all for a long time.

We can resolve that by uping the version for the controller. User will use that a signal.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

If you
really want to do it, remove the obsoleted attribute types, I don't like dead bodies laying around :-)

I could resend the patch getting rid of those definitions.

OK, I can live with it, I don't care for the breakage much.

cool - will send a patch later.

cheers,
jamal

#5 lore raw

* jamal <[email protected]> 2006-12-04 12:48

Quoted 8 lines · Thomas Graf
Quoted 7 lines

* jamal <[email protected]> 2006-12-04 08:01

Quoted 5 lines

The savings bytes is one aspect; the other is the cleanliness. transfering a boolean in that many bits is a little of overkill. I think it is better to fix it now than later.
I know you mentioned libnl uses it. But that is something you can change on your side. I dont know of any other app that uses it.

Quoted 6 lines
Quoted 3 lines

Right but if some distro is based on exactly 2.6.19 the specific libnl parts won't work at all for a long time.

We can resolve that by uping the version for the controller. User will use that a signal.

Good idea, makes me happy :-) please do that in your patch as well.

author
#6 lore raw

RFC 1/1 move command capabilities to flags

Quoted 6 lines · Thomas Graf

* jamal <[email protected]> 2006-12-04 12:48

Quoted 2 lines

We can resolve that by uping the version for the controller. User will use that a signal.

Good idea, makes me happy :-) please do that in your patch as well.

Ok, here she goes...
If looks good, Dave please apply to net-2.6.20

cheers,
jamal

This patch moves command capabilities to command flags. Other than being cleaner, saves several bytes.
We increment the nlctrl version so as to signal to user space that to not expect the attributes. We will try to be careful not to do this too often ;->

---
commit 49ba7537cec41f0db2500054b5fde3c193c37a97
tree f56cb78a17a9847df33101fd4a807617f74d27c6
parent 55a2dc3caa86e03cb3d9e856215e2fceb5cf5f66
author Jamal Hadi Salim <[email protected]> Mon, 04 Dec 2006 15:49:06 -0500 committer Jamal Hadi Salim <[email protected]> Mon, 04 Dec 2006 15:49:06 -0500

 include/linux/genetlink.h |    6 +++---
 net/netlink/genetlink.c   |   18 ++++++++----------
 2 files changed, 11 insertions(+), 13 deletions(-)
include/linux/genetlink.h +3 -3
index 9049dc6..f7a9377 100644
@@ -17,6 +17,9 @@ struct genlmsghdr {
 #define GENL_HDRLEN	NLMSG_ALIGN(sizeof(struct genlmsghdr))
 
 #define GENL_ADMIN_PERM		0x01
+#define GENL_CMD_CAP_DO		0x02
+#define GENL_CMD_CAP_DUMP	0x04
+#define GENL_CMD_CAP_HASPOL	0x08
 
 /*
  * List of reserved static generic netlink identifiers:
@@ -58,9 +61,6 @@ enum {
 	CTRL_ATTR_OP_UNSPEC,
 	CTRL_ATTR_OP_ID,
 	CTRL_ATTR_OP_FLAGS,
-	CTRL_ATTR_OP_POLICY,
-	CTRL_ATTR_OP_DOIT,
-	CTRL_ATTR_OP_DUMPIT,
 	__CTRL_ATTR_OP_MAX,
 };
 
net/netlink/genetlink.c +8 -10
index cc874f0..3e37ea5 100644
@@ -143,6 +143,13 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
 		goto errout;
 	}
 
+	if (ops->dumpit)
+		ops->flags |= GENL_CMD_CAP_DO;
+	if (ops->doit)
+		ops->flags |= GENL_CMD_CAP_DUMP;
+	if (ops->policy)
+		ops->flags |= GENL_CMD_CAP_HASPOL;
+
 	genl_lock();
 	list_add_tail(&ops->ops_list, &family->ops_list);
 	genl_unlock();
@@ -387,7 +394,7 @@ static void genl_rcv(struct sock *sk, int len)
 static struct genl_family genl_ctrl = {
 	.id = GENL_ID_CTRL,
 	.name = "nlctrl",
-	.version = 0x1,
+	.version = 0x2,
 	.maxattr = CTRL_ATTR_MAX,
 };
 
@@ -425,15 +432,6 @@ static int ctrl_fill_info(struct genl_family *family, u32 pid, u32 seq,
 			NLA_PUT_U32(skb, CTRL_ATTR_OP_ID, ops->cmd);
 			NLA_PUT_U32(skb, CTRL_ATTR_OP_FLAGS, ops->flags);
 
-			if (ops->policy)
-				NLA_PUT_FLAG(skb, CTRL_ATTR_OP_POLICY);
-
-			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, nest);
 		}
 
#7 lore raw

* jamal <[email protected]> 2006-12-04 16:07

Quoted 11 lines · Thomas Graf
Quoted 6 lines

* jamal <[email protected]> 2006-12-04 12:48

Quoted 2 lines

We can resolve that by uping the version for the controller. User will use that a signal.

Good idea, makes me happy :-) please do that in your patch as well.

Ok, here she goes...
If looks good, Dave please apply to net-2.6.20

Looks good.

maintainer Applied
#8 lore raw

From: Thomas Graf <[email protected]>
Date: Mon, 4 Dec 2006 22:23:41 +0100

Quoted 7 lines

* jamal <[email protected]> 2006-12-04 16:07

Quoted 6 lines · Thomas Graf
Quoted 5 lines

* jamal <[email protected]> 2006-12-04 12:48

Quoted 2 lines

We can resolve that by uping the version for the controller. User will use that a signal.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Good idea, makes me happy :-) please do that in your patch as well.

Ok, here she goes...
If looks good, Dave please apply to net-2.6.20

Looks good.

Applied, thanks everyone.