if (unformat_user (input, unformat_vlib_cli_sub_command, vm, c, &parent))
;
- else if (! unformat_check_input (input) == UNFORMAT_END_OF_INPUT)
+ else if (! (unformat_check_input (input) == UNFORMAT_END_OF_INPUT))
goto unknown;
else
vlib_cli_output(vm, "vCGN NAT44 Statistics :\n");
vlib_cli_output(vm, "\tActive Translations : %u\n",
NAT44_COMMON_STATS.active_translations);
- vlib_cli_output(vm, "\tTotal free address : %u\n", free);
- vlib_cli_output(vm, "\tTotal used address : %u\n", used);
+ vlib_cli_output(vm, "\tTotal free translation entries : %u\n", free);
+ vlib_cli_output(vm, "\tTotal used translation entries : %u\n", used);
vlib_cli_output(vm, "\ti2o drops due to port limit exceeded : %lu\n",
in2out_drops_port_limit_exceeded);
vlib_cli_output(vm, "\ti2o drops due to system limit reached : %lu\n",
in2out_drops_system_limit_reached);
vlib_cli_output(vm, "\ti2o drops due to resource depletion : %lu\n",
in2out_drops_resource_depletion);
- vlib_cli_output(vm, "\ti2o drops due to no translations : %lu\n",
+ vlib_cli_output(vm, "\to2i drops due to no translations : %lu\n",
NAT44_COMMON_STATS.no_translation_entry_drops);
vlib_cli_output(vm, "\tPool address usage:\n");
u8 status_str[20];
cnat_nfv9_logging_info_t *my_nfv9_logging_info,
*global_nfv9_logging_info = 0;
+
+ vnet_hw_interface_t * hw;
+ dpdk_main_t * dm = &dpdk_main;
+
void cnat_nfv9_show_collector
(vlib_main_t *vm, cnat_nfv9_logging_info_t *my_nfv9_logging_info);
vlib_cli_output(vm, "\tdynamic port start range : %u\n", cnat_static_port_range);
pool_foreach(my_vrfmap, cnat_map_by_vrf, ({
- vlib_cli_output(vm, "\ti-intf-index : 0x%x\n", my_vrfmap->i_vrf);
- vlib_cli_output(vm, "\to-intf-index : 0x%x\n", my_vrfmap->o_vrf);
+ hw = vnet_get_hw_interface (dm->vnet_main, my_vrfmap->i_vrf);
+ vlib_cli_output(vm, "\tInside Interface : %s\n", hw->name);
+ hw = vnet_get_hw_interface (dm->vnet_main, my_vrfmap->o_vrf);
+ vlib_cli_output(vm, "\tOutside Interface : %s\n", hw->name);
memset(status_str, 0x00, sizeof(status_str));
switch(my_vrfmap->status) {
case S_WAO: memcpy(status_str, "S_WAO", 5); break;
case S_WA: memcpy(status_str, "S_WA", 4); break;
case S_WO: memcpy(status_str, "S_WO", 4); break;
- case S_RUN: memcpy(status_str, "S_RUN", 5); break;
+ case S_RUN: memcpy(status_str, "ONLINE", 6); break;
case S_DEL: memcpy(status_str, "S_DEL", 5); break;
default: memcpy(status_str, "Invalid state", 13);
}
vlib_cli_output(vm,
- "\tvrf map table status : %s\n", status_str);
+ "\tAddress pool map table status : %s\n", status_str);
pm = my_vrfmap->portmap_list;
pm_len = vec_len(pm);
cnat_v4_show_translation_entry entry[PLATFORM_MAX_TRANSLATION_ENTRIES];
u8 display_entry;
u8 flag_str[11];
+ vnet_hw_interface_t * hw;
+ dpdk_main_t * dm = &dpdk_main;
ki.k.k.ipv4 = mp->ipv4_addr;
ki.k.k.vrf = mp->vrf_id;
start_port = mp->start_port;
end_port = mp->end_port;
- //memset(flag_str,0x00,11);
- //strncpy(flag_str,"NA",2);
#if DEBUG
vlib_cli_output(vm, "## proto %d, inside-addr 0x%x, start_port %u, "
"end_port %u, vrf 0x%x, flag 0x%x\n",
else strncpy((char *)transl_str, "Unknown", 7); /* currently we are not supporting static/alg entries */
ip.s_addr = clib_net_to_host_u32(u_ki.k.k.ipv4);
+ hw = vnet_get_hw_interface (dm->vnet_main, u_ki.k.k.vrf);
vlib_cli_output (vm, "Inside-translation details\n");
vlib_cli_output (vm, "--------------------------\n");
- vlib_cli_output (vm, "Inside interface index : 0x%x\n", u_ki.k.k.vrf);
+ vlib_cli_output (vm, "Inside interface : %s\n", hw->name);
vlib_cli_output (vm, "Inside address : %s\n", inet_ntoa(ip));
vlib_cli_output (vm, "Start port : %u\n", start_port);
vlib_cli_output (vm, "End port : %u\n", end_port);
u8 done = 0;
u8 display_entry;
u8 flag_str[11];
+ vnet_hw_interface_t * hw;
+ dpdk_main_t * dm = &dpdk_main;
ko.k.k.ipv4 = mp->ipv4_addr;
ko.k.k.vrf = mp->vrf_id;
else strncpy((char *)transl_str, "Unknown", 7); /* currently we are not supporting static/alg entries */
ip.s_addr = clib_net_to_host_u32(ko.k.k.ipv4);
+ hw = vnet_get_hw_interface (dm->vnet_main, (ko.k.k.vrf & CNAT_VRF_MASK));
vlib_cli_output (vm, "Outside-translation details\n");
vlib_cli_output (vm, "--------------------------\n");
- vlib_cli_output (vm, "Outside interface index : 0x%x\n", (ko.k.k.vrf & CNAT_VRF_MASK));
+ vlib_cli_output (vm, "Outside interface : %s\n", hw->name);
vlib_cli_output (vm, "Outside address : %s\n", inet_ntoa(ip));
vlib_cli_output (vm, "Start port : %u\n", start_port);
vlib_cli_output (vm, "End port : %u\n", end_port);
u16 *em_l4_checksum;
} icmp_em_ip_info;
-inline void swap_ip_src_icmp_id(ipv4_header *ip,
+extern void swap_ip_src_icmp_id(ipv4_header *ip,
icmp_v4_t *icmp,
cnat_main_db_entry_t *db,
- u16 vrf);
+ u16 vrf);
-inline void swap_ip_dst_icmp_id(ipv4_header *ip,
+extern void swap_ip_dst_icmp_id(ipv4_header *ip,
icmp_v4_t *icmp,
cnat_main_db_entry_t *db,
- u16 vrf);
+ u16 vrf);
+
+extern void swap_ip_src_emip_dst(ipv4_header *ip,
+ icmp_em_ip_info *icmp_info,
+ cnat_main_db_entry_t *db, u16 vrf);
+
+extern void swap_ip_dst_emip_src(ipv4_header *ip,
+ icmp_em_ip_info *icmp_info,
+ cnat_main_db_entry_t *db, u16 vrf);
+
#endif /* __CNAT_IPV4_ICMP_H__ */
#define NSTAGES 5
-void swap_ip_src_emip_dst(ipv4_header *ip,
+inline void swap_ip_src_emip_dst(ipv4_header *ip,
icmp_em_ip_info *icmp_info,
cnat_main_db_entry_t *db, u16 vrf)
{
#define NSTAGES 5
-void swap_ip_dst_emip_src(ipv4_header *ip,
+inline void swap_ip_dst_emip_src(ipv4_header *ip,
icmp_em_ip_info *icmp_info,
cnat_main_db_entry_t *db, u16 vrf)
{
#define NSTAGES 5
-void swap_ip_src_icmp_id(ipv4_header *ip,
+inline void swap_ip_src_icmp_id(ipv4_header *ip,
icmp_v4_t *icmp,
cnat_main_db_entry_t *db, u16 vrf)
{
#define NSTAGES 5
-void swap_ip_dst_icmp_id(ipv4_header *ip,
+inline void swap_ip_dst_icmp_id(ipv4_header *ip,
icmp_v4_t *icmp,
cnat_main_db_entry_t *db, u16 vrf)
{
#include "cnat_global.h"
#include "cnat_config.h"
-inline void swap_ip_src_udp_port(ipv4_header *ip,
+extern void swap_ip_src_udp_port(ipv4_header *ip,
udp_hdr_type_t *udp,
cnat_main_db_entry_t *db);
-inline void swap_ip_dst_udp_port(ipv4_header *ip,
+extern void swap_ip_dst_udp_port(ipv4_header *ip,
udp_hdr_type_t *udp,
cnat_main_db_entry_t *db,
u16 vrf);
}
#endif
-void swap_ip_src_udp_port(ipv4_header *ip,
+inline void swap_ip_src_udp_port(ipv4_header *ip,
udp_hdr_type_t *udp,
cnat_main_db_entry_t *db)
{
return CNAT_NO_CONFIG;
}*/
-inline void swap_ip_dst(ipv4_header *ip,
+static inline void swap_ip_dst(ipv4_header *ip,
cnat_main_db_entry_t *db, u16 vrf)
{
#endif
}
-void swap_ip_dst_udp_port(ipv4_header *ip,
+inline void swap_ip_dst_udp_port(ipv4_header *ip,
udp_hdr_type_t *udp,
cnat_main_db_entry_t *db, u16 vrf)
{
* returns the difference
*/
+static inline
int cnat_nfv9_pad_added_to_an_addr(u8 *new_addr, u8 *org_addr)
{
uword addr1 = (uword) new_addr;
* pointer to the data pointer
*/
+static inline
u8 *cnat_nfv9_add_end_of_record_padding (u8 *data_ptr)
{
uword tmp = (uword) data_ptr;
* pointer to the data pointer
*/
+static inline
u16 cnat_nfv9_pad_end_of_record_length (u16 record_length)
{
u16 pad_value = NFV9_PAD_VALUE;
* structure that contains the packet context
*/
+static inline
void cnat_nfv9_fill_nfv9_ip_header (cnat_nfv9_logging_info_t *nfv9_logging_info)
{
u16 new_record_length = 0;
* structure that contains the packet context
*/
+static inline
void cnat_nfv9_send_queued_pkt (cnat_nfv9_logging_info_t *nfv9_logging_info)
{
+ return;
}
/*
* structure that contains the packet context
*/
+static inline
void cnat_nfv9_send_pkt (cnat_nfv9_logging_info_t *nfv9_logging_info)
{
cnat_nfv9_fill_nfv9_ip_header(nfv9_logging_info);
/*
* send_vpp3_nfv9_pkt: to send multiple b0 in a frame
*/
-#if 0
-inline void send_vpp3_nfv9_pkt (cnat_nfv9_logging_info_t *nfv9_logging_info)
-{
- vlib_main_t *vm = vlib_get_main();
- vlib_frame_t *f;
- vlib_buffer_t *b0;
- u32 ip4_input_node_index;
- //u32 * to_next, * from, bi0 =0;
- u32 bi0 =0;
- ipv4_header * h0, *ip;
- static u32 * buffers;
- u32 nalloc;
- udp_header_t * udp;
- u16 udp_length, ip_length;
-
-
- ip4_input_node_index = nfv9_logging_info->ip4_input_node_index;
- f = nfv9_logging_info->f;
- if (f == NULL) {
- nfv9_logging_info->f = vlib_get_frame_to_node(vm, ip4_input_node_index);
- f = nfv9_logging_info->f;
- f->n_vectors = 0;
- nfv9_logging_info->to_next = vlib_frame_vector_args (f);
- }
- /* Build a pkt from whole cloth */
- b0 = nfv9_logging_info->current_logging_context;
- //to_next = nfv9_logging_info->to_next;
- ip = vlib_buffer_get_current (b0);
- //if (PREDICT_TRUE(f->n_vectors < VLIB_FRAME_SIZE)) {
- if (PREDICT_TRUE(f->n_vectors < 5)) {
-
- b0->current_length = clib_net_to_host_u16(ip->total_len_bytes);
- bi0 = vlib_get_buffer_index (vm, b0);
- nfv9_logging_info->to_next[0] = bi0;
- printf("f->n_vec %d f %p to_next %p val %d b0 %p\n",
- f->n_vectors, f, nfv9_logging_info->to_next,
- nfv9_logging_info->to_next[0], b0);
- //to_next++;
- nfv9_logging_info->to_next++; // = to_next;
- f->n_vectors++;
- }
-
- //if (f->n_vectors == VLIB_FRAME_SIZE)
- if (f->n_vectors == 5) {
- printf("sending pkt on 256\n");
- printf("%s: total_len_bytes %d bi %d nfv9_logging_info->pkt_length %d index %d\n",
- __func__, clib_net_to_host_u16(ip->total_len_bytes),
- bi0, nfv9_logging_info->pkt_length, ip4_input_node_index);
- vlib_put_frame_to_node(vm, ip4_input_node_index, f);
- nfv9_logging_info->f = NULL;
- nfv9_logging_info->to_next = NULL;
- }
- return;
-}
-#endif
-/*
- * send_vpp3_nfv9_pkt: to send one b0 in a frame
- */
+
+static inline
void send_vpp3_nfv9_pkt (cnat_nfv9_logging_info_t *nfv9_logging_info)
{
vlib_node_t *output_node;
* vlib_node_t structure for rewrite_output node
*/
+static inline
void cnat_nfv9_send_pkt_always_success (
cnat_nfv9_logging_info_t *nfv9_logging_info,
vlib_node_t *output_node)
* the packet context as well.
*/
+static inline
void cnat_nfv9_create_logging_context (
cnat_nfv9_logging_info_t *nfv9_logging_info,
cnat_nfv9_template_add_flag_t template_flag)
*/
-inline
+static inline
void handle_vrfid_name_mapping(void)
{
cnat_nfv9_logging_info_t *nfv9_logging_info = NULL;
bytes[1] = (ip >> 8) & 0xFF;
bytes[2] = (ip >> 16) & 0xFF;
bytes[3] = (ip >> 24) & 0xFF;
- vlib_cli_output(vm, "\tIP Address %d.%d.%d.%d\n", bytes[0], bytes[1], bytes[2], bytes[3]);
+ vlib_cli_output(vm, "\tIP Address : %d.%d.%d.%d\n", bytes[0], bytes[1], bytes[2], bytes[3]);
}
void cnat_nfv9_show_collector (vlib_main_t *vm, cnat_nfv9_logging_info_t *my_nfv9_logging_info)
{
nfv9_server_info_t *server = nfv9_server_info_pool +
my_nfv9_logging_info->server_index;
-
+#if 0
vlib_cli_output(vm,"\tVRF - 0x%x - %s\n", my_nfv9_logging_info->i_vrf,
my_nfv9_logging_info->deleted?"DELETED":"ACTIVE");
+#endif
print_server_ip_address(vm, clib_net_to_host_u32(server->ipv4_address));
- vlib_cli_output(vm,"\tIP port %d\n", server->port);
- vlib_cli_output(vm,"\tTimeout %d\n", server->timeout_rate);
- vlib_cli_output(vm,"\tRefresh %d\n", server->refresh_rate);
- vlib_cli_output(vm,"\tMax PkSz %d\n", my_nfv9_logging_info->max_length_minus_max_record_size);
+ vlib_cli_output(vm,"\tPort : %d\n", server->port);
+ vlib_cli_output(vm,"\tTimeout : %d\n", server->timeout_rate);
+ vlib_cli_output(vm,"\tRefresh Rate : %d\n", server->refresh_rate);
+ vlib_cli_output(vm,"\tMax Pkt Size : %d\n", my_nfv9_logging_info->max_length_minus_max_record_size);
+
+ return;
}
void cnat_db_dump_policy (int argc, unsigned long *argv)
* ip & tcp checksum update (incremental)
*/
-void tcp_in2out_nat_mss_n_checksum (ipv4_header * ip,
+inline void tcp_in2out_nat_mss_n_checksum (ipv4_header * ip,
tcp_hdr_type * tcp,
u32 ipv4_addr,
u16 port,
}
-inline void tcp_in2out_nat_mss_n_checksum (ipv4_header *ip,
+extern void tcp_in2out_nat_mss_n_checksum (ipv4_header *ip,
tcp_hdr_type *tcp,
u32 ipv4_addr,
u16 port,
/* To be filled */
}
-u32 spp_trace_log_get_unix_time_in_seconds (void)
+inline u32 spp_trace_log_get_unix_time_in_seconds (void)
{
vlib_main_t *vlib_main;
* See the License for the specific language governing permissions and
* limitations under the License.
*------------------------------------------------------------------
- */
+ */
#ifndef __SPP_PLATFORM_TRACE_LOG_H__
#define __SPP_PLATFORM_TRACE_LOG_H__
* The following 2 functions are temporary hacks until
* we have RTC support from the PD nodes
*/
+#if 0
inline
u32 spp_trace_log_get_sys_up_time_in_ms (void);
-
-inline
+#endif
+extern
u32 spp_trace_log_get_unix_time_in_seconds (void);
enum {
* requires max number of bytes. If you add more records,
* this needs to be re-checked */
if (max_length_minus_max_record_size < CNAT_NFV9_MIN_RECORD_SIZE) {
- printf(
- "Resetting max_length_minus_max_record_size from %d to %ld\n",
- max_length_minus_max_record_size,
- CNAT_NFV9_MIN_RECORD_SIZE);
-
max_length_minus_max_record_size = CNAT_NFV9_MIN_RECORD_SIZE;
}
return max_length_minus_max_record_size;
u16 i_vrf;
u32 i_vrf_id;
u8 found;
- u8 found_vrf;
/*
* Init NFv9 logging info as needed, this will be done only once
*/
ip_addr, port, refresh_rate,
timeout, pmtu, enable);
#endif
+ if (refresh_rate == 0) refresh_rate = 500; /* num of pkts */
+ if (timeout == 0) timeout = 30; /* in mins */
+
nfv9_conf.enable = enable;
nfv9_conf.ipv4_address = ip_addr;
nfv9_conf.i_vrf_id = vcm->inside_sw_if_index;
/* Do we already have a map for this VRF? */
pool_foreach (my_nfv9_logging_info, cnat_nfv9_logging_info_pool, ({
if (my_nfv9_logging_info->i_vrf_id == i_vrf_id) {
- found_vrf = 1;
- printf("found_vrf %d\n", found_vrf);
nfv9_server_info_t *server = nfv9_server_info_pool +
my_nfv9_logging_info->server_index;
- printf("server ip4 0x%x port %d\n", server->ipv4_address, server->port);
- printf("nfv9_conf v4 0x%x port %d\n", nfv9_conf.ipv4_address, nfv9_conf.port);
if((server->ipv4_address == (nfv9_conf.ipv4_address)) && (server->port == (nfv9_conf.port))) {
found = 1;
my_nfv9_logging_info_tmp = my_nfv9_logging_info;
- printf("found %d\n", found);
break;
}
}
}
my_vrfmap->nf_logging_policy = nfv9_logging_policy;
}
- printf("After deleting the netflow server,Netflow logging policy = %d\n", my_vrfmap->nf_logging_policy);
}
done: