Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp528770imp; Wed, 20 Feb 2019 04:37:30 -0800 (PST) X-Google-Smtp-Source: AHgI3IYTzicWhbImpG5UomQnwLlQvInn1JS249R+uqEjozWiknPWEJy1/iNFKpcPXrXlwazu4ylM X-Received: by 2002:a17:902:e486:: with SMTP id cj6mr36316890plb.86.1550666250055; Wed, 20 Feb 2019 04:37:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550666250; cv=none; d=google.com; s=arc-20160816; b=DyP5e1lK7loUlFg21C5pjavcDe9QU0TgG7NsWnFX6zJN8rnT/CRnPWUYB7K59hAyIc dAnpxZu+sDeQwgQDe3qJU8W7+5TxCK4Rhg+HKJ+h2RvfMKock6SYu/jGVTftPsVugrsH c44ifyhF+nftKNAGvgSSyxfio0rDDIjQEUjVa/yS48C913XS8NzZg2LpynXzZhwa/UUl bHeRInoQ3j7tZKhJJmztEbzlyvsD1LObCKTheiepoG1nxrP603O+TkX0/Xdbrra1MMba 3zSTVmLVktD/TdL9j1dgzUuM09NAtMUg3zXFo/6hucz5MUTLEWfM254+4w8be3z3Fs/V f9+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=zcQ3Vl05gmhZ2X00ViZeTUwrQb0cp3yjs/2jwbFqKUk=; b=sHoeqJh93Pf9UuqBV4AB1WwW6CGGJEwCDZxoppqwDFKBuvbnjT9vv1rrCI09s9zZl5 GN8Fbtg7shBdGrtcq9fnM6Kd/c+N5buzhcs7d+PGAh6AyzGXeju3u0tS3UDzuFaDvVJO nFaREM1/468tX4ZBULDGlSiA5Pwpv/hKjoupNham+smU70aaAUzRwJc4wl0QaprZDCg2 fRx8N9FC7UuDIhOH3T1M1ZZYX+aShw0+OT7hCQVuSUFRuewMPRNdrG42lShOz8ldyXDW RBO3cIz3Fyp9R+eRkRBr1pUGJ/QClfNfmGQg6cwbTnqcSblp8cg8p3E03sGdVuzYpe7I KiUA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p1si19585965pld.353.2019.02.20.04.37.14; Wed, 20 Feb 2019 04:37:30 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727967AbfBTMev (ORCPT + 99 others); Wed, 20 Feb 2019 07:34:51 -0500 Received: from mx2.suse.de ([195.135.220.15]:44506 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726805AbfBTMev (ORCPT ); Wed, 20 Feb 2019 07:34:51 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id A13F6AE65; Wed, 20 Feb 2019 12:34:47 +0000 (UTC) Received: by unicorn.suse.cz (Postfix, from userid 1000) id 08709E00A5; Wed, 20 Feb 2019 13:34:46 +0100 (CET) Date: Wed, 20 Feb 2019 13:34:46 +0100 From: Michal Kubecek To: Jakub Kicinski Cc: netdev@vger.kernel.org, David Miller , Andrew Lunn , Jiri Pirko , linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH net-next v3 10/21] ethtool: provide string sets with GET_STRSET request Message-ID: <20190220123445.GH23151@unicorn.suse.cz> References: <20190219185610.4c6aa82a@cakuba.netronome.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190219185610.4c6aa82a@cakuba.netronome.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 19, 2019 at 06:56:10PM -0800, Jakub Kicinski wrote: > On Mon, 18 Feb 2019 19:22:14 +0100 (CET), Michal Kubecek wrote: > > Requests a contents of one or more string sets, i.e. indexed arrays of > > strings; this information is provided by ETHTOOL_GSSET_INFO and > > ETHTOOL_GSTRINGS commands of ioctl interface. There are three types of > > requests: > > > > - no NLM_F_DUMP, no device: get "global" stringsets > > - no NLM_F_DUMP, with device: get string sets related to the device > > - NLM_F_DUMP, no device: get device related string sets for all devices > > > > It's possible to request all string sets of given type or only specific > > sets. With ETHA_STRSET_COUNTS flag, only set sizes (number of strings) are > > returned. > > > +GET_STRSET > > +---------- > > + > > +Requests contents of a string set as provided by ioctl commands > > +ETHTOOL_GSSET_INFO and ETHTOOL_GSTRINGS. String sets are not user writeable so > > +that the corresponding SET_STRSET message is only used in kernel replies. > > +There are two types of string sets: global (independent of a device, e.g. > > +device feature names) and device specific (e.g. device private flags). > > + > > +Request contents: > > + > > + ETHA_STRSET_DEV (nested) device identification > > + ETHA_STRSET_COUNTS (flag) request only string counts > > + ETHA_STRSET_STRINGSET (nested) string set to request > > + ETHA_STRINGSET_ID (u32) set id > > + > > +Kernel response contents: > > + > > + ETHA_STRSET_DEV (nested) device identification > > + ETHA_STRSET_STRINGSET (nested) string set to request > > Is it common to put the device information outside of the main > attribute nest? There may be multiple string sets (ETHA_STRSET_STIRNGSET nests) in one message but they would be either all global or all related to the same device. If string sets for multiple devices are sent, it would be in response to a dump request and there would be one message per device. > > > + ETHA_STRINGSET_ID (u32) set id > > + ETHA_STRINGSET_COUNT (u32) number of strings > > + ETHA_STRINGSET_STRINGS (nested) array of strings > > + ETHA_STRING_INDEX (u32) string index > > + ETHA_STRING_VALUE (string) string value > > + > > +ETHA_STRSET_DEV, if present, identifies the device to request device specific > > +string sets for. Depending on its presence a and NLM_F_DUMP flag, there are > > +three type of GET_STRSET requests: > > + > > + - no NLM_F_DUMP, no device: get "global" stringsets > > + - no NLM_F_DUMP, with device: get string sets related to the device > > + - NLM_F_DUMP, no device: get device related string sets for all devices > > + > > +If there is no ETHA_STRSET_STRINGSET attribute, all string sets of requested > > +type are returned, otherwise only those specified in the request. Flag > > +ETHA_STRSET_COUNTS tells kernel to only return string counts of the sets, not > > +the actual strings. > > + > > + > > > +static int get_strset_id(const struct nlattr *nest, u32 *val, > > + struct genl_info *info) > > +{ > > + struct nlattr *tb[ETHA_STRINGSET_MAX + 1]; > > + int ret; > > + > > + ret = nla_parse_nested(tb, ETHA_STRINGSET_MAX, nest, stringset_policy, > > + info ? info->extack : NULL); > > Would it make sense to use strict parsing everywhere from the start? > You seem to add REJECTS, but won't attributes > max get ignored? Good point, I forgot about this when the strict checking helpers were added. I'll change the uses of nlmsg_parse() and nla_parse_nested() to their strict variants (and add nla_parse_nested_strict()). Michal