From patchwork Sat Jun 12 08:20:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 459154 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp1612484jae; Sat, 12 Jun 2021 01:13:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbryE47PUcxBJ1q4eO4rFwbrKLJ4RYoAvnMUfYxYpa4hU5/lN1cGFEU9gvjEzyU0jq08A4 X-Received: by 2002:a17:906:fa93:: with SMTP id lt19mr7290896ejb.54.1623485588775; Sat, 12 Jun 2021 01:13:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623485588; cv=none; d=google.com; s=arc-20160816; b=gope9sa89d4pM3zzQLA8tQdqlPvkPvjCRlbWAmZwK6Aoc/QhJ+Ql7PJP/uZONO+IJ1 9zzxYz9+sNIfIQTyI1wgI3qn8WMYrPp2u1KOXrWsne5716pNgb23jr5ccbSutTaO5gk1 hPEo/mo9x5fEmvX569IxWc8Z0DzdPYSL4XsIMI2MmGEYxAbyoZB+yVv4xnudOPSvktFt tZ2AabIV7QJ8vWlEs7iWTsMJM0mdmdZJnGmL3xh2M7gJi8rWj06s0yapoN1wQ8u0LTHY +4DhfHH/dlTIeJeNgpwMT6vswRhA/OXEn+DqwyPXDV3Ta8XPBUknOfdJvFY/qdO48RzY 4UtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=d82HDQRFWnDbNi3qCp9COZeIUQc4rHUgiYVZqY067LM=; b=pZGdxrpngrScKXdci9Nj5pa8wK7Yi7N3w0hJg2aeUsekvj7pfImNMHieHbfAEQejee oN55Wv0SfpEi/KVYp7ngKkNv1WgWkamtxw6w98a092X/0SuKN3GYw6pyD9+uu4hzrhgy piHHaokEsgsEAmW+Vtak+xjtf4EJ3Of5Gotd9ONv/pcvK9Mw9CnWlYqzr20BYwHhQJud id6b+c1qXvY2rLtCNrvUaa2N+uk2WdZtLfoeQQEg1c0DrRKq0FxIZx2SdnkIsysnKWE2 gvft0AO4khGMkNuNDhNW8P/k4ZEdcxq5C+/UdFDZu6zPbcw4lZkBOspdJlmLcAL6D1HO wC/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=R6A2j60Y; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h1si6728008ejo.462.2021.06.12.01.13.08; Sat, 12 Jun 2021 01:13:08 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=R6A2j60Y; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231168AbhFLIOf (ORCPT + 8 others); Sat, 12 Jun 2021 04:14:35 -0400 Received: from mail-wr1-f47.google.com ([209.85.221.47]:34376 "EHLO mail-wr1-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231153AbhFLIOd (ORCPT ); Sat, 12 Jun 2021 04:14:33 -0400 Received: by mail-wr1-f47.google.com with SMTP id q5so8437383wrm.1 for ; Sat, 12 Jun 2021 01:12:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=d82HDQRFWnDbNi3qCp9COZeIUQc4rHUgiYVZqY067LM=; b=R6A2j60YLlbeT3YrQ2AiDVrCQIraxuNnUKNiXbFzDcmEJJakInW5Fpowq4zg/uFfFl lw/hRSlF1kYbt1qvfKB1eG0l/P3hbe3POyNY+Zd9Y2SAz0PpdN/RpRVjsK1Q81iSjv7b gS7nyqaNQG019gyHW3bz2gL8e+ZIygrD47pBeBl+vkAiurO4/ZKpqQZY+1nffrZCeUBS msOE1siKqHUpWFr4DF5sqL3hc6qoTIpS7H0FLjeynhLDpijNOxwOuQYjicGma8jO8zzo fh9ZAehBMiqZv/JPzZzAivMIXZIY9w2xnvU71i8sBtBwOwKE4Z0XypyyMG61+7Ojbm97 8NNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=d82HDQRFWnDbNi3qCp9COZeIUQc4rHUgiYVZqY067LM=; b=PpPhwz2fl3ViK+FWXzsJ+QaHtvIlMXCopEmah/cS8OmbNeCqIxTD5MeQnxY0yfiEWM PaCLF5+REKnTCs0pR7XsLYPzCjRLHPNqyXnb7RkDNsOsBKYE8N1sRab8DUtZjxyIaId2 oumQZhYWAu4gjmeavnOUfPh6cjB+iOgCz9sWSUXAkw1e+MIf++4rolJkT7/D4zNnQrcY vbNFxU19zJ9ZYdE75Nf5YVHu889UYuOvElC6DVxBgMdeXH7bB2wIvIfJu7hqGYdjoVqu 26nhBnzQf9d8HykErRYqZK6e9LnbS3y+xRGe0xm/H1EjJg0DXSCT1GzduK9niKQqqwEs HZEg== X-Gm-Message-State: AOAM531r+HbwPkGIT9VCDcXvthw4d5DALU8StghrlJ0WlxEykjLJDAOZ x7/kWotHNr0Xn/r0h1xNAlTScg== X-Received: by 2002:adf:fd90:: with SMTP id d16mr7979750wrr.35.1623485481147; Sat, 12 Jun 2021 01:11:21 -0700 (PDT) Received: from localhost.localdomain ([2a01:e0a:82c:5f0:85ed:406e:1bc4:a268]) by smtp.gmail.com with ESMTPSA id w13sm10619313wrc.31.2021.06.12.01.11.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 12 Jun 2021 01:11:20 -0700 (PDT) From: Loic Poulain To: kuba@kernel.org, davem@davemloft.net Cc: netdev@vger.kernel.org, m.chetan.kumar@intel.com, johannes.berg@intel.com, leon@kernel.org, ryazanov.s.a@gmail.com, parav@nvidia.com, Loic Poulain Subject: [PATCH net-next v3 2/4] rtnetlink: add IFLA_PARENT_[DEV|DEV_BUS]_NAME Date: Sat, 12 Jun 2021 10:20:55 +0200 Message-Id: <1623486057-13075-3-git-send-email-loic.poulain@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1623486057-13075-1-git-send-email-loic.poulain@linaro.org> References: <1623486057-13075-1-git-send-email-loic.poulain@linaro.org> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Johannes Berg In some cases, for example in the upcoming WWAN framework changes, there's no natural "parent netdev", so sometimes dummy netdevs are created or similar. IFLA_PARENT_DEV_NAME is a new attribute intended to contain a device (sysfs, struct device) name that can be used instead when creating a new netdev, if the rtnetlink family implements it. As suggested by Parav Pandit, we also introduce IFLA_PARENT_DEV_BUS_NAME attribute in order to uniquely identify a device on the system (with bus/name pair). ip-link(8) support for the generic parent device attributes will help us avoid code duplication, so no other link type will require a custom code to handle the parent name attribute. E.g. the WWAN interface creation command will looks like this: $ ip link add wwan0-1 parent-dev wwan0 type wwan channel-id 1 So, some future subsystem (or driver) FOO will have an interface creation command that looks like this: $ ip link add foo1-3 parent-dev foo1 type foo bar-id 3 baz-type Y Below is an example of dumping link info of a random device with these new attributes: $ ip --details link show wlp0s20f3 4: wlp0s20f3: mtu 1500 qdisc noqueue state UP mode DORMANT group default qlen 1000 ... parent_bus pci parent_dev 0000:00:14.3 Co-developed-by: Sergey Ryazanov Signed-off-by: Sergey Ryazanov Co-developed-by: Loic Poulain Signed-off-by: Loic Poulain Suggested-by: Sergey Ryazanov Signed-off-by: Johannes Berg --- include/uapi/linux/if_link.h | 7 +++++++ net/core/rtnetlink.c | 10 ++++++++++ 2 files changed, 17 insertions(+) -- 2.7.4 diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h index a5a7f0e..4882e81 100644 --- a/include/uapi/linux/if_link.h +++ b/include/uapi/linux/if_link.h @@ -341,6 +341,13 @@ enum { IFLA_ALT_IFNAME, /* Alternative ifname */ IFLA_PERM_ADDRESS, IFLA_PROTO_DOWN_REASON, + + /* device (sysfs) name as parent, used instead + * of IFLA_LINK where there's no parent netdev + */ + IFLA_PARENT_DEV_NAME, + IFLA_PARENT_DEV_BUS_NAME, + __IFLA_MAX }; diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 92c3e43..170e97f 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -1821,6 +1821,16 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, if (rtnl_fill_prop_list(skb, dev)) goto nla_put_failure; + if (dev->dev.parent && + nla_put_string(skb, IFLA_PARENT_DEV_NAME, + dev_name(dev->dev.parent))) + goto nla_put_failure; + + if (dev->dev.parent && dev->dev.parent->bus && + nla_put_string(skb, IFLA_PARENT_DEV_BUS_NAME, + dev->dev.parent->bus->name)) + goto nla_put_failure; + nlmsg_end(skb, nlh); return 0;