From: Jakub Kicinski <kuba@kernel.org>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [PATCH net-next v1 3/7] netdevsim: shared UDP tunnel port table support
Date: Tue, 21 Jul 2020 18:27:12 -0700 [thread overview]
Message-ID: <20200722012716.2814777-4-kuba@kernel.org> (raw)
In-Reply-To: <20200722012716.2814777-1-kuba@kernel.org>
Add the ability to simulate a device with a shared UDP tunnel port
table.
Try to reject the configurations and actions which are not supported
by the core, so we don't get syzcaller etc. warning reports.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
drivers/net/netdevsim/netdevsim.h | 7 ++++++-
drivers/net/netdevsim/udp_tunnels.c | 17 ++++++++++++++++-
2 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/drivers/net/netdevsim/netdevsim.h b/drivers/net/netdevsim/netdevsim.h
index d164052e0393..4335ab4e5ce0 100644
--- a/drivers/net/netdevsim/netdevsim.h
+++ b/drivers/net/netdevsim/netdevsim.h
@@ -20,6 +20,7 @@
#include <linux/netdevice.h>
#include <linux/u64_stats_sync.h>
#include <net/devlink.h>
+#include <net/udp_tunnel.h>
#include <net/xdp.h>
#define DRV_NAME "netdevsim"
@@ -77,7 +78,8 @@ struct netdevsim {
struct {
u32 inject_error;
u32 sleep;
- u32 ports[2][NSIM_UDP_TUNNEL_N_PORTS];
+ u32 __ports[2][NSIM_UDP_TUNNEL_N_PORTS];
+ u32 (*ports)[NSIM_UDP_TUNNEL_N_PORTS];
struct debugfs_u32_array dfs_ports[2];
} udp_ports;
};
@@ -197,9 +199,12 @@ struct nsim_dev {
bool fail_trap_policer_set;
bool fail_trap_policer_counter_get;
struct {
+ struct udp_tunnel_nic_shared utn_shared;
+ u32 __ports[2][NSIM_UDP_TUNNEL_N_PORTS];
bool sync_all;
bool open_only;
bool ipv4_only;
+ bool shared;
u32 sleep;
} udp_ports;
};
diff --git a/drivers/net/netdevsim/udp_tunnels.c b/drivers/net/netdevsim/udp_tunnels.c
index ad65b860bd7b..6b98e6d1188f 100644
--- a/drivers/net/netdevsim/udp_tunnels.c
+++ b/drivers/net/netdevsim/udp_tunnels.c
@@ -112,7 +112,7 @@ nsim_udp_tunnels_info_reset_write(struct file *file, const char __user *data,
struct net_device *dev = file->private_data;
struct netdevsim *ns = netdev_priv(dev);
- memset(&ns->udp_ports.ports, 0, sizeof(ns->udp_ports.ports));
+ memset(ns->udp_ports.ports, 0, sizeof(ns->udp_ports.__ports));
rtnl_lock();
udp_tunnel_nic_reset_ntf(dev);
rtnl_unlock();
@@ -132,6 +132,17 @@ int nsim_udp_tunnels_info_create(struct nsim_dev *nsim_dev,
struct netdevsim *ns = netdev_priv(dev);
struct udp_tunnel_nic_info *info;
+ if (nsim_dev->udp_ports.shared && nsim_dev->udp_ports.open_only) {
+ dev_err(&nsim_dev->nsim_bus_dev->dev,
+ "shared can't be used in conjunction with open_only\n");
+ return -EINVAL;
+ }
+
+ if (!nsim_dev->udp_ports.shared)
+ ns->udp_ports.ports = ns->udp_ports.__ports;
+ else
+ ns->udp_ports.ports = nsim_dev->udp_ports.__ports;
+
debugfs_create_u32("udp_ports_inject_error", 0600,
ns->nsim_dev_port->ddir,
&ns->udp_ports.inject_error);
@@ -173,6 +184,8 @@ int nsim_udp_tunnels_info_create(struct nsim_dev *nsim_dev,
info->flags |= UDP_TUNNEL_NIC_INFO_OPEN_ONLY;
if (nsim_dev->udp_ports.ipv4_only)
info->flags |= UDP_TUNNEL_NIC_INFO_IPV4_ONLY;
+ if (nsim_dev->udp_ports.shared)
+ info->shared = &nsim_dev->udp_ports.utn_shared;
dev->udp_tunnel_nic_info = info;
return 0;
@@ -192,6 +205,8 @@ void nsim_udp_tunnels_debugfs_create(struct nsim_dev *nsim_dev)
&nsim_dev->udp_ports.open_only);
debugfs_create_bool("udp_ports_ipv4_only", 0600, nsim_dev->ddir,
&nsim_dev->udp_ports.ipv4_only);
+ debugfs_create_bool("udp_ports_shared", 0600, nsim_dev->ddir,
+ &nsim_dev->udp_ports.shared);
debugfs_create_u32("udp_ports_sleep", 0600, nsim_dev->ddir,
&nsim_dev->udp_ports.sleep);
}
--
2.26.2
next prev parent reply other threads:[~2020-07-22 1:27 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-22 1:27 [Intel-wired-lan] [PATCH net-next v1 0/7] udp_tunnel: convert Intel drivers with shared tables Jakub Kicinski
2020-07-22 1:27 ` [Intel-wired-lan] [PATCH net-next v1 1/7] udp_tunnel: add the ability to share port tables Jakub Kicinski
2020-07-22 1:27 ` [Intel-wired-lan] [PATCH net-next v1 2/7] netdevsim: add warnings on unexpected UDP tunnel port errors Jakub Kicinski
2020-07-22 1:27 ` Jakub Kicinski [this message]
2020-07-22 1:27 ` [Intel-wired-lan] [PATCH net-next v1 4/7] selftests: net: add a test for shared UDP tunnel info tables Jakub Kicinski
2020-09-19 7:23 ` Brown, Aaron F
2020-09-21 21:44 ` Jakub Kicinski
2020-09-22 17:34 ` Brown, Aaron F
2020-09-22 18:35 ` Jakub Kicinski
2020-09-24 22:25 ` Nguyen, Anthony L
2020-09-24 22:28 ` Jakub Kicinski
2020-07-22 1:27 ` [Intel-wired-lan] [PATCH net-next v1 5/7] i40e: convert to new udp_tunnel infrastructure Jakub Kicinski
2020-09-19 7:04 ` Brown, Aaron F
2020-07-22 1:27 ` [Intel-wired-lan] [PATCH net-next v1 6/7] ice: remove unused args from ice_get_open_tunnel_port() Jakub Kicinski
2020-09-19 5:40 ` Brown, Aaron F
2020-07-22 1:27 ` [Intel-wired-lan] [PATCH net-next v1 7/7] ice: convert to new udp_tunnel infrastructure Jakub Kicinski
2020-09-19 5:42 ` Brown, Aaron F
2020-07-22 21:22 ` [Intel-wired-lan] [PATCH net-next v1 0/7] udp_tunnel: convert Intel drivers with shared tables Nguyen, Anthony L
2020-07-23 20:06 ` Nguyen, Anthony L
2020-07-23 20:17 ` David Miller
2020-09-03 23:22 ` Jakub Kicinski
2020-09-04 16:12 ` Nguyen, Anthony L
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200722012716.2814777-4-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=intel-wired-lan@osuosl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox