aboutsummaryrefslogtreecommitdiffstats
path: root/net/openvswitch/datapath.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2019-03-21 17:51:02 -0400
committerDavid S. Miller <davem@davemloft.net>2019-03-22 10:38:23 -0400
commit3b0f31f2b8c9fb348e4530b88f6b64f9621f83d6 (patch)
tree8dcb4d7bede0f23070f3de8a14af775dd9ef07e1 /net/openvswitch/datapath.c
parent601ed4d6dc3a779a31af6376488a988abccfac37 (diff)
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>
Diffstat (limited to 'net/openvswitch/datapath.c')
-rw-r--r--net/openvswitch/datapath.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index 9dd158ab51b3..a64d3eb1f9a9 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -639,7 +639,6 @@ static const struct nla_policy packet_policy[OVS_PACKET_ATTR_MAX + 1] = {
639static const struct genl_ops dp_packet_genl_ops[] = { 639static const struct genl_ops dp_packet_genl_ops[] = {
640 { .cmd = OVS_PACKET_CMD_EXECUTE, 640 { .cmd = OVS_PACKET_CMD_EXECUTE,
641 .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */ 641 .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */
642 .policy = packet_policy,
643 .doit = ovs_packet_cmd_execute 642 .doit = ovs_packet_cmd_execute
644 } 643 }
645}; 644};
@@ -649,6 +648,7 @@ static struct genl_family dp_packet_genl_family __ro_after_init = {
649 .name = OVS_PACKET_FAMILY, 648 .name = OVS_PACKET_FAMILY,
650 .version = OVS_PACKET_VERSION, 649 .version = OVS_PACKET_VERSION,
651 .maxattr = OVS_PACKET_ATTR_MAX, 650 .maxattr = OVS_PACKET_ATTR_MAX,
651 .policy = packet_policy,
652 .netnsok = true, 652 .netnsok = true,
653 .parallel_ops = true, 653 .parallel_ops = true,
654 .ops = dp_packet_genl_ops, 654 .ops = dp_packet_genl_ops,
@@ -1424,23 +1424,19 @@ static const struct nla_policy flow_policy[OVS_FLOW_ATTR_MAX + 1] = {
1424static const struct genl_ops dp_flow_genl_ops[] = { 1424static const struct genl_ops dp_flow_genl_ops[] = {
1425 { .cmd = OVS_FLOW_CMD_NEW, 1425 { .cmd = OVS_FLOW_CMD_NEW,
1426 .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */ 1426 .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */
1427 .policy = flow_policy,
1428 .doit = ovs_flow_cmd_new 1427 .doit = ovs_flow_cmd_new
1429 }, 1428 },
1430 { .cmd = OVS_FLOW_CMD_DEL, 1429 { .cmd = OVS_FLOW_CMD_DEL,
1431 .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */ 1430 .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */
1432 .policy = flow_policy,
1433 .doit = ovs_flow_cmd_del 1431 .doit = ovs_flow_cmd_del
1434 }, 1432 },
1435 { .cmd = OVS_FLOW_CMD_GET, 1433 { .cmd = OVS_FLOW_CMD_GET,
1436 .flags = 0, /* OK for unprivileged users. */ 1434 .flags = 0, /* OK for unprivileged users. */
1437 .policy = flow_policy,
1438 .doit = ovs_flow_cmd_get, 1435 .doit = ovs_flow_cmd_get,
1439 .dumpit = ovs_flow_cmd_dump 1436 .dumpit = ovs_flow_cmd_dump
1440 }, 1437 },
1441 { .cmd = OVS_FLOW_CMD_SET, 1438 { .cmd = OVS_FLOW_CMD_SET,
1442 .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */ 1439 .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */
1443 .policy = flow_policy,
1444 .doit = ovs_flow_cmd_set, 1440 .doit = ovs_flow_cmd_set,
1445 }, 1441 },
1446}; 1442};
@@ -1450,6 +1446,7 @@ static struct genl_family dp_flow_genl_family __ro_after_init = {
1450 .name = OVS_FLOW_FAMILY, 1446 .name = OVS_FLOW_FAMILY,
1451 .version = OVS_FLOW_VERSION, 1447 .version = OVS_FLOW_VERSION,
1452 .maxattr = OVS_FLOW_ATTR_MAX, 1448 .maxattr = OVS_FLOW_ATTR_MAX,
1449 .policy = flow_policy,
1453 .netnsok = true, 1450 .netnsok = true,
1454 .parallel_ops = true, 1451 .parallel_ops = true,
1455 .ops = dp_flow_genl_ops, 1452 .ops = dp_flow_genl_ops,
@@ -1817,23 +1814,19 @@ static const struct nla_policy datapath_policy[OVS_DP_ATTR_MAX + 1] = {
1817static const struct genl_ops dp_datapath_genl_ops[] = { 1814static const struct genl_ops dp_datapath_genl_ops[] = {
1818 { .cmd = OVS_DP_CMD_NEW, 1815 { .cmd = OVS_DP_CMD_NEW,
1819 .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */ 1816 .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */
1820 .policy = datapath_policy,
1821 .doit = ovs_dp_cmd_new 1817 .doit = ovs_dp_cmd_new
1822 }, 1818 },
1823 { .cmd = OVS_DP_CMD_DEL, 1819 { .cmd = OVS_DP_CMD_DEL,
1824 .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */ 1820 .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */
1825 .policy = datapath_policy,
1826 .doit = ovs_dp_cmd_del 1821 .doit = ovs_dp_cmd_del
1827 }, 1822 },
1828 { .cmd = OVS_DP_CMD_GET, 1823 { .cmd = OVS_DP_CMD_GET,
1829 .flags = 0, /* OK for unprivileged users. */ 1824 .flags = 0, /* OK for unprivileged users. */
1830 .policy = datapath_policy,
1831 .doit = ovs_dp_cmd_get, 1825 .doit = ovs_dp_cmd_get,
1832 .dumpit = ovs_dp_cmd_dump 1826 .dumpit = ovs_dp_cmd_dump
1833 }, 1827 },
1834 { .cmd = OVS_DP_CMD_SET, 1828 { .cmd = OVS_DP_CMD_SET,
1835 .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */ 1829 .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */
1836 .policy = datapath_policy,
1837 .doit = ovs_dp_cmd_set, 1830 .doit = ovs_dp_cmd_set,
1838 }, 1831 },
1839}; 1832};
@@ -1843,6 +1836,7 @@ static struct genl_family dp_datapath_genl_family __ro_after_init = {
1843 .name = OVS_DATAPATH_FAMILY, 1836 .name = OVS_DATAPATH_FAMILY,
1844 .version = OVS_DATAPATH_VERSION, 1837 .version = OVS_DATAPATH_VERSION,
1845 .maxattr = OVS_DP_ATTR_MAX, 1838 .maxattr = OVS_DP_ATTR_MAX,
1839 .policy = datapath_policy,
1846 .netnsok = true, 1840 .netnsok = true,
1847 .parallel_ops = true, 1841 .parallel_ops = true,
1848 .ops = dp_datapath_genl_ops, 1842 .ops = dp_datapath_genl_ops,
@@ -2260,23 +2254,19 @@ static const struct nla_policy vport_policy[OVS_VPORT_ATTR_MAX + 1] = {
2260static const struct genl_ops dp_vport_genl_ops[] = { 2254static const struct genl_ops dp_vport_genl_ops[] = {
2261 { .cmd = OVS_VPORT_CMD_NEW, 2255 { .cmd = OVS_VPORT_CMD_NEW,
2262 .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */ 2256 .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */
2263 .policy = vport_policy,
2264 .doit = ovs_vport_cmd_new 2257 .doit = ovs_vport_cmd_new
2265 }, 2258 },
2266 { .cmd = OVS_VPORT_CMD_DEL, 2259 { .cmd = OVS_VPORT_CMD_DEL,
2267 .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */ 2260 .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */
2268 .policy = vport_policy,
2269 .doit = ovs_vport_cmd_del 2261 .doit = ovs_vport_cmd_del
2270 }, 2262 },
2271 { .cmd = OVS_VPORT_CMD_GET, 2263 { .cmd = OVS_VPORT_CMD_GET,
2272 .flags = 0, /* OK for unprivileged users. */ 2264 .flags = 0, /* OK for unprivileged users. */
2273 .policy = vport_policy,
2274 .doit = ovs_vport_cmd_get, 2265 .doit = ovs_vport_cmd_get,
2275 .dumpit = ovs_vport_cmd_dump 2266 .dumpit = ovs_vport_cmd_dump
2276 }, 2267 },
2277 { .cmd = OVS_VPORT_CMD_SET, 2268 { .cmd = OVS_VPORT_CMD_SET,
2278 .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */ 2269 .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */
2279 .policy = vport_policy,
2280 .doit = ovs_vport_cmd_set, 2270 .doit = ovs_vport_cmd_set,
2281 }, 2271 },
2282}; 2272};
@@ -2286,6 +2276,7 @@ struct genl_family dp_vport_genl_family __ro_after_init = {
2286 .name = OVS_VPORT_FAMILY, 2276 .name = OVS_VPORT_FAMILY,
2287 .version = OVS_VPORT_VERSION, 2277 .version = OVS_VPORT_VERSION,
2288 .maxattr = OVS_VPORT_ATTR_MAX, 2278 .maxattr = OVS_VPORT_ATTR_MAX,
2279 .policy = vport_policy,
2289 .netnsok = true, 2280 .netnsok = true,
2290 .parallel_ops = true, 2281 .parallel_ops = true,
2291 .ops = dp_vport_genl_ops, 2282 .ops = dp_vport_genl_ops,