From patchwork Tue Oct 27 14:51:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 11860685 X-Patchwork-Delegate: mkubecek+ethtool@suse.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02588C388F9 for ; Tue, 27 Oct 2020 14:53:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BEBB822284 for ; Tue, 27 Oct 2020 14:53:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1776613AbgJ0Oxg (ORCPT ); Tue, 27 Oct 2020 10:53:36 -0400 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]:34571 "EHLO wout4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1773543AbgJ0OwA (ORCPT ); Tue, 27 Oct 2020 10:52:00 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 27E5416C2; Tue, 27 Oct 2020 10:51:59 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Tue, 27 Oct 2020 10:51:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=FbuojxYDFgKVoY7YEZ6pLG4DyUlV4My59IhjfH7MEp8=; b=Xj+W0mrW mWrFRomhtZW0EePxZpcm4vZHi3kl6H+mqSpABO1kyyx0t0CYCNqoPwXDFAdyub4i aybmewE/32NDAXqe40XUBzc4g0VlvpZ+USRVzB9Qb6VmnFokAFmWoqikeHYewoRQ hrDH9Ku9uPq3CH2v/lAk2PikVTg1NPldXPD9qeNh3L3pIRfc/LUFPKc1PkaYFgpu J4d7DtQ922Wfvkb9BFbhet3nz4zXijqjrMBLwUhXg+rExLBKFdTfQcurC9K/oyMo HMBbLa+HTMJzeY7yndM/yUt5hhwOg5TosT1mWIm4cRUN3spjEqqugBGWnqib5PCC gQt7tMY91tDNsQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrkeelgdeilecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtkeertd ertddtnecuhfhrohhmpefkughoucfutghhihhmmhgvlhcuoehiughoshgthhesihguohhs tghhrdhorhhgqeenucggtffrrghtthgvrhhnpeduteeiveffffevleekleejffekhfekhe fgtdfftefhledvjefggfehgfevjeekhfenucfkphepkeegrddvvdelrdduheefrdelnecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepihguohhstg hhsehiughoshgthhdrohhrgh X-ME-Proxy: Received: from shredder.mtl.com (igld-84-229-153-9.inter.net.il [84.229.153.9]) by mail.messagingengine.com (Postfix) with ESMTPA id 5A39A328006A; Tue, 27 Oct 2020 10:51:56 -0400 (EDT) From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, mkubecek@suse.cz, f.fainelli@gmail.com, andrew@lunn.ch, David.Laight@aculab.com, mlxsw@nvidia.com, Ido Schimmel Subject: [RFC PATCH ethtool 1/2] update UAPI header copies Date: Tue, 27 Oct 2020 16:51:46 +0200 Message-Id: <20201027145147.227053-2-idosch@idosch.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201027145147.227053-1-idosch@idosch.org> References: <20201027145147.227053-1-idosch@idosch.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: mkubecek+ethtool@suse.cz X-Patchwork-State: RFC From: Ido Schimmel Update to kernel commit XXX. Signed-off-by: Ido Schimmel --- uapi/linux/ethtool_netlink.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/uapi/linux/ethtool_netlink.h b/uapi/linux/ethtool_netlink.h index c022883cdb22..030f95d2ccdf 100644 --- a/uapi/linux/ethtool_netlink.h +++ b/uapi/linux/ethtool_netlink.h @@ -94,10 +94,13 @@ enum { #define ETHTOOL_FLAG_OMIT_REPLY (1 << 1) /* request statistics, if supported by the driver */ #define ETHTOOL_FLAG_STATS (1 << 2) +/* be compatible with legacy ioctl interface */ +#define ETHTOOL_FLAG_LEGACY (1 << 3) #define ETHTOOL_FLAG_ALL (ETHTOOL_FLAG_COMPACT_BITSETS | \ ETHTOOL_FLAG_OMIT_REPLY | \ - ETHTOOL_FLAG_STATS) + ETHTOOL_FLAG_STATS | \ + ETHTOOL_FLAG_LEGACY) enum { ETHTOOL_A_HEADER_UNSPEC, From patchwork Tue Oct 27 14:51:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 11861145 X-Patchwork-Delegate: mkubecek+ethtool@suse.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF517C56201 for ; Tue, 27 Oct 2020 17:25:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 90A1E222D9 for ; Tue, 27 Oct 2020 17:25:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752102AbgJ0Oxo (ORCPT ); Tue, 27 Oct 2020 10:53:44 -0400 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]:45929 "EHLO wout4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1774148AbgJ0OwC (ORCPT ); Tue, 27 Oct 2020 10:52:02 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id A1A40177E; Tue, 27 Oct 2020 10:52:01 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Tue, 27 Oct 2020 10:52:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=glr1dXXy1jKXTu4jt+ehlrOdCqohnKeGhVTZndL7yHc=; b=mfThyfPU /GWs+OwyyXDiFH44weGjCILxp/F8Axj+Xky7wb/BsFTyklzTvzoU2xuMaQzR+1eW qo6O7FIxzoACTWGpqkgZCONtgytequpJ8WxsvcP1yAFY26LDSBsDXseJjrJ6DUeu 1Mo/YhRNkz1MGsS71A4f0ugl727xp3Sz7UgVxTDxBI5pAnS5VHWkLluu90uiREcL SegqRd6+YOsrUvHtCs133fLIQelIBfVp3UUd5r/EOe9NLDvOzXRcbzDvwms7Rbxq cvDv5jX9KS9JE40OqUeWLDL8iTlUaunvDVfIrRh/e2xsf9IpNIZucddX2pJOc/Ts 42C0hXuDKD21UA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrkeelgdeilecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtkeertd ertddtnecuhfhrohhmpefkughoucfutghhihhmmhgvlhcuoehiughoshgthhesihguohhs tghhrdhorhhgqeenucggtffrrghtthgvrhhnpeduteeiveffffevleekleejffekhfekhe fgtdfftefhledvjefggfehgfevjeekhfenucfkphepkeegrddvvdelrdduheefrdelnecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepihguohhstg hhsehiughoshgthhdrohhrgh X-ME-Proxy: Received: from shredder.mtl.com (igld-84-229-153-9.inter.net.il [84.229.153.9]) by mail.messagingengine.com (Postfix) with ESMTPA id 07D9A3280064; Tue, 27 Oct 2020 10:51:58 -0400 (EDT) From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, mkubecek@suse.cz, f.fainelli@gmail.com, andrew@lunn.ch, David.Laight@aculab.com, mlxsw@nvidia.com, Ido Schimmel Subject: [RFC PATCH ethtool 2/2] netlink: Set 'ETHTOOL_FLAG_LEGACY' for compatibility with legacy ioctl interface Date: Tue, 27 Oct 2020 16:51:47 +0200 Message-Id: <20201027145147.227053-3-idosch@idosch.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201027145147.227053-1-idosch@idosch.org> References: <20201027145147.227053-1-idosch@idosch.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: mkubecek+ethtool@suse.cz X-Patchwork-State: RFC From: Ido Schimmel Set the above mentioned flag in the ethtool netlink request header of the various commands mapped to 'ethtool set' (e.g., 'ETHTOOL_MSG_LINKMODES_SET'). The purpose of the flag is to indicate to the kernel to be compatible with legacy ioctl interface. The current use case is to ensure that the kernel will advertise all the supported link modes when autoneg is enabled, but without specifying other parameters. To prevent the kernel from complaining about unknown flags, the flag is only set in the request header in case the kernel supports it. This is achieved by using the recently introduced per-operation policy dump infrastructure. Signed-off-by: Ido Schimmel --- netlink/netlink.c | 13 +++++++++++++ netlink/netlink.h | 2 ++ netlink/parser.c | 5 ++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/netlink/netlink.c b/netlink/netlink.c index f655f6ea25b7..11c5a639f381 100644 --- a/netlink/netlink.c +++ b/netlink/netlink.c @@ -289,6 +289,19 @@ u32 get_stats_flag(struct nl_context *nlctx, unsigned int nlcmd, return nlctx->ops_info[nlcmd].hdr_flags & ETHTOOL_FLAG_STATS; } +u32 get_legacy_flag(struct nl_context *nlctx, unsigned int nlcmd, + unsigned int hdrattr) +{ + if (nlcmd > ETHTOOL_MSG_USER_MAX || + !(nlctx->ops_info[nlcmd].op_flags & GENL_CMD_CAP_HASPOL)) + return 0; + + if (read_flags_policy(nlctx, nlctx->ethnl_socket, nlcmd, hdrattr) < 0) + return 0; + + return nlctx->ops_info[nlcmd].hdr_flags & ETHTOOL_FLAG_LEGACY; +} + /* initialization */ static int genl_read_ops(struct nl_context *nlctx, diff --git a/netlink/netlink.h b/netlink/netlink.h index c02558540218..97a1e72ff930 100644 --- a/netlink/netlink.h +++ b/netlink/netlink.h @@ -74,6 +74,8 @@ const char *get_dev_name(const struct nlattr *nest); int get_dev_info(const struct nlattr *nest, int *ifindex, char *ifname); u32 get_stats_flag(struct nl_context *nlctx, unsigned int nlcmd, unsigned int hdrattr); +u32 get_legacy_flag(struct nl_context *nlctx, unsigned int nlcmd, + unsigned int hdrattr); int linkmodes_reply_cb(const struct nlmsghdr *nlhdr, void *data); int linkinfo_reply_cb(const struct nlmsghdr *nlhdr, void *data); diff --git a/netlink/parser.c b/netlink/parser.c index 3b25f5d5a88e..7d4d51235628 100644 --- a/netlink/parser.c +++ b/netlink/parser.c @@ -996,6 +996,7 @@ int nl_parser(struct nl_context *nlctx, const struct param_parser *params, for (parser = params; parser->arg; parser++) { struct nl_msg_buff *msgbuff; struct nlattr *nest; + u32 flags; n_params++; if (group_style == PARSER_GROUP_NONE || !parser->group) @@ -1018,9 +1019,11 @@ int nl_parser(struct nl_context *nlctx, const struct param_parser *params, goto out_free_buffs; break; case PARSER_GROUP_MSG: + flags = get_legacy_flag(nlctx, parser->group, + ETHTOOL_A_LINKINFO_HEADER); if (ethnla_fill_header(msgbuff, ETHTOOL_A_LINKINFO_HEADER, - nlctx->devname, 0)) + nlctx->devname, flags)) goto out_free_buffs; break; default: