32 #define _(sym,string) string, 39 dslite_session_t ** sp,
u32 next,
u8 * error,
u32 thread_index)
57 if (clib_bihash_search_16_8
77 per_thread_data[thread_index].b4s));
81 b4_index = b4_value.
value;
93 ASSERT (oldest_index != ~0);
103 in2out_kv.
key[0] = s->in2out.as_u64[0];
104 in2out_kv.
key[1] = s->in2out.as_u64[1];
105 in2out_kv.
key[2] = s->in2out.as_u64[2];
108 out2in_kv.
key = s->out2in.as_u64;
115 &s->in2out.addr, s->in2out.port,
116 &s->out2in.addr, s->out2in.port,
120 (dm->
addr_pool, 0, thread_index, &out2in_key,
127 (dm->
addr_pool, 0, thread_index, &out2in_key,
130 *error = DSLITE_ERROR_OUT_OF_PORTS;
144 s->per_b4_list_head_index,
152 s->in2out = *in2out_key;
153 s->out2in = out2in_key;
155 in2out_kv.
key[0] = s->in2out.as_u64[0];
156 in2out_kv.
key[1] = s->in2out.as_u64[1];
157 in2out_kv.
key[2] = s->in2out.as_u64[2];
161 out2in_kv.
key = s->out2in.as_u64;
167 s->in2out.port, &s->out2in.addr, s->out2in.port,
176 u8 * error,
u32 thread_index)
178 dslite_session_t *s = 0;
184 u32 new_addr, old_addr;
191 *error = DSLITE_ERROR_BAD_ICMP_TYPE;
199 key.
proto = SNAT_PROTOCOL_ICMP;
207 if (clib_bihash_search_24_8
210 n =
slow_path (dm, &key, &s, next, error, thread_index);
230 sum = icmp->checksum;
243 u32 n_left_from, *from, *to_next;
261 while (n_left_from > 0)
267 while (n_left_from > 0 && n_left_to_next > 0)
274 u8 error0 = DSLITE_ERROR_IN2OUT;
276 dslite_session_t *s0 = 0;
282 u32 new_addr0, old_addr0;
283 u16 old_port0, new_port0;
298 if (ip60->
protocol == IP_PROTOCOL_ICMP6)
303 error0 = DSLITE_ERROR_BAD_IP6_PROTOCOL;
313 error0 = DSLITE_ERROR_UNSUPPORTED_PROTOCOL;
353 if (clib_bihash_search_24_8
359 slow_path (dm, &key0, &s0, next0, &error0, thread_index);
386 old_port0 = tcp0->src_port;
387 tcp0->src_port = s0->out2in.port;
388 new_port0 = tcp0->src_port;
390 sum0 = tcp0->checksum;
409 s0->last_heard = now;
416 s0->per_b4_list_head_index, s0->per_b4_index);
419 (clib_net_to_host_u32
426 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
440 n_left_to_next, bi0, next0);
458 .name =
"dslite-in2out",
459 .vector_size =
sizeof (
u32),
487 .name =
"dslite-in2out-slowpath",
488 .vector_size =
sizeof (
u32),
static void clib_dlist_init(dlist_elt_t *pool, u32 index)
u8 * format_dslite_trace(u8 *s, va_list *args)
static_always_inline u8 icmp_is_error_message(icmp46_header_t *icmp)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static f64 vlib_time_now(vlib_main_t *vm)
vlib_error_t * errors
Vector of errors for this node.
clib_bihash_16_8_t b4_hash
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
struct _tcp_header tcp_header_t
static uword dslite_in2out_node_fn_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, u8 is_slow_path)
static u32 slow_path(dslite_main_t *dm, dslite_session_key_t *in2out_key, dslite_session_t **sp, u32 next, u8 *error, u32 thread_index)
static void * ip4_next_header(ip4_header_t *i)
static char * dslite_in2out_error_strings[]
void snat_free_outside_address_and_port(snat_address_t *addresses, u32 thread_index, snat_session_key_t *k)
Free outside address and port pair.
static void mss_clamping(snat_main_t *sm, tcp_header_t *tcp, ip_csum_t *sum)
int snat_alloc_outside_address_and_port(snat_address_t *addresses, u32 fib_index, u32 thread_index, snat_session_key_t *k, u16 port_per_thread, u32 snat_thread_index)
Alloc outside address and port.
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static void clib_dlist_addtail(dlist_elt_t *pool, u32 head_index, u32 new_index)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
void nat_syslog_dslite_apmadd(u32 ssubix, ip6_address_t *sv6enc, ip4_address_t *isaddr, u16 isport, ip4_address_t *xsaddr, u16 xsport, snat_protocol_t proto)
vl_api_address_union_t src_address
snat_address_t * addr_pool
static void vlib_set_simple_counter(vlib_simple_counter_main_t *cm, u32 thread_index, u32 index, u64 value)
Set a simple counter.
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
Finish enqueueing one buffer forward in the graph.
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
vlib_error_t error
Error code for buffers to be enqueued to error handler.
#define VLIB_REGISTER_NODE(x,...)
static vlib_node_runtime_t * vlib_node_get_runtime(vlib_main_t *vm, u32 node_index)
Get node runtime by node index.
VLIB_NODE_FUNCTION_MULTIARCH(dslite_in2out_node, dslite_in2out_node_fn)
dslite_main_t dslite_main
8 octet key, 8 octet key value pair
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
Release pointer to next frame vector data.
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
static u32 dslite_icmp_in2out(dslite_main_t *dm, ip6_header_t *ip6, ip4_header_t *ip4, dslite_session_t **sp, u32 next, u8 *error, u32 thread_index)
static uword dslite_in2out_slowpath_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static uword dslite_in2out_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
static void clib_dlist_remove(dlist_elt_t *pool, u32 index)
vlib_simple_counter_main_t total_b4s
dslite_per_thread_data_t * per_thread_data
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
struct _vlib_node_registration vlib_node_registration_t
static u32 ip_proto_to_snat_proto(u8 ip_proto)
The NAT inline functions.
vlib_simple_counter_main_t total_sessions
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
#define ip_csum_update(sum, old, new, type, field)
ip6_address_t softwire_id
dslite_session_t * sessions
vlib_node_registration_t dslite_in2out_node
(constructor) VLIB_REGISTER_NODE (dslite_in2out_node)
vlib_node_registration_t dslite_in2out_slowpath_node
(constructor) VLIB_REGISTER_NODE (dslite_in2out_slowpath_node)
#define foreach_dslite_error
u16 flags
Copy of main node flags.
void nat_syslog_dslite_apmdel(u32 ssubix, ip6_address_t *sv6enc, ip4_address_t *isaddr, u16 isport, ip4_address_t *xsaddr, u16 xsport, snat_protocol_t proto)
clib_bihash_24_8_t in2out
#define VLIB_NODE_FLAG_TRACE
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
u32 sessions_per_b4_list_head_index
static u16 ip_csum_fold(ip_csum_t c)
static u32 clib_dlist_remove_head(dlist_elt_t *pool, u32 head_index)
static uword pool_elts(void *v)
Number of active elements in a pool.