genetlink: make policy common to family
authorJohannes Berg <johannes.berg@intel.com>
Thu, 21 Mar 2019 21:51:02 +0000 (22:51 +0100)
committerDavid S. Miller <davem@davemloft.net>
Fri, 22 Mar 2019 14:38:23 +0000 (10:38 -0400)
commit3b0f31f2b8c9fb348e4530b88f6b64f9621f83d6
tree8dcb4d7bede0f23070f3de8a14af775dd9ef07e1
parent601ed4d6dc3a779a31af6376488a988abccfac37
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>
36 files changed:
drivers/block/nbd.c
drivers/net/gtp.c
drivers/net/ieee802154/mac802154_hwsim.c
drivers/net/macsec.c
drivers/net/team/team.c
drivers/net/wireless/mac80211_hwsim.c
drivers/target/target_core_user.c
include/linux/genl_magic_func.h
include/net/genetlink.h
kernel/taskstats.c
net/batman-adv/netlink.c
net/core/devlink.c
net/hsr/hsr_netlink.c
net/ieee802154/ieee802154.h
net/ieee802154/netlink.c
net/ieee802154/nl802154.c
net/ipv4/fou.c
net/ipv4/tcp_metrics.c
net/ipv6/ila/ila_main.c
net/ipv6/seg6.c
net/l2tp/l2tp_netlink.c
net/ncsi/ncsi-netlink.c
net/netfilter/ipvs/ip_vs_ctl.c
net/netlabel/netlabel_calipso.c
net/netlabel/netlabel_cipso_v4.c
net/netlabel/netlabel_mgmt.c
net/netlabel/netlabel_unlabeled.c
net/netlink/genetlink.c
net/nfc/netlink.c
net/openvswitch/conntrack.c
net/openvswitch/datapath.c
net/openvswitch/meter.c
net/smc/smc_pnet.c
net/tipc/netlink.c
net/wimax/stack.c
net/wireless/nl80211.c