From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id EBDD01E2B for ; Mon, 9 Jan 2017 06:03:44 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP; 08 Jan 2017 21:03:43 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,339,1477983600"; d="scan'208";a="806609986" Received: from isb-2.iind.intel.com ([10.223.197.150]) by FMSMGA003.fm.intel.com with ESMTP; 08 Jan 2017 21:03:42 -0800 From: "Jyoti, Anand B" To: dev@dpdk.org Cc: stephen@networkplumber.org, cristian.dumitrescu@intel.com, Anand B Jyoti Date: Mon, 9 Jan 2017 03:25:49 +0530 Message-Id: <1483912549-170299-1-git-send-email-anand.b.jyoti@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: Subject: [dpdk-dev] [PATCH v2] examples/ip_pipeline: check VLAN and MPLS params X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Jan 2017 05:03:45 -0000 This commit add to CLI command check for the following errors 1. SVLAN and CVLAN IDs greater than 12 bits 2. MPLS ID greater than 20 bits 3. max number of supported MPLS labels to avoid array overflow It prevents running CLI commands with invalid parameters. Signed-off-by: Anand B Jyoti Acked-by: Cristian Dumitrescu --- examples/ip_pipeline/pipeline/pipeline_routing.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/examples/ip_pipeline/pipeline/pipeline_routing.c b/examples/ip_pipeline/pipeline/pipeline_routing.c index 3aadbf9..3deaff9 100644 --- a/examples/ip_pipeline/pipeline/pipeline_routing.c +++ b/examples/ip_pipeline/pipeline/pipeline_routing.c @@ -494,6 +494,26 @@ app_pipeline_routing_add_route(struct app_params *app, /* data */ if (data->port_id >= p->n_ports_out) return -1; + + /* Valid range of VLAN tags 12 bits */ + if (data->flags & PIPELINE_ROUTING_ROUTE_QINQ) + if ((data->l2.qinq.svlan & 0xF000) || + (data->l2.qinq.cvlan & 0xF000)) + return -1; + + /* Max number of MPLS labels supported */ + if (data->flags & PIPELINE_ROUTING_ROUTE_MPLS) { + uint32_t i; + + if (data->l2.mpls.n_labels > + PIPELINE_ROUTING_MPLS_LABELS_MAX) + return -1; + + /* Max MPLS label value 20 bits */ + for (i = 0; i < data->l2.mpls.n_labels; i++) + if (data->l2.mpls.labels[i] & 0xFFF00000) + return -1; + } } break; -- 2.7.4