From patchwork Wed Dec 20 01:47:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Wei X-Patchwork-Id: 13499432 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-il1-f178.google.com (mail-il1-f178.google.com [209.85.166.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6887A8827 for ; Wed, 20 Dec 2023 01:47:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=davidwei.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=davidwei.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=davidwei-uk.20230601.gappssmtp.com header.i=@davidwei-uk.20230601.gappssmtp.com header.b="HQ+etCdI" Received: by mail-il1-f178.google.com with SMTP id e9e14a558f8ab-35fb96f3404so8500275ab.2 for ; Tue, 19 Dec 2023 17:47:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=davidwei-uk.20230601.gappssmtp.com; s=20230601; t=1703036870; x=1703641670; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ink5cy61/xEFj7DTnQzb0Xv/R0xZT7Aw5SRjnGefOho=; b=HQ+etCdIgmv91RayXEJ/rMAiqQoHKo1ag6o4jyevgBnjArsMk4QcegVpdmWz91zH0V YCRqMviyP2X2Iia1gE2YtNlNiCtJTk+lnKW6FoEQ8AEnDxNuLn8W4XKbbAK07sMVt62J KSDRqrILGlsDbgRllqB243FPkkRcBl4Zt4Yv1Ae9dPK4fJzo+4mJZXI1xilXIqsjqpC8 MbCJSMvpHNGDHVcVhpWJKboQPi0Eh4vy6817L3mem2HH9rs2qK+VGlt+EUEhsI7oFJbl c1cuOJONLFMUpv2KNeeLuJOXJG79q+HxMWk2R4OPBX1B96TJda2GuYtnDDIkjGX1QVfC 7GgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703036870; x=1703641670; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ink5cy61/xEFj7DTnQzb0Xv/R0xZT7Aw5SRjnGefOho=; b=XlLgNmy8mz+UGQIeDYMnnybFTK9i/PqyrzZe0SzpQMj8qLC1taXUPuqc/sanqsl8XS h7ZyikuQpAyRmPqt5rT3ieDlSRt9altsNgx7iay6YfMcbpJQeiG4J56mn8LWzAj0xX7l FPWMA9qcyXegtdUydIf+lLtmKlSU8hHSLSnNxgYn2T1wVeu42u9BGZiQTdWt3BUOuAyq xOXf+xGVay2h/Cd3CLkW8k5mOEBu73O7XRvi6JMGKH4G1ARxbPKG2BNVuvO6vPU1iOaN CtSZm19gSljjBeXS5CxRW7UPxUgkfNeWluyLuG9mxMXzYHcmLSS/vbMvacsbU75Et2YC xqSg== X-Gm-Message-State: AOJu0YztD+XKffYIL44eC2g9pMyr/WZGvKFEDl3QN08TMbvEXpoq97d2 7PnGpzboHl1LHq0iqAfi3FszLQ== X-Google-Smtp-Source: AGHT+IHqzsB8PqHwr4LOSLr54YHN6AazAZw6Rm/HCo/2alvnYAjzXDvL7SJ4cZA/hdVQ2rBI0dbBfg== X-Received: by 2002:a05:6e02:1605:b0:35d:7ac7:359c with SMTP id t5-20020a056e02160500b0035d7ac7359cmr34093668ilu.40.1703036870488; Tue, 19 Dec 2023 17:47:50 -0800 (PST) Received: from localhost (fwdproxy-prn-015.fbsv.net. [2a03:2880:ff:f::face:b00c]) by smtp.gmail.com with ESMTPSA id 11-20020a170902c14b00b001d3bfd30886sm4241618plj.37.2023.12.19.17.47.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 17:47:50 -0800 (PST) From: David Wei To: Jakub Kicinski , Jiri Pirko , Sabrina Dubroca , netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Paolo Abeni Subject: [PATCH net-next v4 1/5] netdevsim: maintain a list of probed netdevsims Date: Tue, 19 Dec 2023 17:47:43 -0800 Message-Id: <20231220014747.1508581-2-dw@davidwei.uk> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231220014747.1508581-1-dw@davidwei.uk> References: <20231220014747.1508581-1-dw@davidwei.uk> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org This patch adds a linked list nsim_dev_list of probed netdevsims, added during nsim_drv_probe() and removed during nsim_drv_remove(). A mutex nsim_dev_list_lock protects the list. Signed-off-by: David Wei --- drivers/net/netdevsim/dev.c | 17 +++++++++++++++++ drivers/net/netdevsim/netdevsim.h | 1 + 2 files changed, 18 insertions(+) diff --git a/drivers/net/netdevsim/dev.c b/drivers/net/netdevsim/dev.c index b4d3b9cde8bd..e30a12130e07 100644 --- a/drivers/net/netdevsim/dev.c +++ b/drivers/net/netdevsim/dev.c @@ -35,6 +35,9 @@ #include "netdevsim.h" +static LIST_HEAD(nsim_dev_list); +static DEFINE_MUTEX(nsim_dev_list_lock); + static unsigned int nsim_dev_port_index(enum nsim_dev_port_type type, unsigned int port_index) { @@ -1531,6 +1534,7 @@ int nsim_drv_probe(struct nsim_bus_dev *nsim_bus_dev) nsim_bus_dev->initial_net, &nsim_bus_dev->dev); if (!devlink) return -ENOMEM; + mutex_lock(&nsim_dev_list_lock); devl_lock(devlink); nsim_dev = devlink_priv(devlink); nsim_dev->nsim_bus_dev = nsim_bus_dev; @@ -1544,6 +1548,7 @@ int nsim_drv_probe(struct nsim_bus_dev *nsim_bus_dev) spin_lock_init(&nsim_dev->fa_cookie_lock); dev_set_drvdata(&nsim_bus_dev->dev, nsim_dev); + list_add(&nsim_dev->list, &nsim_dev_list); nsim_dev->vfconfigs = kcalloc(nsim_bus_dev->max_vfs, sizeof(struct nsim_vf_config), @@ -1607,6 +1612,7 @@ int nsim_drv_probe(struct nsim_bus_dev *nsim_bus_dev) nsim_dev->esw_mode = DEVLINK_ESWITCH_MODE_LEGACY; devl_unlock(devlink); + mutex_unlock(&nsim_dev_list_lock); return 0; err_hwstats_exit: @@ -1668,8 +1674,18 @@ void nsim_drv_remove(struct nsim_bus_dev *nsim_bus_dev) { struct nsim_dev *nsim_dev = dev_get_drvdata(&nsim_bus_dev->dev); struct devlink *devlink = priv_to_devlink(nsim_dev); + struct nsim_dev *pos, *tmp; + mutex_lock(&nsim_dev_list_lock); devl_lock(devlink); + + list_for_each_entry_safe(pos, tmp, &nsim_dev_list, list) { + if (pos == nsim_dev) { + list_del(&nsim_dev->list); + break; + } + } + nsim_dev_reload_destroy(nsim_dev); nsim_bpf_dev_exit(nsim_dev); @@ -1681,6 +1697,7 @@ void nsim_drv_remove(struct nsim_bus_dev *nsim_bus_dev) kfree(nsim_dev->vfconfigs); kfree(nsim_dev->fa_cookie); devl_unlock(devlink); + mutex_unlock(&nsim_dev_list_lock); devlink_free(devlink); dev_set_drvdata(&nsim_bus_dev->dev, NULL); } diff --git a/drivers/net/netdevsim/netdevsim.h b/drivers/net/netdevsim/netdevsim.h index 028c825b86db..babb61d7790b 100644 --- a/drivers/net/netdevsim/netdevsim.h +++ b/drivers/net/netdevsim/netdevsim.h @@ -277,6 +277,7 @@ struct nsim_vf_config { struct nsim_dev { struct nsim_bus_dev *nsim_bus_dev; + struct list_head list; struct nsim_fib_data *fib_data; struct nsim_trap_data *trap_data; struct dentry *ddir; From patchwork Wed Dec 20 01:47:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Wei X-Patchwork-Id: 13499433 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-il1-f173.google.com (mail-il1-f173.google.com [209.85.166.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 56D398C02 for ; Wed, 20 Dec 2023 01:47:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=davidwei.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=davidwei.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=davidwei-uk.20230601.gappssmtp.com header.i=@davidwei-uk.20230601.gappssmtp.com header.b="xaFiK9Hl" Received: by mail-il1-f173.google.com with SMTP id e9e14a558f8ab-35f71436397so39318665ab.3 for ; Tue, 19 Dec 2023 17:47:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=davidwei-uk.20230601.gappssmtp.com; s=20230601; t=1703036871; x=1703641671; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UbsSgVUnjr/AUF6wkufHvh4W3upHoBUCqZtKEqBoGTE=; b=xaFiK9HlEyPHVqnggHRUCmd/xij57YSqpDvEUt38N4FZkoI0DVnSreDuArggfqmUat H2OFCJ2j/Yhd+RlNW+jqadSHkRl2HVMYXphoaLku0N/aHzdhVLbG+4yIoi+bjcc5F5sI eTc1xMv/wpyUKjGyApiKalzkwhGNOvhspPUQoKupObAMzlN0SbIVRhK1ATA9sm/oqnjb 1bxYxDW5EF9DTRx44zOrIm2xg2EoF0nZf5guOBKm8mW7QeB3YWBoyDh+7sOpgvkYIGXh GlnQf1mNAFDE5UEvGpDsUiIhEtpp60Y4VFFGbxpQyKY88VpdkmIIMNkL1AFeBts8vfPs dPyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703036871; x=1703641671; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UbsSgVUnjr/AUF6wkufHvh4W3upHoBUCqZtKEqBoGTE=; b=JZ1jWxriBrAdluZ/1rpbwxbAMmZoYZJrlPqGehMUUaLiYR6mMT8fYZACqvNVjN+d52 pNp2/FUEigytf/OFgxhnxiZfaFqMKjGZ+pcnxHGdLJfkwnGHM9fegxA/4Noanfw9hrSH RbSZkWZ8pE4rzr5LI/I4Tz1KD27Kn1jaqYc/mtxpXsRYIPZ2+rX1xNjWiRcGjRrpXRSD 6isGzHoKomRSrPyPFrv3YYGj7d1JgolQv8UGTAUMOyFmXtCTws6nE3Cbnq5rSkGjHhOb frL7+e0DfyL1XsLukUnOf9i/u4OtDu0wvVWMiOjtr/o15ROlCnyszWVKqYS1rb0K94k6 ym3Q== X-Gm-Message-State: AOJu0YwAx77m8NuRvG126Lh+eu9xRgO41MqyydxPbP1ArpBFsaAYte2m l+zSS7dR/eXdCq/ULZUELKnVNnQt1UQ1kZZUgfI= X-Google-Smtp-Source: AGHT+IFZS0UuvTl1L9+2/C/JU98VI3pZO/eUpqxblD3BFPxzlZeerp4t0Hxv/JVTm5+g7sVxd9r26g== X-Received: by 2002:a05:6e02:20c1:b0:35f:a119:8434 with SMTP id 1-20020a056e0220c100b0035fa1198434mr10440146ilq.46.1703036871395; Tue, 19 Dec 2023 17:47:51 -0800 (PST) Received: from localhost (fwdproxy-prn-119.fbsv.net. [2a03:2880:ff:77::face:b00c]) by smtp.gmail.com with ESMTPSA id s22-20020a170902989600b001d0b6ba60fdsm21693695plp.175.2023.12.19.17.47.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 17:47:51 -0800 (PST) From: David Wei To: Jakub Kicinski , Jiri Pirko , Sabrina Dubroca , netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Paolo Abeni Subject: [PATCH net-next v4 2/5] netdevsim: allow two netdevsim ports to be connected Date: Tue, 19 Dec 2023 17:47:44 -0800 Message-Id: <20231220014747.1508581-3-dw@davidwei.uk> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231220014747.1508581-1-dw@davidwei.uk> References: <20231220014747.1508581-1-dw@davidwei.uk> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Add a debugfs file in /sys/kernel/debug/netdevsim/netdevsimN/ports/A/peer Writing "M B" to this file will link port A of netdevsim N with port B of netdevsim M. Reading this file will return the linked netdevsim id and port, if any. nsim_dev_list_lock and rtnl_lock are held during read/write of peer to prevent concurrent modification of netdevsims or their ports. Signed-off-by: David Wei --- drivers/net/netdevsim/dev.c | 127 +++++++++++++++++++++++++++--- drivers/net/netdevsim/netdev.c | 6 ++ drivers/net/netdevsim/netdevsim.h | 1 + 3 files changed, 121 insertions(+), 13 deletions(-) diff --git a/drivers/net/netdevsim/dev.c b/drivers/net/netdevsim/dev.c index e30a12130e07..e4621861c70b 100644 --- a/drivers/net/netdevsim/dev.c +++ b/drivers/net/netdevsim/dev.c @@ -391,6 +391,117 @@ static const struct file_operations nsim_dev_rate_parent_fops = { .owner = THIS_MODULE, }; +static struct nsim_dev *nsim_dev_find_by_id(unsigned int id) +{ + struct nsim_dev *dev; + + list_for_each_entry(dev, &nsim_dev_list, list) + if (dev->nsim_bus_dev->dev.id == id) + return dev; + + return NULL; +} + +static struct nsim_dev_port * +__nsim_dev_port_lookup(struct nsim_dev *nsim_dev, enum nsim_dev_port_type type, + unsigned int port_index) +{ + struct nsim_dev_port *nsim_dev_port; + + port_index = nsim_dev_port_index(type, port_index); + list_for_each_entry(nsim_dev_port, &nsim_dev->port_list, list) + if (nsim_dev_port->port_index == port_index) + return nsim_dev_port; + return NULL; +} + +static ssize_t nsim_dev_peer_read(struct file *file, char __user *data, + size_t count, loff_t *ppos) +{ + struct nsim_dev_port *nsim_dev_port; + struct netdevsim *peer; + unsigned int id, port; + char buf[23]; + ssize_t ret; + + mutex_lock(&nsim_dev_list_lock); + rtnl_lock(); + nsim_dev_port = file->private_data; + peer = rtnl_dereference(nsim_dev_port->ns->peer); + if (!peer) + goto out; + + id = peer->nsim_bus_dev->dev.id; + port = peer->nsim_dev_port->port_index; + ret = scnprintf(buf, sizeof(buf), "%u %u\n", id, port); + ret = simple_read_from_buffer(data, count, ppos, buf, ret); + +out: + rtnl_unlock(); + mutex_unlock(&nsim_dev_list_lock); + + return ret; +} + +static ssize_t nsim_dev_peer_write(struct file *file, + const char __user *data, + size_t count, loff_t *ppos) +{ + struct nsim_dev_port *nsim_dev_port, *peer_dev_port; + struct nsim_dev *peer_dev; + unsigned int id, port; + char buf[22]; + ssize_t ret; + + if (count >= sizeof(buf)) + return -ENOSPC; + + ret = copy_from_user(buf, data, count); + if (ret) + return -EFAULT; + buf[count] = '\0'; + + ret = sscanf(buf, "%u %u", &id, &port); + if (ret != 2) { + pr_err("Format for adding a peer is \"id port\" (uint uint)"); + return -EINVAL; + } + + ret = -EINVAL; + mutex_lock(&nsim_dev_list_lock); + rtnl_lock(); + peer_dev = nsim_dev_find_by_id(id); + if (!peer_dev) + goto out; + + peer_dev_port = __nsim_dev_port_lookup(peer_dev, NSIM_DEV_PORT_TYPE_PF, + port); + if (!peer_dev_port) + goto out; + + nsim_dev_port = file->private_data; + if (nsim_dev_port == peer_dev_port) + goto out; + + rcu_assign_pointer(nsim_dev_port->ns->peer, peer_dev_port->ns); + rcu_assign_pointer(peer_dev_port->ns->peer, nsim_dev_port->ns); + ret = count; + +out: + rtnl_unlock(); + mutex_unlock(&nsim_dev_list_lock); + + return ret; +} + +static const struct file_operations nsim_dev_peer_fops = { + .open = simple_open, + .read = nsim_dev_peer_read, + .write = nsim_dev_peer_write, + .llseek = generic_file_llseek, + .owner = THIS_MODULE, +}; + static int nsim_dev_port_debugfs_init(struct nsim_dev *nsim_dev, struct nsim_dev_port *nsim_dev_port) { @@ -421,6 +532,9 @@ static int nsim_dev_port_debugfs_init(struct nsim_dev *nsim_dev, } debugfs_create_symlink("dev", nsim_dev_port->ddir, dev_link_name); + debugfs_create_file("peer", 0600, nsim_dev_port->ddir, + nsim_dev_port, &nsim_dev_peer_fops); + return 0; } @@ -1702,19 +1816,6 @@ void nsim_drv_remove(struct nsim_bus_dev *nsim_bus_dev) dev_set_drvdata(&nsim_bus_dev->dev, NULL); } -static struct nsim_dev_port * -__nsim_dev_port_lookup(struct nsim_dev *nsim_dev, enum nsim_dev_port_type type, - unsigned int port_index) -{ - struct nsim_dev_port *nsim_dev_port; - - port_index = nsim_dev_port_index(type, port_index); - list_for_each_entry(nsim_dev_port, &nsim_dev->port_list, list) - if (nsim_dev_port->port_index == port_index) - return nsim_dev_port; - return NULL; -} - int nsim_drv_port_add(struct nsim_bus_dev *nsim_bus_dev, enum nsim_dev_port_type type, unsigned int port_index) { diff --git a/drivers/net/netdevsim/netdev.c b/drivers/net/netdevsim/netdev.c index aecaf5f44374..434322f6a565 100644 --- a/drivers/net/netdevsim/netdev.c +++ b/drivers/net/netdevsim/netdev.c @@ -388,6 +388,7 @@ nsim_create(struct nsim_dev *nsim_dev, struct nsim_dev_port *nsim_dev_port) ns->nsim_dev = nsim_dev; ns->nsim_dev_port = nsim_dev_port; ns->nsim_bus_dev = nsim_dev->nsim_bus_dev; + RCU_INIT_POINTER(ns->peer, NULL); SET_NETDEV_DEV(dev, &ns->nsim_bus_dev->dev); SET_NETDEV_DEVLINK_PORT(dev, &nsim_dev_port->devlink_port); nsim_ethtool_init(ns); @@ -407,8 +408,13 @@ nsim_create(struct nsim_dev *nsim_dev, struct nsim_dev_port *nsim_dev_port) void nsim_destroy(struct netdevsim *ns) { struct net_device *dev = ns->netdev; + struct netdevsim *peer; rtnl_lock(); + peer = rtnl_dereference(ns->peer); + if (peer) + RCU_INIT_POINTER(peer->peer, NULL); + RCU_INIT_POINTER(ns->peer, NULL); unregister_netdevice(dev); if (nsim_dev_port_is_pf(ns->nsim_dev_port)) { nsim_macsec_teardown(ns); diff --git a/drivers/net/netdevsim/netdevsim.h b/drivers/net/netdevsim/netdevsim.h index babb61d7790b..24fc3fbda791 100644 --- a/drivers/net/netdevsim/netdevsim.h +++ b/drivers/net/netdevsim/netdevsim.h @@ -125,6 +125,7 @@ struct netdevsim { } udp_ports; struct nsim_ethtool ethtool; + struct netdevsim __rcu *peer; }; struct netdevsim * From patchwork Wed Dec 20 01:47:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Wei X-Patchwork-Id: 13499434 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0186A8F42 for ; Wed, 20 Dec 2023 01:47:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=davidwei.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=davidwei.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=davidwei-uk.20230601.gappssmtp.com header.i=@davidwei-uk.20230601.gappssmtp.com header.b="pgGYOQpD" Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-6d099d316a8so4790788b3a.0 for ; Tue, 19 Dec 2023 17:47:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=davidwei-uk.20230601.gappssmtp.com; s=20230601; t=1703036872; x=1703641672; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DSg5u81ARGsA2V0Hw9iYeP01VuoNONJOQ+m4l2NA7u0=; b=pgGYOQpDtfCFIuUJ8Q0KQcTH3qgR25+Pf1PeuuuSVYpEg8MenuqanBh1wL/fSb6pPm +osbJFPpBMe4QCWMLpz6Ot4+urzaWAu+cPkYriS2Rwgd7gklVmICOtIQGYfcoDGoF/c7 H+PIYIB2lHjykJSXzgKYFimx3cb47Gz+9WCgHwb8Kz7+7QssDhPlPqXgiNkeaJqk9kc0 x0EAhU/QWydLrxCHUBfhFYw/P25UoCp9jhfx3JA9Pj7q1XbBV2a9Zzo6M6+xQd3Y/ffF 3KBVg7zU48vprVp55julLRKysYLM5Q93zpmS4+1/kAyT/C9uHoM0S5H/gFxSwUZJisFp jrQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703036872; x=1703641672; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DSg5u81ARGsA2V0Hw9iYeP01VuoNONJOQ+m4l2NA7u0=; b=k/gWcDFVxiZY9ZStDNtgo8tumBzbnZH+cbH/LzR+sif3ntswrRaXxdRxpEF4/a1Zr4 JEsw9SvKP3BZXH7//1CGOTm0EZCNAsit6VgIwEieIOUlyoxqgXe8BKpOqJZwpNtccdEH OVJ0EprN26vC3EKt4CRhPsSUaqc4tqBAcRB7v+dwhSwV6XcU3Ylhx9a8E+ziuoEckvTb DwgIMI4tiC2BoxGT5QTX3FYQGlc2bjIXXSwOQB9+7znNyJjl3vOukbuXWDuzx9LGroxE AZ+Ip2grRaazS5D2BnJJ6D6QJ6x5Jj1e+ncrVsoAZcShWl1td+/XEZ7oJR+XnaiXzXjg Td2w== X-Gm-Message-State: AOJu0Yy/bP03Q0yDBwOcMoZwZE5OU4HMSU2PRu8y5wdb7WqHIOP668HD K6WviVaCR5UgLuN2HmBdc6kUjQ== X-Google-Smtp-Source: AGHT+IH7HlKSNUD7U447zMjXp6LMVCC2ZOTyRJ7TKZ1xtQ76vYFwJKjEk+pYn5m2xz6ZXL+H0loNhQ== X-Received: by 2002:a05:6a21:3286:b0:194:503d:1ab1 with SMTP id yt6-20020a056a21328600b00194503d1ab1mr5927840pzb.70.1703036872303; Tue, 19 Dec 2023 17:47:52 -0800 (PST) Received: from localhost (fwdproxy-prn-116.fbsv.net. [2a03:2880:ff:74::face:b00c]) by smtp.gmail.com with ESMTPSA id k3-20020aa792c3000000b006ce77ba135esm14236280pfa.217.2023.12.19.17.47.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 17:47:52 -0800 (PST) From: David Wei To: Jakub Kicinski , Jiri Pirko , Sabrina Dubroca , netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Paolo Abeni Subject: [PATCH net-next v4 3/5] netdevsim: forward skbs from one connected port to another Date: Tue, 19 Dec 2023 17:47:45 -0800 Message-Id: <20231220014747.1508581-4-dw@davidwei.uk> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231220014747.1508581-1-dw@davidwei.uk> References: <20231220014747.1508581-1-dw@davidwei.uk> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Forward skbs sent from one netdevsim port to its connected netdevsim port using dev_forward_skb, in a spirit similar to veth. Add a tx_dropped variable to struct netdevsim, tracking the number of skbs that could not be forwarded using dev_forward_skb(). The xmit() function accessing the peer ptr is protected by an RCU read critical section. The rcu_read_lock() is functionally redundant as since v5.0 all softirqs are implicitly RCU read critical sections; but it is useful for human readers. If another CPU is concurrently in nsim_destroy(), then it will first set the peer ptr to NULL. This does not affect any existing readers that dereferenced a non-NULL peer. Then, in unregister_netdevice(), there is a synchronize_rcu() before the netdev is actually unregistered and freed. This ensures that any readers i.e. xmit() that got a non-NULL peer will complete before the netdev is freed. Any readers after the RCU_INIT_POINTER() but before synchronize_rcu() will dereference NULL, making it safe. The codepath to nsim_destroy() and nsim_create() takes both the newly added nsim_dev_list_lock and rtnl_lock. This makes it safe with concurrent calls to linking two netdevsims together. Signed-off-by: David Wei --- drivers/net/netdevsim/netdev.c | 25 ++++++++++++++++++++++--- drivers/net/netdevsim/netdevsim.h | 1 + 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/drivers/net/netdevsim/netdev.c b/drivers/net/netdevsim/netdev.c index 434322f6a565..00ab3098eb9f 100644 --- a/drivers/net/netdevsim/netdev.c +++ b/drivers/net/netdevsim/netdev.c @@ -29,6 +29,8 @@ static netdev_tx_t nsim_start_xmit(struct sk_buff *skb, struct net_device *dev) { struct netdevsim *ns = netdev_priv(dev); + struct netdevsim *peer_ns; + int ret = NETDEV_TX_OK; if (!nsim_ipsec_tx(ns, skb)) goto out; @@ -36,12 +38,29 @@ static netdev_tx_t nsim_start_xmit(struct sk_buff *skb, struct net_device *dev) u64_stats_update_begin(&ns->syncp); ns->tx_packets++; ns->tx_bytes += skb->len; + + rcu_read_lock(); + peer_ns = rcu_dereference(ns->peer); + if (!peer_ns) + goto out_stats; + + skb_tx_timestamp(skb); + if (unlikely(dev_forward_skb(peer_ns->netdev, skb) == NET_RX_DROP)) { + ret = NET_XMIT_DROP; + ns->tx_dropped++; + } + + rcu_read_unlock(); u64_stats_update_end(&ns->syncp); + return ret; + +out_stats: + rcu_read_unlock(); + u64_stats_update_end(&ns->syncp); out: dev_kfree_skb(skb); - - return NETDEV_TX_OK; + return ret; } static void nsim_set_rx_mode(struct net_device *dev) @@ -70,6 +89,7 @@ nsim_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats) start = u64_stats_fetch_begin(&ns->syncp); stats->tx_bytes = ns->tx_bytes; stats->tx_packets = ns->tx_packets; + stats->tx_dropped = ns->tx_dropped; } while (u64_stats_fetch_retry(&ns->syncp, start)); } @@ -302,7 +322,6 @@ static void nsim_setup(struct net_device *dev) eth_hw_addr_random(dev); dev->tx_queue_len = 0; - dev->flags |= IFF_NOARP; dev->flags &= ~IFF_MULTICAST; dev->priv_flags |= IFF_LIVE_ADDR_CHANGE | IFF_NO_QUEUE; diff --git a/drivers/net/netdevsim/netdevsim.h b/drivers/net/netdevsim/netdevsim.h index 24fc3fbda791..083b1ee7a1a2 100644 --- a/drivers/net/netdevsim/netdevsim.h +++ b/drivers/net/netdevsim/netdevsim.h @@ -98,6 +98,7 @@ struct netdevsim { u64 tx_packets; u64 tx_bytes; + u64 tx_dropped; struct u64_stats_sync syncp; struct nsim_bus_dev *nsim_bus_dev; From patchwork Wed Dec 20 01:47:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Wei X-Patchwork-Id: 13499435 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B47928F71 for ; Wed, 20 Dec 2023 01:47:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=davidwei.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=davidwei.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=davidwei-uk.20230601.gappssmtp.com header.i=@davidwei-uk.20230601.gappssmtp.com header.b="UMzs563K" Received: by mail-pg1-f171.google.com with SMTP id 41be03b00d2f7-5cd82917ecfso2867281a12.0 for ; Tue, 19 Dec 2023 17:47:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=davidwei-uk.20230601.gappssmtp.com; s=20230601; t=1703036873; x=1703641673; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DhP0/KeAkEXkYbNZIC9cYiWhoMF1Ptz+Mj0ZXLXOzVQ=; b=UMzs563KxTD+JAD70Cg49Kw0b3kwetoLWt8oVcCFs6TwRThoOcToifhTIzeYDVurcr A4+36+nvqh+DUjIQTp0nEQdRBOiFmr5CU+fdEMGQdIkmMxARy9fpi7aEWNCQHky0G1wu wkQE2B++aSUZ1sdXXKSKrj5xzh5oixYP6qtKJsb28fqr9p06Fbz+QVjqn7gxgQ6tBAmQ vQ83hEEWA9UrqnHaR7EgsZ8UAVpKrJSxaJa9oIMXHjiSbOoKxDu/6u3MJ2EcdLLKyUZk ggUk8l7hHZj0l7CZTN3kbIl0fr3i1UPrlEm6dg1evkBSXjKFM6hHU+14Kbu9lXZ5gJvW 4vrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703036873; x=1703641673; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DhP0/KeAkEXkYbNZIC9cYiWhoMF1Ptz+Mj0ZXLXOzVQ=; b=R4nA9RjDU2HzNRYKCI0zCsMPShJYpWluAP/EC1GnARqG+3r/UvqY4/sS9IRP4zYp2A B2u5psv/JAcczr/AMq7fqVZXlC6/BRDUfblx1XOC4p7Azd2mB/6iCkcGJlbNaT3l3rTQ IaRojanSrarP0wJXaXTEmMpaU4boJzpO8pbVOZBz6G8DuiPlZcIVVYNWKyrnQxiT+lkZ RWI4bK2gkFokdEYf3gTRYNg71DodiRmusYTDElMLQSEJjf3jcecIDn3oK/C2noHB3bSu 7eG4/zdL5kGaLmeBxeJxFe6Ax4IoMwK/8+szelLpjONXvhmdeVnHu6FSyVSwmjOl9XOF qQLQ== X-Gm-Message-State: AOJu0YyCl/7LG5EF6yyJk3+OlOUVZSNQoJ0KV22oYS4lbzbvjv+JF1E2 eDe3x4OND+I5RoSimerSoBIpVw== X-Google-Smtp-Source: AGHT+IHRH1ES13uStC+Ujo4x+yM4O0KcqOWMrCspH2ByaznxzzFMHcctOfCJBesEVUXKABDzgs67Cw== X-Received: by 2002:a05:6a20:5492:b0:18c:90b1:7bdf with SMTP id i18-20020a056a20549200b0018c90b17bdfmr24664723pzk.53.1703036873115; Tue, 19 Dec 2023 17:47:53 -0800 (PST) Received: from localhost (fwdproxy-prn-016.fbsv.net. [2a03:2880:ff:10::face:b00c]) by smtp.gmail.com with ESMTPSA id z29-20020aa7991d000000b006d93e9c50a9sm1165243pff.110.2023.12.19.17.47.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 17:47:52 -0800 (PST) From: David Wei To: Jakub Kicinski , Jiri Pirko , Sabrina Dubroca , netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Paolo Abeni Subject: [PATCH net-next v4 4/5] netdevsim: add selftest for forwarding skb between connected ports Date: Tue, 19 Dec 2023 17:47:46 -0800 Message-Id: <20231220014747.1508581-5-dw@davidwei.uk> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231220014747.1508581-1-dw@davidwei.uk> References: <20231220014747.1508581-1-dw@davidwei.uk> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Connect two netdevsim ports in different namespaces together, then send packets between them using socat. Signed-off-by: David Wei --- .../selftests/drivers/net/netdevsim/peer.sh | 123 ++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100755 tools/testing/selftests/drivers/net/netdevsim/peer.sh diff --git a/tools/testing/selftests/drivers/net/netdevsim/peer.sh b/tools/testing/selftests/drivers/net/netdevsim/peer.sh new file mode 100755 index 000000000000..942526640d59 --- /dev/null +++ b/tools/testing/selftests/drivers/net/netdevsim/peer.sh @@ -0,0 +1,123 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0-only + +NSIM_DEV_1_ID=$((RANDOM % 1024)) +NSIM_DEV_1_SYS=/sys/bus/netdevsim/devices/netdevsim$NSIM_DEV_1_ID +NSIM_DEV_1_DFS=/sys/kernel/debug/netdevsim/netdevsim$NSIM_DEV_1_ID +NSIM_DEV_2_ID=$((RANDOM % 1024)) +NSIM_DEV_2_SYS=/sys/bus/netdevsim/devices/netdevsim$NSIM_DEV_2_ID +NSIM_DEV_2_DFS=/sys/kernel/debug/netdevsim/netdevsim$NSIM_DEV_2_ID + +NSIM_DEV_SYS_NEW=/sys/bus/netdevsim/new_device +NSIM_DEV_SYS_DEL=/sys/bus/netdevsim/del_device + +socat_check() +{ + if [ ! -x "$(command -v socat)" ]; then + echo "socat command not found. Skipping test" + return 1 + fi + + return 0 +} + +setup_ns() +{ + set -e + ip netns add nssv + ip netns add nscl + + NSIM_DEV_1_NAME=$(find $NSIM_DEV_1_SYS/net -maxdepth 1 -type d ! \ + -path $NSIM_DEV_1_SYS/net -exec basename {} \;) + NSIM_DEV_2_NAME=$(find $NSIM_DEV_2_SYS/net -maxdepth 1 -type d ! \ + -path $NSIM_DEV_2_SYS/net -exec basename {} \;) + + ip link set $NSIM_DEV_1_NAME netns nssv + ip link set $NSIM_DEV_2_NAME netns nscl + + ip netns exec nssv ip addr add '192.168.1.1/24' dev $NSIM_DEV_1_NAME + ip netns exec nscl ip addr add '192.168.1.2/24' dev $NSIM_DEV_2_NAME + + ip netns exec nssv ip link set dev $NSIM_DEV_1_NAME up + ip netns exec nscl ip link set dev $NSIM_DEV_2_NAME up + set +e +} + +cleanup_ns() +{ + ip netns del nscl + ip netns del nssv +} + +### +### Code start +### + +modprobe netdevsim + +# linking + +echo $NSIM_DEV_1_ID > $NSIM_DEV_SYS_NEW + +echo "$NSIM_DEV_2_ID 0" > ${NSIM_DEV_1_DFS}/ports/0/peer 2>/dev/null +if [ $? -eq 0 ]; then + echo "linking with non-existent netdevsim should fail" + exit 1 +fi + +echo $NSIM_DEV_2_ID > $NSIM_DEV_SYS_NEW + +echo "$NSIM_DEV_2_ID 0" > ${NSIM_DEV_1_DFS}/ports/0/peer +if [ $? -ne 0 ]; then + echo "linking netdevsim1 port0 with netdevsim2 port0 should succeed" + exit 1 +fi + +# argument error checking + +echo "$NSIM_DEV_2_ID 1" > ${NSIM_DEV_1_DFS}/ports/0/peer 2>/dev/null +if [ $? -eq 0 ]; then + echo "linking with non-existent port in a netdevsim should fail" + exit 1 +fi + +echo "$NSIM_DEV_1_ID 0" > ${NSIM_DEV_1_DFS}/ports/0/peer 2>/dev/null +if [ $? -eq 0 ]; then + echo "linking with self should fail" + exit 1 +fi + +echo "$NSIM_DEV_2_ID a" > ${NSIM_DEV_1_DFS}/ports/0/peer 2>/dev/null +if [ $? -eq 0 ]; then + echo "invalid arg should fail" + exit 1 +fi + +# send/recv packets + +socat_check || exit 4 + +setup_ns + +tmp_file=$(mktemp) +ip netns exec nssv socat TCP-LISTEN:1234,fork $tmp_file & +pid=$! + +echo "HI" | ip netns exec nscl socat STDIN TCP:192.168.1.1:1234 + +count=$(cat $tmp_file | wc -c) +if [[ $count -ne 3 ]]; then + echo "expected 3 bytes, got $count" + exit 1 +fi + +echo $NSIM_DEV_2_ID > $NSIM_DEV_SYS_DEL + +kill $pid +echo $NSIM_DEV_1_ID > $NSIM_DEV_SYS_DEL + +cleanup_ns + +modprobe -r netdevsim + +exit 0 From patchwork Wed Dec 20 01:47:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Wei X-Patchwork-Id: 13499436 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-oo1-f49.google.com (mail-oo1-f49.google.com [209.85.161.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 195C3BE68 for ; Wed, 20 Dec 2023 01:47:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=davidwei.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=davidwei.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=davidwei-uk.20230601.gappssmtp.com header.i=@davidwei-uk.20230601.gappssmtp.com header.b="1NBwCSJ0" Received: by mail-oo1-f49.google.com with SMTP id 006d021491bc7-593faaa1afbso484037eaf.0 for ; Tue, 19 Dec 2023 17:47:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=davidwei-uk.20230601.gappssmtp.com; s=20230601; t=1703036874; x=1703641674; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iWOr9qiisUkjpabZ4ff5uQEtv5SlwPvl6ptfPUH6+qE=; b=1NBwCSJ0R5wZO+TDS2xr5LsoLOzVRAJQFqlEqX8+X363Zk3NplTHe2jsc0P+8U6sa9 tYuCuRyLRGw8M+/GfgK4WALyakncfFtGnXoPZIoK/iiL2JtbVGhB2NTFdUCqgKWXFzmh cDInygP8Xwfj5E+mmp+SQge/h7cM6Y/Dfzb1GtSONqUYAp3Nx+tonlMmrDbIJtAhk2jh 0TW8SxF2nH2A39z1ivRLCpH8cgHxATgJ8ZRtV3PzkLsm7ZS++u3Ww6/s2ZQTM43ciRAi MDsuZ243hvywG3NH+KdM9iD6GjMzbkXMnR3tSdkroR1qEG/Bv/uS3CRq6kcq6DyNkh9x vimQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703036874; x=1703641674; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iWOr9qiisUkjpabZ4ff5uQEtv5SlwPvl6ptfPUH6+qE=; b=Y8y0MGjivzvp5CYjycmZLdXYYiVhK4HXxmU+0q6t3x2T0X5G4dUJWUxr3SCD8H4TnW IfkKb8IVKkjeLEX/qXQYMdpJYSkGoPcgoL/NGUvYDxN1evMfFCEhJ6+RzBUxEhPWyQkO mA+tMLfqAzswCJo2DpFRDYGJsuyeej3hmwvUaWRJIADIwOwhA374E0r5nDC24hvjow4z r8fJ1PxPSfnrlaAYKLtTDb3HGiQG8BmBtqACE+DdId77ti5dUQa5b+81HOJfKMVBNzBv yNZpvaqgzsZ2ibXluOfjxVQSU0/yj+zPfrRupPAD7WzyRBkLL/ew1jmGnEg/OSCvd+FF 0BHw== X-Gm-Message-State: AOJu0YwY7KZF+8kAppZm3Lh4pDPu3hgkzd5wGhfCd2mgb7I2ASoLZon/ tWiP07YbVlRH0UlODtjcu7/Ncw== X-Google-Smtp-Source: AGHT+IEPc5q69adE+uwGOOznPo/LLRclOSONBC0SbD6eTPV3X8+frIOBkj/zDV2/bnyByoCGvD9hfA== X-Received: by 2002:a05:6358:7255:b0:172:e226:c16f with SMTP id i21-20020a056358725500b00172e226c16fmr4467530rwa.4.1703036874054; Tue, 19 Dec 2023 17:47:54 -0800 (PST) Received: from localhost (fwdproxy-prn-116.fbsv.net. [2a03:2880:ff:74::face:b00c]) by smtp.gmail.com with ESMTPSA id dw7-20020a17090b094700b00286f2b39a95sm2321150pjb.31.2023.12.19.17.47.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 17:47:53 -0800 (PST) From: David Wei To: Jakub Kicinski , Jiri Pirko , Sabrina Dubroca , netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Paolo Abeni Subject: [PATCH net-next v4 5/5] netdevsim: add Makefile for selftests Date: Tue, 19 Dec 2023 17:47:47 -0800 Message-Id: <20231220014747.1508581-6-dw@davidwei.uk> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231220014747.1508581-1-dw@davidwei.uk> References: <20231220014747.1508581-1-dw@davidwei.uk> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Add a Makefile for netdevsim selftests and add selftests path to MAINTAINERS Signed-off-by: David Wei --- MAINTAINERS | 1 + .../selftests/drivers/net/netdevsim/Makefile | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 tools/testing/selftests/drivers/net/netdevsim/Makefile diff --git a/MAINTAINERS b/MAINTAINERS index dda78b4ce707..d086e49eac57 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14853,6 +14853,7 @@ NETDEVSIM M: Jakub Kicinski S: Maintained F: drivers/net/netdevsim/* +F: tools/testing/selftests/drivers/net/netdevsim/* NETEM NETWORK EMULATOR M: Stephen Hemminger diff --git a/tools/testing/selftests/drivers/net/netdevsim/Makefile b/tools/testing/selftests/drivers/net/netdevsim/Makefile new file mode 100644 index 000000000000..5bace0b7fb57 --- /dev/null +++ b/tools/testing/selftests/drivers/net/netdevsim/Makefile @@ -0,0 +1,18 @@ +# SPDX-License-Identifier: GPL-2.0+ OR MIT + +TEST_PROGS = devlink.sh \ + devlink_in_netns.sh \ + devlink_trap.sh \ + ethtool-coalesce.sh \ + ethtool-fec.sh \ + ethtool-pause.sh \ + ethtool-ring.sh \ + fib.sh \ + hw_stats_l3.sh \ + nexthop.sh \ + peer.sh \ + psample.sh \ + tc-mq-visibility.sh \ + udp_tunnel_nic.sh \ + +include ../../../lib.mk