From patchwork Fri May 3 10:21:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Prakash Shukla X-Patchwork-Id: 1930987 X-Patchwork-Delegate: i.maximets@samsung.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=marvell.com header.i=@marvell.com header.a=rsa-sha256 header.s=pfpt0220 header.b=NdGq+huY; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VW7293pSdz1ybC for ; Fri, 3 May 2024 20:53:19 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id C1D3641F5F; Fri, 3 May 2024 10:53:16 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id xY8JC4NOFON9; Fri, 3 May 2024 10:53:15 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.9.56; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 7B45741F4A Authentication-Results: smtp4.osuosl.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=marvell.com header.i=@marvell.com header.a=rsa-sha256 header.s=pfpt0220 header.b=NdGq+huY Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id 7B45741F4A; Fri, 3 May 2024 10:53:15 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id E6F5EC007C; Fri, 3 May 2024 10:53:14 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 0F306C0037 for ; Fri, 3 May 2024 10:53:14 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 0270141F4B for ; Fri, 3 May 2024 10:53:14 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id ntdUudjapbcp for ; Fri, 3 May 2024 10:53:13 +0000 (UTC) X-Greylist: delayed 1856 seconds by postgrey-1.37 at util1.osuosl.org; Fri, 03 May 2024 10:53:12 UTC DMARC-Filter: OpenDMARC Filter v1.4.2 smtp4.osuosl.org DBB4A41F4A Authentication-Results: smtp4.osuosl.org; dmarc=pass (p=none dis=none) header.from=marvell.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org DBB4A41F4A Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=67.231.156.173; helo=mx0b-0016f401.pphosted.com; envelope-from=prvs=2853e1f135=amitprakashs@marvell.com; receiver= Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by smtp4.osuosl.org (Postfix) with ESMTPS id DBB4A41F4A for ; Fri, 3 May 2024 10:53:12 +0000 (UTC) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4432aPe2011124; Fri, 3 May 2024 03:22:15 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= pfpt0220; bh=PRH1xppdDzjtgGBF9z6PMbhnvb2YO9NdaxhGUUDeNMc=; b=NdG q+huYzDmyfAE8YObpTqMwrpE1sEXPkubAq/u1g1kgJ2iBP93wNOIVX64cTgCIp8p e6hOhrM6Yufv1bHvwyEqqcvjBQqPSLiTnBexn2bI0TRhKAonmf88jtQRYAArtydu o+KUVix6fRoQjzgkKJn16U/bTMA5VQwHFNR7ywe4+7Yg9a+jO/krC3+yIYOM3ODR 4+ihsm+vEjfuoCGZWW338YYVM3a1Xt8WodC3aqYS+Ck4xDeUigS3zcOCGBUE8Tua IdWVZ9YUcNf0ar3EFgbB8LZjcmaUMpznW3McHLbo8Vxb2SVkl+0bx292kbMGx5HH OpVl/SwTUDcKq/XBfxw== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3xvem03e3r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 03 May 2024 03:22:15 -0700 (PDT) Received: from DC6WP-EXCH02.marvell.com (10.76.176.209) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 3 May 2024 03:22:13 -0700 Received: from maili.marvell.com (10.69.176.80) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Fri, 3 May 2024 03:22:13 -0700 Received: from cavium-OptiPlex-5090-BM14.. (unknown [10.28.36.157]) by maili.marvell.com (Postfix) with ESMTP id 83A773F709E; Fri, 3 May 2024 03:22:11 -0700 (PDT) From: Amit Prakash Shukla To: Date: Fri, 3 May 2024 15:51:56 +0530 Message-ID: <20240503102156.7699-1-amitprakashs@marvell.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240503092225.7516-1-amitprakashs@marvell.com> References: <20240503092225.7516-1-amitprakashs@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: YoMQanACvOjMzEm8q9ZMJxPqhVdbZrt1 X-Proofpoint-ORIG-GUID: YoMQanACvOjMzEm8q9ZMJxPqhVdbZrt1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-03_06,2024-05-03_01,2023-05-22_02 Cc: hkalra@marvell.com, jerinj@marvell.com Subject: [ovs-dev] [PATCH v2] lib: Fix segfault for tunnel packet. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Add NULL check to UDP, TCP and SCTP checksum functions. This patch also adds changes to populate inner_l3_ofs and inner_l4_ofs for the tunneled packets received from ports other than vport which are required by the protocol specific checksum function to parse the headers. Thread 22 "pmd-c07/id:15" received signal SIGSEGV, Segmentation fault. [Switching to Thread 0xffff6e70dc00 (LWP 1061)] 0x13f61750 in packet_udp_complete_csum at lib/packets.c:2061 2061 if (!udp->udp_csum) { 0x13f61750 in packet_udp_complete_csum at lib/packets.c:2061 0x13e5126c in dp_packet_ol_send_prepare at lib/dp-packet.c:638 0x13eb7d4c in netdev_push_header at lib/netdev.c:1035 0x13e69830 in push_tnl_action at lib/dpif-netdev.c:9067 0x13e69dac in dp_execute_cb at lib/dpif-netdev.c:9226 0x13ec72c4 in odp_execute_actions at lib/odp-execute.c:1008 0x13e6a7bc in dp_netdev_execute_actions at lib/dpif-netdev.c:9524 0x13e673d0 in packet_batch_per_flow_execute at lib/dpif-netdev.c:8271 0x13e69188 in dp_netdev_input__ at lib/dpif-netdev.c:8899 0x13e691f8 in dp_netdev_input at lib/dpif-netdev.c:8908 0x13e600e4 in dp_netdev_process_rxq_port at lib/dpif-netdev.c:5660 0x13e649a8 in pmd_thread_main at lib/dpif-netdev.c:7295 0x13f44b2c in ovsthread_wrapper at lib/ovs-thread.c:423 CC: Mike Pattrick Fixes: 85bcbbed839a ("userspace: Enable tunnel tests with TSO.") Signed-off-by: Amit Prakash Shukla --- v2: - Added Fixes tag and updated commit message. lib/netdev.c | 7 +++++++ lib/packets.c | 10 +++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/netdev.c b/lib/netdev.c index f2d921ed6..19bd87ef7 100644 --- a/lib/netdev.c +++ b/lib/netdev.c @@ -1032,6 +1032,13 @@ netdev_push_header(const struct netdev *netdev, netdev_get_name(netdev)); continue; } + if (packet->l3_ofs != UINT16_MAX) { + packet->inner_l3_ofs = packet->l3_ofs + data->header_len; + } + if (packet->l4_ofs != UINT16_MAX) { + packet->inner_l4_ofs = packet->l4_ofs + data->header_len; + } + dp_packet_ol_send_prepare(packet, 0); } netdev->netdev_class->push_header(netdev, packet, data); diff --git a/lib/packets.c b/lib/packets.c index 5803d26f4..988c0e41f 100644 --- a/lib/packets.c +++ b/lib/packets.c @@ -2011,6 +2011,10 @@ packet_tcp_complete_csum(struct dp_packet *p, bool inner) tcp_sz = dp_packet_l4_size(p); } + if (!tcp || !ip_hdr) { + return; + } + if (!inner && dp_packet_hwol_is_outer_ipv6(p)) { is_v4 = false; } else if (!inner && dp_packet_hwol_is_outer_ipv4(p)) { @@ -2058,7 +2062,7 @@ packet_udp_complete_csum(struct dp_packet *p, bool inner) } /* Skip csum calculation if the udp_csum is zero. */ - if (!udp->udp_csum) { + if (!udp || !ip_hdr || !udp->udp_csum) { return; } @@ -2109,6 +2113,10 @@ packet_sctp_complete_csum(struct dp_packet *p, bool inner) tp_len = dp_packet_l4_size(p); } + if (!sh) { + return; + } + put_16aligned_be32(&sh->sctp_csum, 0); csum = crc32c((void *) sh, tp_len); put_16aligned_be32(&sh->sctp_csum, csum);