Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6830983rwb; Tue, 22 Nov 2022 20:41:22 -0800 (PST) X-Google-Smtp-Source: AA0mqf4WJ0LeIftqYdU9xL2YNCZcs8nZkVuAi3M61bURuwG9ZiPw1YMH/7Q6tcluFrBq0bjYjL9X X-Received: by 2002:a05:6402:2908:b0:469:770e:ef0a with SMTP id ee8-20020a056402290800b00469770eef0amr6838335edb.205.1669178482095; Tue, 22 Nov 2022 20:41:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669178482; cv=none; d=google.com; s=arc-20160816; b=GZSD/uxGydbXznCrBwZ7ItVRVhHTLnYZ7nMQrsnwtkOBy0ePzc0NhIB9rMaEX/IfnW qNTgDeQfjCMDuudg9VPbyyjLjF0BxWw9jZwNFo8BxkJIb4Oqmty38RNje6xbfzRK57tE Vz0RWMTcoD5ujQV7Ycu7wZ5wxXxgjyc4SVSvTJsM72d6M5piSKf0JhLaES/2hq1EB4mC lGAVnMjXDCKxD+fXIFk7TD7IaWVdlPVBrXtWmMSWI9fpVwpl4tctBZigf7PukdtYVL3j LEfjk//dTLW9KSpddVE13PB5mJnxu73B6rVvOa870pxaa9YhnjA94/MNdOZZGptxeB4B sFOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=xQd2qMOGyBMaPDtFAwFK275+4OFfjXqZAHI5DWC0Auo=; b=IQhcgmq0OaI3aZRdBgXf6bfZY/UZ+qNKAK8SzgaYCd9uAVqHU0wCCxL9HNjPKBGWMv sGPGayx02aqER1vMTS7XpxMQpHN+pRKcPlfGT3o+HuS3CY+kxuYHer8fTTsx052pXqC0 tz4TzWvpLkOnlKGwYdEZER1yFm5qNKrzTHG+UazER9kt1YiATyExC9s6/yg7w/cVaXny ZTIrhjiD1kMvKkVGdVjC9mhhi6ACUn+AqOAHNVuUVtXv/9A90hk+G/K0pTGIMJel3j/1 rNpSxBpeaLH9/lNQNNDk6CnwcsyIJYh4uQ1gh+vHhysDNdwPhpCQROC0LdNLBkCnbYwk 7qKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=U7RoLHwb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qf8-20020a1709077f0800b007ba16fcfefdsi377554ejc.936.2022.11.22.20.40.56; Tue, 22 Nov 2022 20:41:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=U7RoLHwb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235771AbiKWENS (ORCPT + 89 others); Tue, 22 Nov 2022 23:13:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235750AbiKWENA (ORCPT ); Tue, 22 Nov 2022 23:13:00 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3B09641E; Tue, 22 Nov 2022 20:12:48 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 48A3861A25; Wed, 23 Nov 2022 04:12:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 57845C4347C; Wed, 23 Nov 2022 04:12:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669176767; bh=+72b3XhG2hPjlw3D+lPFi2jw3BBqLoiKOxT5UPam+fY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=U7RoLHwb0Kgj69uEoGmbFN5sk15Fh8gO8XnOvlhonv9vf0YHKwcobObTleIRQaKL3 5+AblBNFX4f1LKPkRGYQd6S/K/ePrAGFdAcY0so1yFnL83T13+B5nuHSjlBJsGDXAC CQ7oov/7E5rWNFzUG85So/1TJQU50FWq109b5O3oetMU4cTDlYFXj0vt0KdaVkd7v2 2PFkMFQlJgFSKyfzfgB4aiox/k7rLkAQ8U7SJXauqTLy/6yC7MkV4MPN0bLHmBlDN3 /vROvvyQkcpjVxsZByWtXyujizr74ms/pR6lmDxO6ch7rek5951eYOOM3mLK1guBJA BPhH5jSAZz6rQ== Date: Tue, 22 Nov 2022 20:12:46 -0800 From: Jakub Kicinski To: Vincent Mailhol Cc: Jiri Pirko , netdev@vger.kernel.org, "David S . Miller" , Eric Dumazet , Paolo Abeni , linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH] net: devlink: devlink_nl_info_fill: populate default information Message-ID: <20221122201246.0276680f@kernel.org> In-Reply-To: <20221122154934.13937-1-mailhol.vincent@wanadoo.fr> References: <20221122154934.13937-1-mailhol.vincent@wanadoo.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 23 Nov 2022 00:49:34 +0900 Vincent Mailhol wrote: > static int > devlink_nl_info_fill(struct sk_buff *msg, struct devlink *devlink, > enum devlink_command cmd, u32 portid, > u32 seq, int flags, struct netlink_ext_ack *extack) > { > struct devlink_info_req req = {}; > + struct device *dev = devlink_to_dev(devlink); nit: longest to shortest lines > void *hdr; > int err; > > @@ -6707,6 +6733,16 @@ devlink_nl_info_fill(struct sk_buff *msg, struct devlink *devlink, > if (err) > goto err_cancel_msg; > > + err = devlink_nl_driver_info_get(dev->driver, &req); > + if (err) > + goto err_cancel_msg; won't this result in repeated attributes, potentially? Unlike ethtool which copies data into a struct devlink adds an attribute each time you request. It does not override. So we need to extend req with some tracking of whether driver already put in the info in question > + if (!strcmp(dev->parent->type->name, "usb_device")) { > + err = devlink_nl_usb_info_get(to_usb_device(dev->parent), &req); > + if (err) > + goto err_cancel_msg; > + }