27 #define foreach_cnat_ipv4_icmp_e_outside_input_error \ 28 _(CNAT_V4_ICMP_E_O2I_T_PKT, "cnat v4 icmp_e o2i packet transmit") \ 29 _(CNAT_V4_ICMP_E_O2I_D_PKT, "cnat v4 icmp_e o2i packet drop") \ 30 _(CNAT_V4_ICMP_E_O2I_TTL_DROP, "cnat v4 icmp_e o2i 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->src_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->
dest_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->dest_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->dest_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->dest_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->
src_addr, &postmap_ip, vrf, direction) ==
CNAT_SUCCESS) {
184 old_ip = spp_net_to_host_byte_order_32(&(ip->
src_addr));
185 old_postmap_ip = spp_net_to_host_byte_order_32(&postmap_ip);
188 ((
u16)(old_ip >> 16)),
189 (spp_net_to_host_byte_order_16(&(ip->
checksum))),
190 ((
u16)(old_postmap_ip & 0xFFFF)),
191 ((
u16)(old_postmap_ip >> 16)))
193 spp_host_to_net_byte_order_16(new_l3_c);
204 #define stage0 generic_stage0 228 clib_net_to_host_u16(tcp->
src_port);
234 clib_net_to_host_u16(udp->
src_port);
255 clib_net_to_host_u32(em_ip->
src_addr);
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 +
333 }
while (db_index !=
EMPTY);
346 int counter = CNAT_V4_ICMP_E_O2I_T_PKT;
362 icmp_info.
em_ip = em_ip;
363 icmp_info.
icmp = icmp;
376 ((
u8 *)em_ip + em_ip_hdr_len);
386 printf(
"\nDUMPING ICMP PKT BEFORE\n");
401 printf(
"\nDUMPING ICMP PKT AFTER\n");
407 counter = CNAT_V4_ICMP_E_O2I_D_PKT;
410 em->
counters[node_counter_base_index + counter] += 1;
420 return dispatch_pipeline (vm, node, frame);
426 .name =
"vcgn-v4-icmp-e-o2i",
427 .vector_size =
sizeof (
u32),
cnat_main_db_entry_t * cnat_main_db
bad routing header type(not 4)") sr_error (NO_MORE_SEGMENTS
void ipv4_decr_ttl_n_calc_csum(ipv4_header *ipv4)
struct _vlib_node_registration vlib_node_registration_t
#define STRUCT_OFFSET_OF(t, f)
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.
#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
index_slist_t * cnat_out2in_hash
#define CNAT_MAIN_HASH_MASK
#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_V4_GET_HASH(key64, hash, mask)
#define CLIB_CACHE_LINE_BYTES
void print_icmp_pkt(ipv4_header *ip)
#define CNAT_INVALID_PROTO
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)