From patchwork Fri Aug 5 23:41:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacob Keller X-Patchwork-Id: 12937896 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E62A9C00140 for ; Fri, 5 Aug 2022 23:42:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241878AbiHEXmE (ORCPT ); Fri, 5 Aug 2022 19:42:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241873AbiHEXmD (ORCPT ); Fri, 5 Aug 2022 19:42:03 -0400 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C915C18E27 for ; Fri, 5 Aug 2022 16:42:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1659742922; x=1691278922; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=2CggSbVU5QuQxncKXN9E4rdMkm0fwYXPcMP+bci8tPo=; b=Jb2i8H5IJleL/PSoAVyu1YdsoZ6yV+llJuq9QDajvADts10DP0k8eWyn yZrkojV5qDbTqZzUAVeLRGbXOr7PjfO5i/HD5oFKow1c7iceOAmhWW0tp SE9m55W+QH4IMV1UPTVWOgdFpRFnsuPds1Z0ODa0kjjkt/ya39SHxusF5 D/xWoNOOR+CCPg3xoaO7x+49PZWcxDrBwek5ZKmakm+pMbFxf4IITreu+ +LlHN3HrG2TSuvwQZQYbx4Sa1pEo9+i687hUQMFil8HerePqgpn0OjSLS IpZEVf+wvkfysl/m4jshSmr1mRL1GgbAKw6u2aMqCrlJKpT8UEauP3H/H Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10430"; a="289072930" X-IronPort-AV: E=Sophos;i="5.93,217,1654585200"; d="scan'208";a="289072930" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2022 16:42:02 -0700 X-IronPort-AV: E=Sophos;i="5.93,217,1654585200"; d="scan'208";a="931401645" Received: from jekeller-desk.amr.corp.intel.com (HELO jekeller-desk.jekeller.internal) ([10.166.241.7]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2022 16:42:02 -0700 From: Jacob Keller To: netdev@vger.kernel.org Cc: Jacob Keller , Jonathan Corbet , Jiri Pirko , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , David Ahern , Stephen Hemminger Subject: [RFC iproute2 0/6] devlink: add policy check for all attributes Date: Fri, 5 Aug 2022 16:41:49 -0700 Message-Id: <20220805234155.2878160-1-jacob.e.keller@intel.com> X-Mailer: git-send-email 2.37.1.208.ge72d93e88cb2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: dsahern@gmail.com X-Patchwork-State: RFC This series implements code to check the kernel policy for the devlink commands to determine whether or not attributes are supported before adding them to netlink messages. It implements a new mnlu_gen_get_op_policy to extract the policy information, and uses it to implement checks when parsing option arguments. This is intended to eventually go along with improvements to the policy reporting in devlink kernel code to report separate policy for each command. I think checking every attribute makes sense and is easier to follow than only checking specific attributes. This will help ensure that future attributes don't accidentally get sent to commands when they aren't supported (once the devlink kernel policy is improved to report correct information for each command separately). Cc: Jacob Keller Cc: Jonathan Corbet Cc: Jiri Pirko Cc: "David S. Miller" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: David Ahern Cc: Stephen Hemminger Cc: netdev@vger.kernel.org Jacob Keller (6): mnlg: remove unnused mnlg_socket structure utils: extract CTRL_ATTR_MAXATTR and save it mnl_utils: add function to dump command policy devlink: use dl_no_arg instead of checking dl_argc == 0 devlink: remove dl_argv_parse_put devlink: check attributes against policy devlink/devlink.c | 846 ++++++++++++++++++++++++++++++-------------- devlink/mnlg.c | 8 - include/mnl_utils.h | 28 ++ lib/mnl_utils.c | 258 +++++++++++++- 4 files changed, 858 insertions(+), 282 deletions(-)