diff options
author | Jakub Kicinski <kuba@kernel.org> | 2020-09-26 02:56:42 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2020-09-28 21:50:12 +0200 |
commit | dc9c07537cf200279c357b444a49df8c11f006fd (patch) | |
tree | 0e733c40c00af2e2eaf6760a911f25d12a2d729d /drivers/net/netdevsim/udp_tunnels.c | |
parent | netdevsim: add warnings on unexpected UDP tunnel port errors (diff) | |
download | linux-dc9c07537cf200279c357b444a49df8c11f006fd.tar.xz linux-dc9c07537cf200279c357b444a49df8c11f006fd.zip |
netdevsim: shared UDP tunnel port table support
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/netdevsim/udp_tunnels.c')
-rw-r--r-- | drivers/net/netdevsim/udp_tunnels.c | 17 |
1 files changed, 16 insertions, 1 deletions
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); } |