Commit 334c29a6 authored by Jamal Hadi Salim's avatar Jamal Hadi Salim Committed by David S. Miller

[GENETLINK]: Move command capabilities to flags.

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 ;->
Signed-off-by: default avatarJamal Hadi Salim <hadi@cyberus.ca>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 620034c8
...@@ -17,6 +17,9 @@ struct genlmsghdr { ...@@ -17,6 +17,9 @@ struct genlmsghdr {
#define GENL_HDRLEN NLMSG_ALIGN(sizeof(struct genlmsghdr)) #define GENL_HDRLEN NLMSG_ALIGN(sizeof(struct genlmsghdr))
#define GENL_ADMIN_PERM 0x01 #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: * List of reserved static generic netlink identifiers:
...@@ -58,9 +61,6 @@ enum { ...@@ -58,9 +61,6 @@ enum {
CTRL_ATTR_OP_UNSPEC, CTRL_ATTR_OP_UNSPEC,
CTRL_ATTR_OP_ID, CTRL_ATTR_OP_ID,
CTRL_ATTR_OP_FLAGS, CTRL_ATTR_OP_FLAGS,
CTRL_ATTR_OP_POLICY,
CTRL_ATTR_OP_DOIT,
CTRL_ATTR_OP_DUMPIT,
__CTRL_ATTR_OP_MAX, __CTRL_ATTR_OP_MAX,
}; };
......
...@@ -143,6 +143,13 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops) ...@@ -143,6 +143,13 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
goto errout; 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(); genl_lock();
list_add_tail(&ops->ops_list, &family->ops_list); list_add_tail(&ops->ops_list, &family->ops_list);
genl_unlock(); genl_unlock();
...@@ -387,7 +394,7 @@ static void genl_rcv(struct sock *sk, int len) ...@@ -387,7 +394,7 @@ static void genl_rcv(struct sock *sk, int len)
static struct genl_family genl_ctrl = { static struct genl_family genl_ctrl = {
.id = GENL_ID_CTRL, .id = GENL_ID_CTRL,
.name = "nlctrl", .name = "nlctrl",
.version = 0x1, .version = 0x2,
.maxattr = CTRL_ATTR_MAX, .maxattr = CTRL_ATTR_MAX,
}; };
...@@ -425,15 +432,6 @@ static int ctrl_fill_info(struct genl_family *family, u32 pid, u32 seq, ...@@ -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_ID, ops->cmd);
NLA_PUT_U32(skb, CTRL_ATTR_OP_FLAGS, ops->flags); 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); nla_nest_end(skb, nest);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment