From patchwork Thu Aug 3 11:13:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 13339819 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 073C8182D1 for ; Thu, 3 Aug 2023 11:13:51 +0000 (UTC) Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09D6A196 for ; Thu, 3 Aug 2023 04:13:44 -0700 (PDT) Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-51cff235226so1897141a12.0 for ; Thu, 03 Aug 2023 04:13:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20221208.gappssmtp.com; s=20221208; t=1691061223; x=1691666023; 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=ViZKaG35m/RVktKxjSfoMr1R/MpX8GeTflhXDjZIGsJ5TsweEND2OQBmVB/De2OyPl xdPHVLCicERaK7Ghn2wJ5Dbs6SI9lZgMFnLalvzvqJIks/j3PF6SI0BKRVSNEEoNpwk1 O9uvzFgxHacSlB87eUmEmbiHr/1ouM3z1mF0YEeMXNjTPt59KplS6iOr2GHePDsAzZCN 9cCaitR3npys6RI2IvuaXrJ7i+Zi952M2n/yIM0cn9iVGdEEvJq8MRUaQlp0hKE0M0Fh P1fSPe36NkycHfnC3G1S/B/7t/CfDwCTZE8l3zF6ehM5YQ6c5ZE4eeHNJqCpwKu3Xoj2 dgnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691061223; x=1691666023; 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=lG0L+xc0s4X/3hyz08hA2MTUn9SPJjZyQpjoP+XHiL9i9tcmFPt3IuSUrXy3wywXxb kfrch9sZH3Yko/xpCLnzOhflio8VPnRnVTLM2NeJ4nZ0UgkFlihKIx/msBIM/id8/HpW 0ox2MWWwTAi18TtTX/pQEzYgSH8AFEjrdrq/dOvyK31/fJidUGdKn1+nmzgpLzen/vOc mje+hisgEEWBJuBm15Osnu3I9Hi8uBnPXJOu8FCXIKtDjzl5Ub+MFOp3YSThY9vDZw/+ U9AfW164o8CrTmMy9S7DJaFxpDTzan2tBNJvg9kFAZnzl6V0cWPoEn/oNPlRoqm8V943 w3NQ== X-Gm-Message-State: AOJu0Yzk1uMbIB2L4VRVUluxTa2NdXgW75jQ49HiH8sef9sksjYcrbVb ORfc7iT3gQ+j+G0hiZLQ39i0meQoKUw11mgcPpZutg== X-Google-Smtp-Source: AGHT+IFfKEDSdHtXB84nQN575Q7J6SQA2UgXD+6kQHjjqzA6iGfePKlJOeFdiGlYEK/nvI1HidGi5g== X-Received: by 2002:aa7:c694:0:b0:523:100b:70da with SMTP id n20-20020aa7c694000000b00523100b70damr953683edq.4.1691061223330; Thu, 03 Aug 2023 04:13:43 -0700 (PDT) Received: from localhost ([212.23.236.67]) by smtp.gmail.com with ESMTPSA id p4-20020a056402044400b00521d2f7459fsm10098432edw.49.2023.08.03.04.13.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 04:13:42 -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 v3 01/12] netlink: specs: add dump-strict flag for dont-validate property Date: Thu, 3 Aug 2023 13:13:29 +0200 Message-ID: <20230803111340.1074067-2-jiri@resnulli.us> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230803111340.1074067-1-jiri@resnulli.us> References: <20230803111340.1074067-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 Thu Aug 3 11:13:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 13339818 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 D2F948F7C for ; Thu, 3 Aug 2023 11:13:51 +0000 (UTC) Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99CD0E75 for ; Thu, 3 Aug 2023 04:13:46 -0700 (PDT) Received: by mail-ej1-x644.google.com with SMTP id a640c23a62f3a-99c10ba30afso422955166b.1 for ; Thu, 03 Aug 2023 04:13:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20221208.gappssmtp.com; s=20221208; t=1691061225; x=1691666025; 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=XkoPN3HjHRBwVJxQE1gkkobS8bzHGBfG7clAoAmoZTMWeEqghxm1EOZoXnxl8ME/1X gXpqFgPrSzsA+Vg2At3W3nnWHfGf3zlIBhbR8uW4tdQwdFGKTGtv1gE8f6T1cBe101+T ER8S65DIiQwjiRQPInKr9kjYjBNmybhC1wbou+VcD0F3IU5C3EIM6l3zMYd92J9onGAP b8b/zZ6S7UvBKOPC8sP1IVjehyRp0/S9YmzoEiZVAzfw5Iiy8ZPXzp9srBpP0h0/Vkdt D1tNV8mQSBrOuaINKoJZPotKk81bcGMbLyVonkmbtYMQS3aknOaK8N24jkdblvo2MtsL jzKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691061225; x=1691666025; 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=Qo573dLC5RjAmadYeHN4+LKdtF29+2KnxVlaRpSQIXTzPyckZZZ8QSFbs2nbg7TFSS 3e+EC7A8PG2hj6q3Gc5PKNMg5sWQPzpZ6Wp1feNA6Yz79FXAbET1ZCdlQ08IAArkfDWP oYiePEgK7+L25ErV1NhiVfGa1gigFBcHbnRGwd623LeVTlY8sdbD3nUCcqvAPE6lF0Ld Kn1KMnRaCuSZUEkrZuRRW1LciG4ejnEiyu7GMKqmTxOKuComAwQlr3/fTPWa53Zph7ch apmd+6CRHdL6J5MV7Ib2CdbyDRrK8HYdDPZPJitgfZNAC985fRoWrvRMJnOsvUrpcVFN 2uCw== X-Gm-Message-State: ABy/qLaiM4ShgqMngTaQRPjS8CGUuF/NXEfAOILpbIAs+DRP05L1Eum1 YbXrB0SNkRlRYz8EGTYs1O4C8kQoMjHfC/E/PiBIT2Bs X-Google-Smtp-Source: APBJJlEX/gpQ+ZWPByGKB5SUDU6QnKKXNRvwXErm2eI1xMBVfyeNHKqfqZAcJ+mnEZEe0sC0WXdQnQ== X-Received: by 2002:a17:907:9686:b0:98d:ebb7:a8b0 with SMTP id hd6-20020a170907968600b0098debb7a8b0mr10858705ejc.14.1691061225152; Thu, 03 Aug 2023 04:13:45 -0700 (PDT) Received: from localhost ([212.23.236.67]) by smtp.gmail.com with ESMTPSA id gw19-20020a170906f15300b0097404f4a124sm10400868ejb.2.2023.08.03.04.13.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 04:13:44 -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 v3 02/12] ynl-gen-c.py: filter rendering of validate field values for split ops Date: Thu, 3 Aug 2023 13:13:30 +0200 Message-ID: <20230803111340.1074067-3-jiri@resnulli.us> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230803111340.1074067-1-jiri@resnulli.us> References: <20230803111340.1074067-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 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 Thu Aug 3 11:13:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 13339822 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 8954E19BAD for ; Thu, 3 Aug 2023 11:13:53 +0000 (UTC) Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFF09213F for ; Thu, 3 Aug 2023 04:13:47 -0700 (PDT) Received: by mail-ed1-x52e.google.com with SMTP id 4fb4d7f45d1cf-52227884855so1063789a12.1 for ; Thu, 03 Aug 2023 04:13:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20221208.gappssmtp.com; s=20221208; t=1691061226; x=1691666026; 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=Xm8m68R8BaH37vwbMbGP10geA0/w5IB1ToC+Q7Nn46w=; b=YEKo9jJLNLOvgyugG03qDkMOoC6GLR69SLJNnQHo8RfAlUh+Vu+q+ch06WONoHuZ+V Ee9gMquRu6ALOsHGi1LqFLgHqfoPQ7MUAHNCushg7TFoHcNFilgUzY/A4QIrhZC9pwIi ma+4zOaBrfkVez9MM+YBUQEtWAnHrUaRBTvJKbCd1Z79HbYWT81PPLOWpxOrBNv9zp4m TIoFBA35xSBdRyzAUF89sDaFwYvncdldE5T/Uocu0+racdz8u5Y79eT5e8bcp8JfhImJ NEiok7yI7PGM4TgJgubX+XLbUQiYN2nsL8D6gqHtoosz9aKPxVmqWXGuk4s5XM9z6T47 itlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691061226; x=1691666026; 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=Xm8m68R8BaH37vwbMbGP10geA0/w5IB1ToC+Q7Nn46w=; b=Kh/pui1Nm/syvRFggRaXIj9XnYGHMQ2gsVDGTdDO8nvnjyu8DBfXx1GsKxqiHTpCzz 82vtSGGOcP+2EL3+LyElF7I9GENSn6Hl2pYGTghM5dBDlHZUvdsDG6rII0IJXyOgmxvJ k7Ih5Fzv+PVPgYEUfBwWPbL9/r2xA8eWCNawC6n+OK/u0Kkfmx2clW0UDcxhYkRnxoiG EU3Ng4/RC+riiuJzgNA/eifpyivbAPfSIMJm1zcoYh4bn27iyUhHqMNk7c3sSXe71NAP P5nSQIaGWhZk1Ok0owk+IIyAX+ve5ovvIGgTU3uNwNrZAVK23W4mktGk7mPdID9R/Ds4 bC7Q== X-Gm-Message-State: ABy/qLatScdrc7J2j1S8/YvMfVThO6nnuvwY3lLbjNrKGycQOfgyzdDD HoSHLB4gZQItwLLxzpyHQ1UwSpBd0K7B6oL+aEvLIA== X-Google-Smtp-Source: APBJJlEt0Cqgv7xx6DpKbWuPNXQyfcy2oZpYPVD5AbGTnreMl2LMn04TMvlnKrqzKu5P69w8e6i78g== X-Received: by 2002:aa7:cf01:0:b0:522:455d:6f6f with SMTP id a1-20020aa7cf01000000b00522455d6f6fmr7760947edy.34.1691061226561; Thu, 03 Aug 2023 04:13:46 -0700 (PDT) Received: from localhost ([212.23.236.67]) by smtp.gmail.com with ESMTPSA id s11-20020aa7c54b000000b0051df54c6a27sm9992230edr.56.2023.08.03.04.13.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 04:13:46 -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 v3 03/12] ynl-gen-c.py: allow directional model for kernel mode Date: Thu, 3 Aug 2023 13:13:31 +0200 Message-ID: <20230803111340.1074067-4-jiri@resnulli.us> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230803111340.1074067-1-jiri@resnulli.us> References: <20230803111340.1074067-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 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 --- v2->v3: - fixed double space issue 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..2ea6af892b68 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 Thu Aug 3 11:13:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 13339821 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 52DFD18C07 for ; Thu, 3 Aug 2023 11:13:53 +0000 (UTC) Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3696EA for ; Thu, 3 Aug 2023 04:13:49 -0700 (PDT) Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-98377c5d53eso116647066b.0 for ; Thu, 03 Aug 2023 04:13:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20221208.gappssmtp.com; s=20221208; t=1691061228; x=1691666028; 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=dgMU1yzae+eZsxN9OmMX2LlMkJLp377FcEFSc7ndUY4=; b=RUsTGIyj0lpOY54vIDhfIFe1XXNN4TlmBDue7rTZWHF7t3/afIBvzWGEAmIkvw297q LGXlv1X6LSfKhTvaLNHQm+0JgoBBAQ+6NzUgc3WPpWSN2lf0Rr1QJBwkEujmj21FyOq+ Q79sxGjRTbLrLhkqU9Jl9Bu0Rs6htOfBOsCLF9WYjIMMLD8cPBkXRwoqDu3WHriWXgUa 7/plD0xgVa/PfDBLDvW2k+7onAHscMgI1KuqpFLHGo+ozX5Z9lTbUa2epcKShLV6UxAq yihAuZGP0LOElx6UoLdinNsZOpZjiBvPR6Yn1ELpVU/tm8sJJD4C8erOvXX6qpNRynVg NC8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691061228; x=1691666028; 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=dgMU1yzae+eZsxN9OmMX2LlMkJLp377FcEFSc7ndUY4=; b=I1yUnePrT8l1dG8waZ2X7GdMkm9WZeRzJy8cdiLOcR56DTjBx8NiJ4y7H3Jb86cRLm sjEvyxeUBGmupGNOgmorCrevubaMjHlR9zQ7IivtTC+lU/1jl3re2na5IqiHE96aDBpy A6LCt5kYBRXHxJbhAiMI5c6qEgZ0xrjbFaWUcZjBiP6L2xuE2Wn9HUlj3d0IyBgXiIwq Fsw3rUfHl2TN6ZOG3ltcdriUTOWiIZq/YpODP0PLhYXiaTIVIHV/hPd+LdZgnYW2fBda QMvGrGiJv/paSHTEiXXXnOE/6F6W2gvgG5ODf+FBMm10G/o+jb4VHePxFIcU7PdPOtJ0 sO+A== X-Gm-Message-State: ABy/qLaH4WEwKK15l3Z652IYjU1mKMcPNkNYs5LeIC7EQs6fduvbYX/n e8uS0t5WdFWP+K2n5IvOmew8C8TcDSsILxeM6BWp6g== X-Google-Smtp-Source: APBJJlH5zWdVn74PkMJXTo+L+lxCagAkG83pl499njPo1MPJ9KQKSLqYeKa9Dm06x7HCa1Ri4oGN4A== X-Received: by 2002:a17:907:2cd1:b0:99b:4908:1a6d with SMTP id hg17-20020a1709072cd100b0099b49081a6dmr6922991ejc.52.1691061228150; Thu, 03 Aug 2023 04:13:48 -0700 (PDT) Received: from localhost ([212.23.236.67]) by smtp.gmail.com with ESMTPSA id h8-20020a1709063c0800b0099bcbaa242asm10441322ejg.9.2023.08.03.04.13.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 04:13:47 -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 v3 04/12] ynl-gen-c.py: render netlink policies static for split ops Date: Thu, 3 Aug 2023 13:13:32 +0200 Message-ID: <20230803111340.1074067-5-jiri@resnulli.us> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230803111340.1074067-1-jiri@resnulli.us> References: <20230803111340.1074067-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 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 2ea6af892b68..e64311331726 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 Thu Aug 3 11:13:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 13339823 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 7D6651DDFD for ; Thu, 3 Aug 2023 11:13:54 +0000 (UTC) Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EB302D54 for ; Thu, 3 Aug 2023 04:13:51 -0700 (PDT) Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-99c0cb7285fso109793766b.0 for ; Thu, 03 Aug 2023 04:13:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20221208.gappssmtp.com; s=20221208; t=1691061229; x=1691666029; 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=ad5+079NGe28kGw9icG+l221TNNaYDnYa9kYmd12QkPp8kQXSFa3WeTK1BRVxfMn2+ a20YvSz7TiJ0nYqZMUxOrZwSlN/V0DL7+YwjIgitTzzbcftC0OTX/anQYWjuYR2Dz2Bo 3/kF3nknsiYvmM8LYGf2tOGWJX9AVy+c7+ywNQLiW3U+D6FdpwloMpH3O+mrJb5NC6rr 3EvE6W6Or99Lzb2ZsycAEJ64G/me9KA7ZJP0zzHlV6OW04apabRzHqRiKzFKOhx/3f7r sslh9aQxZAwPBqBH+aEw8yCxGP8ivHDLskgF733CwcvhAeELLcLbwG7lElBCmKDQDl0S /eYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691061229; x=1691666029; 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=HzAtZuRKE+XGz9hm+dyYF79c4mCOnZwyXJbdgvVCIkX1cf1FNZprzbAUTGUDt5+Zo3 ny0mlaRF1O9kYvCajRDQRCTgGj1bqNh5yFhbNdjN3956YhWUBcvctEzPUwpAD500pPBK ANRpDdIyzamk3jhymlTxhDvnDGmrLAg/9lnEtHbPkK4eNtRTYaVtIbBo1KG7vA3wzkc+ J2f/MXCQ+/HM/62LE5xTHKuf4Z/I9cz9GzSKCmYZiDzN1YUfpZ8vxnDFGhwUwW+gmdkE 8TC651X+gD2ZROpmXLaPCI7GIYU7C9ld8ogw+I8ZcKMCnGcnFVXJKrAzppr+JxottWyd aLJw== X-Gm-Message-State: AOJu0YxH74hgznra5MVq3hJz/+0CpLS87jfXrY1A1YVz5ppo8LwMd4N0 1FoGtX7lS9GkUKFDE1BJY1uYqrunnL7ZXlERWxMwiA== X-Google-Smtp-Source: AGHT+IH1FpSdfWO+jvw4mmgko5gFnwzbQ2BShxobyNXGRuBXuohoiVy7V/JlMwREAPcl748min9MnA== X-Received: by 2002:a17:906:314b:b0:99c:4a29:f304 with SMTP id e11-20020a170906314b00b0099c4a29f304mr3520219eje.34.1691061229684; Thu, 03 Aug 2023 04:13:49 -0700 (PDT) Received: from localhost ([212.23.236.67]) by smtp.gmail.com with ESMTPSA id f23-20020a170906495700b0098748422178sm10355652ejt.56.2023.08.03.04.13.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 04:13:49 -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 v3 05/12] devlink: rename devlink_nl_ops to devlink_nl_small_ops Date: Thu, 3 Aug 2023 13:13:33 +0200 Message-ID: <20230803111340.1074067-6-jiri@resnulli.us> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230803111340.1074067-1-jiri@resnulli.us> References: <20230803111340.1074067-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 Thu Aug 3 11:13:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 13339824 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 622651DDFD for ; Thu, 3 Aug 2023 11:13:55 +0000 (UTC) Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1CEA10D for ; Thu, 3 Aug 2023 04:13:52 -0700 (PDT) Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-522382c4840so1050373a12.2 for ; Thu, 03 Aug 2023 04:13:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20221208.gappssmtp.com; s=20221208; t=1691061231; x=1691666031; 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=OHSlYLHKZ15lxC4IDTXfvZjFHzQNpdv05Ngn08MEn2s=; b=3HA8HNRylZjMqYudKXnqare+GElPAe/8I/3ETf9xQqMtHXr46M10E8Xz8tEtuKn8VW bT5yHHfExNQwHbpz7SlfmFHNnLHzq1/GdSIdQdjFbWq8Nni27XJlm/0INS6z4CSVYR2h XrkGn6P3clSvTSqjcdhV10xwYRXecTHkkzfVvKYtQQ68t4ZJ83YPT4yc3Y3SVH4veiqk tHQkOK6x65qsLDzFyvytmaiVZ/Z30iCuKvqYYnM1sJmu35CAIoTZ+2B8BWv82rNfINSp sEzsRnMnGrSVSgU7UF+EkxIWghEFHYgqsZRrWaPMwyfjN7nPev804mR5CH3EldajRces UfMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691061231; x=1691666031; 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=OHSlYLHKZ15lxC4IDTXfvZjFHzQNpdv05Ngn08MEn2s=; b=C/PsprVwImcpSLvXTXxlhuwXvHG1ReFYW5WRi0fvDfYI+f7lNPDgpwTaPdpuFXIRrG umC5ieC2bWlsArkJ/CXB8qcF/avkdvALPk74Z3MvzXptfWVC52vT+0SYn12IXg3446Xi VGieU3js6CAQpdRedriuM/aXJ+gJVd2FTM01YPyUy1fdkLcrrTSclm9XwOV8bfHjZDrw bGYZ15GsFTMedyqIpe74QHXwWjELybyoUTGL0kQVuKC6TQj+riJ381g4xVshEriKnGCE 9PBqwsg2aHuFcvilhLPUodvaZnk+rGKQviVpqbZs5Fomsu23NAkWxRW1y+pn+7+ELbQE KQsA== X-Gm-Message-State: ABy/qLaWVir5vkLjFX5u2nQYNaoNccsf7Lu+hXJT/JsYZtUzQlXrWnLH FvKyCf93mh7D7SDAvCCD1E2Q+DSgcewdCBWdswXHXw== X-Google-Smtp-Source: APBJJlHnoq142SkjEWHN3drnJ52hrIBm2G83V/1eRv1KaXYjFCSIAd2qQny0ACKFEy5Srb7LRyZE+Q== X-Received: by 2002:aa7:d311:0:b0:522:4dd0:de6e with SMTP id p17-20020aa7d311000000b005224dd0de6emr7458196edq.8.1691061231227; Thu, 03 Aug 2023 04:13:51 -0700 (PDT) Received: from localhost ([212.23.236.67]) by smtp.gmail.com with ESMTPSA id bf19-20020a0564021a5300b0051ded17b30bsm9998315edb.40.2023.08.03.04.13.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 04:13:50 -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 v3 06/12] devlink: rename couple of doit netlink callbacks to match generated names Date: Thu, 3 Aug 2023 13:13:34 +0200 Message-ID: <20230803111340.1074067-7-jiri@resnulli.us> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230803111340.1074067-1-jiri@resnulli.us> References: <20230803111340.1074067-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. Change names to be ready to switch to generated split ops header. Signed-off-by: Jiri Pirko --- v2->v3: - added temporary prototypes to devl_internal.h - moved the patch before "devlink: add split ops generated according to spec" in order to fix the build breakage --- net/devlink/dev.c | 4 ++-- net/devlink/devl_internal.h | 4 ++-- net/devlink/leftover.c | 4 ++-- 3 files changed, 6 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 c67f074641d4..d32a32705430 100644 --- a/net/devlink/devl_internal.h +++ b/net/devlink/devl_internal.h @@ -214,11 +214,11 @@ 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_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_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 Thu Aug 3 11:13:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 13339825 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 1726B1DDFD for ; Thu, 3 Aug 2023 11:13:55 +0000 (UTC) Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 413C7EA for ; Thu, 3 Aug 2023 04:13:54 -0700 (PDT) Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-99bcc0adab4so120170366b.2 for ; Thu, 03 Aug 2023 04:13:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20221208.gappssmtp.com; s=20221208; t=1691061232; x=1691666032; 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=mHLqQEQLXBodpfNSH6Ik79GTCpp9uGMnhYBHyud7ZOQ=; b=mlCIHzRmwWREFp0j50lsBkZNUwF3XeLRfZzviOjffRnSEpaYW3zPBqSDTPoCQQZPEc jwsXJq3yUad9MWA9L4hst3XMDTz4lj/hWE5kbRf0yr1oCWXCm1sHBGkPEiL/lr7odzqB ssUlJ1C4QmsMWSRwaNoG2UwUYkQL4UiYwLHHnbXImRRrd9SvAHnXkr5l58s9McZ+4NNE d5YEjjZAnl8/BAvgxZqeVR+K45ptZraZa9Y7wML6XAu0B4pclPCn9H7WQfiGKJS76s4L VZQUnGsr9bDO1RHHZIc8mi8OagMztMmK9BfBBtuMiazPnhOkzdyUTKR+k06HluVfPTbk 3uaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691061232; x=1691666032; 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=mHLqQEQLXBodpfNSH6Ik79GTCpp9uGMnhYBHyud7ZOQ=; b=Q5m/WrMJ3oQEiNGDW6XGYkaA6NPYCgiFqYpdh0Y879W5w2sTWCE2LAsljM0kUk+Tbw 6RZrk1g52DxFioNH4C85/LTeF7pUD9rjStg8DobawMvydAJ16jVnJ0/TcPHn22Dsewu+ JUn8mORh7ubGPRi/ys7gxm6WFkHv5FNiLMEE36z/xz4cYB4qoeRQBZGupv1jXS37OEi0 UGFSCbK2OxqUk7tB8e64pUx90PV84rYcVvNIjzoLM/DMPj1QiF2TxOpCuVpgFA/OE+6P Fyj++huv34GvO4Gs7Jkeh7PG9FB1zssUCVkkjTTsh+ftkNpg3De243ob3dF8q9HOIj9m DQgg== X-Gm-Message-State: ABy/qLZLYORGzVuTi733Vk601gKPoNFn8hD6eeRnqIhBnXqE4rSPDana OoqNmiXZqrMLhzQJqgnYguxwGc2eCngh0ssQTck0wA== X-Google-Smtp-Source: APBJJlFR+4my0+7nSk/Pl/PO/lTumares0Evk0zWXb7aDSYeiYc9ELdrSfmxS65qd275SgB1Q58eYQ== X-Received: by 2002:a17:906:c1:b0:99b:f554:1f10 with SMTP id 1-20020a17090600c100b0099bf5541f10mr6814567eji.7.1691061232751; Thu, 03 Aug 2023 04:13:52 -0700 (PDT) Received: from localhost ([212.23.236.67]) by smtp.gmail.com with ESMTPSA id b14-20020a1709062b4e00b0099bd7b26639sm10393913ejg.6.2023.08.03.04.13.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 04:13:52 -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 v3 07/12] devlink: introduce couple of dumpit callbacks for split ops Date: Thu, 3 Aug 2023 13:13:35 +0200 Message-ID: <20230803111340.1074067-8-jiri@resnulli.us> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230803111340.1074067-1-jiri@resnulli.us> References: <20230803111340.1074067-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 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 --- v2->v3: - fixed double empty line issue - added temporary prototypes to devl_internal.h - moved the patch before "devlink: add split ops generated according to spec" in order to fix the build breakage v1->v2: - fixed typo in patch subject --- net/devlink/dev.c | 22 ++++++++++++---------- net/devlink/devl_internal.h | 17 +++++++++++------ net/devlink/leftover.c | 4 ++-- net/devlink/netlink.c | 21 ++++++++++++--------- 4 files changed, 37 insertions(+), 27 deletions(-) diff --git a/net/devlink/dev.c b/net/devlink/dev.c index 2e120b3da220..5dfba2248b90 100644 --- a/net/devlink/dev.c +++ b/net/devlink/dev.c @@ -217,17 +217,18 @@ 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 +827,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 +841,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 d32a32705430..7d0a9dd1aceb 100644 --- a/net/devlink/devl_internal.h +++ b/net/devlink/devl_internal.h @@ -114,9 +114,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]; @@ -127,8 +130,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) @@ -149,7 +153,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; @@ -157,7 +160,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; @@ -215,10 +217,13 @@ devlink_rate_node_get_from_info(struct devlink *devlink, struct genl_info *info); /* Devlink nl cmds */ 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_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_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); 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 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 82a3238d5344..624d0db7e229 100644 --- a/net/devlink/netlink.c +++ b/net/devlink/netlink.c @@ -178,7 +178,6 @@ static 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 Thu Aug 3 11:13:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 13339826 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 BFB9E1DDFD for ; Thu, 3 Aug 2023 11:13:56 +0000 (UTC) Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E86E10E for ; Thu, 3 Aug 2023 04:13:55 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-991c786369cso112960466b.1 for ; Thu, 03 Aug 2023 04:13:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20221208.gappssmtp.com; s=20221208; t=1691061234; x=1691666034; 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=KDifvWqsoPhrv8/SIuKiKT64B/wL4sV2rAC12AosVps=; b=JaXENHHI3DaVE61M7jXtZ8AcMaUuqDB3F76Y3HH6+RO7Ele+0sSJl8sColGFKypMjo NQMDM/5JViGSoJAWKpQPCYO5MwQAceUZ9ljWKQ/JFL1dUcCLcuOVUd14xh3z59W1bDTG DIkXNfdQdCcTGyKJyaZIZnAesfyztblFY2DsbBgRf4kCYzLnApORCBPqTwqNKPYTiD1p 4xnmuPz4Sprfid4hsmrAi2QGYGg9/pWnWXGevAs8PHnDcfvVuKd+GT3vpIdygN7k5Wye uoAS2B/ygxG42fQIXT9IJx/H1jzaT7/zYc+ETz4e5a7s3t+YcEplDF0qOM4R1oHbdzjN 8nWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691061234; x=1691666034; 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=KDifvWqsoPhrv8/SIuKiKT64B/wL4sV2rAC12AosVps=; b=boGDETOr6vim/QZBch/Ln3tla0pt7v2UIQ5XXlqPSc1bBLYcpN3TMFaQO1jD0QgZyM E7X3NAsxDlUJ8jONVxKg6xCVKyYE6Myjp9CcxGo49SuyO/X1xTX4A+vOglgDXEZkEejt ZoFMMd8ci6gZAweA9qmfEYdXlrUkqZy1kvhC5YqDcCVGDpXEeXAEA0PQKy2zN0LrysyB UUx2z8QOWi0nzEzO+/0Y3o/wEfVmwEe2Q5KgupomlIigh7e77rEn7OY17nnpPSDmi9Go /R7b+6XZ2bmGbbqZg0/596eJ7I3ENC5UXWlicgyW/hEZqvPDW4Gvtz2f6cknKtIxGUaY 6RcA== X-Gm-Message-State: ABy/qLZETTDEZKInRoMRGvI7djgukXAi3CEvOURIn8xvoQDuY09jhql7 6ltOAOMZ1j21iATTgXUIIRNCxUikTkH7EPYVEipcxQ== X-Google-Smtp-Source: APBJJlF9MYgYhIoDkb+uV5COebkBbNjtWQLBkRa5lXyRch4iwBiTt+0L69wRSv1B4fcRaOL3MvFG6A== X-Received: by 2002:a17:906:3005:b0:993:dcca:9607 with SMTP id 5-20020a170906300500b00993dcca9607mr7296921ejz.2.1691061234148; Thu, 03 Aug 2023 04:13:54 -0700 (PDT) Received: from localhost ([212.23.236.67]) by smtp.gmail.com with ESMTPSA id m10-20020a17090607ca00b009931a3adf64sm10587342ejc.17.2023.08.03.04.13.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 04:13:53 -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 v3 08/12] devlink: un-static devlink_nl_pre/post_doit() Date: Thu, 3 Aug 2023 13:13:36 +0200 Message-ID: <20230803111340.1074067-9-jiri@resnulli.us> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230803111340.1074067-1-jiri@resnulli.us> References: <20230803111340.1074067-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 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 To be prepared for the follow-up generated split ops addition, make the functions devlink_nl_pre_doit() and devlink_nl_post_doit() usable outside of netlink.c. Introduce temporary prototypes which are going to be removed once the generated header will be included. Signed-off-by: Jiri Pirko --- v2->v3: - new patch, split from "devlink: include the generated netlink header" --- net/devlink/devl_internal.h | 4 ++++ net/devlink/netlink.c | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/net/devlink/devl_internal.h b/net/devlink/devl_internal.h index 7d0a9dd1aceb..0befa1869fde 100644 --- a/net/devlink/devl_internal.h +++ b/net/devlink/devl_internal.h @@ -216,6 +216,10 @@ struct devlink_rate * devlink_rate_node_get_from_info(struct devlink *devlink, struct genl_info *info); /* Devlink nl cmds */ +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_cmd_reload(struct sk_buff *skb, struct genl_info *info); diff --git a/net/devlink/netlink.c b/net/devlink/netlink.c index 624d0db7e229..98d5c6b0acd8 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 Thu Aug 3 11:13:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 13339827 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 97ED61DDFD for ; Thu, 3 Aug 2023 11:13:58 +0000 (UTC) Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28D46EA for ; Thu, 3 Aug 2023 04:13:57 -0700 (PDT) Received: by mail-ej1-x644.google.com with SMTP id a640c23a62f3a-99bf1f632b8so125112166b.1 for ; Thu, 03 Aug 2023 04:13:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20221208.gappssmtp.com; s=20221208; t=1691061235; x=1691666035; 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=QnuAj4p6o3ULtv73aEVNMrbBTx1qAUskvBfSOJBP9odukSxoADiDfcD692nK7NQPS8 q2gkjZH7Y5yV4UF7nlWAQqkCQ0KgY8cg6NnxOReTEf4rrUrQ1fnEcKvq4heEdkJ4/+zZ LoxSI3jemIdEa+KXB32OoD99w/4m2XpFbL3vjxu2o7s4wfZ5UkmXo1GTMO+RP34szJOc UMeMQwcEy344SxEYz2vKSiBT+5iyRYkTt1hP4M/93Pj3CyfyO0bcKc/9E6+Srs9jACE6 he5mEo1NPPf6vhg/A/MiMzrsgbHWJRhIwxrnT0ZCqx6BQyyMvO5UymJDIfn7Yme8K3/q XzuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691061235; x=1691666035; 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=djd9nwixlGk9wVJ3cSnfGzCHSuhwvpQrlf1HuhGDHW+1z4/POjTzgb2pVQUbqZYp1T dZbzRWiZRpOyFFNm/NEo1JPy5GuWJ7vE22hhy1YJ1sv8HFWjGr9uW6nNuGsF/SO1tYW2 eYgHH0S/GoA27syV3Htow0BI2i+WCtY0lO/RJ1QuEE7YyyFw4Ai5k/LUaCDoHsrWRMKD 7QBQvWXAqPhgSsHfXG7NxLqfPy+pk14qu4S/Hh4i1bDbUqq5hs6AkWyk5sW60u4mmpTP agEca7w1/aOtO8wuDmr8WQouORmpbrCoi8Ai/KrtymQEM9/mexIDOhjZsJwyRaZS08vW JoWw== X-Gm-Message-State: ABy/qLYQnGUZ1kV3VEkMSHImeaGy1Rz4mvjEATX0fSPFnQwdW/FjOY0d 4XSyYUGkkQJIT4qxkyYRsufZLIB9XuYQ5YAEZCtbexk3 X-Google-Smtp-Source: APBJJlFMPyNoqEvyxQPKCrRtoTAqi7HxD1UmyxbFvHrYeAw563lrPbEGTR+/zNU0+ASJTNVwq++eMA== X-Received: by 2002:a17:906:5da5:b0:99b:e5c3:2e45 with SMTP id n5-20020a1709065da500b0099be5c32e45mr6464351ejv.28.1691061235735; Thu, 03 Aug 2023 04:13:55 -0700 (PDT) Received: from localhost ([212.23.236.67]) by smtp.gmail.com with ESMTPSA id pw3-20020a17090720a300b00987e2f84768sm10308464ejb.0.2023.08.03.04.13.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 04:13:55 -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 v3 09/12] netlink: specs: devlink: add info-get dump op Date: Thu, 3 Aug 2023 13:13:37 +0200 Message-ID: <20230803111340.1074067-10-jiri@resnulli.us> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230803111340.1074067-1-jiri@resnulli.us> References: <20230803111340.1074067-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 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 Thu Aug 3 11:13:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 13339828 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 362D91DDFD for ; Thu, 3 Aug 2023 11:14:00 +0000 (UTC) Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB417B2 for ; Thu, 3 Aug 2023 04:13:58 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-52164adea19so1009589a12.1 for ; Thu, 03 Aug 2023 04:13:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20221208.gappssmtp.com; s=20221208; t=1691061237; x=1691666037; 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=acl+6MFV+mmBUdW1tpmvr9zmTCsPCF2C2c03qMnY7Pk=; b=jWuRzMRSykF7eeev+a1N6KIwEQ6X00brNqVNKjQk1lQQhkyBbbm1L5jDmtiqtddOAz xTORfVzSTFqoJK1rqCwK0vJxiadxvs+8L44KHEqDO9rxdOOriHKm7xwHnrrxM6INf5QZ kXpTR+EV3Sp9qVNuAEnlojxivUBx2ov5eOyNK2DLv1EURKG8V+4RZH1+a3VGppTBPZYk rxS1HvKGfzyuBY+c1SpBl0ejk4Dqr+bpCFYB2s5S/Psofl3UziHNb/k650ZSIoFAJHIE XFnWnMqciQvF4KHRG30qlrTvZ3IKN6XlVWm2zRCeZaou9dJ/BVTWfJ4ah2kK+Pt6MmCP GfXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691061237; x=1691666037; 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=acl+6MFV+mmBUdW1tpmvr9zmTCsPCF2C2c03qMnY7Pk=; b=H/RrrgJ3AIcebHkYQJEDuj0D4ObrTjNvsI1uqGjq1x+ncXu74zzIRuCj9BhbnHMmiW FzEaE12Et5f6PJELAC3ptgbJpr6UAyjiZPAZIlq3BBc8aGQDVYp9UM5/RHAo76rb2mJx 9W5bU0MmA4vwsclSNbz+Sp5kFsaEocXMdGx+w9Lxz552VJl9cZ1YfCk32vMwDZYTHmk8 tegJ3EQYtHfJpwEXMpzVKcJ36ffT4yLauDl3qHGsm8ZaxupIAqOG5sGk6zfMteybWXfU hNq274bdvAzcdGnGP65LPn9avf2iJ15zLoeZyAsLW7twXFK0Wpbbh9d4dHhSmfN4UCbR 7n5g== X-Gm-Message-State: ABy/qLaBMtQrppv0F6A8qkkAeGzLdysMSoOwtxFg/wxhXqz94rzNb1Se TvzoQv/qq5jY3x1RWWH9gmfKOuN5GSAXxoV5Zn/NSw== X-Google-Smtp-Source: APBJJlFz4iyOeKD1lHK/TXw+ASZx5LYDb8m1CNiBwPgJGfnNdo4/ILv8862P9CA2m5bLeGIlPOvH/A== X-Received: by 2002:a05:6402:553:b0:522:2061:bc84 with SMTP id i19-20020a056402055300b005222061bc84mr7765775edx.24.1691061237314; Thu, 03 Aug 2023 04:13:57 -0700 (PDT) Received: from localhost ([212.23.236.67]) by smtp.gmail.com with ESMTPSA id j10-20020a50ed0a000000b0051e0cb4692esm9869017eds.17.2023.08.03.04.13.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 04:13:56 -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 v3 10/12] devlink: add split ops generated according to spec Date: Thu, 3 Aug 2023 13:13:38 +0200 Message-ID: <20230803111340.1074067-11-jiri@resnulli.us> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230803111340.1074067-1-jiri@resnulli.us> References: <20230803111340.1074067-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 --- v2->v3: - un-static devlink_nl_pre/post_doit() to fix the build 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 Thu Aug 3 11:13:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 13339829 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 2B1C21DDFD for ; Thu, 3 Aug 2023 11:14:02 +0000 (UTC) Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36AC810B for ; Thu, 3 Aug 2023 04:14:00 -0700 (PDT) Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-99bdeae1d0aso118533266b.1 for ; Thu, 03 Aug 2023 04:14:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20221208.gappssmtp.com; s=20221208; t=1691061238; x=1691666038; 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=69o//OCeLKSkWAV3wkhMe2psFgsCZVnaljp//cCekKE=; b=YpuhhDSItR34PPo66IVO/TYYFTrynH60/OtjL+W/8RBtujXRDpH9aBXRagroNHLpbH dG/Br/x4LhsW8jds9vSNRJiKex8PDcOnYvovG9pTEOLVbEOBLq5b3P2yXlR2HSoPVh/7 64WEwSDqOCX00qb/aEASSUYqhna6G8mG5CO5ifYXBTanfyrKCSocc76XMMdxqhqo1DMy zMsWpNukFeVyM8xY75SGX+qa4BNvXSQh98wVajJ4y8yW2fduBFscRp+lwA5U0DMgbxak NahgAOAOQ3LNZiXF2Fk1RW4BY5cmDDJDd5lff8MXCQkWYOCemyOwXEnHk40E5y+t91Oh KQPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691061238; x=1691666038; 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=69o//OCeLKSkWAV3wkhMe2psFgsCZVnaljp//cCekKE=; b=CQCRnNNd6p6HBIp4WEJBkHxgqdel48m9iOO9oQBPd8KdGMGuqARN0UaTaXBy7j0C6w utiIh9TLNOmm4zaWyIr8nKne29yxJkH2gfm2h7kMoeQ5BG3Vqi7o6fZ3AcbP2J7NLjeU eai5DpOjMvl4V3NoqAWq1V66ur9c8hnQpc4movKhMmoFjvTqW2PnBiHhWgjAfTI1zQiL mqPpkVB70Hw2O7BWfcC5QzLR7rA7t0K8otCYxWr5Xf3caaC+2T2EeEdJ7pCscu1/ytZg 6DvQwXWdF4r5oujxdC6mPKHbC1kiUdLBP2awhhO/5mrHis+BN/o/6soJA5xChPuPH3/L +N5A== X-Gm-Message-State: AOJu0YxsS6AJEfEBkWysus+UeFSStOiGvJbQmp3kvpU1DX3TBjgZaPf0 1PIZ/P6P84F2/m5lWEdYqMQGkJPMZkDhp0N9/H0+8g== X-Google-Smtp-Source: AGHT+IHgRymyVqnXz7fL+1YKomuIMuQmdhsURkTtSIgYXPFyd9wsVuNNdClvMyEhb+cBPt4g0VjbiQ== X-Received: by 2002:a17:906:7782:b0:99c:7915:b84c with SMTP id s2-20020a170906778200b0099c7915b84cmr747668ejm.57.1691061238761; Thu, 03 Aug 2023 04:13:58 -0700 (PDT) Received: from localhost ([212.23.236.67]) by smtp.gmail.com with ESMTPSA id z21-20020a1709067e5500b0099c157cba46sm5758643ejr.119.2023.08.03.04.13.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 04:13:58 -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 v3 11/12] devlink: include the generated netlink header Date: Thu, 3 Aug 2023 13:13:39 +0200 Message-ID: <20230803111340.1074067-12-jiri@resnulli.us> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230803111340.1074067-1-jiri@resnulli.us> References: <20230803111340.1074067-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 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. Remove the duplicated temporary function prototypes. Signed-off-by: Jiri Pirko --- v2->v3: - moved un-static devlink_nl_pre/post_doit() a separate new patch - added removal of the temporary function prototypes --- net/devlink/devl_internal.h | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/net/devlink/devl_internal.h b/net/devlink/devl_internal.h index 0befa1869fde..51de0e1fc769 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 \ @@ -216,18 +218,9 @@ struct devlink_rate * devlink_rate_node_get_from_info(struct devlink *devlink, struct genl_info *info); /* Devlink nl cmds */ -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_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_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); 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); From patchwork Thu Aug 3 11:13:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 13339830 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 410B31DDF6 for ; Thu, 3 Aug 2023 11:14:03 +0000 (UTC) Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE171DF for ; Thu, 3 Aug 2023 04:14:01 -0700 (PDT) Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-99bdd262bb0so119701766b.3 for ; Thu, 03 Aug 2023 04:14:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20221208.gappssmtp.com; s=20221208; t=1691061240; x=1691666040; 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=hw0MOexoVs+iXBXBEraatRJkFiIN4SY4SocJd9Sz3K0Mm+fu1C3SyCAs59iMsjFQNs O9kqICyxr7aE4Kq/hD1oqpW7pCX0l3gAJURKNPayGdzDMgliCXjOIunCFcq53Nvz0mze hFzja2F7B+Z5s6wrxQDFp0mNyJPNSYW4/xteHlLE2EDLfov1ol4bVv8ODZ0hIpYzT/jm qU8IME5XYwXDTV2nw8cnxlbB/J+TDvwWXU66BOXIW5x9j7kIku/RvpiIkFf37WMLr1pv 81vrotKoO3kYUG8XB1p7gANn1G0Qo6M3cUrn/0YXsa13o7k4JCVLowrew5nJdsMArD4e QHAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691061240; x=1691666040; 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=eafuYLQAIHQ0uPpZ1U3+f37PbKB6r1NoDl68NweIM+/3Z5R98l4E+2xRrUCBSW3Idp 8ECSHecVnzk32czoWIl6ubmkNw4Qm/pH8gRnfuWsLZPYSK8RL7w8srWP3L3lIRUSyVIy SaHWghh2y/m20UZqpiavF7v3QQ6m34kiGXOrB/QK+Grg+PGdn/0H5SmiHE9m579V3+eQ 8eFSbrRdODRDVs8Mzehfj0HeqUwPfGHI/aO3d4xfuki0AoYkgBXEpFClBrdfwA2UhTwR wAm6xqU9oy/CVFx9kfAs49Gn1bQ7annrIUQBrwbHgULa+KvogrTVR+s2pUhM6X4Ku5/Q lZ8g== X-Gm-Message-State: ABy/qLYv347acpkpQsDsog/HN85wjcRyVkiqJ8CyRWPQyW9T4ib5D42D ognUXqw9TuHjhvSCweTbJlNvOeDIpoVlzfnmgfFVoA== X-Google-Smtp-Source: APBJJlFNt3zNTDd8n30+hBOsGttW/2vpuyETIbjQTMk9IfZfTEZpOCRSIWrvyPdbpbv4igQUtU3Q8w== X-Received: by 2002:a17:906:220c:b0:992:7594:e6b2 with SMTP id s12-20020a170906220c00b009927594e6b2mr6855198ejs.77.1691061240375; Thu, 03 Aug 2023 04:14:00 -0700 (PDT) Received: from localhost ([212.23.236.67]) by smtp.gmail.com with ESMTPSA id l12-20020a1709065a8c00b00992b2c5598csm10385936ejq.128.2023.08.03.04.13.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 04:13:59 -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 v3 12/12] devlink: use generated split ops and remove duplicated commands from small ops Date: Thu, 3 Aug 2023 13:13:40 +0200 Message-ID: <20230803111340.1074067-13-jiri@resnulli.us> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230803111340.1074067-1-jiri@resnulli.us> References: <20230803111340.1074067-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 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),