From nobody Mon Feb 9 11:07:52 2026 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:ab0:590e:0:0:0:0:0 with SMTP id n14csp2732860uad; Mon, 4 Jul 2022 02:15:02 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vbF77CVg+FF33A1YWxjdSfIWcI1QK91svLJLdf8meF3YEJW1BxRREi381ekNxWui7WqheD X-Received: by 2002:a17:90b:4f44:b0:1ed:64a1:9769 with SMTP id pj4-20020a17090b4f4400b001ed64a19769mr37147403pjb.136.1656926102298; Mon, 04 Jul 2022 02:15:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656926102; cv=none; d=google.com; s=arc-20160816; b=k1jt/nmCNHvmTuRFx4C7y9fxeOTyagppUsYQGkoG4/jr92onbSXoGALAG7lfGT1rW1 1eyrNy/KPvDdban7bsq7hzC0bDx8SGFxM8rM9ijzRGRDUTNaiZ0U+gHc92QVhHrNzpJq yTC7Ag74075Lb05NDPwlLTgUhotqiQFQv8tXOmFb5VL5Ol6Meg0xeiZxoTMl0/uheC6L plUuq46ovKnk7qdgQYpHgI2fKXLwsPixoEXdDMaNa9eMp/9WXPuxK3FcOk0wOfsSDgQi Uuui8pQ6JlJ8rMUCeuCu/aUxbwCVRIXkG5qOtuXsDbeksomowv6eukOlpBOT9ThV/4Zg IJ0Q== 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=00hrlLwCfHmsGG0fifYpdJ6TA4nLO6kOJy830ifafLw=; b=BYbG6OTKx5dSPwQ1nHTsOIYuGW0nMSKkqZAhJF6iV4mG9HSLhlTA/T6bkd++w1LT/k MNgilSUIyutIobGGg/t+3ddpR4Jj4XcVFawdBIPKqIF+oVOj8Os3N7vTlrGv4SY5ILoq hkIG2je0kl/uMQMHGRXdOjNgJBCb/xYV9+pA2ESbQLMjNeNfG94jPkwq4Kmp/wrH8xVr aYpp7kD6J9iL5IvWFv5BJ/u4nNq2c59jnEMReIx7cyuqNi267zErEEz2nimmusxiwQ7T +4sUeb6AFigWOZuI5DPl6I88w+pZHs0JCbwIppS82GoyW8Xrms2jDvJvX6an8H00NJK4 VJqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Pm+lOHor; spf=pass (google.com: domain of mptcp+bounces-5948-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.88.99 as permitted sender) smtp.mailfrom="mptcp+bounces-5948-wpasupplicant.patchew=gmail.com@lists.linux.dev"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id u1-20020a654c01000000b0040986ef2410si23667270pgq.493.2022.07.04.02.15.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Jul 2022 02:15:02 -0700 (PDT) Received-SPF: pass (google.com: domain of mptcp+bounces-5948-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Pm+lOHor; spf=pass (google.com: domain of mptcp+bounces-5948-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 139.178.88.99 as permitted sender) smtp.mailfrom="mptcp+bounces-5948-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id D76E1280C4B for ; Mon, 4 Jul 2022 09:15:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5AF3B23B6; Mon, 4 Jul 2022 09:15:01 +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 BE25623C2 for ; Mon, 4 Jul 2022 09:14:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656926098; 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=00hrlLwCfHmsGG0fifYpdJ6TA4nLO6kOJy830ifafLw=; b=Pm+lOHorQJxSL+Oa5i1IOaJAWdPTkjy5sV9hQTSBUUDE2L1fBerffGi5QvC1b2C3v+J8Xi i/ioO326KsweV4rpTyz/QwCJqymMWKPd0DfTVMs2vdGrvR7MenSLToYctaGE4L7YvWYGsS b3wP6MLMXzGIV1yaKa6gzgu/xplPWsM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-467-7xfhgXZTPiWbdraQANedwg-1; Mon, 04 Jul 2022 05:14:51 -0400 X-MC-Unique: 7xfhgXZTPiWbdraQANedwg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8592A802D1C for ; Mon, 4 Jul 2022 09:14:51 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.39.193.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 171332166B26 for ; Mon, 4 Jul 2022 09:14:50 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.linux.dev Subject: [PATCH v2 mptcp-next 2/5] mptcp: address lookup improvements Date: Mon, 4 Jul 2022 11:14:33 +0200 Message-Id: <9aca8356861affca14c6e4732943f9b76c3923a1.1656925387.git.pabeni@redhat.com> 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.78 on 10.11.54.6 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"; x-default="true" When looking-up a socket address in the endpoint list, we must prefer port-based matches over address only match. Ensure that port-based endpoints are listed first, using head insertion for them. Additionally be sure that only port-based endpoints carry a non zero port number. Signed-off-by: Paolo Abeni --- net/mptcp/pm_netlink.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index e85fbced2c07..c0a4c947347b 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -413,7 +413,7 @@ static bool lookup_address_in_vec(const struct mptcp_ad= dr_info *addrs, unsigned int i; =20 for (i =3D 0; i < nr; i++) { - if (mptcp_addresses_equal(&addrs[i], addr, addr->port)) + if (addrs[i].id =3D=3D addr->id) return true; } =20 @@ -449,7 +449,8 @@ static unsigned int fill_remote_addresses_vec(struct mp= tcp_sock *msk, bool fullm mptcp_for_each_subflow(msk, subflow) { ssk =3D mptcp_subflow_tcp_sock(subflow); remote_address((struct sock_common *)ssk, &addrs[i]); - if (deny_id0 && mptcp_addresses_equal(&addrs[i], &remote, false)) + addrs[i].id =3D subflow->remote_id; + if (deny_id0 && !addrs[i].id) continue; =20 if (!lookup_address_in_vec(addrs, i, &addrs[i]) && @@ -919,10 +920,11 @@ static int mptcp_pm_nl_append_new_local_addr(struct p= m_nl_pernet *pernet, /* do not insert duplicate address, differentiate on port only * singled addresses */ + if (!address_use_port(entry)) + entry->addr.port =3D 0; list_for_each_entry(cur, &pernet->local_addr_list, list) { if (mptcp_addresses_equal(&cur->addr, &entry->addr, - address_use_port(entry) && - address_use_port(cur))) { + cur->addr.port || entry->addr.port)) { /* allow replacing the exiting endpoint only if such * endpoint is an implicit one and the user-space * did not provide an endpoint id @@ -968,7 +970,10 @@ static int mptcp_pm_nl_append_new_local_addr(struct pm= _nl_pernet *pernet, } =20 pernet->addrs++; - list_add_tail_rcu(&entry->list, &pernet->local_addr_list); + if (!entry->addr.port) + list_add_tail_rcu(&entry->list, &pernet->local_addr_list); + else + list_add_rcu(&entry->list, &pernet->local_addr_list); ret =3D entry->addr.id; =20 out: --=20 2.35.3