udp: fix local port reuse check 46/39046/2 v23.06-rc2
authorFlorin Coras <fcoras@cisco.com>
Thu, 25 May 2023 19:04:53 +0000 (12:04 -0700)
committerAndrew Yourtchenko <ayourtch@gmail.com>
Wed, 14 Jun 2023 09:55:28 +0000 (09:55 +0000)
Type: fix

Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: I323946f7838507110c663f5a904399a74fc76691
(cherry picked from commit d921b8988044f708318eb73a1fa883fce094a4d6)

src/vnet/udp/udp.c
test/asf/test_vcl.py

index 7147fa3..4932750 100644 (file)
@@ -364,7 +364,8 @@ udp_open_connection (transport_endpoint_cfg_t * rmt)
   if (rv)
     return rv;
 
-  if (udp_is_valid_dst_port (lcl_port, rmt->is_ip4))
+  if (udp_connection_port_used_extern (clib_net_to_host_u16 (lcl_port),
+                                      rmt->is_ip4))
     {
       /* If specific source port was requested abort */
       if (rmt->peer.port)
@@ -375,7 +376,8 @@ udp_open_connection (transport_endpoint_cfg_t * rmt)
        }
 
       /* Try to find a port that's not used */
-      while (udp_is_valid_dst_port (lcl_port, rmt->is_ip4))
+      while (udp_connection_port_used_extern (clib_net_to_host_u16 (lcl_port),
+                                             rmt->is_ip4))
        {
          transport_release_local_endpoint (TRANSPORT_PROTO_UDP, &lcl_addr,
                                            lcl_port);
index 9853529..59c077e 100644 (file)
@@ -996,6 +996,7 @@ class LDPThruHostStackIperfUdp(VCLTestCase):
             "-t 2",
             "-u",
             "-l 1400",
+            "-P 2",
             "-c",
             self.loop0.local_ip4,
         ]