-int
-nat44_del_session (snat_main_t * sm, ip4_address_t * addr, u16 port,
- nat_protocol_t proto, u32 vrf_id, int is_in)
-{
- snat_main_per_thread_data_t *tsm;
- clib_bihash_kv_8_8_t kv, value;
- ip4_header_t ip;
- u32 fib_index = fib_table_find (FIB_PROTOCOL_IP4, vrf_id);
- snat_session_t *s;
- clib_bihash_8_8_t *t;
-
- if (sm->endpoint_dependent)
- return VNET_API_ERROR_UNSUPPORTED;
-
- ip.dst_address.as_u32 = ip.src_address.as_u32 = addr->as_u32;
- if (sm->num_workers > 1)
- tsm =
- vec_elt_at_index (sm->per_thread_data,
- sm->worker_in2out_cb (&ip, fib_index, 0));
- else
- tsm = vec_elt_at_index (sm->per_thread_data, sm->num_workers);
-
- init_nat_k (&kv, *addr, port, fib_index, proto);
- t = is_in ? &tsm->in2out : &tsm->out2in;
- if (!clib_bihash_search_8_8 (t, &kv, &value))
- {
- if (pool_is_free_index (tsm->sessions, value.value))
- return VNET_API_ERROR_UNSPECIFIED;
-
- s = pool_elt_at_index (tsm->sessions, value.value);
- nat_free_session_data (sm, s, tsm - sm->per_thread_data, 0);
- nat44_delete_session (sm, s, tsm - sm->per_thread_data);
- return 0;
- }
-
- return VNET_API_ERROR_NO_SUCH_ENTRY;
-}
-