From patchwork Fri Apr 23 14:49:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Abeni X-Patchwork-Id: 1469642 X-Patchwork-Delegate: mathew.j.martineau@linux.intel.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.dev (client-ip=147.75.69.165; helo=sjc.edge.kernel.org; envelope-from=mptcp+bounces-404-incoming=patchwork.ozlabs.org@lists.linux.dev; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=D6u/nwtB; dkim-atps=neutral Received: from sjc.edge.kernel.org (sjc.edge.kernel.org [147.75.69.165]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FRchn4yTWz9sW8 for ; Sat, 24 Apr 2021 00:52:41 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sjc.edge.kernel.org (Postfix) with ESMTPS id 2B4093E6194 for ; Fri, 23 Apr 2021 14:50:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6C4952FA4; Fri, 23 Apr 2021 14:50:24 +0000 (UTC) X-Original-To: mptcp@lists.linux.dev Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 396A22FA3 for ; Fri, 23 Apr 2021 14:50:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619189422; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VnQL9rB1RW7nq+Cr8glUJnL5NOD7hyfAN3H2O5iar7k=; b=D6u/nwtBB/NvYLf28mJS+I9klfuZo35uyAnXGoCNmGMHfdvn0N98up9U4Pi8Ax6wuqZOsN 4+C++NUtcXMOlDUSDsLCGfkxvovXvswvWkYotR6mlacI/MI/IznMafQIlNyYobUefTRITG GV62dBgX202ScUifjPCf/hfyk/JQaFU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-568-XdW_MRBPNsyWiQd-Jg7QBg-1; Fri, 23 Apr 2021 10:50:18 -0400 X-MC-Unique: XdW_MRBPNsyWiQd-Jg7QBg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0E8F1343A2; Fri, 23 Apr 2021 14:50:18 +0000 (UTC) Received: from gerbillo.redhat.com (ovpn-115-60.ams2.redhat.com [10.36.115.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3BB9B19D9B; Fri, 23 Apr 2021 14:50:17 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH v4 mptcp-next 03/22] Squash-to: "mptcp: generate the data checksum" Date: Fri, 23 Apr 2021 16:49:42 +0200 Message-Id: <5522102b338b435d651205ba4c69c1c02abe6317.1619189145.git.pabeni@redhat.com> In-Reply-To: References: X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pabeni@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com We must generate the csum for zero window probe, too. Additionally we must update the checksum when setting the data_fin on a data packet. Note that in a later patch we will skip unneeded csum related operation. Changes not included here to keep the delta small. Signed-off-by: Paolo Abeni --- net/mptcp/options.c | 3 +++ net/mptcp/protocol.c | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index 99fc21406168..ebce0326e3b6 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -519,6 +519,9 @@ static void mptcp_write_data_fin(struct mptcp_subflow_context *subflow, */ ext->data_fin = 1; ext->data_len++; + + /* the pseudo header has changed, update the csum accordingly */ + csum_replace2(&ext->csum, ext->data_len - 1, ext->data_len); } } diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index abcb22848a5c..d012b9998fdd 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -1271,6 +1271,9 @@ static bool mptcp_alloc_tx_skb(struct sock *sk, struct sock *ssk) return __mptcp_alloc_tx_skb(sk, ssk, sk->sk_allocation); } +/* note: this always recompute the csum on the whole skb, even + * if we just appended a single frag. More status info needed + */ static __sum16 mptcp_generate_data_checksum(struct sk_buff *skb) { struct csum_pseudo_header header; @@ -1384,8 +1387,10 @@ static int mptcp_sendmsg_frag(struct sock *sk, struct sock *ssk, if (zero_window_probe) { mptcp_subflow_ctx(ssk)->rel_write_seq += ret; mpext->frozen = 1; - ret = 0; + if (READ_ONCE(msk->csum_enabled)) + mpext->csum = mptcp_generate_data_checksum(tail); tcp_push_pending_frames(ssk); + return 0; } out: if (READ_ONCE(msk->csum_enabled))