From patchwork Fri May 3 09:22:25 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: 1930980 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=TMZ1VFwl; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) (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 4VW58y4hsrz1ydX for ; Fri, 3 May 2024 19:29:06 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 1FDB341CB0; Fri, 3 May 2024 09:29:04 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id gNb_ANX8eKYW; Fri, 3 May 2024 09:29:03 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=2605:bc80:3010:104::8cd3:938; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 0AFBE400C4 Authentication-Results: smtp2.osuosl.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=TMZ1VFwl Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp2.osuosl.org (Postfix) with ESMTPS id 0AFBE400C4; Fri, 3 May 2024 09:29:03 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id DD871C0077; Fri, 3 May 2024 09:29:02 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id A6853C0037 for ; Fri, 3 May 2024 09:29:01 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 8163060855 for ; Fri, 3 May 2024 09:29:01 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id NEphClTuQfcM for ; Fri, 3 May 2024 09:29:01 +0000 (UTC) X-Greylist: delayed 386 seconds by postgrey-1.37 at util1.osuosl.org; Fri, 03 May 2024 09:29:00 UTC DMARC-Filter: OpenDMARC Filter v1.4.2 smtp3.osuosl.org CA1BB606B9 Authentication-Results: smtp3.osuosl.org; dmarc=pass (p=none dis=none) header.from=marvell.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org CA1BB606B9 Authentication-Results: smtp3.osuosl.org; dkim=pass (2048-bit key, unprotected) header.d=marvell.com header.i=@marvell.com header.a=rsa-sha256 header.s=pfpt0220 header.b=TMZ1VFwl Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=67.231.148.174; helo=mx0b-0016f401.pphosted.com; envelope-from=prvs=2853e1f135=amitprakashs@marvell.com; receiver= Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by smtp3.osuosl.org (Postfix) with ESMTPS id CA1BB606B9 for ; Fri, 3 May 2024 09:29:00 +0000 (UTC) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4432aijM001743 for ; Fri, 3 May 2024 02:22:34 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding:content-type; s=pfpt0220; bh=2fA85NIr qwTCDCCd6SEQ5CyESF5fuv951CKniZ1JPJ0=; b=TMZ1VFwlyCT/XDb7Am0Bi9lI 74DjqykS8apLw9hraKDlR6O+yI1qWL/ka9IYSHbTcCxU6iGWiS54dXBAlHPW9S2A NONgmaNRXFQgbt/K0cwISf6CMmrA0i5vZnJyshXYFt6EUCqNQX2497EyIp1TqkaT QpvbaYNhCax16EUEPQ1sVcFjAn/W/PvYi/s48y8Rhc2TCeH95k7rfL7qpZvdnGJ2 bKMByG1LFwdheMqh4ChkAgo1HqPxWqLk8TKiBvApY2ibCdrbi3VlulaEjZ4V9PrW glbxbSr2xGR31j0/33WCKXS4rCGVZptnbE/wApJKqLXVEZ5ZZnNlfALjXKWRSA== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3xvgsejh6q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 03 May 2024 02:22:33 -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 02:22:32 -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 02:22:32 -0700 Received: from cavium-OptiPlex-5090-BM14.. (unknown [10.28.36.157]) by maili.marvell.com (Postfix) with ESMTP id F398C3F7040; Fri, 3 May 2024 02:22:30 -0700 (PDT) From: Amit Prakash Shukla To: Date: Fri, 3 May 2024 14:52:25 +0530 Message-ID: <20240503092225.7516-1-amitprakashs@marvell.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Proofpoint-GUID: LvWQMLwbFdfwBdX4y1jGmaWD4fUu9NCe X-Proofpoint-ORIG-GUID: LvWQMLwbFdfwBdX4y1jGmaWD4fUu9NCe 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_05,2024-05-03_01,2023-05-22_02 Cc: hkalra@marvell.com, jerinj@marvell.com Subject: [ovs-dev] [PATCH] 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. Signed-off-by: Amit Prakash Shukla --- 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);