From mboxrd@z Thu Jan 1 00:00:00 1970 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=-9.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,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 9DBACC3A5A2 for ; Sat, 24 Aug 2019 02:43:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 738DE2173B for ; Sat, 24 Aug 2019 02:43:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nic.cz header.i=@nic.cz header.b="Nu6Or/RA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726852AbfHXCnE (ORCPT ); Fri, 23 Aug 2019 22:43:04 -0400 Received: from mail.nic.cz ([217.31.204.67]:37276 "EHLO mail.nic.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725917AbfHXCnC (ORCPT ); Fri, 23 Aug 2019 22:43:02 -0400 Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id B6AD9140D20; Sat, 24 Aug 2019 04:42:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1566614579; bh=MugrABbJ8AsshZDatXz+1ocRDwPULL+0ZzKYCe8l2mE=; h=From:To:Date; b=Nu6Or/RAmhsH+sDbnw7+YKz9nZiF3Mdxpgf/4O30gloicSpv1+tz0tKWgiq51aUv9 VXCZbGHqdv7a9DO3bcKTxYiYAn54nKRboIdvBEQit+hUZzBJOBajBIJcTvXZKYP6mT P4FcXHMpLC4KPBaR+8jT+EcHK1MmyxprksBnjjMc= From: =?UTF-8?q?Marek=20Beh=C3=BAn?= To: netdev@vger.kernel.org Cc: Andrew Lunn , Vivien Didelot , Florian Fainelli , David Ahern , Stephen Hemminger , =?UTF-8?q?Marek=20Beh=C3=BAn?= Subject: [PATCH RFC net-next 2/3] net: add ndo for setting the iflink property Date: Sat, 24 Aug 2019 04:42:49 +0200 Message-Id: <20190824024251.4542-3-marek.behun@nic.cz> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190824024251.4542-1-marek.behun@nic.cz> References: <20190824024251.4542-1-marek.behun@nic.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Virus-Scanned: clamav-milter 0.100.3 at mail.nic.cz X-Virus-Status: Clean Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In DSA the iflink value is used to report to which CPU port a given switch port is connected to. Since we want to support multi-CPU DSA, we want the user to be able to change this value. Add ndo_set_iflink method into the ndo strucutre to be a pair to ndo_get_iflink. Also create dev_set_iflink and call this from the netlink code, so that userspace can change the iflink value. Signed-off-by: Marek BehĂșn --- include/linux/netdevice.h | 5 +++++ net/core/dev.c | 15 +++++++++++++++ net/core/rtnetlink.c | 7 +++++++ 3 files changed, 27 insertions(+) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 55ac223553f8..45eeb6da8583 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -1201,6 +1201,8 @@ struct tlsdev_ops; * TX queue. * int (*ndo_get_iflink)(const struct net_device *dev); * Called to get the iflink value of this device. + * int (*ndo_set_iflink)(struct net_device *dev, int iflink); + * Called to set the iflink value of this device. * void (*ndo_change_proto_down)(struct net_device *dev, * bool proto_down); * This function is used to pass protocol port error state information @@ -1415,6 +1417,8 @@ struct net_device_ops { int queue_index, u32 maxrate); int (*ndo_get_iflink)(const struct net_device *dev); + int (*ndo_set_iflink)(struct net_device *dev, + int iflink); int (*ndo_change_proto_down)(struct net_device *dev, bool proto_down); int (*ndo_fill_metadata_dst)(struct net_device *dev, @@ -2606,6 +2610,7 @@ void dev_add_offload(struct packet_offload *po); void dev_remove_offload(struct packet_offload *po); int dev_get_iflink(const struct net_device *dev); +int dev_set_iflink(struct net_device *dev, int iflink); int dev_fill_metadata_dst(struct net_device *dev, struct sk_buff *skb); struct net_device *__dev_get_by_flags(struct net *net, unsigned short flags, unsigned short mask); diff --git a/net/core/dev.c b/net/core/dev.c index 49589ed2018d..966bab196694 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -693,6 +693,21 @@ int dev_get_iflink(const struct net_device *dev) } EXPORT_SYMBOL(dev_get_iflink); +/** + * dev_set_iflink - set 'iflink' value of an interface + * @dev: target interface + * @iflink: new value + * + * Change the interface to which this interface is linked to. + */ +int dev_set_iflink(struct net_device *dev, int iflink) +{ + if (dev->netdev_ops && dev->netdev_ops->ndo_set_iflink) + return dev->netdev_ops->ndo_set_iflink(dev, iflink); + + return -EOPNOTSUPP; +} + /** * dev_fill_metadata_dst - Retrieve tunnel egress information. * @dev: targeted interface diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 1ee6460f8275..106d5e23ae6f 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -2507,6 +2507,13 @@ static int do_setlink(const struct sk_buff *skb, status |= DO_SETLINK_MODIFIED; } + if (tb[IFLA_LINK]) { + err = dev_set_iflink(dev, nla_get_u32(tb[IFLA_LINK])); + if (err) + goto errout; + status |= DO_SETLINK_MODIFIED; + } + if (tb[IFLA_CARRIER]) { err = dev_change_carrier(dev, nla_get_u8(tb[IFLA_CARRIER])); if (err) -- 2.21.0