32 #define foreach_nat44_classify_error \ 33 _(MAX_REASS, "Maximum reassemblies exceeded") \ 34 _(MAX_FRAG, "Maximum fragments per reassembly exceeded") \ 35 _(NEXT_IN2OUT, "next in2out") \ 36 _(NEXT_OUT2IN, "next out2in") \ 37 _(FRAG_CACHED, "fragment cached") 41 #define _(sym,str) NAT44_CLASSIFY_ERROR_##sym, 48 #define _(sym,string) string, 76 s =
format (s,
"nat44-classify: fragment cached");
79 next = t->
next_in2out ?
"nat44-in2out" :
"nat44-out2in";
80 s =
format (s,
"nat44-classify: next %s", next);
91 u32 n_left_from, *from, *to_next;
97 u32 *fragments_to_drop = 0;
98 u32 *fragments_to_loopback = 0;
99 u32 next_in2out = 0, next_out2in = 0, frag_cached = 0;
105 while (n_left_from > 0)
111 while (n_left_from > 0 && n_left_to_next > 0)
122 nat_reass_ip4_t *reass0;
137 if (is_ed && ip0->
protocol != IP_PROTOCOL_ICMP)
161 node->
errors[NAT44_CLASSIFY_ERROR_MAX_REASS];
165 if (!clib_bihash_search_16_8 (&tsm->
in2out_ed, &ed_kv0,
171 reass0->sess_index = ed_value0.
value;
172 reass0->classify_next =
175 &fragments_to_loopback);
186 &fragments_to_loopback);
192 if (!clib_bihash_search_16_8 (&tsm->
in2out_ed, &ed_kv0,
211 node->
errors[NAT44_CLASSIFY_ERROR_MAX_REASS];
224 node->
errors[NAT44_CLASSIFY_ERROR_MAX_FRAG];
226 (
"maximum fragments per reassembly exceeded");
233 if (reass0->classify_next ==
275 if (!clib_bihash_search_8_8
295 node->
errors[NAT44_CLASSIFY_ERROR_MAX_REASS];
302 reass0->classify_next =
305 reass0->classify_next =
308 &fragments_to_loopback);
324 node->
errors[NAT44_CLASSIFY_ERROR_MAX_REASS];
335 node->
errors[NAT44_CLASSIFY_ERROR_MAX_FRAG];
337 (
"maximum fragments per reassembly exceeded");
344 else if (reass0->classify_next ==
347 else if (reass0->classify_next ==
355 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
377 to_next, n_left_to_next,
381 if (n_left_from == 0 &&
vec_len (fragments_to_loopback))
412 NAT44_CLASSIFY_ERROR_NEXT_IN2OUT, next_in2out);
414 NAT44_CLASSIFY_ERROR_NEXT_OUT2IN, next_out2in);
416 NAT44_CLASSIFY_ERROR_FRAG_CACHED, frag_cached);
431 .name =
"nat44-classify",
432 .vector_size =
sizeof (
u32),
457 .name =
"nat44-ed-classify",
458 .vector_size =
sizeof (
u32),
483 .name =
"nat44-det-classify",
484 .vector_size =
sizeof (
u32),
510 .name =
"nat44-handoff-classify",
511 .vector_size =
sizeof (
u32),
ip4_address_t external_addr
#define clib_memcpy_fast(a, b, c)
vlib_node_registration_t nat44_ed_classify_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_classify_node)
u32 fib_table_get_index_for_sw_if_index(fib_protocol_t proto, u32 sw_if_index)
Get the index of the FIB bound to the interface.
static uword nat44_classify_node_fn_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int is_ed)
static u8 * format_nat44_classify_trace(u8 *s, va_list *args)
vlib_error_t * errors
Vector of errors for this node.
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
static int ip4_is_fragment(const ip4_header_t *i)
static uword nat44_handoff_classify_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static void * ip4_next_header(ip4_header_t *i)
#define NAT_REASS_FLAG_CLASSIFY_ED_CONTINUE
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
VLIB_NODE_FUNCTION_MULTIARCH(nat44_classify_node, nat44_classify_node_fn)
snat_static_mapping_t * static_mappings
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
clib_bihash_8_8_t static_mapping_by_external
vlib_node_registration_t nat44_handoff_classify_node
(constructor) VLIB_REGISTER_NODE (nat44_handoff_classify_node)
u32 node_index
Node index.
#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).
#define nat_log_notice(...)
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 VLIB_REGISTER_NODE(x,...)
static uword nat44_ed_classify_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
#define vec_free(V)
Free vector's memory (no header).
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.
vlib_node_registration_t nat44_classify_node
(constructor) VLIB_REGISTER_NODE (nat44_classify_node)
static void make_ed_kv(clib_bihash_kv_16_8_t *kv, ip4_address_t *l_addr, ip4_address_t *r_addr, u8 proto, u32 fib_index, u16 l_port, u16 r_port)
static char * nat44_classify_error_strings[]
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
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 int ip4_is_first_fragment(const ip4_header_t *i)
static u32 ip_proto_to_snat_proto(u8 ip_proto)
The NAT inline functions.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
snat_main_per_thread_data_t * per_thread_data
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
static uword nat44_classify_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
snat_address_t * addresses
nat_reass_ip4_t * nat_ip4_reass_find_or_create(ip4_address_t src, ip4_address_t dst, u16 frag_id, u8 proto, u8 reset_timeout, u32 **bi_to_drop)
Find or create reassembly.
vlib_node_registration_t nat44_det_classify_node
(constructor) VLIB_REGISTER_NODE (nat44_det_classify_node)
int nat_ip4_reass_add_fragment(nat_reass_ip4_t *reass, u32 bi, u32 **bi_to_drop)
Cache fragment.
#define vec_foreach(var, vec)
Vector iterator.
u16 flags
Copy of main node flags.
static void nat_send_all_to_node(vlib_main_t *vm, u32 *bi_vector, vlib_node_runtime_t *node, vlib_error_t *error, u32 next)
static uword nat44_det_classify_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
clib_bihash_16_8_t in2out_ed
void nat_ip4_reass_get_frags(nat_reass_ip4_t *reass, u32 **bi)
Get cached fragments.
NAT plugin virtual fragmentation reassembly.
#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.
#define foreach_nat44_classify_error
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static uword pool_elts(void *v)
Number of active elements in a pool.