Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2706823ybp; Thu, 10 Oct 2019 11:19:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqzK6rSvEmgblpkiN+10p7lJjxUR33ljccug61JBQteCzkGbymsCXmZ+d/Tc15tWueEb7YaG X-Received: by 2002:a05:6402:21e8:: with SMTP id ce8mr9596990edb.32.1570731587877; Thu, 10 Oct 2019 11:19:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570731587; cv=none; d=google.com; s=arc-20160816; b=Pztx79yqak9iHHfknn/xloVkS+0VbrEroPpbqw8a1imRN7Hc+CYUvz0hPf9/YHhk/7 eXT59/AbNgBU8ZB/srlguhy5L0pzPHeU2XNTlgMJiS4WtzfYXMYqGX9IbnKKQ6npe0r6 g2xWHCpQX3p4MFKWM6rfFiduHf2pYbPFttbmUMisxpzKzMFhpZONaQv/lYLBiWasmbXu 0d7G/VPLY/05BnOtZ9Yz5VoTVBrVFvkw9hr9wlu/YqqDN+BvaN61OK58WhHMLwA2omoZ qXRefWQWqR7iGiXa1kA5s8kRcKibfQ4t2IjjZvV7rP3ousTbnAWVeiAsiXrRUtBhmmN6 2MtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=omH3EOuY44On1IlGHojkkJvGxdfNlS6mahPy+B+WKiY=; b=yByB/jkQlFpltovbbJVD9+w7bovOHP78pLzRCpqnfQSpWSqOUh4wnz02lj4T42EfXT ByHLoF/tHU3UYVaLLC7Wc3FR6DwXjhTEBRt9Hg2BgtlAQOmCnlt9Y4wQnrEyUYQAT866 PaD9tVJD5CmsXg3riP9gnbKohS0YmHQEbY4TOpA6eETCtk/oBefZc37Ts7pwlahi24uA +ya1Q9HTk7jbR0ReTVcm7VLwEZ3nGVaK1Y5JVxjklIWcd4tWMTTwRSzF4jfKF95vBhLw lyBkM3SWSvwmNjN62CaqMVU5Pt2G4DuAkgfoa9nxfZpk4Uwxa0zcAakQW/NDx6dYjsuz kOJw== 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 y50si4131717edd.237.2019.10.10.11.19.24; Thu, 10 Oct 2019 11:19:47 -0700 (PDT) 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 S1726981AbfJJSSX (ORCPT + 99 others); Thu, 10 Oct 2019 14:18:23 -0400 Received: from s3.sipsolutions.net ([144.76.43.62]:44704 "EHLO sipsolutions.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726832AbfJJSSX (ORCPT ); Thu, 10 Oct 2019 14:18:23 -0400 Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.92.2) (envelope-from ) id 1iId0p-0002lF-Lv; Thu, 10 Oct 2019 20:18:07 +0200 Message-ID: Subject: Re: [PATCH net-next v7 09/17] ethtool: generic handlers for GET requests From: Johannes Berg To: Michal Kubecek , netdev@vger.kernel.org Cc: Jiri Pirko , David Miller , Jakub Kicinski , Andrew Lunn , Florian Fainelli , John Linville , Stephen Hemminger , linux-kernel@vger.kernel.org Date: Thu, 10 Oct 2019 20:18:05 +0200 In-Reply-To: <20191010180401.GD22163@unicorn.suse.cz> References: <20191010135639.GJ2223@nanopsycho> <20191010180401.GD22163@unicorn.suse.cz> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.30.5 (3.30.5-1.fc29) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2019-10-10 at 20:04 +0200, Michal Kubecek wrote: > > The only thing I don't like about the genetlink infrastructure is the > design decision that policy and corresponding maxattr is an attribute of > the family rather than a command. This forces anyone who wants to use it > to essentially have one common message format for all commands and if > that is not possible, to do what you suggest above, hide the actual > request into a nest. > > Whether you use one common attribute type for "command specific nest" or > different attribute for each request type, you do not actually make > things simpler, you just move the complexity one level lower. You will > still have to do your own (per request) parsing of the actual request, > the only difference is that you will do it in a different place and use > nla_parse_nested() rather than nlmsg_parse(). > > Rather than bending the message layout to fit into the limitations of > unified genetlink parsing, I prefer to keep the logical message > structure and do the parsing on my own. I can't really agree with this. Having a common format is way more accessible. Generic netlink (now) even exposes the policy (if set) and all of its nested sub-policies to userspace (if you use NLA_POLICY_NESTED), so it's very easy to discover what's in the policy and how it'll be interpreted. This makes it really easy to have tools for introspection, or have common debugging tools that just understand the message format based on the kernel's policy. It's also much easier this way to not mess up things like "attribute # 7 always means a netdev index". You solved that by nesting the common bits, though the part about ETHTOOL_A_HEADER_RFLAGS actually seems ... wrong? Shouldn't that have been somewhere else? Or does that mean each and every request_policy has to have this at the same index? That sounds error prone ... But you even have *two* policies for each kind of message, one for the content and one for the header...? It almost seems though that your argument isn't so much on the actual hierarchy/nesting structure of the message itself, but the easy of parsing it? I have thought previous that it might make sense to create a hierarchical representation of the message, with the nested TBs pre- parsed too in generic netlink, so you wouldn't just have a common attrbuf but (optionally) allocate nested attrbufs for those nested attributes that are present, and give a way of accessing those. I really do think that a single policy that's exposed for introspection and links its nested sub-policies for the different sub-commands (which are then also exposed to introspection) is much superior to having it all just driven by the code like this. johannes