27 #define foreach_cnat_ipv4_icmp_e_inside_input_error \ 28 _(CNAT_V4_ICMP_E_I2O_T_PKT, "cnat v4 icmp_e i2o packet transmit") \ 29 _(CNAT_V4_ICMP_E_I2O_D_PKT, "cnat v4 icmp_e i2o packet drop") \ 30 _(CNAT_V4_ICMP_E_I2O_TTL_DROP, "cnat v4 icmp_e i2o ttl drop") 33 #define _(sym,str) sym, 40 #define _(sym,string) string, 85 em_ip = icmp_info->
em_ip;
90 (clib_net_to_host_u16(em_ip->checksum)),
94 old_ip = clib_net_to_host_u32(em_ip->dest_addr);
95 old_port = clib_net_to_host_u16(*em_port);
96 old_ip_checksum = clib_net_to_host_u16(em_ip->checksum);
101 clib_host_to_net_u16(new_l3_c);
108 icmp = icmp_info->
icmp;
110 ((
u16)(old_ip >> 16)),
113 (clib_net_to_host_u16(icmp->
checksum)),
120 clib_host_to_net_u16(new_icmp_c);
122 old_ip = clib_net_to_host_u32(ip->
src_addr);
128 ((
u16)(old_ip >> 16)),
129 (clib_net_to_host_u16(ip->
checksum)),
133 clib_host_to_net_u16(new_l3_c);
140 em_snat_ip = icmp_info->
em_ip;
141 em_snat_port = icmp_info->
em_port;
143 old_ip = spp_net_to_host_byte_order_32(&(em_snat_ip->src_addr));
144 old_port = spp_net_to_host_byte_order_16(em_snat_port);
145 old_ip_checksum = spp_net_to_host_byte_order_16(&(em_snat_ip->checksum));
147 if(cnat_static_dest_db_get_translation(em_snat_ip->src_addr, &postmap_ip, vrf, direction) ==
CNAT_SUCCESS) {
148 old_postmap_ip = spp_net_to_host_byte_order_32(&postmap_ip);
151 ((
u16)(old_ip >> 16)),
152 (spp_net_to_host_byte_order_16(&(em_snat_ip->checksum))),
153 ((
u16)(old_postmap_ip)),
154 ((
u16)(old_postmap_ip >> 16)))
155 em_snat_ip->src_addr = postmap_ip;
156 em_snat_ip->checksum =
157 spp_host_to_net_byte_order_16(new_l3_c);
162 icmp = icmp_info->
icmp;
164 ((
u16)(old_ip >> 16)),
167 (spp_net_to_host_byte_order_16(&(icmp->
checksum))),
168 ((
u16)(old_postmap_ip & 0xffff)),
169 ((
u16)(old_postmap_ip >> 16)),
174 spp_host_to_net_byte_order_16(new_icmp_c);
181 if(cnat_static_dest_db_get_translation(ip->
dest_addr, &postmap_ip, vrf, direction) ==
CNAT_SUCCESS) {
183 old_ip = spp_net_to_host_byte_order_32(&(ip->
dest_addr));
184 old_postmap_ip = spp_net_to_host_byte_order_32(&postmap_ip);
187 ((
u16)(old_ip >> 16)),
188 (spp_net_to_host_byte_order_16(&(ip->
checksum))),
189 ((
u16)(old_postmap_ip & 0xFFFF)),
190 ((
u16)(old_postmap_ip >> 16)))
194 clib_host_to_net_u16(new_l3_c);
205 #define stage0 generic_stage0 274 #define SPP_LOG2_CACHE_LINE_BYTES 6 275 #define SPP_CACHE_LINE_BYTES (1 << SPP_LOG2_CACHE_LINE_BYTES) 281 uword prefetch_target0, prefetch_target1;
297 prefetch_target1 = prefetch_target0 +
332 }
while (db_index !=
EMPTY);
347 int counter = CNAT_V4_ICMP_E_I2O_T_PKT;
369 counter = CNAT_V4_ICMP_E_I2O_TTL_DROP;
376 icmp_info.
em_ip = em_ip;
377 icmp_info.
icmp = icmp;
390 ((
u8 *)em_ip + em_ip_hdr_len);
407 printf(
"\nDUMPING ICMP PKT BEFORE\n");
422 printf(
"\nDUMPING ICMP PKT AFTER\n");
429 counter = CNAT_V4_ICMP_E_I2O_D_PKT;
434 em->
counters[node_counter_base_index + counter] += 1;
444 return dispatch_pipeline (vm, node, frame);
450 .name =
"vcgn-v4-icmp-e-i2o",
451 .vector_size =
sizeof (
u32),
cnat_main_db_entry_t * cnat_main_db
always_inline vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
bad routing header type(not 4)") sr_error (NO_MORE_SEGMENTS
struct _vlib_node_registration vlib_node_registration_t
#define STRUCT_OFFSET_OF(t, f)
index_slist_t in2out_hash
always_inline void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
vnet_main_t * vnet_get_main(void)
index_slist_t * cnat_in2out_hash
#define VLIB_INIT_FUNCTION(x)
#define CNAT_UPDATE_ICMP_ERR_CHECKSUM(old_ip_1, old_ip_2, old_ip_port, old_ip_c, old_icmp_c, new_ip_1, new_ip_2, new_ip_port, new_ip_c)
vlib_error_main_t error_main
#define CLIB_PREFETCH(addr, size, type)
#define CNAT_UPDATE_ICMP_ERR_CHECKSUM_DECLARE
#define CNAT_UPDATE_L3_CHECKSUM_DECLARE
#define CNAT_MAIN_HASH_MASK
always_inline void ipv4_decr_ttl_n_calc_csum(ipv4_header *ipv4)
u32 in2out_forwarding_count
#define VLIB_REGISTER_NODE(x,...)
#define CNAT_V4_GET_HASH(key64, hash, mask)
#define CLIB_CACHE_LINE_BYTES
void print_icmp_pkt(ipv4_header *ip)
always_inline vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
#define CNAT_INVALID_PROTO
#define CNAT_UPDATE_L3_CHECKSUM(old_l3_1, old_l3_2, old_l3_c,new_l3_1, new_l3_2)