From nobody Sun Feb 8 23:54:30 2026 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:a02:cbb9:0:0:0:0:0 with SMTP id v25csp613298jap; Thu, 9 Dec 2021 09:30:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJwbT/i+CY4+WD3YYTFAVQQShtCox+g4h+ozniF0g0KJXH3u/9xVbO3jkrszlor2iiZUksz5 X-Received: by 2002:a05:620a:1991:: with SMTP id bm17mr14889709qkb.459.1639071057815; Thu, 09 Dec 2021 09:30:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639071057; cv=none; d=google.com; s=arc-20160816; b=oz/WzsfewltbjH9/WOiUcECHSvch+lNKa5qrBC/HLuba4aILfHuDuCRtZJTiQf//zA 9Yvm9dFlUwW9qwt0rXqTv09Lu9Emu3CAlgIMRw2xdsSog+sNwz04+dVrs/BND7elfulQ N2x/hyDIsYPCz6SL6oNRf1l7jynSfw/a8fOu3g+jRfl6iOFBfaNkDdUTIQv/NbTsDuWB x3Fx48AQIYK0V7VbsNSR/JV8gM0dtkAbK+psdy9SCcVbbNSZ3yorz5flfBe8i4NCoyXU j12x9WtwIHuhwYN5k6ZdQi4yfo364CabzWI5qJ/CLmRBlwyxh+VTvYLZuE4pnA0PZWLI yuUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=R1mY7UFdQVRSDeafvZWZ10zEPnX1i9Jjr2qNMeJH7g8=; b=atBmqAlze/PQ/iy8Ae3M4Z6QHSxPx/OVb5qDHi7E43+NPeE8m7zGXz9Rrc3YP0bZkF 7Wt5sr/2IYN7PqTNF0EPB204gfgsJ8Ib9IMYxKVBJ9pucbeUMIP3gudTCzyyZxulQU/9 F8yvNkHJXzoXyOHAK3Hp/+NZwGEddqF2Lz543NXeZOyf1rmzEtlMr2DWmgF4DaIKPLf3 Y1xRbAD5lmOboYk6paxrZiYex4fssLirostRPParAndWPyM2iHn4C45NyOz6nfVGdMFk vfFsW2CbeW03/4czKQJthI+N8vbgZKlUU2QdoQG14tt0YUvu1zWR6O9qs4VCaWT/Yx+k jVVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Qp5r+Rc1; spf=pass (google.com: domain of mptcp+bounces-2702-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:1000:8100::1 as permitted sender) smtp.mailfrom="mptcp+bounces-2702-wpasupplicant.patchew=gmail.com@lists.linux.dev"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sjc.edge.kernel.org (sjc.edge.kernel.org. [2604:1380:1000:8100::1]) by mx.google.com with ESMTPS id 14si584850qvf.171.2021.12.09.09.30.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Dec 2021 09:30:57 -0800 (PST) Received-SPF: pass (google.com: domain of mptcp+bounces-2702-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:1000:8100::1 as permitted sender) client-ip=2604:1380:1000:8100::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Qp5r+Rc1; spf=pass (google.com: domain of mptcp+bounces-2702-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:1000:8100::1 as permitted sender) smtp.mailfrom="mptcp+bounces-2702-wpasupplicant.patchew=gmail.com@lists.linux.dev"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 394293E0F1C for ; Thu, 9 Dec 2021 17:30:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8AAD32C80; Thu, 9 Dec 2021 17:30:54 +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.129.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 D29122CB2 for ; Thu, 9 Dec 2021 17:30:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639071052; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=R1mY7UFdQVRSDeafvZWZ10zEPnX1i9Jjr2qNMeJH7g8=; b=Qp5r+Rc1godnRkVgehz/J8pKxv1rKqZG+clJEx3GPsoY6FKmgNjQWjg0IK/M/nQLsVmcQW uEgdGe8ELMx4nzu2Exldr1aag3TmSrxc0xHbgj2JEMfG889UIF/KSbx0KzBlgbnzTvxu6S EL0C3j24hr5Yx25j15UFAkBnENKrpAo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-493-gcwnJYkSOqefW-P4erij-w-1; Thu, 09 Dec 2021 12:30:50 -0500 X-MC-Unique: gcwnJYkSOqefW-P4erij-w-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E3B9481EE61 for ; Thu, 9 Dec 2021 17:30:49 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.39.194.216]) by smtp.corp.redhat.com (Postfix) with ESMTP id 53B355ED27 for ; Thu, 9 Dec 2021 17:30:49 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.linux.dev Subject: [PATCH mptcp-next v5 2/5] mptcp: clean-up MPJ option writing. Date: Thu, 9 Dec 2021 18:30:39 +0100 Message-Id: In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Check for all MPJ variant at once, this reduces the number of conditionals traversed on average and will simplify the next patch. No functional change intended. Signed-off-by: Paolo Abeni --- net/mptcp/options.c | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index 8a1020e4285c..7a6a39b71633 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -1381,27 +1381,29 @@ void mptcp_write_options(__be32 *ptr, const struct = tcp_sock *tp, =20 /* MPC is additionally mutually exclusive with MP_PRIO */ goto mp_capable_done; - } else if (OPTION_MPTCP_MPJ_SYN & opts->suboptions) { - *ptr++ =3D mptcp_option(MPTCPOPT_MP_JOIN, - TCPOLEN_MPTCP_MPJ_SYN, - opts->backup, opts->join_id); - put_unaligned_be32(opts->token, ptr); - ptr +=3D 1; - put_unaligned_be32(opts->nonce, ptr); - ptr +=3D 1; - } else if (OPTION_MPTCP_MPJ_SYNACK & opts->suboptions) { - *ptr++ =3D mptcp_option(MPTCPOPT_MP_JOIN, - TCPOLEN_MPTCP_MPJ_SYNACK, - opts->backup, opts->join_id); - put_unaligned_be64(opts->thmac, ptr); - ptr +=3D 2; - put_unaligned_be32(opts->nonce, ptr); - ptr +=3D 1; - } else if (OPTION_MPTCP_MPJ_ACK & opts->suboptions) { - *ptr++ =3D mptcp_option(MPTCPOPT_MP_JOIN, - TCPOLEN_MPTCP_MPJ_ACK, 0, 0); - memcpy(ptr, opts->hmac, MPTCPOPT_HMAC_LEN); - ptr +=3D 5; + } else if (OPTIONS_MPTCP_MPJ & opts->suboptions) { + if (OPTION_MPTCP_MPJ_SYN & opts->suboptions) { + *ptr++ =3D mptcp_option(MPTCPOPT_MP_JOIN, + TCPOLEN_MPTCP_MPJ_SYN, + opts->backup, opts->join_id); + put_unaligned_be32(opts->token, ptr); + ptr +=3D 1; + put_unaligned_be32(opts->nonce, ptr); + ptr +=3D 1; + } else if (OPTION_MPTCP_MPJ_SYNACK & opts->suboptions) { + *ptr++ =3D mptcp_option(MPTCPOPT_MP_JOIN, + TCPOLEN_MPTCP_MPJ_SYNACK, + opts->backup, opts->join_id); + put_unaligned_be64(opts->thmac, ptr); + ptr +=3D 2; + put_unaligned_be32(opts->nonce, ptr); + ptr +=3D 1; + } else { + *ptr++ =3D mptcp_option(MPTCPOPT_MP_JOIN, + TCPOLEN_MPTCP_MPJ_ACK, 0, 0); + memcpy(ptr, opts->hmac, MPTCPOPT_HMAC_LEN); + ptr +=3D 5; + } } else if (OPTION_MPTCP_ADD_ADDR & opts->suboptions) { u8 len =3D TCPOLEN_MPTCP_ADD_ADDR_BASE; u8 echo =3D MPTCP_ADDR_ECHO; --=20 2.33.1