From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0044.outbound.protection.outlook.com [104.47.40.44]) by dpdk.org (Postfix) with ESMTP id A5DDAA495 for ; Thu, 11 Jan 2018 12:59:37 +0100 (CET) Received: from CY4PR03CA0019.namprd03.prod.outlook.com (10.168.162.29) by BN3PR03MB2355.namprd03.prod.outlook.com (10.166.74.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.386.5; Thu, 11 Jan 2018 11:59:36 +0000 Received: from BL2FFO11FD028.protection.gbl (2a01:111:f400:7c09::179) by CY4PR03CA0019.outlook.office365.com (2603:10b6:903:33::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.386.5 via Frontend Transport; Thu, 11 Jan 2018 11:59:35 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; NXP1.onmicrosoft.com; dkim=none (message not signed) header.d=none;NXP1.onmicrosoft.com; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BL2FFO11FD028.mail.protection.outlook.com (10.173.161.107) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.345.12 via Frontend Transport; Thu, 11 Jan 2018 11:59:03 +0000 Received: from netperf2.ap.freescale.net ([10.232.133.164]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id w0BBxVGd021280; Thu, 11 Jan 2018 04:59:32 -0700 From: Akhil Goyal To: CC: , , , , Akhil Goyal Date: Thu, 11 Jan 2018 17:25:36 +0530 Message-ID: <20180111115536.20346-1-akhil.goyal@nxp.com> X-Mailer: git-send-email 2.9.3 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131601455434070896; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(396003)(39380400002)(346002)(39860400002)(376002)(2980300002)(1110001)(1109001)(339900001)(189003)(199004)(50466002)(2906002)(356003)(81156014)(305945005)(8936002)(47776003)(85426001)(2351001)(1076002)(8676002)(36756003)(48376002)(498600001)(86362001)(106466001)(104016004)(68736007)(51416003)(53936002)(54906003)(316002)(8656006)(4326008)(296002)(105606002)(16586007)(77096006)(6916009)(97736004)(81166006)(5660300001)(50226002); DIR:OUT; SFP:1101; SCL:1; SRVR:BN3PR03MB2355; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD028; 1:oQ40P5qYpmlWgDIJ3Csv0gIKA+QiJ+JyjHO3iMzIFXX8OFTh7c22rQ248B0ClWw47B9gGQPlkJ3RgrcCSwV/iQ2TE1/oSeDzvtppxF9f25HYHpV2gOPUEvj89AzN0iuX MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c83be587-4b34-4ea0-7b70-08d558eab589 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020065)(5600026)(4604075)(2017052603307); SRVR:BN3PR03MB2355; X-Microsoft-Exchange-Diagnostics: 1; BN3PR03MB2355; 3:OXUMATbfVeILDWkyKrAUEHgTqt4uc3sQwmLHuZLbmg8kUDjn/RE3iFTziuxgTMah0D6T4XQZW/9M7wVNiLpBUQtVZ8SCOABbWTItMnXwsQeAIbo0RflRPLhVMYirhMER589u1Kq3Jv0uMxwiFGwq5UdSoSPkFEeu2IYsp/yV7V9i4slfmdYxKgIb1LTp16PkCEZpG9j6mw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hBKGpMV3zxGTYKX9kV3SZnTSttkH9Lq6AzztORyIV5q9YPfq7nRH X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095135)(2401047)(8121501046)(5005006)(10201501046)(93006095)(93001095)(3002001)(3231023)(944501134)(6055026)(6096035)(20161123556025)(20161123559100)(20161123561025)(201703131430075)(201703131520075)(201703131448075)(201703131433075)(201703151042153)(20161123563025)(20161123565025)(201708071742011); SRVR:BN3PR03MB2355; BCL:0; PCL:0; RULEID:(100000803101)(100110400095)(400006); SRVR:BN3PR03MB2355; X-Forefront-PRVS: 0549E6FD50 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN3PR03MB2355; 23:PaKIENW28PfbNnC34iY6gllZ26ga8T0/GYzYkcqWV?= =?us-ascii?Q?LSQVo2xGDoAgpJ/KD6PdTceQuQ4IWWfJ5EzlWOTZZ0okXnHuG818Iz4UtKYr?= =?us-ascii?Q?Y0Ey8t7+k9juQTYvkkDMHnSy/D035RMNaWHl+oTiPsnw6riuLlp7pPTHHS5x?= =?us-ascii?Q?+TrrpK5csnZUgTHfzrTghq89KkjHisjDYbZmcCkDZf8F99FTMlzIyOSffS9G?= =?us-ascii?Q?kL/fGutcipoNxgHOY817ZP7VnTrUqYwqoUZphsi5MkOjo9Porcgp2X1X6xWE?= =?us-ascii?Q?KHZa1MmGY4Os4WIoU4oIhCzeDwP4aPuP+1ASpBVQa3XwIq7PGLkNpw3syKnZ?= =?us-ascii?Q?HNg87b94Woykpy4ZQJs6EBOpPaOy3Cv1XF0Eiwx3n37E4Ad6rKwpVZvSAbkG?= =?us-ascii?Q?zMwpVyTpRHW9KJSRybKgXfkzTNju5KmlVruZZVlPOe2J4w4X4AnR6a6kpWnJ?= =?us-ascii?Q?AYtJ+gg1hPb5Kf0DloFYBkrJjxaAFGy88nAJc2SPPWTvO7SbpUo/PHrKYAnZ?= =?us-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X6/9iuK2UplP5IulVqvoKOXKONW0TbEUZOaEQsyk6ZWHBZDdsznhsKcwN7HmswagAxGWr1Ue26QR0DZOmXE+/TWv1Dv4cP73k+UYyU35FfRaMvMqwttU/Nk8WD4CaPTrHCwWbKunrTxFCxrh3paxgtf+c=; 24:Bp64rzNwXqFI1bHFsoRJP4k3dHMV7MQmpx16Y5YiUreVqQtskeauBri8RF2nDTa2mzfhEkYxcQuFffp47JL84tKr4GpSEco2HypW6H+dlAI=; 7:SZl7L12/yhfmoRux5MHDo0R14CDVrqsN3yHwAKboTaNeb3sfVJG9YTTXNXaEtb5tbuM7kJJ1jNwS15W0HN4nn53CyTAJaJvyTqF66yJUuHskhVARSSZug7E9QptH4LU55DEK+UvfTkM5fwxfiO3loZRgY5IsCStXQV8Qvp1CgXAQboLNNV3fp6kDAhcwnEFUMFpMkTyD2NRZ/RXSaSyDH8QkpVovNAWIr7Y3WaDfjdUPUHashiARnTm1osMa3M8k SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2018 11:59:03.2198 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c83be587-4b34-4ea0-7b70-08d558eab589 X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR03MB2355 Subject: [dpdk-dev] [PATCH] examples/ipsec-secgw: fix corner case for spi value 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: Thu, 11 Jan 2018 11:59:38 -0000 application is using index 0 of SA table as error, with current value of IPSEC_SA_MAX_ENTRIES(128) it can not support SA with spi = 128, as it uses sa_idx = 0 in the SA table. With this patch, sa_idx = 0 can also be used. PS: spi = 0 is an invalid SPI and application throws error for it. Fixes: d299106e8e31 ("examples/ipsec-secgw: add IPsec sample application") Signed-off-by: Akhil Goyal --- examples/ipsec-secgw/ipsec-secgw.c | 7 ++++--- examples/ipsec-secgw/sa.c | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ipsec-secgw.c index d6f7b36..4d50e72 100644 --- a/examples/ipsec-secgw/ipsec-secgw.c +++ b/examples/ipsec-secgw/ipsec-secgw.c @@ -420,7 +420,8 @@ inbound_sp_sa(struct sp_ctx *sp, struct sa_ctx *sa, struct traffic_type *ip, } sa_idx = ip->res[i] & PROTECT_MASK; - if (sa_idx == 0 || !inbound_sa_check(sa, m, sa_idx)) { + if (sa_idx >= IPSEC_SA_MAX_ENTRIES || + !inbound_sa_check(sa, m, sa_idx)) { rte_pktmbuf_free(m); continue; } @@ -485,9 +486,9 @@ outbound_sp(struct sp_ctx *sp, struct traffic_type *ip, for (i = 0; i < ip->num; i++) { m = ip->pkts[i]; sa_idx = ip->res[i] & PROTECT_MASK; - if ((ip->res[i] == 0) || (ip->res[i] & DISCARD)) + if (ip->res[i] & DISCARD) rte_pktmbuf_free(m); - else if (sa_idx != 0) { + else if (sa_idx < IPSEC_SA_MAX_ENTRIES) { ipsec->res[ipsec->num] = sa_idx; ipsec->pkts[ipsec->num++] = m; } else /* BYPASS */ diff --git a/examples/ipsec-secgw/sa.c b/examples/ipsec-secgw/sa.c index 1ae4e2a..25ceea1 100644 --- a/examples/ipsec-secgw/sa.c +++ b/examples/ipsec-secgw/sa.c @@ -240,6 +240,8 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens, APP_CHECK_TOKEN_IS_NUM(tokens, 1, status); if (status->status < 0) return; + if (atoi(tokens[1]) == INVALID_SPI) + return; rule->spi = atoi(tokens[1]); for (ti = 2; ti < n_tokens; ti++) { -- 2.9.3