summaryrefslogtreecommitdiffstats
path: root/VNFs/vCGNAPT
diff options
context:
space:
mode:
Diffstat (limited to 'VNFs/vCGNAPT')
-rw-r--r--VNFs/vCGNAPT/Makefile11
-rw-r--r--VNFs/vCGNAPT/config/sample_hwlb_2port_2WT.tc11
-rw-r--r--VNFs/vCGNAPT/config/sample_swlb_2port_2WT.tc8
-rw-r--r--VNFs/vCGNAPT/init.c1
-rw-r--r--VNFs/vCGNAPT/main.c18
-rw-r--r--VNFs/vCGNAPT/pipeline/pipeline_cgnapt.c226
-rw-r--r--VNFs/vCGNAPT/pipeline/pipeline_cgnapt.h8
-rw-r--r--VNFs/vCGNAPT/pipeline/pipeline_cgnapt_be.c486
-rw-r--r--VNFs/vCGNAPT/pipeline/pipeline_cgnapt_be.h8
-rw-r--r--VNFs/vCGNAPT/pipeline/pipeline_cgnapt_common.h4
-rw-r--r--VNFs/vCGNAPT/vnf_template.txt80
11 files changed, 569 insertions, 292 deletions
diff --git a/VNFs/vCGNAPT/Makefile b/VNFs/vCGNAPT/Makefile
index e349f627..41cacfb7 100644
--- a/VNFs/vCGNAPT/Makefile
+++ b/VNFs/vCGNAPT/Makefile
@@ -41,6 +41,7 @@ VPATH += $(SRCDIR)/pipeline
VPATH += $(VNF_CORE)/common/VIL/pipeline_txrx
VPATH += $(VNF_CORE)/common/VIL/alg
VPATH += $(VNF_CORE)/common/VIL/l2l3_stack
+VPATH += $(VNF_CORE)/common/VIL/gateway
INC += $(wildcard *.h)
INC += $(wildcard pipeline/*.h)
@@ -54,6 +55,7 @@ INC += $(wildcard $(VNF_CORE)/common/VIL/pipeline_passthrough/*.h)
INC += $(wildcard $(VNF_CORE)/common/VIL/pipeline_txrx/*.h)
INC += $(wildcard $(VNF_CORE)/common/VIL/conntrack/*.h)
INC += $(wildcard $(VNF_CORE)/common/VIL/alg/*.h)
+INC += $(wildcard $(VNF_CORE)/common/VIL/gateway/*.h)
CFLAGS += -I$(SRCDIR) -mrtm -mhle -I$(SRCDIR)/pipeline -I$(VNF_CORE)/common/vnf_common
CFLAGS += -I$(VNF_CORE)/common/VIL/l2l3_stack -I$(VNF_CORE)/common/VIL/conntrack
@@ -61,10 +63,18 @@ CFLAGS += -I$(VNF_CORE)/common/VIL/pipeline_common -I$(VNF_CORE)/common/VIL/pipe
CFLAGS += -I$(VNF_CORE)/common/VIL/pipeline_master -I$(VNF_CORE)/common/VIL/pipeline_passthrough
CFLAGS += -I$(VNF_CORE)/common/VIL/pipeline_txrx -I$(VNF_CORE)/common/VIL/alg
CFLAGS += -I$(VNF_CORE)/common/VIL/pipeline_arpicmp
+CFLAGS += -I$(VNF_CORE)/common/VIL/gateway
+
+TOP = $(RTE_SDK)/../civetweb
+CFLAGS += -I$(TOP)/include $(COPT) -DUSE_WEBSOCKET -DUSE_IPV6 -DUSE_SSL_DH=1
+CFLAGS += -DREST_API_SUPPORT
+LDFLAGS += -ljson -lcrypto -lssl
+LDFLAGS += -L$(RTE_SDK)/../civetweb/ -lcivetweb
# all source are stored in SRCS-y
SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) := main.c
SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += config_parse.c
+SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += rest_api.c
SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += config_parse_tm.c
SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += config_check.c
SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += init.c
@@ -106,6 +116,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += cgnapt_pcp_be.c
SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += cgnapt_pcp_fe.c
SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += lib_sip_alg.c
SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += lib_ftp_alg.c
+SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += gateway.c
CFLAGS += -O3
CFLAGS += -DIPV6
diff --git a/VNFs/vCGNAPT/config/sample_hwlb_2port_2WT.tc b/VNFs/vCGNAPT/config/sample_hwlb_2port_2WT.tc
index 47ee0633..3cb90c9a 100644
--- a/VNFs/vCGNAPT/config/sample_hwlb_2port_2WT.tc
+++ b/VNFs/vCGNAPT/config/sample_hwlb_2port_2WT.tc
@@ -19,12 +19,13 @@ link 1 up
;p 1 arpadd 0 0064:ff9b:0:0:0:0:ca10:6414 00:00:00:00:00:01
;p 1 arpadd 1 0064:ff9b:0:0:0:0:ac10:2814 00:00:00:00:00:02
-routeadd 0 202.16.100.20 0xff000000
-routeadd 2 172.16.40.20 0xff000000
+; routeadd <net/host> <port #> <ipv4 nhip address in decimal> <Mask/NotApplicable>
+routeadd net 0 202.16.100.20 0xff000000
+routeadd net 1 172.16.40.20 0xff000000
-;routeadd <port #> <ipv6 nhip address in hex> <Depth>
-;routeadd 0 0064:ff9b:0:0:0:0:ca10:6414 64
-;routeadd 1 0064:ff9b:0:0:0:0:ac10:6414 64
+;routeadd <net/host> <port #> <ipv6 nhip address in hex> <Depth/NotApplicable>
+;routeadd net 0 0064:ff9b:0:0:0:0:ca10:6414 64
+;routeadd net 1 0064:ff9b:0:0:0:0:ac10:6414 64
set fwd rxonly
diff --git a/VNFs/vCGNAPT/config/sample_swlb_2port_2WT.tc b/VNFs/vCGNAPT/config/sample_swlb_2port_2WT.tc
index 05ed058d..d7465690 100644
--- a/VNFs/vCGNAPT/config/sample_swlb_2port_2WT.tc
+++ b/VNFs/vCGNAPT/config/sample_swlb_2port_2WT.tc
@@ -20,8 +20,8 @@ link 1 up
;p 1 arpadd 1 0064:ff9b:0:0:0:0:ac10:2814 00:00:00:00:00:02
routeadd 0 202.16.100.20 0xff000000
-routeadd 2 172.16.40.20 0xff000000
+routeadd 1 172.16.40.20 0xff000000
-;routeadd <port #> <ipv6 nhip address in hex> <Depth>
-;routeadd 0 0064:ff9b:0:0:0:0:ca10:6414 64
-;routeadd 1 0064:ff9b:0:0:0:0:ac10:6414 64
+; routeadd <net/host> <port #> <ipv4 nhip address in decimal> <Mask/NotApplicable>
+;routeadd net 0 0064:ff9b:0:0:0:0:ca10:6414 64
+;routeadd net 1 0064:ff9b:0:0:0:0:ac10:6414 64
diff --git a/VNFs/vCGNAPT/init.c b/VNFs/vCGNAPT/init.c
index 76621d51..d61e419c 100644
--- a/VNFs/vCGNAPT/init.c
+++ b/VNFs/vCGNAPT/init.c
@@ -75,6 +75,7 @@ app_init_core_mask(struct app_params *app)
p->socket_id,
p->core_id,
p->hyper_th_id);
+ printf("lcore_id:%d\n", lcore_id);
if (lcore_id < 0)
rte_panic("Cannot create CPU core mask\n");
diff --git a/VNFs/vCGNAPT/main.c b/VNFs/vCGNAPT/main.c
index 9ebf6fc3..83fc37ff 100644
--- a/VNFs/vCGNAPT/main.c
+++ b/VNFs/vCGNAPT/main.c
@@ -15,12 +15,14 @@
*/
#include "app.h"
+#include "pipeline_cgnapt.h"
static struct app_params app;
int
main(int argc, char **argv)
{
+ struct mg_context *ctx = NULL;
rte_openlog_stream(stderr);
/* Config */
@@ -28,6 +30,12 @@ main(int argc, char **argv)
app_config_args(&app, argc, argv);
+ /* initialize the rest api */
+ if (is_rest_support()) {
+ set_vnf_type("VCGNAPT");
+ ctx = rest_api_init(&app);
+ }
+
app_config_preproc(&app);
app_config_parse(&app, app.parser_file);
@@ -40,11 +48,21 @@ main(int argc, char **argv)
/* Init */
app_init(&app);
+ if (is_rest_support() && (ctx != NULL)) {
+ /* rest api's for cgnapt */
+ rest_api_cgnapt_init(ctx, &app);
+ }
+
/* Run-time */
rte_eal_mp_remote_launch(
app_thread,
(void *) &app,
CALL_MASTER);
+ if (is_rest_support() && (ctx != NULL)) {
+ mg_stop(ctx);
+ printf("Civet server stopped.\n");
+ }
+
return 0;
}
diff --git a/VNFs/vCGNAPT/pipeline/pipeline_cgnapt.c b/VNFs/vCGNAPT/pipeline/pipeline_cgnapt.c
index fb0b95d1..0c6bf48d 100644
--- a/VNFs/vCGNAPT/pipeline/pipeline_cgnapt.c
+++ b/VNFs/vCGNAPT/pipeline/pipeline_cgnapt.c
@@ -29,6 +29,12 @@
#include <cmdline_parse_string.h>
#include <cmdline_parse_ipaddr.h>
#include <cmdline_parse_etheraddr.h>
+#include <cmdline_rdline.h>
+#include <cmdline_socket.h>
+#include <cmdline.h>
+
+#include <fcntl.h>
+#include <unistd.h>
#include "app.h"
#include "pipeline_common_fe.h"
@@ -40,6 +46,8 @@
#include "cgnapt_pcp_fe.h"
#endif
+#define MAX_BUF_SIZE 2048
+
/**
* A structure defining the CG-NAPT entry that is stored on
* front end.
@@ -66,6 +74,12 @@ struct pipeline_cgnapt_t {
};
+int nat_load_handler(struct mg_connection *conn, __rte_unused void *cbdata);
+int nat_handler(struct mg_connection *conn, __rte_unused void *cbdata);
+uint32_t rules_loaded = 0;
+extern struct cmdline *pipe_cl;
+struct app_params *myapp;
+
/**
* Init function for CG-NAPT FE.
*
@@ -1405,7 +1419,8 @@ cmd_cgnapt_stats_parsed(
__rte_unused struct cmdline *cl,
__rte_unused void *data)
{
- all_cgnapt_stats();
+ char buf[2048];
+ all_cgnapt_stats(&buf[0]);
}
static cmdline_parse_token_string_t cmd_cgnapt_stats_p_string =
@@ -1457,7 +1472,8 @@ cmd_cgnapt_clear_stats_parsed(
__rte_unused struct cmdline *cl,
__rte_unused void *data)
{
- all_cgnapt_clear_stats();
+ char buf[2048];
+ all_cgnapt_clear_stats(&buf[0]);
}
static cmdline_parse_token_string_t cmd_cgnapt_clear_stats_p_string =
@@ -1475,6 +1491,212 @@ static cmdline_parse_token_string_t cmd_cgnapt_clear_stats_stats_string =
TOKEN_STRING_INITIALIZER(struct cmd_cgnapt_clear_stats_result, stats_string,
"stats");
+int cgnapt_stats_handler(struct mg_connection *conn, void *cbdata)
+{
+ uint32_t num_links = 0, len = 0;
+ char buf[1024];
+ const struct mg_request_info *ri = mg_get_request_info(conn);
+ struct app_params *app = myapp;
+ int i;
+
+ if (!strcmp(ri->request_method, "GET")) {
+ all_cgnapt_stats(&buf[0]);
+ mg_printf(conn, "%s\n", &buf[0]);
+ return 1;
+ }
+
+ if (strcmp(ri->request_method, "POST")) {
+ mg_printf(conn,
+ "HTTP/1.1 405 Method Not Allowed\r\nConnection: close\r\n");
+ mg_printf(conn, "Content-Type: text/plain\r\n\r\n");
+ mg_printf(conn,
+ "%s method not allowed in the GET handler\n",
+ ri->request_method);
+ }
+
+ all_cgnapt_clear_stats(&buf[0]);
+ mg_printf(conn, "%s\n", &buf[0]);
+ return 1;
+
+}
+
+int cgnapt_cmd_ver_handler(struct mg_connection *conn, void *cbdata)
+{
+ const struct mg_request_info *req_info = mg_get_request_info(conn);
+
+ mg_printf(conn,
+ "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nConnection: "
+ "close\r\n\r\n");
+ mg_printf(conn, "<html><body>");
+ mg_printf(conn, "<p>Command Passed</p>");
+ mg_printf(conn, "</body></html>\n");
+
+ return 1;
+}
+
+/*
+ * loadrules
+ */
+
+/**
+ * Open file and process all commands in the file.
+ *
+ * @param ctx
+ * A pointer to the CLI context
+ * @param file_name
+ * A pointer to the file to process.
+ *
+ */
+static void cgnapt_loadrules_file(cmdline_parse_ctx_t *ctx, const char *file_name)
+{
+ struct cmdline *file_cl;
+ int fd;
+
+ fd = open(file_name, O_RDONLY);
+ if (fd < 0) {
+ printf("Cannot open file \"%s\"\n", file_name);
+ return;
+ }
+
+ file_cl = cmdline_new(ctx, "", fd, 1);
+ cmdline_interact(file_cl);
+ close(fd);
+}
+
+
+int nat_handler(struct mg_connection *conn, __rte_unused void *cbdata)
+{
+
+ const struct mg_request_info *req_info = mg_get_request_info(conn);
+ if (strcmp(req_info->request_method, "GET")) {
+ mg_printf(conn, "Only GET method allowed");
+ return 1;
+ }
+
+ mg_printf(conn,
+ "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nConnection: "
+ "close\r\n\r\n");
+ mg_printf(conn, "<html><body>");
+ mg_printf(conn, "<h2> These are the methods that are supported </h2>");
+ mg_printf(conn, "<h3> /load </h3>");
+ mg_printf(conn, "<html><body>");
+
+ mg_printf(conn, "</body></html>\n");
+
+ return 1;
+}
+
+static int nat_field_found(const char *key,
+ const char *filename,
+ char *path,
+ size_t pathlen,
+ void *user_data)
+{
+ struct mg_connection *conn = (struct mg_connection *)user_data;
+
+ mg_printf(conn, "\r\n\r\n%s:\r\n", key);
+ mg_printf(conn, "Inside vfw_field_found %s \n", filename);
+
+ if (filename && *filename) {
+ snprintf(path, pathlen, "/tmp/%s", filename);
+ struct app_params *app = myapp;
+ int status;
+ int fd;
+
+ mg_printf(conn, "path: %s\n", path);
+
+ /* Make sure the file exists before clearing rules and actions */
+ fd = open(path, O_RDONLY);
+ if (fd < 0) {
+ mg_printf(conn, "Cannot open file \"%s\"\n", filename);
+ return FORM_FIELD_STORAGE_GET;
+ }
+
+ close(fd);
+ return FORM_FIELD_STORAGE_STORE;
+ }
+
+ return FORM_FIELD_STORAGE_GET;
+}
+
+static int nat_field_get(const char *key, const char *value, size_t valuelen,
+ void *user_data)
+{
+ struct mg_connection *conn = (struct mg_connection *)user_data;
+
+ if (key[0]) {
+ mg_printf(conn, "%s = ", key);
+ }
+ mg_write(conn, value, valuelen);
+
+ return 0;
+}
+
+static int nat_field_stored(const char *path, long long file_size,
+ void *user_data)
+{
+ struct mg_connection *conn = (struct mg_connection *)user_data;
+ int status;
+
+ mg_printf(conn,
+ "stored as %s (%lu bytes)\r\n\r\n",
+ path,
+ (unsigned long)file_size);
+
+ /* Process commands in script file */
+ cgnapt_loadrules_file(pipe_cl->ctx, path);
+ rules_loaded = 1;
+
+ return 0;
+}
+
+int nat_load_handler(struct mg_connection *conn, __rte_unused void *cbdata)
+{
+ /* Handler may access the request info using mg_get_request_info */
+ int ret;
+ const struct mg_request_info *req_info = mg_get_request_info(conn);
+ struct mg_form_data_handler fdh = {nat_field_found, nat_field_get,
+ nat_field_stored, 0};
+
+ /* It would be possible to check the request info here before calling
+ * mg_handle_form_request. */
+ (void)req_info;
+
+ mg_printf(conn,
+ "HTTP/1.1 200 OK\r\nContent-Type: "
+ "text/plain\r\nConnection: close\r\n\r\n");
+
+ if (!strcmp(req_info->request_method, "GET")) {
+ mg_printf(conn, "Rule file is %s\n", rules_loaded? "LOADED":"NOT LOADED");
+ }
+
+ if (strcmp(req_info->request_method, "PUT")) {
+ mg_printf(conn, "Only PUT method allowed");
+ return 1;
+ }
+
+ fdh.user_data = (void *)conn;
+
+ /* Call the form handler */
+ mg_printf(conn, "Form data:");
+ ret = mg_handle_form_request(conn, &fdh);
+ mg_printf(conn, "\r\n%i fields found", ret);
+
+ return 1;
+}
+
+void rest_api_cgnapt_init(struct mg_context *ctx, struct app_params *app)
+{
+ myapp = app;
+
+ /* vCGNAPT commands */
+ mg_set_request_handler(ctx, "/vnf/config/nat", nat_handler, 0);
+ mg_set_request_handler(ctx, "/vnf/config/nat/load", nat_load_handler, 0);
+ mg_set_request_handler(ctx, "/vnf/status", cgnapt_cmd_ver_handler, 0);
+ mg_set_request_handler(ctx, "/vnf/stats", cgnapt_stats_handler, 0);
+
+}
+
static cmdline_parse_inst_t cmd_clear_stats = {
.f = cmd_cgnapt_clear_stats_parsed,
.data = NULL,
diff --git a/VNFs/vCGNAPT/pipeline/pipeline_cgnapt.h b/VNFs/vCGNAPT/pipeline/pipeline_cgnapt.h
index 5491648a..6497de27 100644
--- a/VNFs/vCGNAPT/pipeline/pipeline_cgnapt.h
+++ b/VNFs/vCGNAPT/pipeline/pipeline_cgnapt.h
@@ -28,6 +28,8 @@
#include "pipeline.h"
#include "pipeline_cgnapt_common.h"
+#include <civetweb.h>
+#include <json/json.h>
/**
* Add NAPT rule to the NAPT rule table.
@@ -129,6 +131,12 @@ int
app_pipeline_cgnapt_nsp_del_entry(struct app_params *app,
uint32_t pipeline_id,
struct pipeline_cgnapt_nsp_t *nsp);
+#ifdef REST_API_SUPPORT
+/* REST api's are defined here */
+int cgnapt_cmd_ver_handler(struct mg_connection *conn, void *cbdata);
+int cgnapt_stats_handler(struct mg_connection *conn, void *cbdata);
+void rest_api_cgnapt_init(struct mg_context *ctx, struct app_params *app);
+#endif
/*
* Pipeline type
diff --git a/VNFs/vCGNAPT/pipeline/pipeline_cgnapt_be.c b/VNFs/vCGNAPT/pipeline/pipeline_cgnapt_be.c
index eb0aca96..7758c5b3 100644
--- a/VNFs/vCGNAPT/pipeline/pipeline_cgnapt_be.c
+++ b/VNFs/vCGNAPT/pipeline/pipeline_cgnapt_be.c
@@ -64,6 +64,7 @@
#include "vnf_common.h"
#include "lib_sip_alg.h"
#include "lib_icmpv6.h"
+#include "gateway.h"
#include "pipeline_common_fe.h"
#ifdef CT_CGNAT
@@ -177,21 +178,6 @@ uint8_t well_known_prefix[16] = {
0x00, 0x00, 0x00, 0x00
};
-static uint32_t local_get_nh_ipv4(
- uint32_t ip,
- uint32_t *port,
- uint32_t *nhip,
- struct pipeline_cgnapt *p_nat);
-static void do_local_nh_ipv4_cache(
- uint32_t dest_if,
- struct pipeline_cgnapt *p_nat);
-
-static uint32_t local_get_nh_ipv6(
- uint8_t *ip,
- uint32_t *port,
- uint8_t nhip[],
- struct pipeline_cgnapt *p_nat);
-
static uint8_t check_arp_icmp(
struct rte_mbuf *pkt,
uint64_t pkt_mask,
@@ -219,123 +205,6 @@ uint64_t nextPowerOf2(uint64_t n)
return n;
}
-void remove_local_cache(uint8_t port)
-{
- link_hw_laddr_valid[port] = 0;
-}
-
-/**
- * Function to get IPv4-IP NH from thread local array
- *
- * @params ip
- * IPv4 - IP
- * @params port
- * NH port number
- * @params nhip
- * NHIP of IPv4 type
- * @params p_nat
- * CGNAPT pipeline ptr
- *
- * @return
- * 1 on success, 0 for failure
- */
-
-static uint32_t local_get_nh_ipv4(
- uint32_t ip,
- uint32_t *port,
- uint32_t *nhip,
- struct pipeline_cgnapt *p_nat)
-{
- int i;
- for (i = 0; i < p_nat->local_lib_arp_route_ent_cnt; i++) {
- if (((p_nat->local_lib_arp_route_table[i].ip &
- p_nat->local_lib_arp_route_table[i].mask) ==
- (ip & p_nat->local_lib_arp_route_table[i].mask))) {
- *port = p_nat->local_lib_arp_route_table[i].port;
-
- *nhip = p_nat->local_lib_arp_route_table[i].nh;
- return 1;
- }
- }
- return 0;
-}
-
-/**
- * Function to make local copy for NH of type IPv4
- *
- * @params dest_if
- * Physical port number
- * @params p_nat
- * CGNAPT pipeline ptr
- *
- */
-
-static void do_local_nh_ipv4_cache(
- uint32_t dest_if,
- struct pipeline_cgnapt *p_nat)
-{
- return;
-}
-
-
-/**
- * Function to get IPv6-IP NH from thread local array
- *
- * @params ip
- * Pointer to starting addr of IPv6
- * @params port
- * NH port number
- * @params nhip
- * NHIP of IPv6 type
- * @params p_nat
- * CGNAPT pipeline ptr
- *
- * @return
- * 1 on success, 0 for failure
- */
-
-static uint32_t local_get_nh_ipv6(
- uint8_t *ip,
- uint32_t *port,
- uint8_t nhip[],
- struct pipeline_cgnapt *p_nat)
-{
- int i = 0;
- uint8_t netmask_ipv6[16];
- uint8_t k = 0, l = 0, depthflags = 0, depthflags1 = 0;
-
- for (i = 0; i < p_nat->local_lib_nd_route_ent_cnt; i++) {
-
- convert_prefixlen_to_netmask_ipv6(
- p_nat->local_lib_nd_route_table[i].depth,
- netmask_ipv6);
-
- for (k = 0; k < 16; k++)
- if (p_nat->local_lib_nd_route_table[i].ipv6[k] &
- netmask_ipv6[k])
- depthflags++;
-
- for (l = 0; l < 16; l++)
- if (ip[l] & netmask_ipv6[l])
- depthflags1++;
-
- int j = 0;
- if (depthflags == depthflags1) {
- *port = p_nat->local_lib_nd_route_table[i].port;
-
- for (j = 0; j < 16; j++)
- nhip[j] = p_nat->local_lib_nd_route_table[i].
- nhipv6[j];
- return 1;
- }
-
- depthflags = 0;
- depthflags1 = 0;
- }
- return 0;
-}
-
-
#ifdef SIP_ALG
/* Commented code may be required for future usage, Please keep it*/
#if 0
@@ -2078,7 +1947,7 @@ static int cgnapt_in_port_ah_mix(struct rte_pipeline *rte_p,
uint8_t nh_ipv6[16];
uint32_t nhip = 0;
- uint32_t dest_if = 0xff;
+ uint32_t dest_if = INVALID_DESTIF;
uint32_t ret;
uint16_t *outport_id =
@@ -2091,52 +1960,54 @@ static int cgnapt_in_port_ah_mix(struct rte_pipeline *rte_p,
&& rte_be_to_cpu_16(*dst_port) == 53) {
p_nat->invalid_packets |= 1LLU << pkt_index;
p_nat->naptDroppedPktCount++;
- #ifdef CGNAPT_DEBUGGING
+#ifdef CGNAPT_DEBUGGING
p_nat->naptDroppedPktCount6++;
- #endif
+#endif
continue;
}
dest_address = rte_bswap32(*dst_addr);
- ret = local_get_nh_ipv4(dest_address, &dest_if,
- &nhip, p_nat);
- if (!ret) {
- dest_if = get_prv_to_pub_port(&dest_address,
- IP_VERSION_4);
- if (dest_if == INVALID_DESTIF) {
- p_nat->invalid_packets |=
- 1LLU << pkt_index;
- p_nat->naptDroppedPktCount++;
- #ifdef CGNAPT_DEBUGGING
- p_nat->naptDroppedPktCount6++;
- #endif
- continue;
- }
- do_local_nh_ipv4_cache(dest_if, p_nat);
- }
+ /* Gateway Proc Starts */
- *outport_id = p_nat->outport_id[dest_if];
- struct arp_entry_data *ret_arp_data;
- ret_arp_data = get_dest_mac_addr_port(dest_address,
- &dest_if, (struct ether_addr *)eth_dest);
+ struct arp_entry_data *ret_arp_data = NULL;
+ uint32_t src_phy_port = *src_port;
- if (unlikely(ret_arp_data == NULL)) {
+ gw_get_nh_port_ipv4(dest_address,
+ &dest_if, &nhip);
- #ifdef CGNAPT_DEBUGGING
- printf("%s: NHIP Not Found, nhip: %x, "
- "outport_id: %d\n", __func__, nhip,
- *outport_id);
- #endif
- /* Drop the pkt */
- p_nat->invalid_packets |= pkt_mask;
+ if (dest_if == INVALID_DESTIF) {
+ p_nat->invalid_packets |=
+ 1LLU << pkt_index;
p_nat->naptDroppedPktCount++;
-
- #ifdef CGNAPT_DEBUGGING
- p_nat->naptDroppedPktCount4++;
- #endif
+#ifdef CGNAPT_DEBUGGING
+ p_nat->naptDroppedPktCount6++;
+#endif
continue;
}
+ *outport_id = p_nat->outport_id[dest_if];
+
+ ret_arp_data = get_dest_mac_addr_ipv4(nhip, dest_if, &hw_addr);
+
+ if (unlikely(ret_arp_data == NULL)) {
+
+ #ifdef CGNAPT_DEBUGGING
+ printf("%s: NHIP Not Found, nhip: %x, "
+ "outport_id: %d\n", __func__, nhip,
+ *outport_id);
+ #endif
+ /* Drop the pkt */
+ p_nat->invalid_packets |= pkt_mask;
+ p_nat->naptDroppedPktCount++;
+
+ #ifdef CGNAPT_DEBUGGING
+ p_nat->naptDroppedPktCount4++;
+ #endif
+ continue;
+ }
+
+ /* Gateway Proc Ends */
+
if (ret_arp_data->status == COMPLETE) {
if (ret_arp_data->num_pkts) {
@@ -2267,21 +2138,28 @@ static int cgnapt_in_port_ah_mix(struct rte_pipeline *rte_p,
&entry->data.u.prv_ipv6[0], 16);
memset(nh_ipv6, 0, 16);
struct nd_entry_data *ret_nd_data = NULL;
- ret_nd_data = get_dest_mac_address_ipv6_port((uint8_t *)
- &dst_addr[0], &dest_if,
- &hw_addr, &nh_ipv6[0]);
+
+ dest_if = INVALID_DESTIF;
+
+ uint32_t src_phy_port = pkts[pkt_index]->port;
+
+ gw_get_nh_port_ipv6((uint8_t *) &dst_addr[0],
+ &dest_if, &nh_ipv6[0]);
+
+ ret_nd_data = get_dest_mac_addr_ipv6(&nh_ipv6[0],
+ dest_if, &hw_addr);
*outport_id = p_nat->outport_id[dest_if];
if (nd_cache_dest_mac_present(dest_if)) {
ether_addr_copy(get_link_hw_addr(dest_if),
- (struct ether_addr *)eth_src);
+ (struct ether_addr *)eth_src);
update_nhip_access(dest_if);
if (unlikely(ret_nd_data && ret_nd_data->num_pkts)) {
p_nat->naptedPktCount += ret_nd_data->num_pkts;
nd_send_buffered_pkts(ret_nd_data,
- (struct ether_addr *)eth_dest,
- *outport_id);
+ (struct ether_addr *)eth_dest,
+ *outport_id);
}
} else {
if (unlikely(ret_nd_data == NULL)) {
@@ -2335,46 +2213,49 @@ static int cgnapt_in_port_ah_mix(struct rte_pipeline *rte_p,
} else {
*dst_addr = rte_bswap32(entry->data.u.prv_ip);
dest_address = entry->data.u.prv_ip;
- ret = local_get_nh_ipv4(dest_address, &dest_if,
- &nhip, p_nat);
- if (!ret) {
- dest_if = get_pub_to_prv_port(
- &dest_address, IP_VERSION_4);
+ /* Gateway Proc Starts */
+
+ struct arp_entry_data *ret_arp_data = NULL;
+ dest_if = INVALID_DESTIF;
+ uint32_t src_phy_port = *src_port;
+
+ gw_get_nh_port_ipv4(dest_address,
+ &dest_if, &nhip);
+
if (dest_if == INVALID_DESTIF) {
p_nat->invalid_packets |=
1LLU << pkt_index;
p_nat->naptDroppedPktCount++;
- #ifdef CGNAPT_DEBUGGING
+#ifdef CGNAPT_DEBUGGING
p_nat->naptDroppedPktCount6++;
- #endif
+#endif
continue;
}
- do_local_nh_ipv4_cache(dest_if, p_nat);
- };
*outport_id = p_nat->outport_id[dest_if];
- struct arp_entry_data *ret_arp_data;
- ret_arp_data = get_dest_mac_addr_port(dest_address,
- &dest_if, (struct ether_addr *)eth_dest);
+
+ ret_arp_data = get_dest_mac_addr_ipv4(nhip,
+ dest_if, (struct ether_addr *)eth_dest);
if (unlikely(ret_arp_data == NULL)) {
- #ifdef CGNAPT_DEBUGGING
+#ifdef CGNAPT_DEBUGGING
printf("%s: NHIP Not Found, nhip: %x, "
- "outport_id: %d\n", __func__, nhip,
- *outport_id);
- #endif
-
+ "outport_id: %d\n", __func__, nhip,
+ *outport_id);
+#endif
/* Drop the pkt */
p_nat->invalid_packets |= pkt_mask;
p_nat->naptDroppedPktCount++;
- #ifdef CGNAPT_DEBUGGING
+#ifdef CGNAPT_DEBUGGING
p_nat->naptDroppedPktCount4++;
- #endif
+#endif
continue;
}
+ /* Gateway Proc Ends */
+
if (ret_arp_data->status == COMPLETE) {
if (ret_arp_data->num_pkts) {
@@ -3713,7 +3594,7 @@ pkt_work_cgnapt_ipv4_prv(
uint8_t protocol = RTE_MBUF_METADATA_UINT8(pkt, PROT_OFST_IP4);
- uint32_t dest_if = 0xff; /* Added for Multiport */
+ uint32_t dest_if = INVALID_DESTIF; /* Added for Multiport */
uint16_t *outport_id =
RTE_MBUF_METADATA_UINT16_PTR(pkt, cgnapt_meta_offset);
@@ -3822,7 +3703,6 @@ pkt_work_cgnapt_ipv4_prv(
if (entry->data.ttl == NAPT_ENTRY_STALE)
entry->data.ttl = NAPT_ENTRY_VALID;
- struct ether_addr hw_addr;
uint32_t dest_address = 0;
/* Egress */
@@ -3840,8 +3720,14 @@ pkt_work_cgnapt_ipv4_prv(
dest_address = rte_bswap32(*dst_addr);
uint32_t nhip = 0;
struct arp_entry_data *ret_arp_data = NULL;
- ret_arp_data = get_dest_mac_addr_port(dest_address,
- &dest_if, (struct ether_addr *)eth_dest);
+
+ uint32_t src_phy_port = *src_port;
+
+ gw_get_nh_port_ipv4(dest_address, &dest_if, &nhip);
+
+ ret_arp_data = get_dest_mac_addr_ipv4(nhip, dest_if,
+ (struct ether_addr *)eth_dest);
+
*outport_id = p_nat->outport_id[dest_if];
if (arp_cache_dest_mac_present(dest_if)) {
@@ -3850,7 +3736,7 @@ pkt_work_cgnapt_ipv4_prv(
if (unlikely(ret_arp_data && ret_arp_data->num_pkts)) {
p_nat->naptedPktCount += ret_arp_data->num_pkts;
arp_send_buffered_pkts(ret_arp_data,
- (struct ether_addr *)eth_dest, *outport_id);
+ (struct ether_addr *)eth_dest, *outport_id);
}
} else {
@@ -4083,7 +3969,7 @@ pkt_work_cgnapt_ipv4_pub(
uint8_t protocol = RTE_MBUF_METADATA_UINT8(pkt, PROT_OFST_IP4);
- uint32_t dest_if = 0xff; /* Added for Multiport */
+ uint32_t dest_if = INVALID_DESTIF; /* Added for Multiport */
uint16_t *outport_id =
RTE_MBUF_METADATA_UINT16_PTR(pkt, cgnapt_meta_offset);
@@ -4166,7 +4052,6 @@ pkt_work_cgnapt_ipv4_pub(
if (entry->data.ttl == NAPT_ENTRY_STALE)
entry->data.ttl = NAPT_ENTRY_VALID;
- struct ether_addr hw_addr;
uint32_t dest_address = 0;
/* Multiport Changes */
@@ -4188,8 +4073,13 @@ pkt_work_cgnapt_ipv4_pub(
dest_address = entry->data.u.prv_ip;
struct arp_entry_data *ret_arp_data = NULL;
- ret_arp_data = get_dest_mac_addr_port(dest_address,
- &dest_if, (struct ether_addr *)eth_dest);
+
+ uint32_t src_phy_port = *src_port;
+
+ gw_get_nh_port_ipv4(dest_address, &dest_if, &nhip);
+
+ ret_arp_data = get_dest_mac_addr_ipv4(nhip, dest_if,
+ (struct ether_addr *)eth_dest);
*outport_id = p_nat->outport_id[dest_if];
if (arp_cache_dest_mac_present(dest_if)) {
@@ -4441,7 +4331,7 @@ pkt4_work_cgnapt_ipv4_prv(
__rte_unused void *arg,
struct pipeline_cgnapt *p_nat)
{
- uint32_t dest_if = 0xff; /* Added for Multiport */
+ uint32_t dest_if = INVALID_DESTIF; /* Added for Multiport */
struct rte_mbuf *pkt;
uint8_t i;
uint8_t pkt_num;
@@ -4602,7 +4492,6 @@ pkt4_work_cgnapt_ipv4_prv(
if (entry->data.ttl == NAPT_ENTRY_STALE)
entry->data.ttl = NAPT_ENTRY_VALID;
- struct ether_addr hw_addr;
uint32_t dest_address = 0;
/*Multiport Changes */
uint32_t nhip = 0;
@@ -4626,9 +4515,15 @@ pkt4_work_cgnapt_ipv4_prv(
dest_address = rte_bswap32(*dst_addr);
struct arp_entry_data *ret_arp_data = NULL;
uint64_t start, end;
- ret_arp_data = get_dest_mac_addr_port(dest_address,
- &dest_if, (struct ether_addr *)eth_dest);
+ uint32_t src_phy_port = *src_port;
+
+ gw_get_nh_port_ipv4(dest_address, &dest_if, &nhip);
+
+ ret_arp_data = get_dest_mac_addr_ipv4(nhip, dest_if,
+ (struct ether_addr *)eth_dest);
+
*outport_id = p_nat->outport_id[dest_if];
+
if (arp_cache_dest_mac_present(dest_if)) {
ether_addr_copy(get_link_hw_addr(dest_if),
(struct ether_addr *)eth_src);
@@ -4882,7 +4777,7 @@ pkt4_work_cgnapt_ipv4_pub(
uint8_t protocol = RTE_MBUF_METADATA_UINT8(pkt, PROT_OFST_IP4);
- uint32_t dest_if = 0xff; /* Added for Multiport */
+ uint32_t dest_if = INVALID_DESTIF; /* Added for Multiport */
uint16_t *outport_id =
RTE_MBUF_METADATA_UINT16_PTR(pkt, cgnapt_meta_offset);
@@ -4971,7 +4866,6 @@ pkt4_work_cgnapt_ipv4_pub(
if (entry->data.ttl == NAPT_ENTRY_STALE)
entry->data.ttl = NAPT_ENTRY_VALID;
- struct ether_addr hw_addr;
uint32_t dest_address = 0;
/* Multiport Changes */
uint32_t nhip = 0;
@@ -4991,23 +4885,29 @@ pkt4_work_cgnapt_ipv4_pub(
}
dest_address = entry->data.u.prv_ip;
struct arp_entry_data *ret_arp_data = NULL;
- ret_arp_data = get_dest_mac_addr_port(dest_address,
- &dest_if, (struct ether_addr *)eth_dest);
+ uint32_t src_phy_port = *src_port;
+
+ gw_get_nh_port_ipv4(dest_address, &dest_if, &nhip);
+
+ ret_arp_data = get_dest_mac_addr_ipv4(nhip, dest_if,
+ (struct ether_addr *)eth_dest);
+
*outport_id = p_nat->outport_id[dest_if];
- if (arp_cache_dest_mac_present(dest_if)) {
- ether_addr_copy(get_link_hw_addr(dest_if), (struct ether_addr *)eth_src);
- update_nhip_access(dest_if);
+ if (arp_cache_dest_mac_present(dest_if)) {
+ ether_addr_copy(get_link_hw_addr(dest_if),
+ (struct ether_addr *)eth_src);
+ update_nhip_access(dest_if);
- if (ret_arp_data && ret_arp_data->num_pkts) {
- p_nat->naptedPktCount += ret_arp_data->num_pkts;
- arp_send_buffered_pkts(ret_arp_data,
- (struct ether_addr *)eth_dest, *outport_id);
- }
+ if (ret_arp_data && ret_arp_data->num_pkts) {
+ p_nat->naptedPktCount += ret_arp_data->num_pkts;
+ arp_send_buffered_pkts(ret_arp_data,
+ (struct ether_addr *)eth_dest, *outport_id);
+ }
- } else {
+ } else {
- if (unlikely(ret_arp_data == NULL)) {
+ if (unlikely(ret_arp_data == NULL)) {
#ifdef CGNAPT_DEBUGGING
printf("%s: NHIP Not Found, nhip: %x, "
@@ -6058,7 +5958,6 @@ pkt_work_cgnapt_ipv6_prv(
struct ipv6_hdr ipv6_hdr;
- struct ether_addr hw_addr;
uint32_t dest_address = 0;
uint32_t nhip = 0;
/* Egress */
@@ -6164,9 +6063,16 @@ pkt_work_cgnapt_ipv6_prv(
#endif
struct arp_entry_data *ret_arp_data;
- ret_arp_data = get_dest_mac_addr_port(dest_address,
- &dest_if, (struct ether_addr *)eth_dest);
+
+ uint32_t src_phy_port = *src_port;
+
+ gw_get_nh_port_ipv4(dest_address, &dest_if, &nhip);
+
+ ret_arp_data = get_dest_mac_addr_ipv4(nhip, dest_if,
+ (struct ether_addr *)eth_dest);
+
*outport_id = p_nat->outport_id[dest_if];
+
if (arp_cache_dest_mac_present(dest_if)) {
ether_addr_copy(get_link_hw_addr(dest_if),
(struct ether_addr *)eth_src);
@@ -6342,11 +6248,16 @@ pkt_work_cgnapt_ipv6_pub(
memset(nh_ipv6, 0, 16);
struct nd_entry_data *ret_nd_data = NULL;
- ret_nd_data = get_dest_mac_address_ipv6_port(
- &dest_addr_ipv6[0],
- &dest_if,
- (struct ether_addr *)eth_dest,
- &nh_ipv6[0]);
+
+ dest_if = INVALID_DESTIF;
+
+ uint32_t src_phy_port = pkt->port;
+
+ gw_get_nh_port_ipv6((uint8_t *) &dest_addr_ipv6[0],
+ &dest_if, &nh_ipv6[0]);
+
+ ret_nd_data = get_dest_mac_addr_ipv6(&nh_ipv6[0],
+ dest_if, (struct ether_addr *)eth_dest);
*outport_id = p_nat->outport_id[dest_if];
@@ -6536,7 +6447,6 @@ pkt4_work_cgnapt_ipv6_prv(
p_nat->entries[pkt_num] = &(entry->head);
struct ipv6_hdr ipv6_hdr;
- struct ether_addr hw_addr;
uint32_t dest_address = 0;
uint8_t nh_ipv6[16];
uint32_t nhip = 0;
@@ -6645,15 +6555,18 @@ pkt4_work_cgnapt_ipv6_prv(
{
struct arp_entry_data *ret_arp_data;
- ret_arp_data = get_dest_mac_addr_port(dest_address,
- &dest_if, (struct ether_addr *)eth_dest);
+ uint32_t src_phy_port = *src_port;
+
+ gw_get_nh_port_ipv4(dest_address, &dest_if, &nhip);
+
+ ret_arp_data = get_dest_mac_addr_ipv4(nhip, dest_if,
+ (struct ether_addr *)eth_dest);
*outport_id = p_nat->outport_id[dest_if];
if (arp_cache_dest_mac_present(dest_if)) {
ether_addr_copy(get_link_hw_addr(dest_if),
(struct ether_addr *)eth_src);
update_nhip_access(dest_if);
-
if (unlikely(ret_arp_data && ret_arp_data->num_pkts)) {
p_nat->naptedPktCount += ret_arp_data->num_pkts;
arp_send_buffered_pkts(ret_arp_data,
@@ -6846,10 +6759,15 @@ pkt4_work_cgnapt_ipv6_pub(
memset(nh_ipv6, 0, 16);
struct nd_entry_data *ret_nd_data = NULL;
- ret_nd_data = get_dest_mac_address_ipv6_port
- (&dest_addr_ipv6[0], &dest_if,
- (struct ether_addr *)eth_dest, &nh_ipv6[0]);
+ dest_if = INVALID_DESTIF;
+
+ uint32_t src_phy_port = pkt->port;
+ gw_get_nh_port_ipv6((uint8_t *) &dest_addr_ipv6[0],
+ &dest_if, &nh_ipv6[0]);
+
+ ret_nd_data = get_dest_mac_addr_ipv6(&nh_ipv6[0],
+ dest_if, (struct ether_addr *)eth_dest);
*outport_id = p_nat->outport_id[dest_if];
if (nd_cache_dest_mac_present(dest_if)) {
@@ -10551,9 +10469,9 @@ void *pipeline_cgnapt_msg_req_ver_handler(__rte_unused struct pipeline *p,
* Function to show CGNAPT stats
*
*/
-void all_cgnapt_stats(void)
+void all_cgnapt_stats(char *buf)
{
- int i;
+ int i, len = 0;
struct pipeline_cgnapt *p_nat;
uint64_t receivedPktCount = 0;
uint64_t missedPktCount = 0;
@@ -10563,7 +10481,7 @@ void all_cgnapt_stats(void)
uint64_t enaptedPktCount = 0;
uint64_t arpicmpPktCount = 0;
- printf("\nCG-NAPT Packet Stats:\n");
+ len += sprintf(buf + len, "\nCG-NAPT Packet Stats:\n");
for (i = 0; i < n_cgnapt_pipeline; i++) {
p_nat = all_pipeline_cgnapt[i];
@@ -10575,6 +10493,16 @@ void all_cgnapt_stats(void)
enaptedPktCount += p_nat->enaptedPktCount;
arpicmpPktCount += p_nat->arpicmpPktCount;
+ len += sprintf(buf + len, "pipeline %d stats:\n", p_nat->pipeline_num);
+ len += sprintf(buf + len, "Received %" PRIu64 ",", p_nat->receivedPktCount);
+ len += sprintf(buf + len, "Missed %" PRIu64 ",", p_nat->missedPktCount);
+ len += sprintf(buf + len, "Dropped %" PRIu64 ",", p_nat->naptDroppedPktCount);
+ len += sprintf(buf + len, "Translated %" PRIu64 ",", p_nat->naptedPktCount);
+ len += sprintf(buf + len, "ingress %" PRIu64 ",", p_nat->inaptedPktCount);
+ len += sprintf(buf + len, "egress %" PRIu64 "\n", p_nat->enaptedPktCount);
+ len += sprintf(buf + len, "arpicmp pkts %" PRIu64 "\n", p_nat->arpicmpPktCount);
+
+ printf("\nCG-NAPT Packet Stats:\n");
printf("pipeline %d stats:\n", p_nat->pipeline_num);
printf("Received %" PRIu64 ",", p_nat->receivedPktCount);
printf("Missed %" PRIu64 ",", p_nat->missedPktCount);
@@ -10585,33 +10513,34 @@ void all_cgnapt_stats(void)
printf("arpicmp pkts %" PRIu64 "\n", p_nat->arpicmpPktCount);
+
#ifdef CGNAPT_DEBUGGING
- printf("\n Drop detail 1:%" PRIu64 ",",
+ len += sprintf(buf + len, "\n Drop detail 1:%" PRIu64 ",",
p_nat->naptDroppedPktCount1);
- printf("\n Drop detail 2:%" PRIu64 ",",
+ len += sprintf(buf + len, "\n Drop detail 2:%" PRIu64 ",",
p_nat->naptDroppedPktCount2);
- printf("\n Drop detail 3:%" PRIu64 ",",
+ len += sprintf(buf + len, "\n Drop detail 3:%" PRIu64 ",",
p_nat->naptDroppedPktCount3);
- printf("\n Drop detail 4:%" PRIu64 ",",
+ len += sprintf(buf + len, "\n Drop detail 4:%" PRIu64 ",",
p_nat->naptDroppedPktCount4);
- printf("\n Drop detail 5:%" PRIu64 ",",
+ len += sprintf(buf + len, "\n Drop detail 5:%" PRIu64 ",",
p_nat->naptDroppedPktCount5);
- printf("\n Drop detail 6:%" PRIu64 "",
+ len += sprintf(buf + len, "\n Drop detail 6:%" PRIu64 "",
p_nat->naptDroppedPktCount6);
- printf("\nPkt_miss: %" PRIu64 " %" PRIu64 "",
+ len += sprintf(buf + len, "\nPkt_miss: %" PRIu64 " %" PRIu64 "",
p_nat->missedpktcount1,
p_nat->missedpktcount2);
- printf("\nPkt_miss: %" PRIu64 " %" PRIu64 "",
+ len += sprintf(buf + len, "\nPkt_miss: %" PRIu64 " %" PRIu64 "",
p_nat->missedpktcount3,
p_nat->missedpktcount4);
- printf("\nPkt_miss: %" PRIu64 " %" PRIu64 "",
+ len += sprintf(buf + len, "\nPkt_miss: %" PRIu64 " %" PRIu64 "",
p_nat->missedpktcount5,
p_nat->missedpktcount6);
- printf("\nPkt_miss: %" PRIu64 " %" PRIu64 "",
+ len += sprintf(buf + len, "\nPkt_miss: %" PRIu64 " %" PRIu64 "",
p_nat->missedpktcount7,
p_nat->missedpktcount8);
- printf("\nPkt_miss: %" PRIu64 " %" PRIu64 "",
+ len += sprintf(buf + len, "\nPkt_miss: %" PRIu64 " %" PRIu64 "",
p_nat->missedpktcount9,
p_nat->missedpktcount10);
@@ -10619,7 +10548,16 @@ void all_cgnapt_stats(void)
}
- printf("\nTotal pipeline stats:\n");
+ len += sprintf(buf + len, "\nTotal pipeline stats:\n");
+ len += sprintf(buf + len, "Received %" PRIu64 ",", receivedPktCount);
+ len += sprintf(buf + len, "Missed %" PRIu64 ",", missedPktCount);
+ len += sprintf(buf + len, "Dropped %" PRIu64 ",", naptDroppedPktCount);
+ len += sprintf(buf + len, "Translated %" PRIu64 ",", naptedPktCount);
+ len += sprintf(buf + len, "ingress %" PRIu64 ",", inaptedPktCount);
+ len += sprintf(buf + len, "egress %" PRIu64 "\n", enaptedPktCount);
+ len += sprintf(buf + len, "arpicmp pkts %" PRIu64 "\n", arpicmpPktCount);
+
+ printf("\nTotal pipeline stats:\n");
printf("Received %" PRIu64 ",", receivedPktCount);
printf("Missed %" PRIu64 ",", missedPktCount);
printf("Dropped %" PRIu64 ",", naptDroppedPktCount);
@@ -10627,24 +10565,27 @@ void all_cgnapt_stats(void)
printf("ingress %" PRIu64 ",", inaptedPktCount);
printf("egress %" PRIu64 "\n", enaptedPktCount);
printf("arpicmp pkts %" PRIu64 "\n", arpicmpPktCount);
+
+ if (!rest_api_supported())
+ printf("%s\n", buf);
}
-void all_cgnapt_clear_stats(void)
+void all_cgnapt_clear_stats(char *buf)
{
- int i;
+ int i, len = 0;
struct pipeline_cgnapt *p_nat;
- printf("\nCG-NAPT Packet Stats:\n");
+ len += sprintf(buf + len, "\nCG-NAPT Packet Stats:\n");
for (i = 0; i < n_cgnapt_pipeline; i++) {
p_nat = all_pipeline_cgnapt[i];
- printf("pipeline %d stats:\n", p_nat->pipeline_num);
- printf("Received %" PRIu64 ",", p_nat->receivedPktCount);
- printf("Missed %" PRIu64 ",", p_nat->missedPktCount);
- printf("Dropped %" PRIu64 ",", p_nat->naptDroppedPktCount);
- printf("Translated %" PRIu64 ",", p_nat->naptedPktCount);
- printf("ingress %" PRIu64 ",", p_nat->inaptedPktCount);
- printf("egress %" PRIu64 "\n", p_nat->enaptedPktCount);
- printf("arpicmp pkts %" PRIu64 "\n", p_nat->arpicmpPktCount);
+ len += sprintf(buf + len, "pipeline %d stats:\n", p_nat->pipeline_num);
+ len += sprintf(buf + len, "Received %" PRIu64 ",", p_nat->receivedPktCount);
+ len += sprintf(buf + len, "Missed %" PRIu64 ",", p_nat->missedPktCount);
+ len += sprintf(buf + len, "Dropped %" PRIu64 ",", p_nat->naptDroppedPktCount);
+ len += sprintf(buf + len, "Translated %" PRIu64 ",", p_nat->naptedPktCount);
+ len += sprintf(buf + len, "ingress %" PRIu64 ",", p_nat->inaptedPktCount);
+ len += sprintf(buf + len, "egress %" PRIu64 "\n", p_nat->enaptedPktCount);
+ len += sprintf(buf + len, "arpicmp pkts %" PRIu64 "\n", p_nat->arpicmpPktCount);
p_nat->receivedPktCount = 0;
p_nat->missedPktCount = 0;
@@ -10655,38 +10596,41 @@ void all_cgnapt_clear_stats(void)
p_nat->arpicmpPktCount = 0;
#ifdef CGNAPT_DEBUGGING
- printf("\n Drop detail 1:%" PRIu64 ",",
+ len += sprintf(buf + len, "\n Drop detail 1:%" PRIu64 ",",
p_nat->naptDroppedPktCount1);
- printf("\n Drop detail 2:%" PRIu64 ",",
+ len += sprintf(buf + len, "\n Drop detail 2:%" PRIu64 ",",
p_nat->naptDroppedPktCount2);
- printf("\n Drop detail 3:%" PRIu64 ",",
+ len += sprintf(buf + len, "\n Drop detail 3:%" PRIu64 ",",
p_nat->naptDroppedPktCount3);
- printf("\n Drop detail 4:%" PRIu64 ",",
+ len += sprintf(buf + len, "\n Drop detail 4:%" PRIu64 ",",
p_nat->naptDroppedPktCount4);
- printf("\n Drop detail 5:%" PRIu64 ",",
+ len += sprintf(buf + len, "\n Drop detail 5:%" PRIu64 ",",
p_nat->naptDroppedPktCount5);
- printf("\n Drop detail 6:%" PRIu64 "",
+ len += sprintf(buf + len, "\n Drop detail 6:%" PRIu64 "",
p_nat->naptDroppedPktCount6);
- printf("\nPkt_miss: %" PRIu64 " %" PRIu64 "",
+ len += sprintf(buf + len, "\nPkt_miss: %" PRIu64 " %" PRIu64 "",
p_nat->missedpktcount1,
p_nat->missedpktcount2);
- printf("\nPkt_miss: %" PRIu64 " %" PRIu64 "",
+ len += sprintf(buf + len, "\nPkt_miss: %" PRIu64 " %" PRIu64 "",
p_nat->missedpktcount3,
p_nat->missedpktcount4);
- printf("\nPkt_miss: %" PRIu64 " %" PRIu64 "",
+ len += sprintf(buf + len, "\nPkt_miss: %" PRIu64 " %" PRIu64 "",
p_nat->missedpktcount5,
p_nat->missedpktcount6);
- printf("\nPkt_miss: %" PRIu64 " %" PRIu64 "",
+ len += sprintf(buf + len, "\nPkt_miss: %" PRIu64 " %" PRIu64 "",
p_nat->missedpktcount7,
p_nat->missedpktcount8);
- printf("\nPkt_miss: %" PRIu64 " %" PRIu64 "",
+ len += sprintf(buf + len, "\nPkt_miss: %" PRIu64 " %" PRIu64 "",
p_nat->missedpktcount9,
p_nat->missedpktcount10);
#endif
}
+
+ if (!rest_api_supported())
+ printf("%s\n", buf);
}
/**
diff --git a/VNFs/vCGNAPT/pipeline/pipeline_cgnapt_be.h b/VNFs/vCGNAPT/pipeline/pipeline_cgnapt_be.h
index 943d0fc7..7fde0c5a 100644
--- a/VNFs/vCGNAPT/pipeline/pipeline_cgnapt_be.h
+++ b/VNFs/vCGNAPT/pipeline/pipeline_cgnapt_be.h
@@ -418,14 +418,6 @@ struct pipeline_cgnapt {
uint8_t vnf_set; /* to identify as separate LB-CGNAPT set */
- /* Local ARP & ND Tables */
- struct lib_arp_route_table_entry
- local_lib_arp_route_table[MAX_ARP_RT_ENTRY];
- uint8_t local_lib_arp_route_ent_cnt;
- struct lib_nd_route_table_entry
- local_lib_nd_route_table[MAX_ND_RT_ENTRY];
- uint8_t local_lib_nd_route_ent_cnt;
-
/* For internal debugging purpose */
#ifdef CGNAPT_TIMING_INST
uint64_t in_port_exit_timestamp;
diff --git a/VNFs/vCGNAPT/pipeline/pipeline_cgnapt_common.h b/VNFs/vCGNAPT/pipeline/pipeline_cgnapt_common.h
index 4f4253cd..a7cd88a4 100644
--- a/VNFs/vCGNAPT/pipeline/pipeline_cgnapt_common.h
+++ b/VNFs/vCGNAPT/pipeline/pipeline_cgnapt_common.h
@@ -265,7 +265,7 @@ struct pipeline_cgnapt_entry_dbg_msg_req {
extern struct pipeline_be_ops pipeline_cgnapt_be_ops;
void print_num_ip_clients(void);
-void all_cgnapt_stats(void);
-void all_cgnapt_clear_stats(void);
+void all_cgnapt_stats(char *);
+void all_cgnapt_clear_stats(char *);
void print_static_cgnapt_entries(void);
#endif
diff --git a/VNFs/vCGNAPT/vnf_template.txt b/VNFs/vCGNAPT/vnf_template.txt
new file mode 100644
index 00000000..385c5312
--- /dev/null
+++ b/VNFs/vCGNAPT/vnf_template.txt
@@ -0,0 +1,80 @@
+[MASTER]
+type = MASTER
+core = 0
+
+[ARPICMP]
+type = ARPICMP
+core = 1
+pktq_in = SWQ0
+pktq_out = TXQ0.0 TXQ1.0
+pktq_in_prv = RXQ0.0
+prv_to_pub_map = (0,1)
+prv_que_handler = (0)
+
+[TIMER]
+type = TIMER
+core = 2
+n_flows = 1048576
+
+[TXRX-BEGIN]
+type = TXRX
+core = 2
+pktq_in = RXQ0.0 RXQ1.0
+pktq_out = SWQ0 SWQ1 SWQ2
+pipeline_txrx_type = RXRX
+dest_if_offset=176
+
+[TXRX-END]
+type = TXRX
+core = 5
+pktq_in = SWQ5 SWQ6
+pktq_out = TXQ0.1 TXQ1.1
+pipeline_txrx_type = TXTX
+
+[LOADB]
+type = LOADB
+core = 3
+pktq_in = SWQ0 SWQ1
+pktq_out = SWQ3 SWQ4
+outport_offset = 136
+phyport_offset = 204
+n_vnf_threads = 1
+prv_que_handler = (0)
+
+[VACL]
+type = ACL
+core = 4
+pktq_in = SWQ3 SWQ4
+pktq_out = SWQ5 SWQ6
+n_flows = 1000000
+pkt_type = ipv6
+traffic_type = 6
+
+[VCGNAPT]
+type = CGNAPT
+core = 3
+pktq_in = RXQ0.0 RXQ1.0
+pktq_out = TXQ0.1 TXQ1.1 SWQ0
+phyport_offset = 204
+n_flows = 1048576
+key_offset = 192;64
+key_size = 8
+hash_offset = 200;72
+timer_period = 100
+max_clients_per_ip = 65535
+max_port_per_client = 10
+pkt_type = ipv4
+cgnapt_meta_offset = 128
+prv_que_handler = (0,)
+
+[VFW]
+type = VFW
+core = s0c4
+pktq_in = SWQ3 SWQ4
+pktq_out = SWQ7 SWQ8;TXQ0.0 TXQ1.0
+n_rules = 10000
+n_flows = 1000000
+pkt_type = ipv6
+traffic_type = 6
+tcp_time_wait = 10
+