From patchwork Wed Aug 2 15:20:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 13338386 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C3FB38460 for ; Wed, 2 Aug 2023 15:21:08 +0000 (UTC) Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 680A24C06 for ; Wed, 2 Aug 2023 08:20:44 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-3fba8e2aa52so74558245e9.1 for ; Wed, 02 Aug 2023 08:20:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20221208.gappssmtp.com; s=20221208; t=1690989627; x=1691594427; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jN4tj6ro1FneEJbRj7B8hPejpVe40Jja+XIMGYax1bc=; b=uX+6pPpAIRAZwmYRuQdsRxjDdm6t8phXmddpI5wFFk5cmZHtnUzGtQu5z69ic1+/f7 rnk+tTRaCMcG4sH8CqO4sRCXXCLvpkhIJZoAfKY9r9gB5SHBcTszWYLkmoFXytMunyFH IKucltjolF71d7u6C7ncL1+RGD1P91svUEj3FcjJRWXjQcR+5QDt+SNEhiL9DdAxqMTL KE2XleJ2L625SM99h96/Ts/z/G7nxD47RQ4qccJzo8eTgQly5MtepVLGPP+la0wu25wk ug9m0gHONGHFK1Tlfl3lgSAB1nx4gxGOEaLKWCXm2pyB4YmHFxyJRJKm+at0Zk5n1HlS L9lA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690989627; x=1691594427; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jN4tj6ro1FneEJbRj7B8hPejpVe40Jja+XIMGYax1bc=; b=dlIiYgWlEu7HmROYPlv15WKjgglZ2nhko7GL7JWdgXZqff7J+Kzqbt6GgBnumvQxxo pWRbTeM7xA+Rxask6gX37ZbNjzRFHGV4Wg25C45xfXyGU90aCKXLSUE3+tYhlxjYhvot RV8LF0hhC3MXHQALbhSGuosbYCFfWClZQC9o0p0m6pB4tPOVvd04vWpRQ1s7ZMaC+I1a mDfZWCKaUNOCHTzheLe8Ib30n0px036f0B7MiYupWdHGRSZXB/kUvss9GJ07ef+zDzoi e10OkEIiqCPjrd/RGqUmmnaBxOlhBiorIUbXZwK/Hi6P6nXWCgV/A2GZvr4fQwTMiu+O 7iEw== X-Gm-Message-State: ABy/qLa7wqyzY+OfrKUwM/oYvsNHH9BJiiDmVvg4ETIf+d5TzWlfjB8G SQpDHcP/gQJz6eukdqmuuw9FjvBdCPCKTFQLHop2UQ== X-Google-Smtp-Source: APBJJlFDH5piI9ZE7C8Tu+4uRfLFN48R7fZPB/Od9D9a0vHGrbfT5g3XfN+FtzMJN0Z8Ds/2GmDkGQ== X-Received: by 2002:a1c:7419:0:b0:3fb:e2af:49f6 with SMTP id p25-20020a1c7419000000b003fbe2af49f6mr4808926wmc.39.1690989627526; Wed, 02 Aug 2023 08:20:27 -0700 (PDT) Received: from localhost ([212.23.236.67]) by smtp.gmail.com with ESMTPSA id w10-20020a5d4b4a000000b003176c6e87b1sm18877760wrs.81.2023.08.02.08.20.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 08:20:26 -0700 (PDT) From: Jiri Pirko To: netdev@vger.kernel.org Cc: kuba@kernel.org, pabeni@redhat.com, davem@davemloft.net, edumazet@google.com, moshe@nvidia.com, saeedm@nvidia.com, idosch@nvidia.com, petrm@nvidia.com Subject: [patch net-next v2 01/11] netlink: specs: add dump-strict flag for dont-validate property Date: Wed, 2 Aug 2023 17:20:13 +0200 Message-ID: <20230802152023.941837-2-jiri@resnulli.us> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802152023.941837-1-jiri@resnulli.us> References: <20230802152023.941837-1-jiri@resnulli.us> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Jiri Pirko Allow user to specify GENL_DONT_VALIDATE_DUMP_STRICT flag for validation and add this flag to netlink spec schema. Signed-off-by: Jiri Pirko --- v1->v2: - new patch --- Documentation/netlink/genetlink-c.yaml | 2 +- Documentation/netlink/genetlink-legacy.yaml | 2 +- Documentation/netlink/genetlink.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Documentation/netlink/genetlink-c.yaml b/Documentation/netlink/genetlink-c.yaml index 57d1c1c4918f..4c1f8c22627b 100644 --- a/Documentation/netlink/genetlink-c.yaml +++ b/Documentation/netlink/genetlink-c.yaml @@ -274,7 +274,7 @@ properties: description: Kernel attribute validation flags. type: array items: - enum: [ strict, dump ] + enum: [ strict, dump, dump-strict ] do: &subop-type description: Main command handler. type: object diff --git a/Documentation/netlink/genetlink-legacy.yaml b/Documentation/netlink/genetlink-legacy.yaml index 43b769c98fb2..196076dfa309 100644 --- a/Documentation/netlink/genetlink-legacy.yaml +++ b/Documentation/netlink/genetlink-legacy.yaml @@ -321,7 +321,7 @@ properties: description: Kernel attribute validation flags. type: array items: - enum: [ strict, dump ] + enum: [ strict, dump, dump-strict ] # Start genetlink-legacy fixed-header: *fixed-header # End genetlink-legacy diff --git a/Documentation/netlink/genetlink.yaml b/Documentation/netlink/genetlink.yaml index 1cbb448d2f1c..3d338c48bf21 100644 --- a/Documentation/netlink/genetlink.yaml +++ b/Documentation/netlink/genetlink.yaml @@ -243,7 +243,7 @@ properties: description: Kernel attribute validation flags. type: array items: - enum: [ strict, dump ] + enum: [ strict, dump, dump-strict ] do: &subop-type description: Main command handler. type: object From patchwork Wed Aug 2 15:20:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 13338387 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7D35EAD2A for ; Wed, 2 Aug 2023 15:21:14 +0000 (UTC) Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2E8B2D74 for ; Wed, 2 Aug 2023 08:20:49 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id ffacd0b85a97d-317716a4622so6410602f8f.1 for ; Wed, 02 Aug 2023 08:20:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20221208.gappssmtp.com; s=20221208; t=1690989629; x=1691594429; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=J0LhtMaDHhRm3mbnKfWT8/Dhmh40h6lBxv/BhmqqlQo=; b=zwZSFFg0xcS1wi6bCBGhtGm0EXLe6emOvD1g4F318i01oBpfOw4f9+rXoq846D3xOs fOZ4vrikEFiud83LB9uVsVD8ZU2On7UoalNc/lvRCQlAw2XoiUENsmuuf5yWZup6B/DN C570T+eho9+Ti02RCzKBVWs7VG11+bijz3WJhsEZej7GQF8SzUYbrakZZMABGnMTl3l1 omljMM31bcl8x5JAgMYV8MBpaE58KjI1D+FKf0P1NEf6ht4D97vzmL0J+y3FXDRZTfMf /YPW/nK5Hdmj1tWpr39cP+mKDOLK3EeQSeWpB1ijnutnJGSsB7rqDYZ25Kngj9W4kIae yOEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690989629; x=1691594429; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=J0LhtMaDHhRm3mbnKfWT8/Dhmh40h6lBxv/BhmqqlQo=; b=hvwvydLU+zenv5QSZ2h+vzWPCf176Iog7MrSvC3yG2k32X/T65En5KNk3vQmYLqXgz V7Opl+cUOc97nfbOFYyM0AupP6DxBVPkfVia/F6rPGizCELwJQTXGbj2fq5O5RtTVTn8 cz2AFVeGa8BQqOaMdvrVM78R0D6FIH5wWo9LZiIVHD6AEdYyDPRLoQ1tvLrFWy91SWWw y+NKOa1ieQOV3eQqd1kO0YltwHMsEgyOgTX0zaasC1Qh+0j2Ua0mhp/1g3eb5jGlrtDe 8AYU61Jh+HQFV4J2piS1zc+Jn5M6ZaYulYzyFWPm70EV3l7ZOyetOg45IQN3StpnwYNb 7XvA== X-Gm-Message-State: ABy/qLYNFtqlMXpRySmvL7dScZu/uEHfz3Gm9PIY1bVIHR8eT13yL64P YBI67+JWa4rO0aRGj8RaTcvfsGUqHrNZ/eBRHojpArvV X-Google-Smtp-Source: APBJJlGPJDaOcQtpHNPltbUnswYs61j1ld1B31hVl3ZMvkchZR000IdlEG0eoNTwWpgDD98oBv3KkQ== X-Received: by 2002:a5d:6082:0:b0:316:fb39:e045 with SMTP id w2-20020a5d6082000000b00316fb39e045mr4799283wrt.48.1690989629094; Wed, 02 Aug 2023 08:20:29 -0700 (PDT) Received: from localhost ([212.23.236.67]) by smtp.gmail.com with ESMTPSA id bf10-20020a0560001cca00b0031432f1528csm19301649wrb.45.2023.08.02.08.20.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 08:20:28 -0700 (PDT) From: Jiri Pirko To: netdev@vger.kernel.org Cc: kuba@kernel.org, pabeni@redhat.com, davem@davemloft.net, edumazet@google.com, moshe@nvidia.com, saeedm@nvidia.com, idosch@nvidia.com, petrm@nvidia.com Subject: [patch net-next v2 02/11] ynl-gen-c.py: filter rendering of validate field values for split ops Date: Wed, 2 Aug 2023 17:20:14 +0200 Message-ID: <20230802152023.941837-3-jiri@resnulli.us> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802152023.941837-1-jiri@resnulli.us> References: <20230802152023.941837-1-jiri@resnulli.us> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Jiri Pirko For split ops, do and dump has different meaningful values in validate field. Fix the rendering to allow the values per op type as follows: do: strict dump: dump, strict-dump Signed-off-by: Jiri Pirko --- v1->v2: - consider strict-dump flag newly added by the previous patch - re-phrased the commit message, altered the patch subject a bit --- tools/net/ynl/ynl-gen-c.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py index 650be9b8b693..a3f70ca929fb 100755 --- a/tools/net/ynl/ynl-gen-c.py +++ b/tools/net/ynl/ynl-gen-c.py @@ -1988,9 +1988,17 @@ def print_kernel_op_table(family, cw): cw.block_start() members = [('cmd', op.enum_name)] if 'dont-validate' in op: + dont_validate = [] + for x in op['dont-validate']: + if op_mode == 'do' and x in ['dump', 'dump-strict']: + continue + if op_mode == "dump" and x == 'strict': + continue + dont_validate.append(x) + members.append(('validate', ' | '.join([c_upper('genl-dont-validate-' + x) - for x in op['dont-validate']])), ) + for x in dont_validate])), ) name = c_lower(f"{family.name}-nl-{op_name}-{op_mode}it") if 'pre' in op[op_mode]: members.append((cb_names[op_mode]['pre'], c_lower(op[op_mode]['pre']))) From patchwork Wed Aug 2 15:20:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 13338388 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3E4EFC8F8 for ; Wed, 2 Aug 2023 15:21:15 +0000 (UTC) Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CC4B2D7D for ; Wed, 2 Aug 2023 08:20:50 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-3fe167d4a18so46774545e9.0 for ; Wed, 02 Aug 2023 08:20:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20221208.gappssmtp.com; s=20221208; t=1690989630; x=1691594430; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=q6dEKsVObuwCBVkuwQ2aMV2dMYfNJE9+/kM8MgMaO1A=; b=ryuUf2UWyFt1x//0z9wkh7gSYXbVtc1QrLB6a+V0tPdQpaF8CvlDCXNeNbN/CqdGr5 IALFkZFPt+ThzdRa2oGDy7WuNjsFxqLYilBxYNM8YO41obwYd5p7XUtsLRqETroNDRTd 6r0U2VJMqszMa6D6iML+M5U/1BZK+pfrzxvT+N9H22At8lljGcG2GWd9VaxKzQXlszte waxgHD902xC+AciUWRj73JNnM8UHQ46mA+dkqmGoxkfwXeVpUcMMka0FSGLD2eFc6DBm UM32y7e8TKPi988qEbY77j3KJksh/IVV4HcRyb/g+szNla3fO6riVtCX6I2Vby6gJ/xk yiJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690989630; x=1691594430; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=q6dEKsVObuwCBVkuwQ2aMV2dMYfNJE9+/kM8MgMaO1A=; b=E1/gvSpj4eYxw2F5uyuIYZBk3VoIVN6l6ABY/44g2abDv5XlbZLEhWF1wZjSAFe3Ei BQi6MBJVzPjd/m1vhlfkK3wzJLDPd3L9wLF2L3wj1P1prS6BtM15vC0BowcsVI7QVp/U 90wUcjkEY9lRzrh6yW8FDIKWbthYxXAAdIyr9Dg9v0h2rUZ7LCisFlh1CBYYVQ99PEm6 Z9i+IYauzi1hOitdoJFeuKL4lsRqryyEYqY+LkdM+gEmTHpoircRpF/wTcRmFUKORzOC gxhnt3oi1tVTWwDMqIxVGW0ZpTWP6kPKZrMlo8vOddwWvpeoCCqFxJ5JN1L+8EnE2OW+ KKCg== X-Gm-Message-State: ABy/qLZRKfI6qSoy6o61+WRDaIZp7EDqiSfYGSraNh+R6ZnRYRqC5nNv rGLsSnmtw7Am3RLSp5XhiCVfP2eOgG6M+R3wjWKSrA== X-Google-Smtp-Source: APBJJlFMUaRdH9hF62yeF7ofYdEXrOvvXe2UC5pa8saBWNPQTpvOU4dP0lFKCcZ/3NbbjJX2t+iduQ== X-Received: by 2002:a5d:50d0:0:b0:314:3c84:4da2 with SMTP id f16-20020a5d50d0000000b003143c844da2mr5315090wrt.13.1690989630692; Wed, 02 Aug 2023 08:20:30 -0700 (PDT) Received: from localhost ([212.23.236.67]) by smtp.gmail.com with ESMTPSA id k14-20020a5d524e000000b0030fd03e3d25sm19312441wrc.75.2023.08.02.08.20.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 08:20:30 -0700 (PDT) From: Jiri Pirko To: netdev@vger.kernel.org Cc: kuba@kernel.org, pabeni@redhat.com, davem@davemloft.net, edumazet@google.com, moshe@nvidia.com, saeedm@nvidia.com, idosch@nvidia.com, petrm@nvidia.com Subject: [patch net-next v2 03/11] ynl-gen-c.py: allow directional model for kernel mode Date: Wed, 2 Aug 2023 17:20:15 +0200 Message-ID: <20230802152023.941837-4-jiri@resnulli.us> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802152023.941837-1-jiri@resnulli.us> References: <20230802152023.941837-1-jiri@resnulli.us> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Jiri Pirko Directional model limitation is only applicable for uapi mode. For kernel mode, the code is generated correctly using right cmd values for do/dump requests. Lift the limitation. Signed-off-by: Jiri Pirko --- v1->v2: - re-phrased the patch description --- tools/net/ynl/ynl-gen-c.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py index a3f70ca929fb..34ee7b8e3f71 100755 --- a/tools/net/ynl/ynl-gen-c.py +++ b/tools/net/ynl/ynl-gen-c.py @@ -2317,7 +2317,7 @@ def main(): return supported_models = ['unified'] - if args.mode == 'user': + if args.mode in ['user', 'kernel']: supported_models += ['directional'] if parsed.msg_id_model not in supported_models: print(f'Message enum-model {parsed.msg_id_model} not supported for {args.mode} generation') From patchwork Wed Aug 2 15:20:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 13338389 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 55EDED30F for ; Wed, 2 Aug 2023 15:21:18 +0000 (UTC) Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4B234C0D for ; Wed, 2 Aug 2023 08:20:53 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-3fbc5d5742bso74355935e9.2 for ; Wed, 02 Aug 2023 08:20:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20221208.gappssmtp.com; s=20221208; t=1690989632; x=1691594432; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LvjR0egsx3QP5ZoVehOstU8TmWV+b/KA1hWFGZTG2ls=; b=y2C1b/WtW0Mf1xw8l2HfO8Kd+RSmu2o+zsD6KjFw6RvJR2L0/Qtvc1y9QnwpVaXbvb eX/mmeopctUqNoUUu42FkVIId7PFpuoS0afsdtk7vUMx6nnsg2LPDwAeu71ny56N1S44 Edt87TvWp4ojd9tcR128Surwimbxop2Lw76AC6dT0ykFPiQ734wDIba5sCGVZeiF+VTB CxI73/eOWCBczgyJMPdS+5DqXZwXV/iJLDgKpF9wB/0zdGfqipqX3DEJf4TXVkY/4yCW +kEyGdI4/AkD8FKS6PeaGjITtVhmHtVE0KKLhNcoAQXwyH7YcX6KH3huIjOWlapqkLg2 hbPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690989632; x=1691594432; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LvjR0egsx3QP5ZoVehOstU8TmWV+b/KA1hWFGZTG2ls=; b=f6GfFZ3bEQ4VTW7v+gxkK62Gmivfnu4Qcnn7kAfRzvxbai8Xr+FZn//uz/Dm3wcr1j k8VO74oM0nSgUk9mw8+60KIqv2qwAZ7vkSyi7nYmzDSXdDnWDygA65dnyyxB/Ht8LtVE oc8e4Rn4diUMUtpfA5n5c6z1igsoULECP7c7ki11XaAV17TeVtPExVrieT/yASV/zf5d NmHTvB2R+09poydh5RX/mzeO0PoCMqQfDzCwHUtWSykFGP03/nOsh52XxoD/31mhdv5n 6U5PvzWcXA1N1lvb+A7XvxjqBYumfxw7PF5OjKDX6FT6NMr3XrBhnJL/pwuvxhn5D6KY gnlw== X-Gm-Message-State: ABy/qLastGg9Y5BAJiK9EMGhq8AbLWCqoRlhCTK19IhJsy5yDJ0AzaOe 6LhBuCFhk7G5dRpA7DeG/ZeT5hCSnxN0v1REthyO5w== X-Google-Smtp-Source: APBJJlF/NRu7uNjgaJLMWI9yEE7fHXA5C634ks2STZItS4/DOomkS0S4c5GS1JpjhkbKdoEcrWgR7g== X-Received: by 2002:a05:600c:2303:b0:3fe:1bef:4034 with SMTP id 3-20020a05600c230300b003fe1bef4034mr5265122wmo.37.1690989632526; Wed, 02 Aug 2023 08:20:32 -0700 (PDT) Received: from localhost ([212.23.236.67]) by smtp.gmail.com with ESMTPSA id f10-20020a7bc8ca000000b003fe1afb99b5sm2317312wml.0.2023.08.02.08.20.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 08:20:31 -0700 (PDT) From: Jiri Pirko To: netdev@vger.kernel.org Cc: kuba@kernel.org, pabeni@redhat.com, davem@davemloft.net, edumazet@google.com, moshe@nvidia.com, saeedm@nvidia.com, idosch@nvidia.com, petrm@nvidia.com Subject: [patch net-next v2 04/11] ynl-gen-c.py: render netlink policies static for split ops Date: Wed, 2 Aug 2023 17:20:16 +0200 Message-ID: <20230802152023.941837-5-jiri@resnulli.us> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802152023.941837-1-jiri@resnulli.us> References: <20230802152023.941837-1-jiri@resnulli.us> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Jiri Pirko When policies are rendered for split ops, they are consumed in the same file. No need to expose them for user outside, make them static. Signed-off-by: Jiri Pirko --- v1->v2: - new patch --- tools/net/ynl/ynl-gen-c.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py index 34ee7b8e3f71..d0753cb39901 100755 --- a/tools/net/ynl/ynl-gen-c.py +++ b/tools/net/ynl/ynl-gen-c.py @@ -1843,13 +1843,13 @@ def print_ntf_type_free(ri): def print_req_policy_fwd(cw, struct, ri=None, terminate=True): - if terminate and ri and kernel_can_gen_family_struct(struct.family): + if terminate and ri and policy_should_be_static(struct.family): return if terminate: prefix = 'extern ' else: - if kernel_can_gen_family_struct(struct.family) and ri: + if ri and policy_should_be_static(struct.family): prefix = 'static ' else: prefix = '' @@ -1877,6 +1877,10 @@ def kernel_can_gen_family_struct(family): return family.proto == 'genetlink' +def policy_should_be_static(family): + return family.kernel_policy == 'split' or kernel_can_gen_family_struct(family) + + def print_kernel_op_table_fwd(family, cw, terminate): exported = not kernel_can_gen_family_struct(family) From patchwork Wed Aug 2 15:20:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 13338390 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 194C9D514 for ; Wed, 2 Aug 2023 15:21:21 +0000 (UTC) Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4DAF4EDE for ; Wed, 2 Aug 2023 08:20:54 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-3fe2d218eedso14723575e9.0 for ; Wed, 02 Aug 2023 08:20:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20221208.gappssmtp.com; s=20221208; t=1690989634; x=1691594434; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=z0V95E+E9v5A3LYct/pBl2OmVmab1G7YRAMVTHMnX1c=; b=OKecDwoNWfTWNqGZpWcOBBH7F2W0mJ5Iei0oNHcsoBLGDgtzPtHUIcJqY3dhZJqyxn vqwdU3cF4Wr9Qnr573YPdSs+Xz2e37bjKBY4MudvOsmA/wikmtiYmMjrkcfycNvB/4Cz MT9aBzswGKO2V1yGrWAzpoacZyZc3ZuXF61joQiGMlgi6Getqqe9ci3g/ZsHG+ioAdm4 K6LUL6X8yziNV8rB+9XPi6T+/dCDHhSEtBHUbnnC+VDMSR+vK2eJU1oV19YK0Xeb36AR a1fAohjL033mhKSI/u1GD5WlWtGD8yL2Lj3eH4ctQ+JiUnqodbMGEhZ+afKDjFFq6ptf YxWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690989634; x=1691594434; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=z0V95E+E9v5A3LYct/pBl2OmVmab1G7YRAMVTHMnX1c=; b=D5Lp2Gc8y+j4YmmnOzZVlJMKN2HthE2larfMYqAKhLvFvOtjEsLjisgqbDkYXCz5Cc ljqVK8uo0WNSDIRIWBjRKpNEZ7Q0X3z3X/Bdk7M50sTDyJRVLqkyWsb5w+Jqk9/g8dyP UAR9QTjsykWP/PrZIJiBMu3Xn7NArbsIVEwk/hv0ArWmd2LKxKwT1BmtBauZ5rQvtMvi 7EkoLi3ujCISRQVXfFo3yuuw/g8ZSlFrDKavF32aC8uCgnW0fIxZUnBuwa5Uc6xR4Zl9 AxDwatuvLcL3q/CE2MssFjp3pfWVhbAH3HcZXaVaWfE5FZCPdsIjmhTUHzt/0FH/bSQd FsTA== X-Gm-Message-State: ABy/qLb2r7vVpkLsNx5s4seSjDw+cI7pitPGFRoP6hc75MA+EP/9ETJJ ItZ3AyAMaiWCV1MYxXOfaDI7s76qzvdR7utaZ4q07A== X-Google-Smtp-Source: APBJJlGjN06Slmc0PRLrf23JzhdT/hc72QHo3LNnKqCFuTBqDjTxYKU/BTPOFY4RGw9XeGwzIDN8sg== X-Received: by 2002:adf:fe51:0:b0:317:5f04:c3de with SMTP id m17-20020adffe51000000b003175f04c3demr5356255wrs.4.1690989634130; Wed, 02 Aug 2023 08:20:34 -0700 (PDT) Received: from localhost ([212.23.236.67]) by smtp.gmail.com with ESMTPSA id p15-20020a056000018f00b0030ae53550f5sm19211086wrx.51.2023.08.02.08.20.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 08:20:33 -0700 (PDT) From: Jiri Pirko To: netdev@vger.kernel.org Cc: kuba@kernel.org, pabeni@redhat.com, davem@davemloft.net, edumazet@google.com, moshe@nvidia.com, saeedm@nvidia.com, idosch@nvidia.com, petrm@nvidia.com Subject: [patch net-next v2 05/11] devlink: rename devlink_nl_ops to devlink_nl_small_ops Date: Wed, 2 Aug 2023 17:20:17 +0200 Message-ID: <20230802152023.941837-6-jiri@resnulli.us> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802152023.941837-1-jiri@resnulli.us> References: <20230802152023.941837-1-jiri@resnulli.us> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Jiri Pirko In order to avoid name collision with the generated split ops array which is going to be introduced as a follow-up patch, rename the existing ops array to devlink_nl_small_ops. Signed-off-by: Jiri Pirko --- net/devlink/devl_internal.h | 2 +- net/devlink/leftover.c | 2 +- net/devlink/netlink.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/net/devlink/devl_internal.h b/net/devlink/devl_internal.h index 62921b2eb0d3..c67f074641d4 100644 --- a/net/devlink/devl_internal.h +++ b/net/devlink/devl_internal.h @@ -119,7 +119,7 @@ struct devlink_cmd { struct netlink_callback *cb); }; -extern const struct genl_small_ops devlink_nl_ops[56]; +extern const struct genl_small_ops devlink_nl_small_ops[56]; struct devlink * devlink_get_from_attrs_lock(struct net *net, struct nlattr **attrs); diff --git a/net/devlink/leftover.c b/net/devlink/leftover.c index 5128b9c7eea8..8f42f1f45705 100644 --- a/net/devlink/leftover.c +++ b/net/devlink/leftover.c @@ -6278,7 +6278,7 @@ static int devlink_nl_cmd_trap_policer_set_doit(struct sk_buff *skb, return devlink_trap_policer_set(devlink, policer_item, info); } -const struct genl_small_ops devlink_nl_ops[56] = { +const struct genl_small_ops devlink_nl_small_ops[56] = { { .cmd = DEVLINK_CMD_GET, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, diff --git a/net/devlink/netlink.c b/net/devlink/netlink.c index 7a332eb70f70..82a3238d5344 100644 --- a/net/devlink/netlink.c +++ b/net/devlink/netlink.c @@ -243,8 +243,8 @@ struct genl_family devlink_nl_family __ro_after_init = { .pre_doit = devlink_nl_pre_doit, .post_doit = devlink_nl_post_doit, .module = THIS_MODULE, - .small_ops = devlink_nl_ops, - .n_small_ops = ARRAY_SIZE(devlink_nl_ops), + .small_ops = devlink_nl_small_ops, + .n_small_ops = ARRAY_SIZE(devlink_nl_small_ops), .resv_start_op = DEVLINK_CMD_SELFTESTS_RUN + 1, .mcgrps = devlink_nl_mcgrps, .n_mcgrps = ARRAY_SIZE(devlink_nl_mcgrps), From patchwork Wed Aug 2 15:20:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 13338391 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C580DD514 for ; Wed, 2 Aug 2023 15:21:21 +0000 (UTC) Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 619454EE3 for ; Wed, 2 Aug 2023 08:20:55 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id ffacd0b85a97d-3175d5ca8dbso6180335f8f.2 for ; Wed, 02 Aug 2023 08:20:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20221208.gappssmtp.com; s=20221208; t=1690989635; x=1691594435; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JjXfH+A0B1Bx2EXBFqrsTnqeGAmKJdYOCJ870ddFWlM=; b=OJyCO89dG/jp45Eq1pxH6DcPys4ZnVsuIKAU3XnjshBMgBa3rN2EjukAfrOqrGAmMr cZ522drGTmp+qx6DHgb58ER/vfVjLP0wNQCeSjdTMatq9Iy9LU5sw9/cuuP8jQ+Z9VOB tE0oPyNJ6foMZxkD2bCejdNhjQBnU1rwYeOLFxYNaFsCig+N1oUfkG+Zu0SR9pV1T7h2 6sVJDBzAWRfuIM9FTFVbzpU13ONd8ProlnbQOujV5Z3eT5WuWDLOPMyK3Cyzu0rkqSZZ 7PlClFW1lg7rcT9f/oPyrcAIdTm5UEQArdN5j3WKrKF/8MAARyyp9giP7RvBGzetLwO4 FOPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690989635; x=1691594435; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JjXfH+A0B1Bx2EXBFqrsTnqeGAmKJdYOCJ870ddFWlM=; b=OO/uk5H/44K7Ch+FkKnWUTQ8XticyUu4VhrUvqtP4hcUT95bjuxIEj0K3bIYsHsaIv XXV3DCsESE558kSm4Tetv9vo765KSwM4vIxm6FXgmGF6KoIOJ2wtB/0t7N3jBneyfa8N BKbZGMFCTG6TIChUAtgD+wDHDdVRQZi4zWqKZxRmZ7lxLo36Xo+5CxIwXIeD3sQ+v3km AlYlmAx7kkuITMB6cvLJRdgp09xveB+znbqj7GJOLq0wl3Iw/Z2E8dEiBkWoUI6TGaxe org7HshXBasd6DPrRSo10KRrCQtl8Ut/hJKukcdOSGj9tAqtqdsMu/v2bFZx19OXcOdH eXQw== X-Gm-Message-State: ABy/qLb1fmu2/qZZyg/WiKCOwcdtcJFeZWpWgR2PD2rnhKVS6Ew5hZZj UYaIYBHuGtVT4hY8GC7N0UBRnnqyJkoCkFETHPbLrGCX X-Google-Smtp-Source: APBJJlFJnopw3C35I/Oe/BrmU97jjNMYQZ4vUNvyDbSnsmaYAjxs/0v7Xmqqw/DUzm8a/D93Ygr/gw== X-Received: by 2002:adf:f44c:0:b0:317:3f64:4901 with SMTP id f12-20020adff44c000000b003173f644901mr4922330wrp.41.1690989635711; Wed, 02 Aug 2023 08:20:35 -0700 (PDT) Received: from localhost ([212.23.236.67]) by smtp.gmail.com with ESMTPSA id z17-20020adfec91000000b003179d7ed4f3sm11017711wrn.12.2023.08.02.08.20.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 08:20:35 -0700 (PDT) From: Jiri Pirko To: netdev@vger.kernel.org Cc: kuba@kernel.org, pabeni@redhat.com, davem@davemloft.net, edumazet@google.com, moshe@nvidia.com, saeedm@nvidia.com, idosch@nvidia.com, petrm@nvidia.com Subject: [patch net-next v2 06/11] netlink: specs: devlink: add info-get dump op Date: Wed, 2 Aug 2023 17:20:18 +0200 Message-ID: <20230802152023.941837-7-jiri@resnulli.us> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802152023.941837-1-jiri@resnulli.us> References: <20230802152023.941837-1-jiri@resnulli.us> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Jiri Pirko Add missing dump op for info-get command and re-generate related devlink-user.[ch] code. Signed-off-by: Jiri Pirko --- v1->v2: - new patch, spec split from the next one, adding forgotten changes in devlink-user.[ch] code --- Documentation/netlink/specs/devlink.yaml | 4 +- tools/net/ynl/generated/devlink-user.c | 53 ++++++++++++++++++++++++ tools/net/ynl/generated/devlink-user.h | 10 +++++ 3 files changed, 66 insertions(+), 1 deletion(-) diff --git a/Documentation/netlink/specs/devlink.yaml b/Documentation/netlink/specs/devlink.yaml index 5d46ca966979..12699b7ce292 100644 --- a/Documentation/netlink/specs/devlink.yaml +++ b/Documentation/netlink/specs/devlink.yaml @@ -194,7 +194,7 @@ operations: request: value: 51 attributes: *dev-id-attrs - reply: + reply: &info-get-reply value: 51 attributes: - bus-name @@ -204,3 +204,5 @@ operations: - info-version-fixed - info-version-running - info-version-stored + dump: + reply: *info-get-reply diff --git a/tools/net/ynl/generated/devlink-user.c b/tools/net/ynl/generated/devlink-user.c index 939bd45feaca..8492789433b9 100644 --- a/tools/net/ynl/generated/devlink-user.c +++ b/tools/net/ynl/generated/devlink-user.c @@ -716,6 +716,59 @@ devlink_info_get(struct ynl_sock *ys, struct devlink_info_get_req *req) return NULL; } +/* DEVLINK_CMD_INFO_GET - dump */ +void devlink_info_get_list_free(struct devlink_info_get_list *rsp) +{ + struct devlink_info_get_list *next = rsp; + + while ((void *)next != YNL_LIST_END) { + unsigned int i; + + rsp = next; + next = rsp->next; + + free(rsp->obj.bus_name); + free(rsp->obj.dev_name); + free(rsp->obj.info_driver_name); + free(rsp->obj.info_serial_number); + for (i = 0; i < rsp->obj.n_info_version_fixed; i++) + devlink_dl_info_version_free(&rsp->obj.info_version_fixed[i]); + free(rsp->obj.info_version_fixed); + for (i = 0; i < rsp->obj.n_info_version_running; i++) + devlink_dl_info_version_free(&rsp->obj.info_version_running[i]); + free(rsp->obj.info_version_running); + for (i = 0; i < rsp->obj.n_info_version_stored; i++) + devlink_dl_info_version_free(&rsp->obj.info_version_stored[i]); + free(rsp->obj.info_version_stored); + free(rsp); + } +} + +struct devlink_info_get_list *devlink_info_get_dump(struct ynl_sock *ys) +{ + struct ynl_dump_state yds = {}; + struct nlmsghdr *nlh; + int err; + + yds.ys = ys; + yds.alloc_sz = sizeof(struct devlink_info_get_list); + yds.cb = devlink_info_get_rsp_parse; + yds.rsp_cmd = DEVLINK_CMD_INFO_GET; + yds.rsp_policy = &devlink_nest; + + nlh = ynl_gemsg_start_dump(ys, ys->family_id, DEVLINK_CMD_INFO_GET, 1); + + err = ynl_exec_dump(ys, nlh, &yds); + if (err < 0) + goto free_list; + + return yds.first; + +free_list: + devlink_info_get_list_free(yds.first); + return NULL; +} + const struct ynl_family ynl_devlink_family = { .name = "devlink", }; diff --git a/tools/net/ynl/generated/devlink-user.h b/tools/net/ynl/generated/devlink-user.h index a008b99b6e24..af65e2f2f529 100644 --- a/tools/net/ynl/generated/devlink-user.h +++ b/tools/net/ynl/generated/devlink-user.h @@ -207,4 +207,14 @@ void devlink_info_get_rsp_free(struct devlink_info_get_rsp *rsp); struct devlink_info_get_rsp * devlink_info_get(struct ynl_sock *ys, struct devlink_info_get_req *req); +/* DEVLINK_CMD_INFO_GET - dump */ +struct devlink_info_get_list { + struct devlink_info_get_list *next; + struct devlink_info_get_rsp obj __attribute__ ((aligned (8))); +}; + +void devlink_info_get_list_free(struct devlink_info_get_list *rsp); + +struct devlink_info_get_list *devlink_info_get_dump(struct ynl_sock *ys); + #endif /* _LINUX_DEVLINK_GEN_H */ From patchwork Wed Aug 2 15:20:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 13338392 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 36D7FD527 for ; Wed, 2 Aug 2023 15:21:23 +0000 (UTC) Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13E7A4EE7 for ; Wed, 2 Aug 2023 08:20:55 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-3fe2bc2702cso16626395e9.1 for ; Wed, 02 Aug 2023 08:20:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20221208.gappssmtp.com; s=20221208; t=1690989637; x=1691594437; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SObDBYoFomzzFPqCkfSUruqmSzpgvk3HNcTMlAHGFyM=; b=KuQz4A93OEex6sM+NiAtOJFDKhEGnB4QFjTeQ4JY30EP9XfsgbO02IGcBe3v8dmtz6 lWtGaQsgUFKeixtQG7+oCxSOh7OfdKCtz4U9e9hvRKD4zDYjQQ/nvOsgaKQJzRB2f02Z ULqLX3Du6XGyCEsbYhSlA4nzUhm7BpH3YyAyMwRHqIQnPUM3r+EjJ3O09Rj0er/s3Xkp jDQiXYMP8uskWLYUJppXYWb613SdSEiT97FwD7BqcHcvW9yhcvWPqwuZzQgxJVODX0R+ wg4PZPMDXwBZ1jatqVOKOdbkpP3s6ZILblpWDB+B5aj8H3jz0B/rD3/GcxGxMSjp/HsP mL7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690989637; x=1691594437; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SObDBYoFomzzFPqCkfSUruqmSzpgvk3HNcTMlAHGFyM=; b=SeAJnf90X+U2ZzTVhNIwg/bBK6lR/4TAyh6JQhS4AM77etq3iCxLWqAXkM+w09hDU/ E9MaJ6jcSGucQECRoZyyQtb4hyZ6V9FnP484CWq5ZQOLXaXs0c9Pp3q7NlpxciNdEUDz 5E29ixxExsUQn49hp4IZXadYonJGDNKfBV7VgoMYJTF8k6CBnddoly3OBVoG3xdjwvpf tf/BoXnBDYVFxsRWvW/9xs58CEeHzsWOxPK2o4lXEveIk0QelaGV9HfxUPcHd6XCyfIh ZM7CPKF3omlH+3+4yoLMr6Vp0BrRRfbSf3kOrVl1WMzoORLvY8P49qGvC4yT5QNIfHh8 ZZCw== X-Gm-Message-State: ABy/qLbSehBCk9o6NKa5clwD9OcznejMlX/P2tlZddANjPYYIRDT15f1 TOJ62IY9TclJM1b8/x3S35d8chdGqt8FC308mQOQDg== X-Google-Smtp-Source: APBJJlFlNAxoAwn/VVMy85QJQwMmYqCn0x5B/7Gcm/Anjmix8XJ2Ikv0NKVfT3iiqO7YkMgJ6GwFlQ== X-Received: by 2002:a1c:f211:0:b0:3f4:d18f:b2fb with SMTP id s17-20020a1cf211000000b003f4d18fb2fbmr5374093wmc.8.1690989637224; Wed, 02 Aug 2023 08:20:37 -0700 (PDT) Received: from localhost ([212.23.236.67]) by smtp.gmail.com with ESMTPSA id t22-20020a7bc3d6000000b003fe1ddd6ac0sm1963792wmj.35.2023.08.02.08.20.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 08:20:36 -0700 (PDT) From: Jiri Pirko To: netdev@vger.kernel.org Cc: kuba@kernel.org, pabeni@redhat.com, davem@davemloft.net, edumazet@google.com, moshe@nvidia.com, saeedm@nvidia.com, idosch@nvidia.com, petrm@nvidia.com Subject: [patch net-next v2 07/11] devlink: add split ops generated according to spec Date: Wed, 2 Aug 2023 17:20:19 +0200 Message-ID: <20230802152023.941837-8-jiri@resnulli.us> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802152023.941837-1-jiri@resnulli.us> References: <20230802152023.941837-1-jiri@resnulli.us> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Jiri Pirko Improve the existing devlink spec in order to serve as a source for generation of valid devlink split ops for the existing commands. Add the generated sources. Node that the policies are narrowed down only to the attributes that are actually parsed. The dont-validate-strict parsing policy makes sure that other possibly passed garbage attributes from userspace are ignored during validation. Signed-off-by: Jiri Pirko --- v1->v2: - fixed "for" typo - added note to patch description about narrowing down the policy - moved info-get dump op addition to a separate patch - regenerated files according to static policies change --- Documentation/netlink/specs/devlink.yaml | 10 ++++ net/devlink/Makefile | 2 +- net/devlink/netlink_gen.c | 59 ++++++++++++++++++++++++ net/devlink/netlink_gen.h | 29 ++++++++++++ 4 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 net/devlink/netlink_gen.c create mode 100644 net/devlink/netlink_gen.h diff --git a/Documentation/netlink/specs/devlink.yaml b/Documentation/netlink/specs/devlink.yaml index 12699b7ce292..f6df0b3fd502 100644 --- a/Documentation/netlink/specs/devlink.yaml +++ b/Documentation/netlink/specs/devlink.yaml @@ -165,8 +165,13 @@ operations: name: get doc: Get devlink instances. attribute-set: devlink + dont-validate: + - strict + - dump do: + pre: devlink-nl-pre-doit + post: devlink-nl-post-doit request: value: 1 attributes: &dev-id-attrs @@ -189,8 +194,13 @@ operations: name: info-get doc: Get device information, like driver name, hardware and firmware versions etc. attribute-set: devlink + dont-validate: + - strict + - dump do: + pre: devlink-nl-pre-doit + post: devlink-nl-post-doit request: value: 51 attributes: *dev-id-attrs diff --git a/net/devlink/Makefile b/net/devlink/Makefile index ef91a76646a3..a087af581847 100644 --- a/net/devlink/Makefile +++ b/net/devlink/Makefile @@ -1,3 +1,3 @@ # SPDX-License-Identifier: GPL-2.0 -obj-y := leftover.o core.o netlink.o dev.o health.o +obj-y := leftover.o core.o netlink.o netlink_gen.o dev.o health.o diff --git a/net/devlink/netlink_gen.c b/net/devlink/netlink_gen.c new file mode 100644 index 000000000000..32d8cbed0c30 --- /dev/null +++ b/net/devlink/netlink_gen.c @@ -0,0 +1,59 @@ +// SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) +/* Do not edit directly, auto-generated from: */ +/* Documentation/netlink/specs/devlink.yaml */ +/* YNL-GEN kernel source */ + +#include +#include + +#include "netlink_gen.h" + +#include + +/* DEVLINK_CMD_GET - do */ +static const struct nla_policy devlink_get_nl_policy[DEVLINK_ATTR_DEV_NAME + 1] = { + [DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, }, + [DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, }, +}; + +/* DEVLINK_CMD_INFO_GET - do */ +static const struct nla_policy devlink_info_get_nl_policy[DEVLINK_ATTR_DEV_NAME + 1] = { + [DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, }, + [DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, }, +}; + +/* Ops table for devlink */ +const struct genl_split_ops devlink_nl_ops[4] = { + { + .cmd = DEVLINK_CMD_GET, + .validate = GENL_DONT_VALIDATE_STRICT, + .pre_doit = devlink_nl_pre_doit, + .doit = devlink_nl_get_doit, + .post_doit = devlink_nl_post_doit, + .policy = devlink_get_nl_policy, + .maxattr = DEVLINK_ATTR_DEV_NAME, + .flags = GENL_CMD_CAP_DO, + }, + { + .cmd = DEVLINK_CMD_GET, + .validate = GENL_DONT_VALIDATE_DUMP, + .dumpit = devlink_nl_get_dumpit, + .flags = GENL_CMD_CAP_DUMP, + }, + { + .cmd = DEVLINK_CMD_INFO_GET, + .validate = GENL_DONT_VALIDATE_STRICT, + .pre_doit = devlink_nl_pre_doit, + .doit = devlink_nl_info_get_doit, + .post_doit = devlink_nl_post_doit, + .policy = devlink_info_get_nl_policy, + .maxattr = DEVLINK_ATTR_DEV_NAME, + .flags = GENL_CMD_CAP_DO, + }, + { + .cmd = DEVLINK_CMD_INFO_GET, + .validate = GENL_DONT_VALIDATE_DUMP, + .dumpit = devlink_nl_info_get_dumpit, + .flags = GENL_CMD_CAP_DUMP, + }, +}; diff --git a/net/devlink/netlink_gen.h b/net/devlink/netlink_gen.h new file mode 100644 index 000000000000..11980e04a718 --- /dev/null +++ b/net/devlink/netlink_gen.h @@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ +/* Do not edit directly, auto-generated from: */ +/* Documentation/netlink/specs/devlink.yaml */ +/* YNL-GEN kernel header */ + +#ifndef _LINUX_DEVLINK_GEN_H +#define _LINUX_DEVLINK_GEN_H + +#include +#include + +#include + +/* Ops table for devlink */ +extern const struct genl_split_ops devlink_nl_ops[4]; + +int devlink_nl_pre_doit(const struct genl_split_ops *ops, struct sk_buff *skb, + struct genl_info *info); +void +devlink_nl_post_doit(const struct genl_split_ops *ops, struct sk_buff *skb, + struct genl_info *info); + +int devlink_nl_get_doit(struct sk_buff *skb, struct genl_info *info); +int devlink_nl_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb); +int devlink_nl_info_get_doit(struct sk_buff *skb, struct genl_info *info); +int devlink_nl_info_get_dumpit(struct sk_buff *skb, + struct netlink_callback *cb); + +#endif /* _LINUX_DEVLINK_GEN_H */ From patchwork Wed Aug 2 15:20:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 13338393 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 253138C15 for ; Wed, 2 Aug 2023 15:21:26 +0000 (UTC) Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 441994EF6 for ; Wed, 2 Aug 2023 08:20:58 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-317715ec496so7112427f8f.3 for ; Wed, 02 Aug 2023 08:20:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20221208.gappssmtp.com; s=20221208; t=1690989639; x=1691594439; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ijBgMWxuFtml0C6g7UT+aYSZs/zH2hddHHLPUS4ODZ4=; b=W7sQX946qKJ5oJGFudzxQ+yK0f/Y9W6x4kLCaZlSIEo7gtFrHptxKbsmfN6qcFO2Au uzjyCiLDjrItORt1+ek8ERxKCb6YAMPmbTaTVHPygPHCEWXLeIFhz6xSEKViH28KD/Fe VnV3XGV4p2Qy4OldqpmMU4Ij0pfduImbx2qgrtblcucfYaQsRuH5onBlE4BD/9S26KLw 3G1eaJU3+K+m3MMK616VGA5EIqu8YFPrCdljpmAWIzIE6mJYT1PVUShtaHiWd1Ss53dA hUOwWqcoPQFCxmOv1fkbDYWxct1fRb/W/8KUR4fLQgpRO6zq1ZvrTlIBD1l9YX3aC3ad LtaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690989639; x=1691594439; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ijBgMWxuFtml0C6g7UT+aYSZs/zH2hddHHLPUS4ODZ4=; b=FbZzynv4I2ZH25KKzdVSc3+xu2IG9k2/xAfwtEsWFB5y+rbRvqBf19zSNkwNbpBu/1 o0nRKQkFkZI5zpcBd/DQgf1cOEVxf991QLRxd3nhclW69h7iXS3fbcQYBpvrwNFaPnYI HCSMA3Z4kDn3d2HzaxJziB+cguBqSATbYUR1byn63BXv/KjOBQ50PuHrxVbiHpGysMO6 gU2k7ztNbP6EPYFOKQ/uY5LC3b8khVHiOXHz75uV/4jKGJlatrFq323ZjFuZ5kpoX+pa H5hIsfd6HK6eSbhp0R0A2rrvfbmmx+UT/wNFTlnLmzSSjeh0b5iHd7vEEYef5pannWh1 DsRg== X-Gm-Message-State: ABy/qLYkAh/G0KhOtcZQVMmuEaUQy8e/CIq9OZgE1ovs6wb8oH7Pc4hq nXP6bkgy11OHn3D/DDdY7P7xD1NQCZillNBmiM4VBg== X-Google-Smtp-Source: APBJJlHtu8oigFNHu7V1TRKvwy12DBYEtNcg9iqq29h3hJzslQq6Ptdapx7q2G3f2PyevAwIJGD99A== X-Received: by 2002:a5d:484d:0:b0:317:55de:d8 with SMTP id n13-20020a5d484d000000b0031755de00d8mr5081499wrs.14.1690989639025; Wed, 02 Aug 2023 08:20:39 -0700 (PDT) Received: from localhost ([212.23.236.67]) by smtp.gmail.com with ESMTPSA id f3-20020a5d50c3000000b00317909f9985sm14858917wrt.113.2023.08.02.08.20.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 08:20:38 -0700 (PDT) From: Jiri Pirko To: netdev@vger.kernel.org Cc: kuba@kernel.org, pabeni@redhat.com, davem@davemloft.net, edumazet@google.com, moshe@nvidia.com, saeedm@nvidia.com, idosch@nvidia.com, petrm@nvidia.com Subject: [patch net-next v2 08/11] devlink: include the generated netlink header Date: Wed, 2 Aug 2023 17:20:20 +0200 Message-ID: <20230802152023.941837-9-jiri@resnulli.us> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802152023.941837-1-jiri@resnulli.us> References: <20230802152023.941837-1-jiri@resnulli.us> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Jiri Pirko Put the newly added generated header to the include list. Un-static the pre-doit and post-doit functions as they are used in the generated files. Signed-off-by: Jiri Pirko --- net/devlink/devl_internal.h | 2 ++ net/devlink/netlink.c | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/net/devlink/devl_internal.h b/net/devlink/devl_internal.h index c67f074641d4..f5ad66d5773c 100644 --- a/net/devlink/devl_internal.h +++ b/net/devlink/devl_internal.h @@ -12,6 +12,8 @@ #include #include +#include "netlink_gen.h" + #define DEVLINK_REGISTERED XA_MARK_1 #define DEVLINK_RELOAD_STATS_ARRAY_SIZE \ diff --git a/net/devlink/netlink.c b/net/devlink/netlink.c index 82a3238d5344..39e07a5a69af 100644 --- a/net/devlink/netlink.c +++ b/net/devlink/netlink.c @@ -109,8 +109,8 @@ devlink_get_from_attrs_lock(struct net *net, struct nlattr **attrs) return ERR_PTR(-ENODEV); } -static int devlink_nl_pre_doit(const struct genl_split_ops *ops, - struct sk_buff *skb, struct genl_info *info) +int devlink_nl_pre_doit(const struct genl_split_ops *ops, + struct sk_buff *skb, struct genl_info *info) { struct devlink_linecard *linecard; struct devlink_port *devlink_port; @@ -167,8 +167,8 @@ static int devlink_nl_pre_doit(const struct genl_split_ops *ops, return err; } -static void devlink_nl_post_doit(const struct genl_split_ops *ops, - struct sk_buff *skb, struct genl_info *info) +void devlink_nl_post_doit(const struct genl_split_ops *ops, + struct sk_buff *skb, struct genl_info *info) { struct devlink *devlink; From patchwork Wed Aug 2 15:20:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 13338394 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 03203DF4C for ; Wed, 2 Aug 2023 15:21:27 +0000 (UTC) Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C81024EFD for ; Wed, 2 Aug 2023 08:20:58 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-3177f520802so709607f8f.1 for ; Wed, 02 Aug 2023 08:20:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20221208.gappssmtp.com; s=20221208; t=1690989641; x=1691594441; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6aG2vhvT3L7ndx5Y3qElr7N1jus2m24HM/CUdo9QK2c=; b=smqkfGP7Pxz0yjF+bxDknWR5pRm9BESMeXK+Qz9iuVQKdoxWRpgIXALhn3Ojw3nndh 8vvnj7ZU1ecvqVciWkLF5gJUhpk3QGOnqiLrDLjBZFbadnn4UU0uqDv02XAjlxdNbvOx U524HOjvZwyxmy31y3TWrqU0J/TEezNXx7NslPvIAuPwQOkWxGZOXyACYaEvbOVgSNFC sls20X6Gjtgar7Ukix2mLFiqsSSXIkkxtY/AKobfIE2YOumXXOH0QkLGg6F3mrjiN57+ d6zNaQZ4VNd4uUmIcDw7aMU+nt2hRUaQy416lrjMTt73ZKi0W0DHoYH1oUQzZFN0kLpe E6SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690989641; x=1691594441; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6aG2vhvT3L7ndx5Y3qElr7N1jus2m24HM/CUdo9QK2c=; b=UgOXvodZ9a1zYMZ49gZV6ILNsRu+xAUsZx9Sl/zG2uBwujrwS+xJjCg9mnApQywqlO JBsEWpVb4y6BX/93BlTu/mH4oFp8OTX7DIUVpH8SjVCijd+2phd0TREnhpxKF+VMk79x Bql3mq5JmcoWOTq9/j4Ql6tp6R3ODldL8FIk4P38YXUEpP77cNL8LrGhTsd6FYYhGzGz R/5xuqod9bgE2/BMYYQ9Imb7msEUFz9SUvPiwctszOvC/frEf+5NVdYrIxVuxQD4bvYr VRjyUoy/hxIIePEGnThYXgOgJB+M0BFaAgVhCCQnYZmvC3kPmGC35eKzIKcIGIKRb8YJ hYYQ== X-Gm-Message-State: ABy/qLaUgxAuHFHgtXANTDGttDrrqe4itjPMPoTpQwlVc5efhjySlqfk AA39Dgx5xuDAUT2HqBavvLyeMg1q2mdirykHe1M7fQ== X-Google-Smtp-Source: APBJJlFHz0TyLR18anVrsH0huKv+DLXJ3b5uXdmxVAwayL8vWc7KhdMWDmAKqAhjL+nCtnO4HIOYHQ== X-Received: by 2002:a5d:65cc:0:b0:314:3c72:d1ba with SMTP id e12-20020a5d65cc000000b003143c72d1bamr5248711wrw.20.1690989640855; Wed, 02 Aug 2023 08:20:40 -0700 (PDT) Received: from localhost ([212.23.236.67]) by smtp.gmail.com with ESMTPSA id s21-20020a7bc395000000b003fe2ebf479fsm1881830wmj.36.2023.08.02.08.20.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 08:20:40 -0700 (PDT) From: Jiri Pirko To: netdev@vger.kernel.org Cc: kuba@kernel.org, pabeni@redhat.com, davem@davemloft.net, edumazet@google.com, moshe@nvidia.com, saeedm@nvidia.com, idosch@nvidia.com, petrm@nvidia.com Subject: [patch net-next v2 09/11] devlink: rename couple of doit netlink callbacks to match generated names Date: Wed, 2 Aug 2023 17:20:21 +0200 Message-ID: <20230802152023.941837-10-jiri@resnulli.us> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802152023.941837-1-jiri@resnulli.us> References: <20230802152023.941837-1-jiri@resnulli.us> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Jiri Pirko The generated names of the doit netlink callback are missing "cmd" in their names. Fix the names and remove the original prototypes. Signed-off-by: Jiri Pirko --- net/devlink/dev.c | 4 ++-- net/devlink/devl_internal.h | 2 -- net/devlink/leftover.c | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/net/devlink/dev.c b/net/devlink/dev.c index bf1d6f1bcfc7..2e120b3da220 100644 --- a/net/devlink/dev.c +++ b/net/devlink/dev.c @@ -196,7 +196,7 @@ void devlink_notify(struct devlink *devlink, enum devlink_command cmd) msg, 0, DEVLINK_MCGRP_CONFIG, GFP_KERNEL); } -int devlink_nl_cmd_get_doit(struct sk_buff *skb, struct genl_info *info) +int devlink_nl_get_doit(struct sk_buff *skb, struct genl_info *info) { struct devlink *devlink = info->user_ptr[0]; struct sk_buff *msg; @@ -804,7 +804,7 @@ devlink_nl_info_fill(struct sk_buff *msg, struct devlink *devlink, return err; } -int devlink_nl_cmd_info_get_doit(struct sk_buff *skb, struct genl_info *info) +int devlink_nl_info_get_doit(struct sk_buff *skb, struct genl_info *info) { struct devlink *devlink = info->user_ptr[0]; struct sk_buff *msg; diff --git a/net/devlink/devl_internal.h b/net/devlink/devl_internal.h index f5ad66d5773c..419bc92da503 100644 --- a/net/devlink/devl_internal.h +++ b/net/devlink/devl_internal.h @@ -216,11 +216,9 @@ struct devlink_rate * devlink_rate_node_get_from_info(struct devlink *devlink, struct genl_info *info); /* Devlink nl cmds */ -int devlink_nl_cmd_get_doit(struct sk_buff *skb, struct genl_info *info); int devlink_nl_cmd_reload(struct sk_buff *skb, struct genl_info *info); int devlink_nl_cmd_eswitch_get_doit(struct sk_buff *skb, struct genl_info *info); int devlink_nl_cmd_eswitch_set_doit(struct sk_buff *skb, struct genl_info *info); -int devlink_nl_cmd_info_get_doit(struct sk_buff *skb, struct genl_info *info); int devlink_nl_cmd_flash_update(struct sk_buff *skb, struct genl_info *info); int devlink_nl_cmd_selftests_get_doit(struct sk_buff *skb, struct genl_info *info); int devlink_nl_cmd_selftests_run(struct sk_buff *skb, struct genl_info *info); diff --git a/net/devlink/leftover.c b/net/devlink/leftover.c index 8f42f1f45705..094cd0e8224e 100644 --- a/net/devlink/leftover.c +++ b/net/devlink/leftover.c @@ -6282,7 +6282,7 @@ const struct genl_small_ops devlink_nl_small_ops[56] = { { .cmd = DEVLINK_CMD_GET, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, - .doit = devlink_nl_cmd_get_doit, + .doit = devlink_nl_get_doit, .dumpit = devlink_nl_instance_iter_dumpit, /* can be retrieved by unprivileged users */ }, @@ -6536,7 +6536,7 @@ const struct genl_small_ops devlink_nl_small_ops[56] = { { .cmd = DEVLINK_CMD_INFO_GET, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, - .doit = devlink_nl_cmd_info_get_doit, + .doit = devlink_nl_info_get_doit, .dumpit = devlink_nl_instance_iter_dumpit, /* can be retrieved by unprivileged users */ }, From patchwork Wed Aug 2 15:20:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 13338395 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 87F87DF4C for ; Wed, 2 Aug 2023 15:21:28 +0000 (UTC) Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB3E75242 for ; Wed, 2 Aug 2023 08:21:00 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-3090d3e9c92so7015187f8f.2 for ; Wed, 02 Aug 2023 08:21:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20221208.gappssmtp.com; s=20221208; t=1690989642; x=1691594442; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MIQMFhLT2av1GsEw/YC99xvev1k+/HTSgdU+tCayBxI=; b=kd/a+a4CRwUU8hd5bS3LoHORRtwu/YAsWQ3O7jvoNm9mG/e0bBE3lFXDO+0MEcbCGq qEP1qYT3CNzGCI93FxpvEif4pDTNIPFDMijg0gBvsiGbR1DS5CaN4xKKl+kw66pXgvSe jRl6AtqdsUbli4DvGaddi0iiwVSneyhSi1zD2cpoQdQpNneTO3CXV9QFcr44IG4bK6FX SlcnYGv5vrUjqOtoQu9n9hQs0peI3Be9eN298+RHy//2jKX0gJMjkIk16+pMJdp9CXNi qBetruPJ9aMfbZCB/lg0UHlb8LqysGR8UjE/6I/0KAD6SGeNKShHcLoqnbopvi41GtZr 67sA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690989642; x=1691594442; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MIQMFhLT2av1GsEw/YC99xvev1k+/HTSgdU+tCayBxI=; b=VLWX7zzX6MHJOQs6ULYUkIynhjozHjI0qI8Yr8GEi91Y7htOmExauRBOGEychDKB6y uEomCpUBx+RmrsdlTCq3qR9A1qR+e+Mzrn0QrUHiwdJncrTdK8WmQqK3Mn+lfkYZBj7e UldxG1ziSC2t+MYSy5DAzdhvnf3/iQU25jfPXZC3orUmvkQfqmsAXS4x527415xX+U8k 70HDolv28d0pd0Kb5RO1dZh3dORE9vOF2XboArnn9v+1S8FA+Jt5/7n8WjP8huFxAHv1 v0jNhlJkjwkS0GAvP+TkOp6t+Wf29ThU3VUDwQFrF5QloOgE/8jKGhrWy4kfpsYHW1bS uFiQ== X-Gm-Message-State: ABy/qLZ8tJpzwqTMQ2Da14n6T00fGthcrzXzossb6Bg4DRBrkqwyNZZy 0/QjS+59OvzwPfYC3l9I7mDqvJ0ka8E4pAlbqPt2Tw== X-Google-Smtp-Source: APBJJlETFcMJ5k0TwVxDvXERnkLVs2Lh74XWW8XVcD0yIxtJTBOWKIpLyQWyJtVCMaEpGZ/ShCYXjw== X-Received: by 2002:adf:de12:0:b0:314:748:d59d with SMTP id b18-20020adfde12000000b003140748d59dmr4822224wrm.27.1690989642470; Wed, 02 Aug 2023 08:20:42 -0700 (PDT) Received: from localhost ([212.23.236.67]) by smtp.gmail.com with ESMTPSA id r18-20020adfce92000000b0031272fced4dsm19202288wrn.52.2023.08.02.08.20.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 08:20:41 -0700 (PDT) From: Jiri Pirko To: netdev@vger.kernel.org Cc: kuba@kernel.org, pabeni@redhat.com, davem@davemloft.net, edumazet@google.com, moshe@nvidia.com, saeedm@nvidia.com, idosch@nvidia.com, petrm@nvidia.com Subject: [patch net-next v2 10/11] devlink: introduce couple of dumpit callbacks for split ops Date: Wed, 2 Aug 2023 17:20:22 +0200 Message-ID: <20230802152023.941837-11-jiri@resnulli.us> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802152023.941837-1-jiri@resnulli.us> References: <20230802152023.941837-1-jiri@resnulli.us> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Jiri Pirko Introduce couple of dumpit callbacks for generated split ops. Have them as a thin wrapper around iteration function and allow to pass dump_one() function pointer directly without need to store in devlink_cmd structs. Signed-off-by: Jiri Pirko --- v1->v2: - fixed typo in patch subject --- net/devlink/dev.c | 23 +++++++++++++---------- net/devlink/devl_internal.h | 14 ++++++++------ net/devlink/leftover.c | 4 ++-- net/devlink/netlink.c | 21 ++++++++++++--------- 4 files changed, 35 insertions(+), 27 deletions(-) diff --git a/net/devlink/dev.c b/net/devlink/dev.c index 2e120b3da220..1782157351ed 100644 --- a/net/devlink/dev.c +++ b/net/devlink/dev.c @@ -217,17 +217,19 @@ int devlink_nl_get_doit(struct sk_buff *skb, struct genl_info *info) } static int -devlink_nl_cmd_get_dump_one(struct sk_buff *msg, struct devlink *devlink, - struct netlink_callback *cb) +devlink_nl_get_dump_one(struct sk_buff *msg, struct devlink *devlink, + struct netlink_callback *cb) { return devlink_nl_fill(msg, devlink, DEVLINK_CMD_NEW, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq, NLM_F_MULTI); } -const struct devlink_cmd devl_cmd_get = { - .dump_one = devlink_nl_cmd_get_dump_one, -}; +int devlink_nl_get_dumpit(struct sk_buff *msg, struct netlink_callback *cb) +{ + return devlink_nl_dumpit(msg, cb, devlink_nl_get_dump_one); +} + static void devlink_reload_failed_set(struct devlink *devlink, bool reload_failed) @@ -826,8 +828,8 @@ int devlink_nl_info_get_doit(struct sk_buff *skb, struct genl_info *info) } static int -devlink_nl_cmd_info_get_dump_one(struct sk_buff *msg, struct devlink *devlink, - struct netlink_callback *cb) +devlink_nl_info_get_dump_one(struct sk_buff *msg, struct devlink *devlink, + struct netlink_callback *cb) { int err; @@ -840,9 +842,10 @@ devlink_nl_cmd_info_get_dump_one(struct sk_buff *msg, struct devlink *devlink, return err; } -const struct devlink_cmd devl_cmd_info_get = { - .dump_one = devlink_nl_cmd_info_get_dump_one, -}; +int devlink_nl_info_get_dumpit(struct sk_buff *msg, struct netlink_callback *cb) +{ + return devlink_nl_dumpit(msg, cb, devlink_nl_info_get_dump_one); +} static int devlink_nl_flash_update_fill(struct sk_buff *msg, struct devlink *devlink, diff --git a/net/devlink/devl_internal.h b/net/devlink/devl_internal.h index 419bc92da503..51de0e1fc769 100644 --- a/net/devlink/devl_internal.h +++ b/net/devlink/devl_internal.h @@ -116,9 +116,12 @@ struct devlink_nl_dump_state { }; }; +typedef int devlink_nl_dump_one_func_t(struct sk_buff *msg, + struct devlink *devlink, + struct netlink_callback *cb); + struct devlink_cmd { - int (*dump_one)(struct sk_buff *msg, struct devlink *devlink, - struct netlink_callback *cb); + devlink_nl_dump_one_func_t *dump_one; }; extern const struct genl_small_ops devlink_nl_small_ops[56]; @@ -129,8 +132,9 @@ devlink_get_from_attrs_lock(struct net *net, struct nlattr **attrs); void devlink_notify_unregister(struct devlink *devlink); void devlink_notify_register(struct devlink *devlink); -int devlink_nl_instance_iter_dumpit(struct sk_buff *msg, - struct netlink_callback *cb); +int devlink_nl_dumpit(struct sk_buff *msg, struct netlink_callback *cb, + devlink_nl_dump_one_func_t *dump_one); +int devlink_nl_instance_iter_dumpit(struct sk_buff *msg, struct netlink_callback *cb); static inline struct devlink_nl_dump_state * devlink_dump_state(struct netlink_callback *cb) @@ -151,7 +155,6 @@ devlink_nl_put_handle(struct sk_buff *msg, struct devlink *devlink) } /* Commands */ -extern const struct devlink_cmd devl_cmd_get; extern const struct devlink_cmd devl_cmd_port_get; extern const struct devlink_cmd devl_cmd_sb_get; extern const struct devlink_cmd devl_cmd_sb_pool_get; @@ -159,7 +162,6 @@ extern const struct devlink_cmd devl_cmd_sb_port_pool_get; extern const struct devlink_cmd devl_cmd_sb_tc_pool_bind_get; extern const struct devlink_cmd devl_cmd_param_get; extern const struct devlink_cmd devl_cmd_region_get; -extern const struct devlink_cmd devl_cmd_info_get; extern const struct devlink_cmd devl_cmd_health_reporter_get; extern const struct devlink_cmd devl_cmd_trap_get; extern const struct devlink_cmd devl_cmd_trap_group_get; diff --git a/net/devlink/leftover.c b/net/devlink/leftover.c index 094cd0e8224e..895b732bed8e 100644 --- a/net/devlink/leftover.c +++ b/net/devlink/leftover.c @@ -6283,7 +6283,7 @@ const struct genl_small_ops devlink_nl_small_ops[56] = { .cmd = DEVLINK_CMD_GET, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .doit = devlink_nl_get_doit, - .dumpit = devlink_nl_instance_iter_dumpit, + .dumpit = devlink_nl_get_dumpit, /* can be retrieved by unprivileged users */ }, { @@ -6537,7 +6537,7 @@ const struct genl_small_ops devlink_nl_small_ops[56] = { .cmd = DEVLINK_CMD_INFO_GET, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .doit = devlink_nl_info_get_doit, - .dumpit = devlink_nl_instance_iter_dumpit, + .dumpit = devlink_nl_info_get_dumpit, /* can be retrieved by unprivileged users */ }, { diff --git a/net/devlink/netlink.c b/net/devlink/netlink.c index 39e07a5a69af..98d5c6b0acd8 100644 --- a/net/devlink/netlink.c +++ b/net/devlink/netlink.c @@ -178,7 +178,6 @@ void devlink_nl_post_doit(const struct genl_split_ops *ops, } static const struct devlink_cmd *devl_cmds[] = { - [DEVLINK_CMD_GET] = &devl_cmd_get, [DEVLINK_CMD_PORT_GET] = &devl_cmd_port_get, [DEVLINK_CMD_SB_GET] = &devl_cmd_sb_get, [DEVLINK_CMD_SB_POOL_GET] = &devl_cmd_sb_pool_get, @@ -186,7 +185,6 @@ static const struct devlink_cmd *devl_cmds[] = { [DEVLINK_CMD_SB_TC_POOL_BIND_GET] = &devl_cmd_sb_tc_pool_bind_get, [DEVLINK_CMD_PARAM_GET] = &devl_cmd_param_get, [DEVLINK_CMD_REGION_GET] = &devl_cmd_region_get, - [DEVLINK_CMD_INFO_GET] = &devl_cmd_info_get, [DEVLINK_CMD_HEALTH_REPORTER_GET] = &devl_cmd_health_reporter_get, [DEVLINK_CMD_TRAP_GET] = &devl_cmd_trap_get, [DEVLINK_CMD_TRAP_GROUP_GET] = &devl_cmd_trap_group_get, @@ -196,23 +194,19 @@ static const struct devlink_cmd *devl_cmds[] = { [DEVLINK_CMD_SELFTESTS_GET] = &devl_cmd_selftests_get, }; -int devlink_nl_instance_iter_dumpit(struct sk_buff *msg, - struct netlink_callback *cb) +int devlink_nl_dumpit(struct sk_buff *msg, struct netlink_callback *cb, + devlink_nl_dump_one_func_t *dump_one) { - const struct genl_dumpit_info *info = genl_dumpit_info(cb); struct devlink_nl_dump_state *state = devlink_dump_state(cb); - const struct devlink_cmd *cmd; struct devlink *devlink; int err = 0; - cmd = devl_cmds[info->op.cmd]; - while ((devlink = devlinks_xa_find_get(sock_net(msg->sk), &state->instance))) { devl_lock(devlink); if (devl_is_registered(devlink)) - err = cmd->dump_one(msg, devlink, cb); + err = dump_one(msg, devlink, cb); else err = 0; @@ -233,6 +227,15 @@ int devlink_nl_instance_iter_dumpit(struct sk_buff *msg, return msg->len; } +int devlink_nl_instance_iter_dumpit(struct sk_buff *msg, + struct netlink_callback *cb) +{ + const struct genl_dumpit_info *info = genl_dumpit_info(cb); + const struct devlink_cmd *cmd = devl_cmds[info->op.cmd]; + + return devlink_nl_dumpit(msg, cb, cmd->dump_one); +} + struct genl_family devlink_nl_family __ro_after_init = { .name = DEVLINK_GENL_NAME, .version = DEVLINK_GENL_VERSION, From patchwork Wed Aug 2 15:20:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 13338396 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D2793F9EC for ; Wed, 2 Aug 2023 15:21:28 +0000 (UTC) Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98EF42D72 for ; Wed, 2 Aug 2023 08:21:01 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-3fe1fc8768aso35880105e9.1 for ; Wed, 02 Aug 2023 08:21:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20221208.gappssmtp.com; s=20221208; t=1690989644; x=1691594444; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vYAfhr+kIZLqFF0wZYJ8uWRcm1Dn7Z+b4KAI90SijJI=; b=xhmgeH32pgHr9MQc6gGwGqddLTLlil0p8kufx1JtjdHbt0zhMLvzZ75p7jRS8BGPs3 I6lwY7iR12qxXPSsTtlLYGHE7TEDFwxHTuIBB1HYz15Giu6xwBhUaDr6hG6sh44BPbfz aZpTyVuFtO2fq+iPnwsNovUMb30kQ6y1VsUhaQVzUC0Dam7npUtU9Oou6RQLWaxPKejB LGpJu+05j45af22/FVUvWVZRVrzu1lhd/pZkFX+zRLocZjRZ7xAufudtIWt/AvR4+R2z mWRGIgKTUTpHUddwmKjBAAim+QxvApWV4IQweRijvkLiqyzsKDx4ZLPGUX63OfE6elpt FkEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690989644; x=1691594444; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vYAfhr+kIZLqFF0wZYJ8uWRcm1Dn7Z+b4KAI90SijJI=; b=OJuKmSoFn9VwHa2/zJMxdUdYa4EldvssFDrSeUrhEqWYjgIl/8YsvjNxtzf/eORQpr zW2frRNGvAUBYaICinONrqGy+qdE452BHwVkRWmKKRiOKrJ557/oeJafMK6iohDzy8R2 8aoK1lqq/SaB3W+5U3JV8lcyYxd1qlbSpAkDzzm2FZRuFOEBTnFwCcxN5ANa89QxKY0w 9Ca2asUIcTM2HFUiYTGjxF5DOCjkJI0/MuRrJwSbT4+pJhvrmb4Tb76PkTZgKd3S3EWq 8CR+pneSC/5MlERXrbSe38FUTKMvx/2T1VHavIA6rH246YiUrmZhj+BbietDg7Gh7jwO 9b7Q== X-Gm-Message-State: ABy/qLaTZNYsX4OUOwmmjgkA5w/3FRBiKpsGLh/PbxXFXccBbbzVNzHw Yk6x/j46uT/BUAlGGsLqDfzSM70cji/vM4FxySasNA== X-Google-Smtp-Source: APBJJlG8nTY6/YXT3H8MzinVxAwDebc6iKgbfGVdqn/EVDx53mS6kCGRex9LGPvgMOwzOF1RcSIE+Q== X-Received: by 2002:adf:e883:0:b0:317:6e08:ed35 with SMTP id d3-20020adfe883000000b003176e08ed35mr5496988wrm.1.1690989644054; Wed, 02 Aug 2023 08:20:44 -0700 (PDT) Received: from localhost ([212.23.236.67]) by smtp.gmail.com with ESMTPSA id v18-20020a5d43d2000000b003177074f830sm19163075wrr.59.2023.08.02.08.20.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 08:20:43 -0700 (PDT) From: Jiri Pirko To: netdev@vger.kernel.org Cc: kuba@kernel.org, pabeni@redhat.com, davem@davemloft.net, edumazet@google.com, moshe@nvidia.com, saeedm@nvidia.com, idosch@nvidia.com, petrm@nvidia.com Subject: [patch net-next v2 11/11] devlink: use generated split ops and remove duplicated commands from small ops Date: Wed, 2 Aug 2023 17:20:23 +0200 Message-ID: <20230802152023.941837-12-jiri@resnulli.us> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802152023.941837-1-jiri@resnulli.us> References: <20230802152023.941837-1-jiri@resnulli.us> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Jiri Pirko Do the switch and use generated split ops for get and info_get commands. Remove those from small ops array. Signed-off-by: Jiri Pirko --- net/devlink/devl_internal.h | 2 +- net/devlink/leftover.c | 16 +--------------- net/devlink/netlink.c | 2 ++ 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/net/devlink/devl_internal.h b/net/devlink/devl_internal.h index 51de0e1fc769..7fdd956ff992 100644 --- a/net/devlink/devl_internal.h +++ b/net/devlink/devl_internal.h @@ -124,7 +124,7 @@ struct devlink_cmd { devlink_nl_dump_one_func_t *dump_one; }; -extern const struct genl_small_ops devlink_nl_small_ops[56]; +extern const struct genl_small_ops devlink_nl_small_ops[54]; struct devlink * devlink_get_from_attrs_lock(struct net *net, struct nlattr **attrs); diff --git a/net/devlink/leftover.c b/net/devlink/leftover.c index 895b732bed8e..3bf42f5335ed 100644 --- a/net/devlink/leftover.c +++ b/net/devlink/leftover.c @@ -6278,14 +6278,7 @@ static int devlink_nl_cmd_trap_policer_set_doit(struct sk_buff *skb, return devlink_trap_policer_set(devlink, policer_item, info); } -const struct genl_small_ops devlink_nl_small_ops[56] = { - { - .cmd = DEVLINK_CMD_GET, - .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, - .doit = devlink_nl_get_doit, - .dumpit = devlink_nl_get_dumpit, - /* can be retrieved by unprivileged users */ - }, +const struct genl_small_ops devlink_nl_small_ops[54] = { { .cmd = DEVLINK_CMD_PORT_GET, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, @@ -6533,13 +6526,6 @@ const struct genl_small_ops devlink_nl_small_ops[56] = { .dumpit = devlink_nl_cmd_region_read_dumpit, .flags = GENL_ADMIN_PERM, }, - { - .cmd = DEVLINK_CMD_INFO_GET, - .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, - .doit = devlink_nl_info_get_doit, - .dumpit = devlink_nl_info_get_dumpit, - /* can be retrieved by unprivileged users */ - }, { .cmd = DEVLINK_CMD_HEALTH_REPORTER_GET, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, diff --git a/net/devlink/netlink.c b/net/devlink/netlink.c index 98d5c6b0acd8..bada2819827b 100644 --- a/net/devlink/netlink.c +++ b/net/devlink/netlink.c @@ -248,6 +248,8 @@ struct genl_family devlink_nl_family __ro_after_init = { .module = THIS_MODULE, .small_ops = devlink_nl_small_ops, .n_small_ops = ARRAY_SIZE(devlink_nl_small_ops), + .split_ops = devlink_nl_ops, + .n_split_ops = ARRAY_SIZE(devlink_nl_ops), .resv_start_op = DEVLINK_CMD_SELFTESTS_RUN + 1, .mcgrps = devlink_nl_mcgrps, .n_mcgrps = ARRAY_SIZE(devlink_nl_mcgrps),