X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fplugins%2Fnat%2Fin2out_ed.c;h=8eafb5ba7edbf13928cc7aa94081e25d2262a987;hb=bf9a0c8097d47f052efea13a09d3a6c6fc68fb35;hp=080f37e7c155d8e59e19baf3321feb3b859b82c2;hpb=7c8644c368e19d8d34059ffa13e208f1534e23be;p=vpp.git diff --git a/src/plugins/nat/in2out_ed.c b/src/plugins/nat/in2out_ed.c index 080f37e7c15..8eafb5ba7ed 100644 --- a/src/plugins/nat/in2out_ed.c +++ b/src/plugins/nat/in2out_ed.c @@ -217,14 +217,14 @@ nat_ed_alloc_addr_and_port (snat_main_t * sm, u32 rx_fib_index, if (a->fib_index == rx_fib_index) \ { \ /* first try port suggested by caller */ \ - u16 port = clib_net_to_host_u16 (*outside_port); \ + u16 port = clib_net_to_host_u16 (*outside_port); \ u16 port_offset = port - port_thread_offset; \ if (port <= port_thread_offset || \ port > port_thread_offset + port_per_thread) \ { \ /* need to pick a different port, suggested port doesn't fit in \ * this thread's port range */ \ - port_offset = snat_random_port (1, port_per_thread); \ + port_offset = snat_random_port (0, port_per_thread - 1); \ port = port_thread_offset + port_offset; \ } \ u16 attempts = port_per_thread; \ @@ -240,8 +240,8 @@ nat_ed_alloc_addr_and_port (snat_main_t * sm, u32 rx_fib_index, ++a->busy_##n##_port_refcounts[port]; \ a->busy_##n##_ports_per_thread[thread_index]++; \ a->busy_##n##_ports++; \ - *outside_addr = a->addr; \ - *outside_port = clib_host_to_net_u16 (port); \ + *outside_addr = a->addr; \ + *outside_port = clib_host_to_net_u16 (port); \ return 0; \ } \ port_offset = (port_offset + 1) % port_per_thread; \