43 s =
format (s,
"SNAT_OUT2IN: sw_if_index %d, next index %d, session index %d",
50 #define foreach_snat_out2in_error \ 51 _(UNSUPPORTED_PROTOCOL, "Unsupported protocol") \ 52 _(OUT2IN_PACKETS, "Good out2in packets processed") \ 53 _(BAD_ICMP_TYPE, "icmp type not echo-reply") \ 54 _(NO_TRANSLATION, "No translation") 57 #define _(sym,str) SNAT_OUT2IN_ERROR_##sym, 64 #define _(sym,string) string, 77 icmp46_header_t * icmp0,
87 u32 new_addr0, old_addr0;
101 if (clib_bihash_search_8_8 (&sm->
out2in, &kv0, &value0))
119 b0->
error = node->
errors[SNAT_OUT2IN_ERROR_NO_TRANSLATION];
137 new_id0 = s0->in2out.port;
140 sum0 = icmp0->checksum;
146 s0->last_heard = now;
161 u32 n_left_from, * from, * to_next;
163 u32 pkts_processed = 0;
173 while (n_left_from > 0)
178 to_next, n_left_to_next);
180 while (n_left_from >= 4 && n_left_to_next >= 2)
186 u32 sw_if_index0, sw_if_index1;
189 u32 new_addr0, old_addr0;
190 u16 new_port0, old_port0;
191 u32 new_addr1, old_addr1;
192 u16 new_port1, old_port1;
195 icmp46_header_t * icmp0, * icmp1;
197 u32 rx_fib_index0, rx_fib_index1;
199 snat_session_t * s0 = 0, * s1 = 0;
217 to_next[0] = bi0 = from[0];
218 to_next[1] = bi1 = from[1];
230 icmp0 = (icmp46_header_t *) udp0;
241 proto0 = (ip0->
protocol == IP_PROTOCOL_UDP)
243 proto0 = (ip0->
protocol == IP_PROTOCOL_TCP)
245 proto0 = (ip0->
protocol == IP_PROTOCOL_ICMP)
254 (sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, node,
266 if (clib_bihash_search_8_8 (&sm->
out2in, &kv0, &value0))
306 s0->last_heard = now;
332 icmp1 = (icmp46_header_t *) udp1;
343 proto1 = (ip1->
protocol == IP_PROTOCOL_UDP)
345 proto1 = (ip1->
protocol == IP_PROTOCOL_TCP)
347 proto1 = (ip1->
protocol == IP_PROTOCOL_ICMP)
356 (sm, b1, ip1, icmp1, sw_if_index1, rx_fib_index1, node,
368 if (clib_bihash_search_8_8 (&sm->
out2in, &kv1, &value1))
408 s1->last_heard = now;
433 to_next, n_left_to_next,
434 bi0, bi1, next0, next1);
437 while (n_left_from > 0 && n_left_to_next > 0)
445 u32 new_addr0, old_addr0;
446 u16 new_port0, old_port0;
449 icmp46_header_t * icmp0;
453 snat_session_t * s0 = 0;
469 icmp0 = (icmp46_header_t *) udp0;
480 proto0 = (ip0->
protocol == IP_PROTOCOL_UDP)
482 proto0 = (ip0->
protocol == IP_PROTOCOL_TCP)
484 proto0 = (ip0->
protocol == IP_PROTOCOL_ICMP)
493 (sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, node,
505 if (clib_bihash_search_8_8 (&sm->
out2in, &kv0, &value0))
545 s0->last_heard = now;
569 to_next, n_left_to_next,
577 SNAT_OUT2IN_ERROR_OUT2IN_PACKETS,
584 .name =
"snat-out2in",
585 .vector_size =
sizeof (
u32),
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.
VLIB_NODE_FUNCTION_MULTIARCH(snat_out2in_node, snat_out2in_node_fn)
u32 current_config_index
Used by feature subgraph arcs to visit enabled feature nodes.
bad routing header type(not 4)") sr_error (NO_MORE_SEGMENTS
ip4_address_t * ip4_interface_first_address(ip4_main_t *im, u32 sw_if_index, ip_interface_address_t **result_ia)
static f64 vlib_time_now(vlib_main_t *vm)
ip_lookup_main_t * ip4_lookup_main
ip_config_main_t rx_config_mains[VNET_N_CAST]
rx/tx interface/feature configuration.
struct _vlib_node_registration vlib_node_registration_t
u32 * fib_index_by_sw_if_index
Table index indexed by software interface.
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
static void * ip4_next_header(ip4_header_t *i)
#define foreach_snat_out2in_error
#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 * vnet_get_config_data(vnet_config_main_t *cm, u32 *config_index, u32 *next_index, u32 n_data_bytes)
#define vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, next0, next1)
Finish enqueueing two buffers forward in the graph.
vlib_node_registration_t snat_out2in_node
(constructor) VLIB_REGISTER_NODE (snat_out2in_node)
#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.
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
#define CLIB_PREFETCH(addr, size, type)
8 octet key, 8 octet key value pair
#define VLIB_NODE_FLAG_TRACE
static void clib_dlist_remove(dlist_elt_t *pool, u32 index)
#define VLIB_BUFFER_IS_TRACED
snat_session_t * sessions
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
#define vec_elt(v, i)
Get vector value at index i.
static char * snat_out2in_error_strings[]
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)
static u8 * format_snat_out2in_trace(u8 *s, va_list *args)
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
#define VLIB_REGISTER_NODE(x,...)
static uword snat_out2in_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static u32 icmp_out2in_slow_path(snat_main_t *sm, vlib_buffer_t *b0, ip4_header_t *ip0, icmp46_header_t *icmp0, u32 sw_if_index0, u32 rx_fib_index0, vlib_node_runtime_t *node, u32 next0, f64 now)
#define CLIB_CACHE_LINE_BYTES
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
uword runtime_data[(128-1 *sizeof(vlib_node_function_t *)-1 *sizeof(vlib_error_t *)-11 *sizeof(u32)-5 *sizeof(u16))/sizeof(uword)]
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
vnet_config_main_t config_main
static u16 ip_csum_fold(ip_csum_t c)