Skip to content

Commit a4bb4f5

Browse files
kuba-moodavem330
authored andcommitted
genetlink: switch control commands to per-op policies
In preparation for adding a new attribute to CTRL_CMD_GETPOLICY split the policies for getpolicy and getfamily apart. This will cause a slight user-visible change in that dumping the policies will switch from per family to per op, but supposedly sniffer-type applications (which are the main use case for policy dumping thus far) should support both, anyway. Signed-off-by: Jakub Kicinski <[email protected]> Reviewed-by: Johannes Berg <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 8e1ed28 commit a4bb4f5

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

net/netlink/genetlink.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,7 @@ ctrl_build_mcgrp_msg(const struct genl_family *family,
10161016
return skb;
10171017
}
10181018

1019-
static const struct nla_policy ctrl_policy[CTRL_ATTR_MAX+1] = {
1019+
static const struct nla_policy ctrl_policy_family[] = {
10201020
[CTRL_ATTR_FAMILY_ID] = { .type = NLA_U16 },
10211021
[CTRL_ATTR_FAMILY_NAME] = { .type = NLA_NUL_STRING,
10221022
.len = GENL_NAMSIZ - 1 },
@@ -1115,6 +1115,12 @@ struct ctrl_dump_policy_ctx {
11151115
u16 fam_id;
11161116
};
11171117

1118+
static const struct nla_policy ctrl_policy_policy[] = {
1119+
[CTRL_ATTR_FAMILY_ID] = { .type = NLA_U16 },
1120+
[CTRL_ATTR_FAMILY_NAME] = { .type = NLA_NUL_STRING,
1121+
.len = GENL_NAMSIZ - 1 },
1122+
};
1123+
11181124
static int ctrl_dumppolicy_start(struct netlink_callback *cb)
11191125
{
11201126
const struct genl_dumpit_info *info = genl_dumpit_info(cb);
@@ -1196,11 +1202,15 @@ static const struct genl_ops genl_ctrl_ops[] = {
11961202
{
11971203
.cmd = CTRL_CMD_GETFAMILY,
11981204
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
1205+
.policy = ctrl_policy_family,
1206+
.maxattr = ARRAY_SIZE(ctrl_policy_family) - 1,
11991207
.doit = ctrl_getfamily,
12001208
.dumpit = ctrl_dumpfamily,
12011209
},
12021210
{
12031211
.cmd = CTRL_CMD_GETPOLICY,
1212+
.policy = ctrl_policy_policy,
1213+
.maxattr = ARRAY_SIZE(ctrl_policy_policy) - 1,
12041214
.start = ctrl_dumppolicy_start,
12051215
.dumpit = ctrl_dumppolicy,
12061216
.done = ctrl_dumppolicy_done,
@@ -1220,8 +1230,6 @@ static struct genl_family genl_ctrl __ro_after_init = {
12201230
.id = GENL_ID_CTRL,
12211231
.name = "nlctrl",
12221232
.version = 0x2,
1223-
.maxattr = CTRL_ATTR_MAX,
1224-
.policy = ctrl_policy,
12251233
.netnsok = true,
12261234
};
12271235

0 commit comments

Comments
 (0)