summary |
shortlog |
log |
commit | commitdiff |
review |
tree
raw |
patch |
inline | side by side (from parent 1:
9fefa89)
Type: improvement
Signed-off-by: Klement Sekera <ksekera@cisco.com>
Change-Id: I83f44711264376389989152666f3c71216146bdd
#include <nat/nat44/ed_inlines.h>
#include <nat/lib/nat_inlines.h>
#include <nat/nat44/ed_inlines.h>
#include <nat/lib/nat_inlines.h>
+/* number of attempts to get a port for ED overloading algorithm, if rolling
+ * a dice this many times doesn't produce a free port, it's treated
+ * as if there were no free ports available to conserve resources */
+#define ED_PORT_ALLOC_ATTEMPTS (10)
+
static char *nat_in2out_ed_error_strings[] = {
#define _(sym,string) string,
foreach_nat_in2out_ed_error
static char *nat_in2out_ed_error_strings[] = {
#define _(sym,string) string,
foreach_nat_in2out_ed_error
port_offset = snat_random_port (0, port_per_thread - 1); \
port = port_thread_offset + port_offset; \
} \
port_offset = snat_random_port (0, port_per_thread - 1); \
port = port_thread_offset + port_offset; \
} \
- u16 attempts = port_per_thread; \
+ u16 attempts = ED_PORT_ALLOC_ATTEMPTS; \
do \
{ \
init_ed_kv (out2in_ed_kv, a->addr, clib_host_to_net_u16 (port), \
do \
{ \
init_ed_kv (out2in_ed_kv, a->addr, clib_host_to_net_u16 (port), \
*outside_port = clib_host_to_net_u16 (port); \
return 0; \
} \
*outside_port = clib_host_to_net_u16 (port); \
return 0; \
} \
- port_offset = (port_offset + 1) % port_per_thread; \
+ port_offset = snat_random_port (0, port_per_thread - 1); \
port = port_thread_offset + port_offset; \
--attempts; \
} \
port = port_thread_offset + port_offset; \
--attempts; \
} \