From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 4E6CA569A for ; Thu, 17 Sep 2015 14:58:39 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 17 Sep 2015 05:58:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,547,1437462000"; d="scan'208";a="806559921" Received: from unknown (HELO stargo) ([10.217.248.233]) by orsmga002.jf.intel.com with SMTP; 17 Sep 2015 05:58:37 -0700 Received: by stargo (sSMTP sendmail emulation); Thu, 17 Sep 2015 14:58:55 +0200 From: Maciej Gajdzica To: dev@dpdk.org Date: Thu, 17 Sep 2015 14:58:33 +0200 Message-Id: <1442494713-24421-1-git-send-email-maciejx.t.gajdzica@intel.com> X-Mailer: git-send-email 1.9.1 Subject: [dpdk-dev] [PATCH 1/1] ip_pipeline: add pipeline type validation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Sep 2015 12:58:40 -0000 This commit add to CLI command check for pipeline type. It prevents running CLI commands on not supported pipeline types. Signed-off-by: Maciej Gajdzica --- examples/ip_pipeline/app.h | 1 + examples/ip_pipeline/init.c | 2 ++ examples/ip_pipeline/pipeline/pipeline_common_fe.h | 5 +++- examples/ip_pipeline/pipeline/pipeline_firewall.c | 26 +++++++++++++------- .../pipeline/pipeline_flow_classification.c | 12 ++++----- examples/ip_pipeline/pipeline/pipeline_routing.c | 22 ++++++++--------- 6 files changed, 41 insertions(+), 27 deletions(-) diff --git a/examples/ip_pipeline/app.h b/examples/ip_pipeline/app.h index 521e3a0..23a09c9 100644 --- a/examples/ip_pipeline/app.h +++ b/examples/ip_pipeline/app.h @@ -219,6 +219,7 @@ struct app_pipeline_params { struct app_pipeline_data { void *be; void *fe; + struct pipeline_type *ptype; uint64_t timer_period; }; diff --git a/examples/ip_pipeline/init.c b/examples/ip_pipeline/init.c index 3f9c68d..19b82e9 100644 --- a/examples/ip_pipeline/init.c +++ b/examples/ip_pipeline/init.c @@ -1220,6 +1220,8 @@ app_init_pipelines(struct app_params *app) "init error\n", params->name); } + data->ptype = ptype; + data->timer_period = (rte_get_tsc_hz() * params->timer_period) / 1000; } diff --git a/examples/ip_pipeline/pipeline/pipeline_common_fe.h b/examples/ip_pipeline/pipeline/pipeline_common_fe.h index 693848d..02ebe9e 100644 --- a/examples/ip_pipeline/pipeline/pipeline_common_fe.h +++ b/examples/ip_pipeline/pipeline/pipeline_common_fe.h @@ -60,7 +60,7 @@ app_pipeline_data(struct app_params *app, uint32_t id) } static inline void * -app_pipeline_data_fe(struct app_params *app, uint32_t id) +app_pipeline_data_fe(struct app_params *app, uint32_t id, struct pipeline_type *ptype) { struct app_pipeline_data *pipeline_data; @@ -68,6 +68,9 @@ app_pipeline_data_fe(struct app_params *app, uint32_t id) if (pipeline_data == NULL) return NULL; + if (strcmp(pipeline_data->ptype->name, ptype->name) != 0) + return NULL; + return pipeline_data->fe; } diff --git a/examples/ip_pipeline/pipeline/pipeline_firewall.c b/examples/ip_pipeline/pipeline/pipeline_firewall.c index f6924ab..3a097ae 100644 --- a/examples/ip_pipeline/pipeline/pipeline_firewall.c +++ b/examples/ip_pipeline/pipeline/pipeline_firewall.c @@ -127,7 +127,7 @@ app_pipeline_firewall_rule_find(struct app_pipeline_firewall *p, return NULL; } -static void +static int app_pipeline_firewall_ls( struct app_params *app, uint32_t pipeline_id) @@ -139,11 +139,11 @@ app_pipeline_firewall_ls( /* Check input arguments */ if (app == NULL) - return; + return -1; - p = app_pipeline_data_fe(app, pipeline_id); + p = app_pipeline_data_fe(app, pipeline_id, &pipeline_firewall); if (p == NULL) - return; + return -1; n_rules = p->n_rules; for (priority = 0; n_rules; priority++) @@ -161,6 +161,8 @@ app_pipeline_firewall_ls( printf("Default rule: DROP\n"); printf("\n"); + + return 0; } static void* @@ -275,7 +277,7 @@ app_pipeline_firewall_add_rule(struct app_params *app, (key->type != PIPELINE_FIREWALL_IPV4_5TUPLE)) return -1; - p = app_pipeline_data_fe(app, pipeline_id); + p = app_pipeline_data_fe(app, pipeline_id, &pipeline_firewall); if (p == NULL) return -1; @@ -363,7 +365,7 @@ app_pipeline_firewall_delete_rule(struct app_params *app, (key->type != PIPELINE_FIREWALL_IPV4_5TUPLE)) return -1; - p = app_pipeline_data_fe(app, pipeline_id); + p = app_pipeline_data_fe(app, pipeline_id, &pipeline_firewall); if (p == NULL) return -1; @@ -419,7 +421,7 @@ app_pipeline_firewall_add_default_rule(struct app_params *app, if (app == NULL) return -1; - p = app_pipeline_data_fe(app, pipeline_id); + p = app_pipeline_data_fe(app, pipeline_id, &pipeline_firewall); if (p == NULL) return -1; @@ -470,7 +472,7 @@ app_pipeline_firewall_delete_default_rule(struct app_params *app, if (app == NULL) return -1; - p = app_pipeline_data_fe(app, pipeline_id); + p = app_pipeline_data_fe(app, pipeline_id, &pipeline_firewall); if (p == NULL) return -1; @@ -948,8 +950,14 @@ cmd_firewall_ls_parsed( { struct cmd_firewall_ls_result *params = parsed_result; struct app_params *app = data; + int status; - app_pipeline_firewall_ls(app, params->pipeline_id); + status = app_pipeline_firewall_ls(app, params->pipeline_id); + + if (status != 0) { + printf("Command failed\n"); + return; + } } cmdline_parse_token_string_t cmd_firewall_ls_p_string = diff --git a/examples/ip_pipeline/pipeline/pipeline_flow_classification.c b/examples/ip_pipeline/pipeline/pipeline_flow_classification.c index 4b82180..195e78a 100644 --- a/examples/ip_pipeline/pipeline/pipeline_flow_classification.c +++ b/examples/ip_pipeline/pipeline/pipeline_flow_classification.c @@ -296,7 +296,7 @@ app_pipeline_fc_add(struct app_params *app, (key == NULL)) return -1; - p = app_pipeline_data_fe(app, pipeline_id); + p = app_pipeline_data_fe(app, pipeline_id, &pipeline_flow_classification); if (p == NULL) return -1; @@ -392,7 +392,7 @@ app_pipeline_fc_add_bulk(struct app_params *app, (n_keys == 0)) return -1; - p = app_pipeline_data_fe(app, pipeline_id); + p = app_pipeline_data_fe(app, pipeline_id, &pipeline_flow_classification); if (p == NULL) return -1; @@ -580,7 +580,7 @@ app_pipeline_fc_del(struct app_params *app, (key == NULL)) return -1; - p = app_pipeline_data_fe(app, pipeline_id); + p = app_pipeline_data_fe(app, pipeline_id, &pipeline_flow_classification); if (p == NULL) return -1; @@ -638,7 +638,7 @@ app_pipeline_fc_add_default(struct app_params *app, if (app == NULL) return -1; - p = app_pipeline_data_fe(app, pipeline_id); + p = app_pipeline_data_fe(app, pipeline_id, &pipeline_flow_classification); if (p == NULL) return -1; @@ -690,7 +690,7 @@ app_pipeline_fc_del_default(struct app_params *app, if (app == NULL) return -1; - p = app_pipeline_data_fe(app, pipeline_id); + p = app_pipeline_data_fe(app, pipeline_id, &pipeline_flow_classification); if (p == NULL) return -EINVAL; @@ -865,7 +865,7 @@ app_pipeline_fc_ls(struct app_params *app, if (app == NULL) return -1; - p = app_pipeline_data_fe(app, pipeline_id); + p = app_pipeline_data_fe(app, pipeline_id, &pipeline_flow_classification); if (p == NULL) return -1; diff --git a/examples/ip_pipeline/pipeline/pipeline_routing.c b/examples/ip_pipeline/pipeline/pipeline_routing.c index beec982..ebadc99 100644 --- a/examples/ip_pipeline/pipeline/pipeline_routing.c +++ b/examples/ip_pipeline/pipeline/pipeline_routing.c @@ -232,7 +232,7 @@ app_pipeline_routing_route_ls(struct app_params *app, uint32_t pipeline_id) struct pipeline_routing *p; struct app_pipeline_routing_route *it; - p = app_pipeline_data_fe(app, pipeline_id); + p = app_pipeline_data_fe(app, pipeline_id, &pipeline_routing); if (p == NULL) return -EINVAL; @@ -270,7 +270,7 @@ app_pipeline_routing_add_route(struct app_params *app, (route_params == NULL)) return -1; - p = app_pipeline_data_fe(app, pipeline_id); + p = app_pipeline_data_fe(app, pipeline_id, &pipeline_routing); if (p == NULL) return -1; @@ -374,7 +374,7 @@ app_pipeline_routing_delete_route(struct app_params *app, (key == NULL)) return -1; - p = app_pipeline_data_fe(app, pipeline_id); + p = app_pipeline_data_fe(app, pipeline_id, &pipeline_routing); if (p == NULL) return -1; @@ -446,7 +446,7 @@ app_pipeline_routing_add_default_route(struct app_params *app, if (app == NULL) return -1; - p = app_pipeline_data_fe(app, pipeline_id); + p = app_pipeline_data_fe(app, pipeline_id, &pipeline_routing); if (p == NULL) return -1; @@ -498,7 +498,7 @@ app_pipeline_routing_delete_default_route(struct app_params *app, if (app == NULL) return -1; - p = app_pipeline_data_fe(app, pipeline_id); + p = app_pipeline_data_fe(app, pipeline_id, &pipeline_routing); if (p == NULL) return -1; @@ -536,7 +536,7 @@ app_pipeline_routing_arp_ls(struct app_params *app, uint32_t pipeline_id) struct pipeline_routing *p; struct app_pipeline_routing_arp_entry *it; - p = app_pipeline_data_fe(app, pipeline_id); + p = app_pipeline_data_fe(app, pipeline_id, &pipeline_routing); if (p == NULL) return -EINVAL; @@ -573,7 +573,7 @@ app_pipeline_routing_add_arp_entry(struct app_params *app, uint32_t pipeline_id, (macaddr == NULL)) return -1; - p = app_pipeline_data_fe(app, pipeline_id); + p = app_pipeline_data_fe(app, pipeline_id, &pipeline_routing); if (p == NULL) return -1; @@ -668,7 +668,7 @@ app_pipeline_routing_delete_arp_entry(struct app_params *app, (key == NULL)) return -1; - p = app_pipeline_data_fe(app, pipeline_id); + p = app_pipeline_data_fe(app, pipeline_id, &pipeline_routing); if (p == NULL) return -EINVAL; @@ -736,7 +736,7 @@ app_pipeline_routing_add_default_arp_entry(struct app_params *app, if (app == NULL) return -1; - p = app_pipeline_data_fe(app, pipeline_id); + p = app_pipeline_data_fe(app, pipeline_id, &pipeline_routing); if (p == NULL) return -1; @@ -788,7 +788,7 @@ app_pipeline_routing_delete_default_arp_entry(struct app_params *app, if (app == NULL) return -1; - p = app_pipeline_data_fe(app, pipeline_id); + p = app_pipeline_data_fe(app, pipeline_id, &pipeline_routing); if (p == NULL) return -EINVAL; @@ -1483,7 +1483,7 @@ cmd_arp_ls_parsed( struct app_params *app = data; struct pipeline_routing *p; - p = app_pipeline_data_fe(app, params->p); + p = app_pipeline_data_fe(app, params->p, &pipeline_routing); if (p == NULL) return; -- 1.7.9.5