From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id AC6A6A0547; Sun, 4 Apr 2021 11:49:34 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4853D140E23; Sun, 4 Apr 2021 11:49:23 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by mails.dpdk.org (Postfix) with ESMTP id 6C9A1140E03 for ; Sun, 4 Apr 2021 11:49:19 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from salems@nvidia.com) with SMTP; 4 Apr 2021 12:49:14 +0300 Received: from nvidia.com ([10.228.128.224]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 1349nDQB018750; Sun, 4 Apr 2021 12:49:14 +0300 From: Salem Sol To: dev@dpdk.org Cc: Jiawei Wang , Ori Kam , Xiaoyun Li Date: Sun, 4 Apr 2021 12:49:04 +0300 Message-Id: <20210404094910.95413-2-salems@nvidia.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210404094910.95413-1-salems@nvidia.com> References: <20210404094910.95413-1-salems@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v4 1/7] app/testpmd: store VXLAN/NVGRE encap data globally X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Jiawei Wang With the current code the VXLAN/NVGRE parsing routine stored the configuration of the header on stack, this might lead to overwriting the data on the stack. This patch stores the external data of vxlan and nvgre encap into global data as a pre-step to supporting vxlan and nvgre encap as a sample actions. Signed-off-by: Jiawei Wang --- app/test-pmd/cmdline_flow.c | 72 ++++++++++++++++++++++--------------- 1 file changed, 44 insertions(+), 28 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 49d9f9c043..16b2120dbc 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -5244,31 +5244,11 @@ parse_vc_action_rss_queue(struct context *ctx, const struct token *token, return len; } -/** Parse VXLAN encap action. */ +/** Setup VXLAN encap configuration. */ static int -parse_vc_action_vxlan_encap(struct context *ctx, const struct token *token, - const char *str, unsigned int len, - void *buf, unsigned int size) +parse_setup_vxlan_encap_data(struct action_vxlan_encap_data *action_vxlan_encap_data) { - struct buffer *out = buf; - struct rte_flow_action *action; - struct action_vxlan_encap_data *action_vxlan_encap_data; - int ret; - - ret = parse_vc(ctx, token, str, len, buf, size); - if (ret < 0) - return ret; - /* Nothing else to do if there is no buffer. */ - if (!out) - return ret; - if (!out->args.vc.actions_n) - return -1; - action = &out->args.vc.actions[out->args.vc.actions_n - 1]; - /* Point to selected object. */ - ctx->object = out->args.vc.data; - ctx->objmask = NULL; /* Set up default configuration. */ - action_vxlan_encap_data = ctx->object; *action_vxlan_encap_data = (struct action_vxlan_encap_data){ .conf = (struct rte_flow_action_vxlan_encap){ .definition = action_vxlan_encap_data->items, @@ -5372,19 +5352,18 @@ parse_vc_action_vxlan_encap(struct context *ctx, const struct token *token, } memcpy(action_vxlan_encap_data->item_vxlan.vni, vxlan_encap_conf.vni, RTE_DIM(vxlan_encap_conf.vni)); - action->conf = &action_vxlan_encap_data->conf; - return ret; + return 0; } -/** Parse NVGRE encap action. */ +/** Parse VXLAN encap action. */ static int -parse_vc_action_nvgre_encap(struct context *ctx, const struct token *token, +parse_vc_action_vxlan_encap(struct context *ctx, const struct token *token, const char *str, unsigned int len, void *buf, unsigned int size) { struct buffer *out = buf; struct rte_flow_action *action; - struct action_nvgre_encap_data *action_nvgre_encap_data; + struct action_vxlan_encap_data *action_vxlan_encap_data; int ret; ret = parse_vc(ctx, token, str, len, buf, size); @@ -5399,8 +5378,17 @@ parse_vc_action_nvgre_encap(struct context *ctx, const struct token *token, /* Point to selected object. */ ctx->object = out->args.vc.data; ctx->objmask = NULL; + action_vxlan_encap_data = ctx->object; + parse_setup_vxlan_encap_data(action_vxlan_encap_data); + action->conf = &action_vxlan_encap_data->conf; + return ret; +} + +/** Setup NVGRE encap configuration. */ +static int +parse_setup_nvgre_encap_data(struct action_nvgre_encap_data *action_nvgre_encap_data) +{ /* Set up default configuration. */ - action_nvgre_encap_data = ctx->object; *action_nvgre_encap_data = (struct action_nvgre_encap_data){ .conf = (struct rte_flow_action_nvgre_encap){ .definition = action_nvgre_encap_data->items, @@ -5463,6 +5451,34 @@ parse_vc_action_nvgre_encap(struct context *ctx, const struct token *token, RTE_FLOW_ITEM_TYPE_VOID; memcpy(action_nvgre_encap_data->item_nvgre.tni, nvgre_encap_conf.tni, RTE_DIM(nvgre_encap_conf.tni)); + return 0; +} + +/** Parse NVGRE encap action. */ +static int +parse_vc_action_nvgre_encap(struct context *ctx, const struct token *token, + const char *str, unsigned int len, + void *buf, unsigned int size) +{ + struct buffer *out = buf; + struct rte_flow_action *action; + struct action_nvgre_encap_data *action_nvgre_encap_data; + int ret; + + ret = parse_vc(ctx, token, str, len, buf, size); + if (ret < 0) + return ret; + /* Nothing else to do if there is no buffer. */ + if (!out) + return ret; + if (!out->args.vc.actions_n) + return -1; + action = &out->args.vc.actions[out->args.vc.actions_n - 1]; + /* Point to selected object. */ + ctx->object = out->args.vc.data; + ctx->objmask = NULL; + action_nvgre_encap_data = ctx->object; + parse_setup_nvgre_encap_data(action_nvgre_encap_data); action->conf = &action_nvgre_encap_data->conf; return ret; } -- 2.21.0