Skip to content

Commit e508673

Browse files
kuba-moodavem330
authored andcommitted
genetlink: reorg struct genl_family
There are holes and oversized members in struct genl_family. Before: /* size: 104, cachelines: 2, members: 16 */ After: /* size: 88, cachelines: 2, members: 16 */ The command field in struct genlmsghdr is a u8, so no point in the operation count being 32 bit. Also operation 0 is usually undefined, so we only need 255 entries. netnsok and parallel_ops are only ever initialized to true. We can grow the fields as needed, compiler should warn us if someone tries to assign larger constants. Signed-off-by: Jakub Kicinski <kuba@kernel.org> Reviewed-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 5a38b4f commit e508673

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

‎include/net/genetlink.h‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,11 @@ struct genl_family {
4848
char name[GENL_NAMSIZ];
4949
unsigned int version;
5050
unsigned int maxattr;
51-
bool netnsok;
52-
bool parallel_ops;
51+
unsigned int mcgrp_offset; /* private */
52+
u8 netnsok:1;
53+
u8 parallel_ops:1;
54+
u8 n_ops;
55+
u8 n_mcgrps;
5356
const struct nla_policy *policy;
5457
int (*pre_doit)(const struct genl_ops *ops,
5558
struct sk_buff *skb,
@@ -59,9 +62,6 @@ struct genl_family {
5962
struct genl_info *info);
6063
const struct genl_ops * ops;
6164
const struct genl_multicast_group *mcgrps;
62-
unsigned int n_ops;
63-
unsigned int n_mcgrps;
64-
unsigned int mcgrp_offset; /* private */
6565
struct module *module;
6666
};
6767

0 commit comments

Comments
 (0)