nat: set buf error if can't create user 38/27638/1
authorKlement Sekera <ksekera@cisco.com>
Mon, 22 Jun 2020 12:52:29 +0000 (12:52 +0000)
committerKlement Sekera <ksekera@cisco.com>
Mon, 22 Jun 2020 12:58:00 +0000 (12:58 +0000)
Type: fix
Signed-off-by: Klement Sekera <ksekera@cisco.com>
Change-Id: I747d78966a7296dcbae54d54b0c165d407c8863d

src/plugins/nat/in2out.c
src/plugins/nat/in2out_ed.c
src/plugins/nat/nat.h
src/plugins/nat/out2in.c

index b8febc1..f904d02 100644 (file)
@@ -94,8 +94,7 @@ _(UDP_PACKETS, "UDP packets")                           \
 _(ICMP_PACKETS, "ICMP packets")                         \
 _(OTHER_PACKETS, "other protocol packets")              \
 _(FRAGMENTS, "fragments")                               \
-_(CACHED_FRAGMENTS, "cached fragments")                 \
-_(PROCESSED_FRAGMENTS, "processed fragments")
+_(CANNOT_CREATE_USER, "cannot create NAT user")
 
 typedef enum
 {
@@ -312,7 +311,7 @@ slow_path (snat_main_t * sm, vlib_buffer_t * b0,
                              thread_index);
   if (!u)
     {
-      nat_elog_warn ("create NAT user failed");
+      b0->error = node->errors[SNAT_IN2OUT_ERROR_CANNOT_CREATE_USER];
       return SNAT_IN2OUT_NEXT_DROP;
     }
 
index 19b1288..e5f29e4 100644 (file)
@@ -368,12 +368,7 @@ slow_path_ed (snat_main_t * sm,
        &sm_fib_index, 0, 0, 0, &lb, 0, &identity_nat))
     {
       s = nat_ed_session_alloc (sm, thread_index, now, proto);
-      if (!s)
-       {
-         nat_elog_warn ("create NAT session failed");
-         b->error = node->errors[NAT_IN2OUT_ED_ERROR_MAX_USER_SESS_EXCEEDED];
-         return NAT_NEXT_DROP;
-       }
+      ASSERT (s);
       s->in2out.addr = l_addr;
       s->in2out.port = l_port;
       s->nat_proto = nat_proto;
@@ -418,12 +413,7 @@ slow_path_ed (snat_main_t * sm,
          return next;
        }
       s = nat_ed_session_alloc (sm, thread_index, now, proto);
-      if (!s)
-       {
-         nat_elog_warn ("create NAT session failed");
-         b->error = node->errors[NAT_IN2OUT_ED_ERROR_MAX_USER_SESS_EXCEEDED];
-         return NAT_NEXT_DROP;
-       }
+      ASSERT (s);
       s->out2in.addr = sm_addr;
       s->out2in.port = sm_port;
       s->in2out.addr = l_addr;
@@ -863,7 +853,7 @@ nat44_ed_in2out_unknown_proto (snat_main_t * sm,
       s = nat_ed_session_alloc (sm, thread_index, now, ip->protocol);
       if (!s)
        {
-         b->error = node->errors[NAT_IN2OUT_ED_ERROR_MAX_USER_SESS_EXCEEDED];
+         b->error = node->errors[NAT_IN2OUT_ED_ERROR_MAX_SESSIONS_EXCEEDED];
          nat_elog_warn ("create NAT session failed");
          return 0;
        }
index d5b236d..1885ab5 100644 (file)
@@ -154,18 +154,14 @@ _(IN2OUT_PACKETS, "good in2out packets processed")      \
 _(OUT_OF_PORTS, "out of ports")                         \
 _(BAD_ICMP_TYPE, "unsupported ICMP type")               \
 _(MAX_SESSIONS_EXCEEDED, "maximum sessions exceeded")   \
-_(MAX_USER_SESS_EXCEEDED, "max user sessions exceeded") \
 _(DROP_FRAGMENT, "drop fragment")                       \
-_(CANNOT_CREATE_USER, "cannot create NAT user")         \
 _(NON_SYN, "non-SYN packet try to create session")      \
 _(TCP_PACKETS, "TCP packets")                           \
 _(TCP_CLOSED, "drops due to TCP in transitory timeout") \
 _(UDP_PACKETS, "UDP packets")                           \
 _(ICMP_PACKETS, "ICMP packets")                         \
 _(OTHER_PACKETS, "other protocol packets")              \
-_(FRAGMENTS, "fragments")                               \
-_(CACHED_FRAGMENTS, "cached fragments")                 \
-_(PROCESSED_FRAGMENTS, "processed fragments")
+_(FRAGMENTS, "fragments")
 
 typedef enum
 {
@@ -191,9 +187,7 @@ _(TCP_CLOSED, "drops due to TCP in transitory timeout") \
 _(UDP_PACKETS, "UDP packets")                           \
 _(ICMP_PACKETS, "ICMP packets")                         \
 _(OTHER_PACKETS, "other protocol packets")              \
-_(FRAGMENTS, "fragments")                               \
-_(CACHED_FRAGMENTS, "cached fragments")                 \
-_(PROCESSED_FRAGMENTS, "processed fragments")
+_(FRAGMENTS, "fragments")
 
 typedef enum
 {
index 57e658b..071e16d 100644 (file)
@@ -85,8 +85,7 @@ _(UDP_PACKETS, "UDP packets")                           \
 _(ICMP_PACKETS, "ICMP packets")                         \
 _(OTHER_PACKETS, "other protocol packets")              \
 _(FRAGMENTS, "fragments")                               \
-_(CACHED_FRAGMENTS, "cached fragments")                 \
-_(PROCESSED_FRAGMENTS, "processed fragments")
+_(CANNOT_CREATE_USER, "cannot create NAT user")
 
 typedef enum
 {
@@ -206,7 +205,7 @@ create_session_for_static_mapping (snat_main_t * sm,
   u = nat_user_get_or_create (sm, &i2o_addr, i2o_fib_index, thread_index);
   if (!u)
     {
-      nat_elog_warn ("create NAT user failed");
+      b0->error = node->errors[SNAT_OUT2IN_ERROR_CANNOT_CREATE_USER];
       return 0;
     }