Commit 860e9d32 authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller

netdevsim: add warnings on unexpected UDP tunnel port errors

We should never see a removal of a port which is not in the table
or adding a port to an occupied entry in the table. To make sure
such errors don't escape the checks in the test script add a
warning/kernel spat.

Error injection will not trigger those, nor should it ever put
us in a bad state.
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 74cc6d18
No related merge requests found
...@@ -22,12 +22,14 @@ nsim_udp_tunnel_set_port(struct net_device *dev, unsigned int table, ...@@ -22,12 +22,14 @@ nsim_udp_tunnel_set_port(struct net_device *dev, unsigned int table,
msleep(ns->udp_ports.sleep); msleep(ns->udp_ports.sleep);
if (!ret) { if (!ret) {
if (ns->udp_ports.ports[table][entry]) if (ns->udp_ports.ports[table][entry]) {
WARN(1, "entry already in use\n");
ret = -EBUSY; ret = -EBUSY;
else } else {
ns->udp_ports.ports[table][entry] = ns->udp_ports.ports[table][entry] =
be16_to_cpu(ti->port) << 16 | ti->type; be16_to_cpu(ti->port) << 16 | ti->type;
} }
}
netdev_info(dev, "set [%d, %d] type %d family %d port %d - %d\n", netdev_info(dev, "set [%d, %d] type %d family %d port %d - %d\n",
table, entry, ti->type, ti->sa_family, ntohs(ti->port), table, entry, ti->type, ti->sa_family, ntohs(ti->port),
...@@ -50,11 +52,14 @@ nsim_udp_tunnel_unset_port(struct net_device *dev, unsigned int table, ...@@ -50,11 +52,14 @@ nsim_udp_tunnel_unset_port(struct net_device *dev, unsigned int table,
if (!ret) { if (!ret) {
u32 val = be16_to_cpu(ti->port) << 16 | ti->type; u32 val = be16_to_cpu(ti->port) << 16 | ti->type;
if (val == ns->udp_ports.ports[table][entry]) if (val == ns->udp_ports.ports[table][entry]) {
ns->udp_ports.ports[table][entry] = 0; ns->udp_ports.ports[table][entry] = 0;
else } else {
WARN(1, "entry not installed %x vs %x\n",
val, ns->udp_ports.ports[table][entry]);
ret = -ENOENT; ret = -ENOENT;
} }
}
netdev_info(dev, "unset [%d, %d] type %d family %d port %d - %d\n", netdev_info(dev, "unset [%d, %d] type %d family %d port %d - %d\n",
table, entry, ti->type, ti->sa_family, ntohs(ti->port), table, entry, ti->type, ti->sa_family, ntohs(ti->port),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment