+ if (!clib_bihash_search_16_8 (&sm->in2out_ed, &kv, &value))
+ {
+ s = pool_elt_at_index (tsm->sessions, value.value);
+ }
+ else
+ {
+ if (PREDICT_FALSE (maximum_sessions_exceeded(sm, thread_index)))
+ return;
+
+ u = nat_user_get_or_create (sm, &ip->dst_address, sm->inside_fib_index, thread_index);
+ if (!u)
+ {
+ clib_warning ("create NAT user failed");
+ return;
+ }
+
+ s = nat_session_alloc_or_recycle (sm, u, thread_index);
+ if (!s)
+ {
+ clib_warning ("create NAT session failed");
+ return;
+ }
+
+ s->ext_host_addr = key.r_addr;
+ s->ext_host_port = key.r_port;
+ s->flags |= SNAT_SESSION_FLAG_FWD_BYPASS;
+ s->outside_address_index = ~0;
+ s->out2in.addr = key.l_addr;
+ s->out2in.port = key.l_port;
+ s->out2in.protocol = ip_proto_to_snat_proto (key.proto);
+ s->out2in.fib_index = 0;
+ s->in2out = s->out2in;
+ user_session_increment (sm, u, 0);
+
+ kv.value = s - tsm->sessions;
+ if (clib_bihash_add_del_16_8 (&sm->in2out_ed, &kv, 1))
+ clib_warning ("in2out_ed key add failed");
+ }
+
+ if (ip->protocol == IP_PROTOCOL_TCP)
+ {
+ tcp_header_t *tcp = ip4_next_header(ip);
+ if (nat44_set_tcp_session_state_o2i (sm, s, tcp, thread_index))
+ return;
+ }
+ /* Per-user LRU list maintenance */
+ clib_dlist_remove (tsm->list_pool, s->per_user_index);
+ clib_dlist_addtail (tsm->list_pool, s->per_user_list_head_index,
+ s->per_user_index);
+ /* Accounting */
+ s->last_heard = now;
+ s->total_pkts++;