From patchwork Fri Mar 6 22:37:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gregory Rose X-Patchwork-Id: 1250648 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=SBA8jwCI; dkim-atps=neutral Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48Z2Yw1psMz9sPR for ; Sat, 7 Mar 2020 09:37:40 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 9192B86F8D; Fri, 6 Mar 2020 22:37:38 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CS554LmWP5-G; Fri, 6 Mar 2020 22:37:33 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by fraxinus.osuosl.org (Postfix) with ESMTP id B389B86F90; Fri, 6 Mar 2020 22:37:33 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 79E02C1D8F; Fri, 6 Mar 2020 22:37:33 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id B4CB9C013E for ; Fri, 6 Mar 2020 22:37:32 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 8B23A228E3 for ; Fri, 6 Mar 2020 22:37:32 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7mHomcmWPtNy for ; Fri, 6 Mar 2020 22:37:29 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) by silver.osuosl.org (Postfix) with ESMTPS id 0CF39228BD for ; Fri, 6 Mar 2020 22:37:29 +0000 (UTC) Received: by mail-pg1-f196.google.com with SMTP id h8so1720841pgs.9 for ; Fri, 06 Mar 2020 14:37:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xYner+xGJ/OLjp6iikteBsUyk/HXn0BrO61OmGZSfMY=; b=SBA8jwCIZA5t/QHALYp4jvSO4IOzsjJZpxokXX1Se7nRVj3Ox1qTGvnegOvPPVBC0v pe5HZBMhmEQW859J53Qr43UU3ntwAe4m+2tbt5nojVL+KvAegzNPZ574RNt+tgi1PrVD VZ5VuRezRq+lrtYZZX5xxfpG0JPOgtLUT+adCIweCCBEXRiRWQlOXxDywC9GU+k268MX PfoyEvTPiosvkBqLsOihRJR4zRZCSu2l3gRcyu6+DOxLebWhVZCfoyVTVxVBhmNhxTj2 lt0ZjMacsCsFjArBPmnww2+cel2lmGERDblejC0AnXCiOaaQiF5ovOKyU4fCHkMB8+qm 6Mvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xYner+xGJ/OLjp6iikteBsUyk/HXn0BrO61OmGZSfMY=; b=ddZOByYwHycPrfAnBx/Sr/fGdn1gzNG7jDve7Tr4jemFsJhJtYNSYwOHkNzXlnMb0C UpBzPJzOqI3n7j+sWgwXnAqGIc0zVMQGqagTqJtg8ggv690gKB6MvQ+fbCZYV3iC1JV9 uxnH3U3cl/IdL/sGunXyCb54s2V8tvLs0MgR6Wik3WIa7uvZV50KM/Inn0LylJoZdawj 8h+EidG7EkaBmZONV5H0Sf7skt8fuXgMWg80zN/HQH2Si+zXDDfRz5NJrirT8HRYwKqz /n6OpcujCZQiMKtLCg/DMVEn6QnkNdVsLLZdQIJMkO52xCSdsDF6RVux7kb1rk5NlqL2 K0ZA== X-Gm-Message-State: ANhLgQ2MdiPBuPljopyUx+c3nwdVqCN34YOR7HNB7v0LLycVW27Ns5kM 7ZLSACGGSm0I2wxpI1//NMRaZ8R/ENQ= X-Google-Smtp-Source: ADFU+vt3/nQPpvsg/GVmXnCEEI+DSoH3NkG0yugPVIzFsiCD+y90u4cFnQB+xGlgcR1Q/XQrIv8qUA== X-Received: by 2002:a62:6842:: with SMTP id d63mr5965524pfc.113.1583534248089; Fri, 06 Mar 2020 14:37:28 -0800 (PST) Received: from gizo.domain (97-115-106-43.ptld.qwest.net. [97.115.106.43]) by smtp.gmail.com with ESMTPSA id k3sm35939602pgh.34.2020.03.06.14.37.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Mar 2020 14:37:27 -0800 (PST) From: Greg Rose To: dev@openvswitch.org Date: Fri, 6 Mar 2020 14:37:15 -0800 Message-Id: <1583534241-16600-4-git-send-email-gvrose8192@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1583534241-16600-1-git-send-email-gvrose8192@gmail.com> References: <1583534241-16600-1-git-send-email-gvrose8192@gmail.com> Cc: Johannes Berg Subject: [ovs-dev] [PATCH V4 3/9] compat: Move genl_ops policy to genl_family X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Johannes Berg Upstream commit: commit 3b0f31f2b8c9fb348e4530b88f6b64f9621f83d6 Author: Johannes Berg Date: Thu Mar 21 22:51:02 2019 +0100 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 Signed-off-by: David S. Miller Since commit 3b0f31f2b8c9f ("genetlink: make policy common to family") the policy field of the genl_ops structure has been moved into the genl_family structure. Add necessary compat layer infrastructure to still support older kernels. Acked-by: Yi-Hung Wei Signed-off-by: Greg Rose --- V3 - Add policy back to genl_family instead of completely removing it. --- acinclude.m4 | 3 +++ datapath/conntrack.c | 9 +++++++++ datapath/datapath.c | 38 ++++++++++++++++++++++++++++++++++++++ datapath/meter.c | 11 +++++++++++ 4 files changed, 61 insertions(+) diff --git a/acinclude.m4 b/acinclude.m4 index 3a555ad..729d2c6 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -1050,6 +1050,9 @@ AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [ [OVS_DEFINE([HAVE_DST_OPS_CONFIRM_NEIGH])]) OVS_GREP_IFELSE([$KSRC/include/net/inet_frag.h], [fqdir], [OVS_DEFINE([HAVE_INET_FRAG_FQDIR])]) + OVS_FIND_FIELD_IFELSE([$KSRC/include/net/genetlink.h], [genl_ops], + [policy], + [OVS_DEFINE([HAVE_GENL_OPS_POLICY])]) if cmp -s datapath/linux/kcompat.h.new \ datapath/linux/kcompat.h >/dev/null 2>&1; then diff --git a/datapath/conntrack.c b/datapath/conntrack.c index 838cf63..b7eb53f 100644 --- a/datapath/conntrack.c +++ b/datapath/conntrack.c @@ -2312,7 +2312,9 @@ static struct genl_ops ct_limit_genl_ops[] = { #endif .flags = GENL_ADMIN_PERM, /* Requires CAP_NET_ADMIN * privilege. */ +#ifdef HAVE_GENL_OPS_POLICY .policy = ct_limit_policy, +#endif .doit = ovs_ct_limit_cmd_set, }, { .cmd = OVS_CT_LIMIT_CMD_DEL, @@ -2321,7 +2323,9 @@ static struct genl_ops ct_limit_genl_ops[] = { #endif .flags = GENL_ADMIN_PERM, /* Requires CAP_NET_ADMIN * privilege. */ +#ifdef HAVE_GENL_OPS_POLICY .policy = ct_limit_policy, +#endif .doit = ovs_ct_limit_cmd_del, }, { .cmd = OVS_CT_LIMIT_CMD_GET, @@ -2329,7 +2333,9 @@ static struct genl_ops ct_limit_genl_ops[] = { .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, #endif .flags = 0, /* OK for unprivileged users. */ +#ifdef HAVE_GENL_OPS_POLICY .policy = ct_limit_policy, +#endif .doit = ovs_ct_limit_cmd_get, }, }; @@ -2343,6 +2349,9 @@ struct genl_family dp_ct_limit_genl_family __ro_after_init = { .name = OVS_CT_LIMIT_FAMILY, .version = OVS_CT_LIMIT_VERSION, .maxattr = OVS_CT_LIMIT_ATTR_MAX, +#ifndef HAVE_GENL_OPS_POLICY + .policy = ct_limit_policy, +#endif .netnsok = true, .parallel_ops = true, .ops = ct_limit_genl_ops, diff --git a/datapath/datapath.c b/datapath/datapath.c index 853bfb5..6f74c8f 100644 --- a/datapath/datapath.c +++ b/datapath/datapath.c @@ -657,7 +657,9 @@ static struct genl_ops dp_packet_genl_ops[] = { .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, #endif .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */ +#ifdef HAVE_GENL_OPS_POLICY .policy = packet_policy, +#endif .doit = ovs_packet_cmd_execute } }; @@ -667,6 +669,9 @@ static struct genl_family dp_packet_genl_family __ro_after_init = { .name = OVS_PACKET_FAMILY, .version = OVS_PACKET_VERSION, .maxattr = OVS_PACKET_ATTR_MAX, +#ifndef HAVE_GENL_OPS_POLICY + .policy = packet_policy, +#endif .netnsok = true, .parallel_ops = true, .ops = dp_packet_genl_ops, @@ -1449,7 +1454,9 @@ static const struct genl_ops dp_flow_genl_ops[] = { .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, #endif .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */ +#ifdef HAVE_GENL_OPS_POLICY .policy = flow_policy, +#endif .doit = ovs_flow_cmd_new }, { .cmd = OVS_FLOW_CMD_DEL, @@ -1457,7 +1464,9 @@ static const struct genl_ops dp_flow_genl_ops[] = { .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, #endif .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */ +#ifdef HAVE_GENL_OPS_POLICY .policy = flow_policy, +#endif .doit = ovs_flow_cmd_del }, { .cmd = OVS_FLOW_CMD_GET, @@ -1465,7 +1474,9 @@ static const struct genl_ops dp_flow_genl_ops[] = { .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, #endif .flags = 0, /* OK for unprivileged users. */ +#ifdef HAVE_GENL_OPS_POLICY .policy = flow_policy, +#endif .doit = ovs_flow_cmd_get, .dumpit = ovs_flow_cmd_dump }, @@ -1474,7 +1485,9 @@ static const struct genl_ops dp_flow_genl_ops[] = { .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, #endif .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */ +#ifdef HAVE_GENL_OPS_POLICY .policy = flow_policy, +#endif .doit = ovs_flow_cmd_set, }, }; @@ -1484,6 +1497,9 @@ static struct genl_family dp_flow_genl_family __ro_after_init = { .name = OVS_FLOW_FAMILY, .version = OVS_FLOW_VERSION, .maxattr = OVS_FLOW_ATTR_MAX, +#ifndef HAVE_GENL_OPS_POLICY + .policy = flow_policy, +#endif .netnsok = true, .parallel_ops = true, .ops = dp_flow_genl_ops, @@ -1853,7 +1869,9 @@ static const struct genl_ops dp_datapath_genl_ops[] = { .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, #endif .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */ +#ifdef HAVE_GENL_OPS_POLICY .policy = datapath_policy, +#endif .doit = ovs_dp_cmd_new }, { .cmd = OVS_DP_CMD_DEL, @@ -1861,7 +1879,9 @@ static const struct genl_ops dp_datapath_genl_ops[] = { .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, #endif .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */ +#ifdef HAVE_GENL_OPS_POLICY .policy = datapath_policy, +#endif .doit = ovs_dp_cmd_del }, { .cmd = OVS_DP_CMD_GET, @@ -1869,7 +1889,9 @@ static const struct genl_ops dp_datapath_genl_ops[] = { .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, #endif .flags = 0, /* OK for unprivileged users. */ +#ifdef HAVE_GENL_OPS_POLICY .policy = datapath_policy, +#endif .doit = ovs_dp_cmd_get, .dumpit = ovs_dp_cmd_dump }, @@ -1878,7 +1900,9 @@ static const struct genl_ops dp_datapath_genl_ops[] = { .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, #endif .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */ +#ifdef HAVE_GENL_OPS_POLICY .policy = datapath_policy, +#endif .doit = ovs_dp_cmd_set, }, }; @@ -1888,6 +1912,9 @@ static struct genl_family dp_datapath_genl_family __ro_after_init = { .name = OVS_DATAPATH_FAMILY, .version = OVS_DATAPATH_VERSION, .maxattr = OVS_DP_ATTR_MAX, +#ifndef HAVE_GENL_OPS_POLICY + .policy = datapath_policy, +#endif .netnsok = true, .parallel_ops = true, .ops = dp_datapath_genl_ops, @@ -2310,7 +2337,9 @@ static const struct genl_ops dp_vport_genl_ops[] = { .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, #endif .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */ +#ifdef HAVE_GENL_OPS_POLICY .policy = vport_policy, +#endif .doit = ovs_vport_cmd_new }, { .cmd = OVS_VPORT_CMD_DEL, @@ -2318,7 +2347,9 @@ static const struct genl_ops dp_vport_genl_ops[] = { .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, #endif .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */ +#ifdef HAVE_GENL_OPS_POLICY .policy = vport_policy, +#endif .doit = ovs_vport_cmd_del }, { .cmd = OVS_VPORT_CMD_GET, @@ -2326,7 +2357,9 @@ static const struct genl_ops dp_vport_genl_ops[] = { .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, #endif .flags = 0, /* OK for unprivileged users. */ +#ifdef HAVE_GENL_OPS_POLICY .policy = vport_policy, +#endif .doit = ovs_vport_cmd_get, .dumpit = ovs_vport_cmd_dump }, @@ -2335,7 +2368,9 @@ static const struct genl_ops dp_vport_genl_ops[] = { .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, #endif .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */ +#ifdef HAVE_GENL_OPS_POLICY .policy = vport_policy, +#endif .doit = ovs_vport_cmd_set, }, }; @@ -2345,6 +2380,9 @@ struct genl_family dp_vport_genl_family __ro_after_init = { .name = OVS_VPORT_FAMILY, .version = OVS_VPORT_VERSION, .maxattr = OVS_VPORT_ATTR_MAX, +#ifndef HAVE_GENL_OPS_POLICY + .policy = vport_policy, +#endif .netnsok = true, .parallel_ops = true, .ops = dp_vport_genl_ops, diff --git a/datapath/meter.c b/datapath/meter.c index 7d8f51a..8cecd5a 100644 --- a/datapath/meter.c +++ b/datapath/meter.c @@ -542,7 +542,9 @@ static struct genl_ops dp_meter_genl_ops[] = { .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, #endif .flags = 0, /* OK for unprivileged users. */ +#ifdef HAVE_GENL_OPS_POLICY .policy = meter_policy, +#endif .doit = ovs_meter_cmd_features }, { .cmd = OVS_METER_CMD_SET, @@ -552,7 +554,9 @@ static struct genl_ops dp_meter_genl_ops[] = { .flags = GENL_ADMIN_PERM, /* Requires CAP_NET_ADMIN * privilege. */ +#ifdef HAVE_GENL_OPS_POLICY .policy = meter_policy, +#endif .doit = ovs_meter_cmd_set, }, { .cmd = OVS_METER_CMD_GET, @@ -560,7 +564,9 @@ static struct genl_ops dp_meter_genl_ops[] = { .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, #endif .flags = 0, /* OK for unprivileged users. */ +#ifdef HAVE_GENL_OPS_POLICY .policy = meter_policy, +#endif .doit = ovs_meter_cmd_get, }, { .cmd = OVS_METER_CMD_DEL, @@ -570,7 +576,9 @@ static struct genl_ops dp_meter_genl_ops[] = { .flags = GENL_ADMIN_PERM, /* Requires CAP_NET_ADMIN * privilege. */ +#ifdef HAVE_GENL_OPS_POLICY .policy = meter_policy, +#endif .doit = ovs_meter_cmd_del }, }; @@ -584,6 +592,9 @@ struct genl_family dp_meter_genl_family __ro_after_init = { .name = OVS_METER_FAMILY, .version = OVS_METER_VERSION, .maxattr = OVS_METER_ATTR_MAX, +#ifndef HAVE_GENL_OPS_POLICY + .policy = meter_policy, +#endif .netnsok = true, .parallel_ops = true, .ops = dp_meter_genl_ops,