From patchwork Wed May 22 02:19:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?6LWW6aaZ5q2m?= <15310488637@163.com> X-Patchwork-Id: 1937582 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" (1024-bit key; unprotected) header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=mfijdPVC; 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 4VkZlV3j0rz2020 for ; Wed, 22 May 2024 12:20:20 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 79DD340702; Wed, 22 May 2024 02:20:18 +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 aQSG68gkzRSP; Wed, 22 May 2024 02:20:17 +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 1FBB4406BF Authentication-Results: smtp4.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=mfijdPVC Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id 1FBB4406BF; Wed, 22 May 2024 02:20:17 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id D1733C0077; Wed, 22 May 2024 02:20:16 +0000 (UTC) X-Original-To: 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 03E84C0037 for ; Wed, 22 May 2024 02:20:14 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id CA711406C2 for ; Wed, 22 May 2024 02:20: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 S3QZjHZYNVPy for ; Wed, 22 May 2024 02:20:14 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=117.135.210.4; helo=m16.mail.163.com; envelope-from=15310488637@163.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp4.osuosl.org 2E9E5406BF Authentication-Results: smtp4.osuosl.org; dmarc=pass (p=none dis=none) header.from=163.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 2E9E5406BF Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.4]) by smtp4.osuosl.org (Postfix) with ESMTP id 2E9E5406BF for ; Wed, 22 May 2024 02:20:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version: Content-Type; bh=jMeITdxx7QWxd/MkSU5TBor//cYd3TQ1rWfz0BJzUG4=; b=mfijdPVCenLa1uebLlGWKKw6b7YbNqEoGA0CyS74FWDO2Z3JkKOA1Q4AUrqXoQ u48UF4j92CzL5WKHNxH/yI0CRqVgfjUpmKUFkSx0L3NLf42AemekQJRMgQ/0INaa VvOLuyRrxDDQLEX0Da6DxbvQFYKUn4Tjn8Kdtxz6Vs2mM= Received: from localhost.localdomain (unknown [223.108.79.102]) by gzga-smtp-mta-g2-2 (Coremail) with SMTP id _____wD33sNPVk1m0T66FQ--.64918S2; Wed, 22 May 2024 10:19:59 +0800 (CST) From: laixiangwu <15310488637@163.com> To: dev@openvswitch.org Date: Wed, 22 May 2024 02:19:57 +0000 Message-Id: <20240522021957.2292-1-15310488637@163.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-CM-TRANSID: _____wD33sNPVk1m0T66FQ--.64918S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxZFy8Xr4DZFWfKFW5uryUZFb_yoW5XrWkpa y3Ga47GFs7ta1kKr4UXr40ka1FvF4rtrW2qry3Wa4Yyw4qvayrKFn2yryYkF1fXr48Cw4f Wr4kKFyUWF15JrJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0pRMlksUUUUU= X-Originating-IP: [223.108.79.102] X-CM-SenderInfo: zprvjiaquymlitx6il2tof0z/xtbBzhvl3WV4IyxPOQADsK Cc: laixiangwu <15310488637@163.com> Subject: [ovs-dev] [PATCH]ipf: Fix ovs ipf crash. 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" Description: when 1) The fragment timeout is between 15 seconds and 25 seconds; 2) The ipf_list currently has received more than 32 fragments, and there are other fragments of same big packet that have not been received. When the above two scenario conditions are met, due to exceeding the capacity of the packet batch(here is 32), ipf_dp_packet_batch_add returns false, and ipf_list will not be cleared. However, the 32 fragments packets added to the packet batch will be processed normally. When receiving the subsequent fragments of the ipf_list, because the first 32 fragments have been processed, when processing subsequent fragment packets, relevant information about the processed fragment packets will be read,therefore will occur carsh. One solution is do not forward timeout fragment packets from the above scenarios, that is, do not add them to the packet batch, and handle other scenarios according to the original logic. --- lib/ipf.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/ipf.c b/lib/ipf.c index d45266374..9258173ab 100644 --- a/lib/ipf.c +++ b/lib/ipf.c @@ -1011,7 +1011,7 @@ ipf_purge_list_check(struct ipf *ipf, struct ipf_list *ipf_list, } /* Does the packet batch management and common accounting work associated - * with 'ipf_send_completed_frags()' and 'ipf_send_expired_frags()'. */ + * with 'ipf_send_completed_frags()'. */ static bool ipf_send_frags_in_list(struct ipf *ipf, struct ipf_list *ipf_list, struct dp_packet_batch *pb, @@ -1076,8 +1076,7 @@ ipf_send_completed_frags(struct ipf *ipf, struct dp_packet_batch *pb, * a packet batch to be processed by the calling application, typically * conntrack. Also cleans up the list context when it is empty.*/ static void -ipf_send_expired_frags(struct ipf *ipf, struct dp_packet_batch *pb, - long long now, bool v6) +ipf_clean_expired_frags(struct ipf *ipf, long long now) { enum { /* Very conservative, due to DOS probability. */ @@ -1099,8 +1098,7 @@ ipf_send_expired_frags(struct ipf *ipf, struct dp_packet_batch *pb, break; } - if (ipf_send_frags_in_list(ipf, ipf_list, pb, IPF_FRAG_EXPIRY_LIST, - v6, now)) { + if (ipf_purge_list_check(ipf, ipf_list, now)) { ipf_expiry_list_clean(&ipf->frag_lists, ipf_list); lists_removed++; } else { @@ -1249,7 +1247,7 @@ ipf_postprocess_conntrack(struct ipf *ipf, struct dp_packet_batch *pb, bool v6 = dl_type == htons(ETH_TYPE_IPV6); ipf_post_execute_reass_pkts(ipf, pb, v6); ipf_send_completed_frags(ipf, pb, now, v6); - ipf_send_expired_frags(ipf, pb, now, v6); + ipf_clean_expired_frags(ipf, now); } }