aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/udp/udp_cli.c
diff options
context:
space:
mode:
authorBenoît Ganne <bganne@cisco.com>2023-06-05 10:02:29 +0200
committerAndrew Yourtchenko <ayourtch@gmail.com>2023-06-13 12:49:36 +0000
commitf7687220e06f30105d4318679bec3d2ea04189c6 (patch)
tree7055ba1d336f5032e94c645648b940852d2de6ad /src/vnet/udp/udp_cli.c
parent63e76fad7e369746f71305a3c9a88d035ec5cb58 (diff)
udp: improve port validity check
- do not allocate port sparse vector when only checking if a port is already in use - do not display port that have been unregistered by default Type: improvement Change-Id: I6cc94e35806dd8d415cd5d1c1c51e6b066ac26a1 Signed-off-by: Benoît Ganne <bganne@cisco.com> (cherry picked from commit d52f80f422439227e98d9d26bf43394c69f8a7fd)
Diffstat (limited to 'src/vnet/udp/udp_cli.c')
-rw-r--r--src/vnet/udp/udp_cli.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/vnet/udp/udp_cli.c b/src/vnet/udp/udp_cli.c
index d60f0dde50b..1e723923c2f 100644
--- a/src/vnet/udp/udp_cli.c
+++ b/src/vnet/udp/udp_cli.c
@@ -211,16 +211,21 @@ static void
table_format_udp_port_ (vlib_main_t *vm, udp_main_t *um, table_t *t, int *c,
int port, int bind, int is_ip4)
{
- const udp_dst_port_info_t *pi = udp_get_dst_port_info (um, port, is_ip4);
- if (!pi)
+ const udp_dst_port_info_t *pi;
+
+ if (bind && !udp_is_valid_dst_port (port, is_ip4))
return;
- if (bind && ~0 == pi->node_index)
+
+ pi = udp_get_dst_port_info (um, port, is_ip4);
+ if (!pi)
return;
+
table_format_cell (t, *c, 0, "%d", pi->dst_port);
table_format_cell (t, *c, 1, is_ip4 ? "ip4" : "ip6");
table_format_cell (t, *c, 2, ~0 == pi->node_index ? "none" : "%U",
format_vlib_node_name, vm, pi->node_index);
table_format_cell (t, *c, 3, "%s", pi->name);
+
(*c)++;
}