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 7DFFF43CB0; Thu, 14 Mar 2024 03:01:42 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1B20040297; Thu, 14 Mar 2024 03:01:42 +0100 (CET) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2095.outbound.protection.outlook.com [40.107.220.95]) by mails.dpdk.org (Postfix) with ESMTP id 4EF724025E; Thu, 14 Mar 2024 03:01:40 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JI3EVA0Qy6BluNr40gHdH/cCahs5iWPClV9A415OzZLGHofMgeIUsr/Wnr8QtynNtyOUX8zEGAZa+Wpo3hSDUZt/UmFoTbAqTRqpZhubWFOHvxYPflyIu20PRwaL2P8t/ShQN4yot8FhMplrlwUNm/YifXANAB4GQJxLI6FFQDAyLj29aoLEvEnMhV0imGHj6lc2CvgTncedo4IXA6wC+/CEGUtqexjhCX9GgyddDoYPXUdxZTTfP10v5Tffz/Ig9th3vKGh/3drRoNsxrgabvULU4HSOLkVZOl/hBemCXZchDV9UitO6D0JIvK2vHoB1OSZ5FRCCAxgQd4HFh2T6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=YA7qu348NPFYoDkNUpqArJelw6K/lAisjUN3QIe3iHM=; b=ldGrIolFQQjsqwA8e45I4Kq39Cq9NJUiQX4ZCGzU8eS+cc9kUQXNE0/Kac8eagGSn3Ff3JC6DA3bjjOW/olXeI3TQeHoZ9Xk2VpX9mkOtkat9kkzdYE5U426QNa46xyIvlCvUQFYCrpxsVy6038GSmLutR6V7jYYfoLpIxHqk+k6dDuoOxHMfsNUbNjoRlZsyfqP6fZ0RZEGZLI98Pc2vx3X8LckQPlSKlyxfI5pgEo7Alcwgs4ON2TEvW+wwa0tY74Po93Yw2G0BmOs18JnDrwB/zOlPDMm13UeprZGpDoYxlnVHBk1c9WxqLSl9Tgdp1eyvrCo41bK7U0XSZcK7Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YA7qu348NPFYoDkNUpqArJelw6K/lAisjUN3QIe3iHM=; b=tS/0xUksyGl/aUEh6O0SUyCUP8ZQwhmsSd9Htf1AJez4KBos6wDuagZW0YpTf0u62VDNloHq8n03nSlL2XmOQ6dmLqj/HQqcRWrKckX7bBQkDcafniCF8JnAljGwaYYzwztRKdpxJDYZePgIGX0psgJXlLdqkTV188uJqGLIyZE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) by MW5PR13MB5945.namprd13.prod.outlook.com (2603:10b6:303:1aa::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.36; Thu, 14 Mar 2024 02:01:37 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::ec12:7411:559a:850e]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::ec12:7411:559a:850e%5]) with mapi id 15.20.7362.035; Thu, 14 Mar 2024 02:01:37 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Shihong Wang , stable@dpdk.org, Chaoyong He Subject: [PATCH v2] examples/ipsec-secgw: fix SA salt endianness problem Date: Thu, 14 Mar 2024 10:00:52 +0800 Message-Id: <20240314020052.3107549-1-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20240311024939.2523778-2-chaoyong.he@corigine.com> References: <20240311024939.2523778-2-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: PH8PR22CA0009.namprd22.prod.outlook.com (2603:10b6:510:2d1::25) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|MW5PR13MB5945:EE_ X-MS-Office365-Filtering-Correlation-Id: 7a1e5743-cc75-4c76-239c-08dc43caae6b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: w9xvQcBH9T+oVoRByBjODwi/ZJkD+o05tSPziO7gy2VMjbw0+I/TUEM6OnR3D2qMG0U1BVctg0g4aMcL3q07Ev43ok/Q+EcREw66G2SHwoVYEHIToka2764GHNSPsttXhQD1X4ab+mkSCMfZrJGy5AHGPJc2pQDbUE9h2v6L0MzW3sNMks7IB5uEZn5qXyM9taiSGPMyRCRX9vO4HQ5/hmKWCu6MQbUBBBcLASLb+/k4cIAuvWp9RptBC8yIM1GDJq1pFThZ7Nq6xNSMS02fUVYMAk5hFwN8ZDOQHnwLowfARKKSkVG0RY7epYrqKCsfF5NvG+pHFChtGb/nqYDNfBidk0D0JddFzkUYZimB/0u5Qx9QyTvk/oKrToz8Ig0w2VslQD9zrzSKqS6GHShuuqaXKdDnaV4LObWoAUfvv0UlAPFl8J9O6Shk+R7Bfp3RmgMu3wwyLcwZHihamVxPTi5yb473sZozn5ZdBA9316nLGbHIhll0Gb5MhOLmRhaanURoGliJUxyInWXLujuF1YjWgnc6rdBZcebL/dx/IIg7XxYFGCqJxfgsR/gK0emndneZIGXXebggFbes3r17VTuftCLdmseMx+bN7TrISSdYETYOvmiT7dWIggu/qHTX/JPEEQHh6B+MQiiab/uePaCX/AzyKvLNAwhErQK2wyN/bNeAYrKci3QgXpExd2qBf8rpZ5474FxDoK6jvMdSmbGccBYXF9O5K8tT77u+Cjk= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR13MB5545.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(52116005)(1800799015)(376005)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?R1ZYM1l5Rzh5QVBVYUdQeGI2bkE5T0w2N0dtSkV5WXVWWUhmTU14MXJZSUNz?= =?utf-8?B?WVB2SVNmUDFNQmwxR2hPRk9jdHNteEt0Q2ZPcXhCQVNrdnBPWHNZSnVqdHd6?= =?utf-8?B?K3EyN1VDdzB0RWRwL2lOWldrSDQ0L2twdDlJNnVYNElxL0RoQ1FhYWpVcjVQ?= =?utf-8?B?NXZOMUZYaWJiQ1p5VzB6MXl3d2JWN3MwcW5xMCtyZ1ZWK2hETkhJcW1Selpj?= =?utf-8?B?MEExNG5lTTcwQ2xnQmRsVnZCYkdXT1U1d1VQZ0o0R1piSElCejFOYTl2SGZD?= =?utf-8?B?ckYxVkNWejhBekg3N0c1VEpVbGszQ2wxRjF2RDUxZ25mSHB2K3RibkxEZFdS?= =?utf-8?B?QWxrSWJES01yV1AxUFlyL2N5cFZXTnpmWkRZNjI1dWNPNXRUZEQ0cVFKWVFV?= =?utf-8?B?QmcyOHV4NS9OOFUxcWY1MmJKY05MOXNwdThjazUrdXVIK05UTzZ1SUNBUDRr?= =?utf-8?B?eG5Ud3RqVlJqc0hFcE5mdkR0bnB0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xMSGhvQTBmUW5PSXkrVm1YdzRjc2RUUzdadWNpeW9DTEZYN09U?= =?utf-8?B?NUUzZ3lPeDV3NE5tbk53WHdEVEg2bWRSdzAybHc3OW8wRzBFaTQ1UVFRWito?= =?utf-8?B?dnZKYWNJdXVoZkhjSEh5MlVFenhDWHpIbUU4NHgwNFNKY3kvbEY3aVcwN2Zj?= =?utf-8?B?S3hKMDhOakVFN2lsdTN6NVJJd2pWcStYZkxGeXgwT0R6UFZpODIvKzdhdlJH?= =?utf-8?B?RFgvNDRKdk9OaWVBRHI5SmpoQ3pCdVd1bUxlMEdoSUV6UStjZ2ZzLzRRdit6?= =?utf-8?B?QXJKa0tpK1ljUitNZTVPUlptMWJRZHM4dTVsWkFObW03OGM1Qk1Tcm50enpK?= =?utf-8?B?M0RBcDJEZnpIUG0zV21FckFkaFlQWVZXb0owbFNRQUJEejVSMk5KYmNCU25N?= =?utf-8?B?d2NZWUxOT25WY0ZXRXFwWENTYXN3T3d2WDRiS090d1dqQTBGUUNGNzVWYmli?= =?utf-8?B?SFMzaUdaRzY0bFhTYmNla0Vqbnh4Qndzc2FjZ2tPWXpiWXVCdXY2NnhCVjJs?= =?utf-8?B?R3FPbkc2OEVDZ2Y3VHRKdHhmNDA0dW1UTGNhOXFiRm1zQTJiWjAvVmdXTk0r?= =?utf-8?B?WHZBOGpKWjFuQWNISldtVkhlNURLY2FhVHl0aGVFV3lSNC9mc3lxRHVoWVlX?= =?utf-8?B?aWdnL21EWjJJdHhnK054WDZBbVVTMGRic2ErcWhKRk1udm84SXJFOHVTc2FZ?= =?utf-8?B?R1BFeDhXcmNsdEV2Q3hLYkEyYksyd3pPTXpQNkYzU2lzOXhPNFliYTRROGNl?= =?utf-8?B?OVE9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7a1e5743-cc75-4c76-239c-08dc43caae6b X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Mar 2024 02:01:37.2157 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: MDgCH4RgKVfMX8j66XePE7yNciG22HQxfvhmIxn1TLXMMgB/+GYlJ+1EcWxTLGFb5SgWVHQRRv/LTDud30W5/BOkXHse71jXPiPL38Wy0FA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW5PR13MB5945 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 From: Shihong Wang The SA salt of struct ipsec_sa is a CPU-endian u32 variable, but it’s value is stored in an array of encryption or authentication keys according to big-endian. So it maybe need to convert the endianness order to ensure that the value assigned to the SA salt is CPU-endian. Fixes: 50d75cae2a2c ("examples/ipsec-secgw: initialize SA salt") Fixes: 9413c3901f31 ("examples/ipsec-secgw: support additional algorithms") Fixes: 501e9c226adf ("examples/ipsec-secgw: add AEAD parameters") Cc: stable@dpdk.org Signed-off-by: Shihong Wang Reviewed-by: Chaoyong He --- v2: * Put the 'memcpy()' call in a singal line as the review comment. --- examples/ipsec-secgw/sa.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/examples/ipsec-secgw/sa.c b/examples/ipsec-secgw/sa.c index c4bac17cd7..8aa9aca739 100644 --- a/examples/ipsec-secgw/sa.c +++ b/examples/ipsec-secgw/sa.c @@ -374,6 +374,7 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens, uint32_t ti; /*token index*/ uint32_t *ri /*rule index*/; struct ipsec_sa_cnt *sa_cnt; + rte_be32_t salt; /*big-endian salt*/ uint32_t cipher_algo_p = 0; uint32_t auth_algo_p = 0; uint32_t aead_algo_p = 0; @@ -508,8 +509,8 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens, if (algo->algo == RTE_CRYPTO_CIPHER_AES_CTR) { key_len -= 4; rule->cipher_key_len = key_len; - memcpy(&rule->salt, - &rule->cipher_key[key_len], 4); + memcpy(&salt, &rule->cipher_key[key_len], 4); + rule->salt = rte_be_to_cpu_32(salt); } cipher_algo_p = 1; @@ -573,8 +574,8 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens, key_len -= 4; rule->auth_key_len = key_len; rule->iv_len = algo->iv_len; - memcpy(&rule->salt, - &rule->auth_key[key_len], 4); + memcpy(&salt, &rule->auth_key[key_len], 4); + rule->salt = rte_be_to_cpu_32(salt); } auth_algo_p = 1; @@ -632,8 +633,8 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens, key_len -= 4; rule->cipher_key_len = key_len; - memcpy(&rule->salt, - &rule->cipher_key[key_len], 4); + memcpy(&salt, &rule->cipher_key[key_len], 4); + rule->salt = rte_be_to_cpu_32(salt); aead_algo_p = 1; continue; -- 2.39.1