genetlink: make policy common to family
Since maxattr is common, the policy can't really differ sanely, so make it common as well. The only user that did in fact manage to make a non-common policy is taskstats, which has to be really careful about it (since it's still using a common maxattr!). This is no longer supported, but we can fake it using pre_doit. This reduces the size of e.g. nl80211.o (which has lots of commands): text data bss dec hex filename 398745 14323 2240 415308 6564c net/wireless/nl80211.o (before) 397913 14331 2240 414484 65314 net/wireless/nl80211.o (after) -------------------------------- -832 +8 0 -824 Which is obviously just 8 bytes for each command, and an added 8 bytes for the new policy pointer. I'm not sure why the ops list is counted as .text though. Most of the code transformations were done using the following spatch: @ops@ identifier OPS; expression POLICY; @@ struct genl_ops OPS[] = { ..., { - .policy = POLICY, }, ... }; @@ identifier ops.OPS; expression ops.POLICY; identifier fam; expression M; @@ struct genl_family fam = { .ops = OPS, .maxattr = M, + .policy = POLICY, ... }; This also gets rid of devlink_nl_cmd_region_read_dumpit() accessing the cb->data as ops, which we want to change in a later genl patch. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
601ed4d6dc
commit
3b0f31f2b8
@@ -322,28 +322,24 @@ static const struct genl_ops netlbl_calipso_ops[] = {
|
||||
{
|
||||
.cmd = NLBL_CALIPSO_C_ADD,
|
||||
.flags = GENL_ADMIN_PERM,
|
||||
.policy = calipso_genl_policy,
|
||||
.doit = netlbl_calipso_add,
|
||||
.dumpit = NULL,
|
||||
},
|
||||
{
|
||||
.cmd = NLBL_CALIPSO_C_REMOVE,
|
||||
.flags = GENL_ADMIN_PERM,
|
||||
.policy = calipso_genl_policy,
|
||||
.doit = netlbl_calipso_remove,
|
||||
.dumpit = NULL,
|
||||
},
|
||||
{
|
||||
.cmd = NLBL_CALIPSO_C_LIST,
|
||||
.flags = 0,
|
||||
.policy = calipso_genl_policy,
|
||||
.doit = netlbl_calipso_list,
|
||||
.dumpit = NULL,
|
||||
},
|
||||
{
|
||||
.cmd = NLBL_CALIPSO_C_LISTALL,
|
||||
.flags = 0,
|
||||
.policy = calipso_genl_policy,
|
||||
.doit = NULL,
|
||||
.dumpit = netlbl_calipso_listall,
|
||||
},
|
||||
@@ -354,6 +350,7 @@ static struct genl_family netlbl_calipso_gnl_family __ro_after_init = {
|
||||
.name = NETLBL_NLTYPE_CALIPSO_NAME,
|
||||
.version = NETLBL_PROTO_VERSION,
|
||||
.maxattr = NLBL_CALIPSO_A_MAX,
|
||||
.policy = calipso_genl_policy,
|
||||
.module = THIS_MODULE,
|
||||
.ops = netlbl_calipso_ops,
|
||||
.n_ops = ARRAY_SIZE(netlbl_calipso_ops),
|
||||
|
@@ -734,28 +734,24 @@ static const struct genl_ops netlbl_cipsov4_ops[] = {
|
||||
{
|
||||
.cmd = NLBL_CIPSOV4_C_ADD,
|
||||
.flags = GENL_ADMIN_PERM,
|
||||
.policy = netlbl_cipsov4_genl_policy,
|
||||
.doit = netlbl_cipsov4_add,
|
||||
.dumpit = NULL,
|
||||
},
|
||||
{
|
||||
.cmd = NLBL_CIPSOV4_C_REMOVE,
|
||||
.flags = GENL_ADMIN_PERM,
|
||||
.policy = netlbl_cipsov4_genl_policy,
|
||||
.doit = netlbl_cipsov4_remove,
|
||||
.dumpit = NULL,
|
||||
},
|
||||
{
|
||||
.cmd = NLBL_CIPSOV4_C_LIST,
|
||||
.flags = 0,
|
||||
.policy = netlbl_cipsov4_genl_policy,
|
||||
.doit = netlbl_cipsov4_list,
|
||||
.dumpit = NULL,
|
||||
},
|
||||
{
|
||||
.cmd = NLBL_CIPSOV4_C_LISTALL,
|
||||
.flags = 0,
|
||||
.policy = netlbl_cipsov4_genl_policy,
|
||||
.doit = NULL,
|
||||
.dumpit = netlbl_cipsov4_listall,
|
||||
},
|
||||
@@ -766,6 +762,7 @@ static struct genl_family netlbl_cipsov4_gnl_family __ro_after_init = {
|
||||
.name = NETLBL_NLTYPE_CIPSOV4_NAME,
|
||||
.version = NETLBL_PROTO_VERSION,
|
||||
.maxattr = NLBL_CIPSOV4_A_MAX,
|
||||
.policy = netlbl_cipsov4_genl_policy,
|
||||
.module = THIS_MODULE,
|
||||
.ops = netlbl_cipsov4_ops,
|
||||
.n_ops = ARRAY_SIZE(netlbl_cipsov4_ops),
|
||||
|
@@ -773,56 +773,48 @@ static const struct genl_ops netlbl_mgmt_genl_ops[] = {
|
||||
{
|
||||
.cmd = NLBL_MGMT_C_ADD,
|
||||
.flags = GENL_ADMIN_PERM,
|
||||
.policy = netlbl_mgmt_genl_policy,
|
||||
.doit = netlbl_mgmt_add,
|
||||
.dumpit = NULL,
|
||||
},
|
||||
{
|
||||
.cmd = NLBL_MGMT_C_REMOVE,
|
||||
.flags = GENL_ADMIN_PERM,
|
||||
.policy = netlbl_mgmt_genl_policy,
|
||||
.doit = netlbl_mgmt_remove,
|
||||
.dumpit = NULL,
|
||||
},
|
||||
{
|
||||
.cmd = NLBL_MGMT_C_LISTALL,
|
||||
.flags = 0,
|
||||
.policy = netlbl_mgmt_genl_policy,
|
||||
.doit = NULL,
|
||||
.dumpit = netlbl_mgmt_listall,
|
||||
},
|
||||
{
|
||||
.cmd = NLBL_MGMT_C_ADDDEF,
|
||||
.flags = GENL_ADMIN_PERM,
|
||||
.policy = netlbl_mgmt_genl_policy,
|
||||
.doit = netlbl_mgmt_adddef,
|
||||
.dumpit = NULL,
|
||||
},
|
||||
{
|
||||
.cmd = NLBL_MGMT_C_REMOVEDEF,
|
||||
.flags = GENL_ADMIN_PERM,
|
||||
.policy = netlbl_mgmt_genl_policy,
|
||||
.doit = netlbl_mgmt_removedef,
|
||||
.dumpit = NULL,
|
||||
},
|
||||
{
|
||||
.cmd = NLBL_MGMT_C_LISTDEF,
|
||||
.flags = 0,
|
||||
.policy = netlbl_mgmt_genl_policy,
|
||||
.doit = netlbl_mgmt_listdef,
|
||||
.dumpit = NULL,
|
||||
},
|
||||
{
|
||||
.cmd = NLBL_MGMT_C_PROTOCOLS,
|
||||
.flags = 0,
|
||||
.policy = netlbl_mgmt_genl_policy,
|
||||
.doit = NULL,
|
||||
.dumpit = netlbl_mgmt_protocols,
|
||||
},
|
||||
{
|
||||
.cmd = NLBL_MGMT_C_VERSION,
|
||||
.flags = 0,
|
||||
.policy = netlbl_mgmt_genl_policy,
|
||||
.doit = netlbl_mgmt_version,
|
||||
.dumpit = NULL,
|
||||
},
|
||||
@@ -833,6 +825,7 @@ static struct genl_family netlbl_mgmt_gnl_family __ro_after_init = {
|
||||
.name = NETLBL_NLTYPE_MGMT_NAME,
|
||||
.version = NETLBL_PROTO_VERSION,
|
||||
.maxattr = NLBL_MGMT_A_MAX,
|
||||
.policy = netlbl_mgmt_genl_policy,
|
||||
.module = THIS_MODULE,
|
||||
.ops = netlbl_mgmt_genl_ops,
|
||||
.n_ops = ARRAY_SIZE(netlbl_mgmt_genl_ops),
|
||||
|
@@ -1318,56 +1318,48 @@ static const struct genl_ops netlbl_unlabel_genl_ops[] = {
|
||||
{
|
||||
.cmd = NLBL_UNLABEL_C_STATICADD,
|
||||
.flags = GENL_ADMIN_PERM,
|
||||
.policy = netlbl_unlabel_genl_policy,
|
||||
.doit = netlbl_unlabel_staticadd,
|
||||
.dumpit = NULL,
|
||||
},
|
||||
{
|
||||
.cmd = NLBL_UNLABEL_C_STATICREMOVE,
|
||||
.flags = GENL_ADMIN_PERM,
|
||||
.policy = netlbl_unlabel_genl_policy,
|
||||
.doit = netlbl_unlabel_staticremove,
|
||||
.dumpit = NULL,
|
||||
},
|
||||
{
|
||||
.cmd = NLBL_UNLABEL_C_STATICLIST,
|
||||
.flags = 0,
|
||||
.policy = netlbl_unlabel_genl_policy,
|
||||
.doit = NULL,
|
||||
.dumpit = netlbl_unlabel_staticlist,
|
||||
},
|
||||
{
|
||||
.cmd = NLBL_UNLABEL_C_STATICADDDEF,
|
||||
.flags = GENL_ADMIN_PERM,
|
||||
.policy = netlbl_unlabel_genl_policy,
|
||||
.doit = netlbl_unlabel_staticadddef,
|
||||
.dumpit = NULL,
|
||||
},
|
||||
{
|
||||
.cmd = NLBL_UNLABEL_C_STATICREMOVEDEF,
|
||||
.flags = GENL_ADMIN_PERM,
|
||||
.policy = netlbl_unlabel_genl_policy,
|
||||
.doit = netlbl_unlabel_staticremovedef,
|
||||
.dumpit = NULL,
|
||||
},
|
||||
{
|
||||
.cmd = NLBL_UNLABEL_C_STATICLISTDEF,
|
||||
.flags = 0,
|
||||
.policy = netlbl_unlabel_genl_policy,
|
||||
.doit = NULL,
|
||||
.dumpit = netlbl_unlabel_staticlistdef,
|
||||
},
|
||||
{
|
||||
.cmd = NLBL_UNLABEL_C_ACCEPT,
|
||||
.flags = GENL_ADMIN_PERM,
|
||||
.policy = netlbl_unlabel_genl_policy,
|
||||
.doit = netlbl_unlabel_accept,
|
||||
.dumpit = NULL,
|
||||
},
|
||||
{
|
||||
.cmd = NLBL_UNLABEL_C_LIST,
|
||||
.flags = 0,
|
||||
.policy = netlbl_unlabel_genl_policy,
|
||||
.doit = netlbl_unlabel_list,
|
||||
.dumpit = NULL,
|
||||
},
|
||||
@@ -1378,6 +1370,7 @@ static struct genl_family netlbl_unlabel_gnl_family __ro_after_init = {
|
||||
.name = NETLBL_NLTYPE_UNLABELED_NAME,
|
||||
.version = NETLBL_PROTO_VERSION,
|
||||
.maxattr = NLBL_UNLABEL_A_MAX,
|
||||
.policy = netlbl_unlabel_genl_policy,
|
||||
.module = THIS_MODULE,
|
||||
.ops = netlbl_unlabel_genl_ops,
|
||||
.n_ops = ARRAY_SIZE(netlbl_unlabel_genl_ops),
|
||||
|
Reference in New Issue
Block a user