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 949DFA0543; Mon, 13 Jun 2022 19:28:40 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7564A40222; Mon, 13 Jun 2022 19:28:40 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id 638A540150 for ; Mon, 13 Jun 2022 19:28:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1655141318; x=1686677318; h=from:to:subject:date:message-id:in-reply-to:references; bh=3lCuSoxGiTyudiUEY167SkuQJ1h17x+LU+frvZqb3FU=; b=Mn7VLRCLEtibKUVccWJu/XVcX4mB83GEeCEiNXp7qDSZywSSBid9mzb4 2mLiG/nTZipYGkdw3YwwsSAwKFqNUluOX3ku+be+Kgl68BybfkL2Jqe1Q xkU1rQz8XUNcZTNVXMNBTKa5jeUOAN31N9wUG3zkA85K0yK/Z8ggPkOm+ 7weohfCsCDCzLjsO1vW1NCcaOMh/Vnv89b4CEa1NxSCCMz3MBEgmjrciE eWXf1I+941wIuGjNXfLa+76y1wDGyVTQYTe4/kedQ5LPg6LM5KFgqxJhk K4vyqWqhA1Op8p/ca0f64zomcteu7Yq785zAm6Vf1mUFCkJR4Vlq62PmN Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10377"; a="275886118" X-IronPort-AV: E=Sophos;i="5.91,297,1647327600"; d="scan'208";a="275886118" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jun 2022 10:28:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,297,1647327600"; d="scan'208";a="829910323" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com) ([10.237.223.107]) by fmsmga006.fm.intel.com with ESMTP; 13 Jun 2022 10:28:35 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Subject: [PATCH V2] pipeline: fix packet mirroring configuration Date: Mon, 13 Jun 2022 18:28:34 +0100 Message-Id: <20220613172834.85915-1-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220613172320.85777-1-cristian.dumitrescu@intel.com> References: <20220613172320.85777-1-cristian.dumitrescu@intel.com> 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 Fix segmentation fault due to null pointer dereferencing inside the "mirror" instruction when number of mirroring slots is set to 0. This was taking place when the "mirror" instruction was used without the mirror feature being properly configured, i.e. the API function rte_swx_pipeline_mirroring_config was not called at initialization. Fixes: dac0ecd9098 (" pipeline: support packet mirroring") Signed-off-by: Cristian Dumitrescu --- lib/pipeline/rte_swx_pipeline.c | 5 ++--- lib/pipeline/rte_swx_pipeline.h | 10 ++++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/pipeline/rte_swx_pipeline.c b/lib/pipeline/rte_swx_pipeline.c index 659d8726d1..066356684e 100644 --- a/lib/pipeline/rte_swx_pipeline.c +++ b/lib/pipeline/rte_swx_pipeline.c @@ -612,9 +612,6 @@ mirroring_build(struct rte_swx_pipeline *p) { uint32_t i; - if (!p->n_mirroring_slots || !p->n_mirroring_sessions) - return 0; - for (i = 0; i < RTE_SWX_PIPELINE_THREADS_MAX; i++) { struct thread *t = &p->threads[i]; @@ -9772,6 +9769,8 @@ rte_swx_pipeline_config(struct rte_swx_pipeline **p, int numa_node) TAILQ_INIT(&pipeline->metarrays); pipeline->n_structs = 1; /* Struct 0 is reserved for action_data. */ + pipeline->n_mirroring_slots = RTE_SWX_PACKET_MIRRORING_SLOTS_DEFAULT; + pipeline->n_mirroring_sessions = RTE_SWX_PACKET_MIRRORING_SESSIONS_DEFAULT; pipeline->numa_node = numa_node; status = port_in_types_register(pipeline); diff --git a/lib/pipeline/rte_swx_pipeline.h b/lib/pipeline/rte_swx_pipeline.h index adc7fa53b7..9299f27094 100644 --- a/lib/pipeline/rte_swx_pipeline.h +++ b/lib/pipeline/rte_swx_pipeline.h @@ -163,6 +163,16 @@ rte_swx_pipeline_port_out_config(struct rte_swx_pipeline *p, * Packet mirroring */ +/** Default number of packet mirroring slots. */ +#ifndef RTE_SWX_PACKET_MIRRORING_SLOTS_DEFAULT +#define RTE_SWX_PACKET_MIRRORING_SLOTS_DEFAULT 4 +#endif + +/** Default maximum number of packet mirroring sessions. */ +#ifndef RTE_SWX_PACKET_MIRRORING_SESSIONS_DEFAULT +#define RTE_SWX_PACKET_MIRRORING_SESSIONS_DEFAULT 64 +#endif + /** Packet mirroring parameters. */ struct rte_swx_pipeline_mirroring_params { /** Number of packet mirroring slots. */ -- 2.17.1