36 #define foreach_cnat_ipv4_udp_outside_input_error \ 37 _(CNAT_V4_UDP_O2I_T_PKT, "v4 udp o2i transmit") \ 38 _(CNAT_V4_DSLITE_ENCAP_CTR, "to dslite encap") \ 39 _(CNAT_V4_UDP_O2I_MISS_PKT, "v4 udp o2i db miss drop") \ 40 _(CNAT_V4_UDP_O2I_TTL_GEN, "v4 udp o2i TTL gen") \ 41 _(CNAT_V4_UDP_O2I_TTL_DROP, "v4 udp o2i TTL drop") \ 42 _(CNAT_V4_UDP_O2I_PTB_GEN, "v4 ptb gen") \ 43 _(CNAT_V4_UDP_O2I_PTB_DROP, "v4 ptb throttle drop") \ 44 _(CNAT_V4_UDP_O2I_SESSION_DROP, "v4 udp o2i session drop") \ 45 _(CNAT_V4_UDP_O2I_FILTER_DROP, "v4 udp o2i drop: end point filtering") \ 46 _(CNAT_V4_UDP_O2I_SUB_FRAG_NO_DB_DROP, "v4 udp o2i subsequent frag no DB drop") \ 47 _(CNAT_V4_UDP_O2I_1ST_FRAG_FILTER_DROP, "v4 udp i2o 1st frag filter drop") 50 #define _(sym,str) sym, 57 #define _(sym,string) string, 90 #define stage0 generic_stage0 94 typedef struct cnat_ipv4_udp_outside_input_pipeline_data_ {
96 dslite_common_pipeline_data_t common_data;
108 } cnat_ipv4_udp_outside_input_pipeline_data_t;
112 #define CNAT_UDP_OUTSIDE_UPDATE_FLAG_TIMER(db,dslite_nat44_inst_id) \ 113 if (PREDICT_FALSE(!(db->flags & CNAT_DB_FLAG_UDP_ACTIVE))) { \ 114 db->flags |= CNAT_DB_FLAG_UDP_ACTIVE; \ 115 CNAT_DB_TIMEOUT_RST(db); \ 116 } else if (PREDICT_FALSE(db->flags & CNAT_DB_DSLITE_FLAG)) { \ 117 if (PREDICT_TRUE(dslite_table_db_ptr[dslite_nat44_inst_id].mapping_refresh_both_direction)) { \ 118 CNAT_DB_TIMEOUT_RST(db); \ 120 } else if (PREDICT_TRUE(mapping_refresh_both_direction)) { \ 121 CNAT_DB_TIMEOUT_RST(db); \ 125 static cnat_ipv4_udp_outside_input_pipeline_data_t pctx_data[SPP_MAXDISPATCH];
126 #define EXTRA_PIPELINE_ARGS_PROTO , cnat_ipv4_udp_outside_input_pipeline_data_t *pctx 127 #define EXTRA_PIPELINE_ARGS , pctx 140 static inline void __attribute__((unused))
149 ((
u16)(db->out2in_key.k.ipv4 >> 16)),
150 (clib_host_to_net_u16(ip->checksum)),
151 ((
u16)(db->in2out_key.k.ipv4)),
152 ((
u16)(db->in2out_key.k.ipv4 >> 16)))
155 clib_host_to_net_u32(db->in2out_key.k.ipv4);
157 clib_host_to_net_u16(new_l3_c);
163 if(cnat_static_dest_db_get_translation(ip->src_addr, &postmap_ip, vrf, direction) ==
CNAT_SUCCESS) {
164 old_ip = spp_net_to_host_byte_order_32(&(ip->src_addr));
165 old_postmap_ip = spp_net_to_host_byte_order_32(&postmap_ip);
168 ((
u16)(old_ip >> 16)),
169 (spp_net_to_host_byte_order_16(&(ip->checksum))),
170 ((
u16)(old_postmap_ip & 0xFFFF)),
171 ((
u16)(old_postmap_ip >> 16)))
173 clib_host_to_net_u16(new_l3_c);
174 ip->src_addr = postmap_ip;
185 #define UDP_PACKET_DEBUG 1 188 #ifdef UDP_PACKET_DEBUG 190 printf(
"\nOut2In UDP packet before translation");
198 if(cnat_static_dest_db_get_translation(ip->
src_addr, &postmap_ip, vrf, direction) ==
CNAT_SUCCESS) {
202 old_ip = spp_net_to_host_byte_order_32(&(ip->
src_addr));
203 old_postmap_ip = spp_net_to_host_byte_order_32(&postmap_ip);
206 ((
u16)(old_ip >> 16)),
207 (spp_net_to_host_byte_order_16(&(udp->
src_port))),
208 (spp_net_to_host_byte_order_16(&(ip->
checksum))),
210 ((
u16)(old_postmap_ip & 0xFFFF)),
211 ((
u16)(old_postmap_ip >> 16)),
212 (spp_net_to_host_byte_order_16(&(udp->
src_port))))
215 clib_host_to_net_u16(new_l3_c);
233 (clib_net_to_host_u16(ip->
checksum)),
246 clib_host_to_net_u16(new_l3_c);
263 #ifdef UDP_PACKET_DEBUG 265 printf(
"\nOut2In UDP checksum 0x%x disabled by force", new_l4_c);
269 printf(
"\nOut2In UDP packet after translation");
313 #define SPP_LOG2_CACHE_LINE_BYTES 6 314 #define SPP_CACHE_LINE_BYTES (1 << SPP_LOG2_CACHE_LINE_BYTES) 320 uword prefetch_target0, prefetch_target1;
336 prefetch_target1 = prefetch_target0 +
371 }
while (db_index !=
EMPTY);
382 stage5(
spp_ctx_t **ctxs,
int index, spp_node_t *np,
383 u8 *disp_used EXTRA_PIPELINE_ARGS_PROTO))
386 u32 db_index = pctx[index].bucket;
388 u16 dslite_id = *(pctx[index].common_data.dslite_id_ptr);
390 DSLITE_PREFETCH_COUNTER(pctx[index].udp_counter,
393 v4_to_v6_udp_output_count,
396 DSLITE_PREFETCH_COUNTER(pctx[index].icmp_gen_counter,
407 db_index, user_db_index,
410 SPP_PREFETCH(prefetch_target0, 0, LOAD);
411 pctx[index].user_bucket = user_db_index;
429 int counter = CNAT_V4_UDP_O2I_T_PKT;
439 u16 dslite_nat44_inst_id __attribute__((unused)) = 0;
496 counter = CNAT_V4_UDP_O2I_SESSION_DROP;
521 counter = CNAT_V4_UDP_O2I_SESSION_DROP;
547 counter = CNAT_V4_UDP_O2I_MISS_PKT;
554 em->
counters[node_counter_base_index + counter] += 1;
564 return dispatch_pipeline (vm, node, frame);
570 .name =
"vcgn-v4-udp-o2i",
571 .vector_size =
sizeof (
u32),
574 .n_errors =
ARRAY_LEN(cnat_ipv4_udp_outside_input_error_strings),
cnat_main_db_entry_t * cnat_main_db
#define DSLITE_PRINTF(level,...)
nat44_dslite_global_stats_t nat44_dslite_global_stats[2]
cnat_session_entry_t * cnat_create_session_db_entry(cnat_key_t *ko, cnat_main_db_entry_t *bdb, u8 log)
bad routing header type(not 4)") sr_error (NO_MORE_SEGMENTS
u64 no_translation_entry_drops
void ipv4_decr_ttl_n_calc_csum(ipv4_header *ipv4)
struct _vlib_node_registration vlib_node_registration_t
#define STRUCT_OFFSET_OF(t, f)
cnat_session_entry_t * cnat_handle_1to2_session(cnat_main_db_entry_t *mdb, cnat_key_t *dest_info)
#define CNAT_UPDATE_L3_L4_CHECKSUM(old_l3_1, old_l3_2, old_l4, old_l3_c, old_l4_c, new_l3_1, new_l3_2, new_l4)
index_slist_t out2in_hash
vnet_main_t * vnet_get_main(void)
#define VLIB_INIT_FUNCTION(x)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
u32 udp_outside_checksum_disable
vlib_error_main_t error_main
u32 udp_outside_packet_dump_enable
cnat_user_db_entry_t * cnat_user_db
void print_udp_pkt(ipv4_header *ip)
#define CLIB_PREFETCH(addr, size, type)
u32 out2in_forwarding_count
void cnat_add_dest_n_log(cnat_main_db_entry_t *mdb, cnat_key_t *dest_info)
#define CNAT_UPDATE_L3_CHECKSUM_DECLARE
index_slist_t * cnat_out2in_hash
dslite_counters_t dslite_all_counters[DSLITE_MAX_DSLITE_ENTRIES]
#define CNAT_MAIN_HASH_MASK
struct _spp_ctx spp_ctx_t
#define VLIB_REGISTER_NODE(x,...)
static vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
Get vlib node by index.
#define CNAT_UPDATE_L3_L4_CHECKSUM_DECLARE
#define CNAT_V4_GET_HASH(key64, hash, mask)
#define CLIB_CACHE_LINE_BYTES
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
#define CNAT_UPDATE_L3_CHECKSUM(old_l3_1, old_l3_2, old_l3_c,new_l3_1, new_l3_2)
nat44_dslite_common_stats_t nat44_dslite_common_stats[255]