udp: improve port validity check
[vpp.git] / src / vnet / udp / udp_cli.c
index d60f0dd..1e72392 100644 (file)
@@ -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)++;
 }