From nobody Mon Feb 9 08:29:45 2026 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:a17:907:7811:b0:6d8:2910:9a8 with SMTP id la17csp2185411ejc; Thu, 24 Mar 2022 06:58:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQmoXKuj/dxysggoj3sJ5vOId6nxs59gchB0Zd1G5GsBQWrUbsq/pWNoelS5gAWwwSDFaR X-Received: by 2002:a05:6a00:8d4:b0:4f6:6da0:f380 with SMTP id s20-20020a056a0008d400b004f66da0f380mr5502405pfu.34.1648130302381; Thu, 24 Mar 2022 06:58:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648130302; cv=none; d=google.com; s=arc-20160816; b=a7bgk5yO+PrMEXBKB9310Ul1oONlXMUJAVDjv02dBwncW4WGxHsuz7yxPuH3JFl4Zj wjkRF5AxQBaOEqvpwEuzNdd6FfLpp9KsQFz3TmbPcTqKpWNWZNy4KGCJDFv+bjth08qq puCf2sorswT3oG34dZ59fQatRYzHqg6+uHTY/OUvdH5fHWP2Svj7Pq2DToTIYJF19NFB qdm2374d4n0GOPl6xnkcHFka9SoeHADOZoPMDQcapeaOUQS2XXpXM1G4z2MbVmF+VDxL TCjOnnppFqipgYWGLt/u1BAxh9tHMpi5MBBy4R5+noqxe3kWESjuoJMbah8VKHGJkSE2 hsqg== 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:cc:to:from; bh=qZsQ3ZORcg19cR5FBwQTY2fK7TjM8X5N5KGGk6cfnBA=; b=r3Uf71WR7MoCUx+y0e3njd7JUpf7WBHOgfPNL07xMKeg/yxKhZ+dUbgKZdg6PzFvNe asNWBnQt8hKP5tt5PaVQPxOconPqKiaQXMxlMnNZKzRkGD4t3Ero9U2QRKmxopFfNP/0 ew8BIwUHlha1bDHNJzVai1UJ5KLAWGwjKjdxNV9O+iikMADL3vwT0stSOL5rhvLpI1FI 46hhiaf+KZZ0VAMRc6O1slUq6W0W2Vt34ikN6Fkglt6TjNasD2BazX9to4RurOm0TvIn tPwS2rhAGxuXQhoUR00VtAasxLREhs5kzlEyrNqoQ2PGFmXKbn9KjygAQCbLjElUVNtL wHTA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of mptcp+bounces-4400-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:1000:8100::1 as permitted sender) smtp.mailfrom="mptcp+bounces-4400-wpasupplicant.patchew=gmail.com@lists.linux.dev" Return-Path: Received: from sjc.edge.kernel.org (sjc.edge.kernel.org. [2604:1380:1000:8100::1]) by mx.google.com with ESMTPS id c17-20020a056a000ad100b004fa3a8dfff9si17657695pfl.176.2022.03.24.06.58.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Mar 2022 06:58:22 -0700 (PDT) Received-SPF: pass (google.com: domain of mptcp+bounces-4400-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; spf=pass (google.com: domain of mptcp+bounces-4400-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:1000:8100::1 as permitted sender) smtp.mailfrom="mptcp+bounces-4400-wpasupplicant.patchew=gmail.com@lists.linux.dev" 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 0DE683E0FA8 for ; Thu, 24 Mar 2022 13:58:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 448461FC0; Thu, 24 Mar 2022 13:58:21 +0000 (UTC) X-Original-To: mptcp@lists.linux.dev Received: from Chamillionaire.breakpoint.cc (Chamillionaire.breakpoint.cc [193.142.43.52]) (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 D548D1FC7 for ; Thu, 24 Mar 2022 13:58:19 +0000 (UTC) Received: from fw by Chamillionaire.breakpoint.cc with local (Exim 4.92) (envelope-from ) id 1nXNyk-000702-1d; Thu, 24 Mar 2022 14:58:18 +0100 From: Florian Westphal To: Cc: Florian Westphal Subject: [PATCH mptcp-next 3/4] mptcp: listen diag dump support Date: Thu, 24 Mar 2022 14:57:52 +0100 Message-Id: <20220324135753.25182-4-fw@strlen.de> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220324135753.25182-1-fw@strlen.de> References: <20220324135753.25182-1-fw@strlen.de> Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" makes 'ss -Ml' show mptcp listen sockets. Signed-off-by: Florian Westphal --- net/mptcp/mptcp_diag.c | 67 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/net/mptcp/mptcp_diag.c b/net/mptcp/mptcp_diag.c index c4992eeb67d8..6a6dfc7eac33 100644 --- a/net/mptcp/mptcp_diag.c +++ b/net/mptcp/mptcp_diag.c @@ -69,6 +69,8 @@ static int mptcp_diag_dump_one(struct netlink_callback *c= b, struct mptcp_diag_ctx { long s_slot; long s_num; + unsigned int l_slot; + unsigned int l_num; }; =20 static void mptcp_diag_dump(struct sk_buff *skb, struct netlink_callback *= cb, @@ -114,6 +116,71 @@ static void mptcp_diag_dump(struct sk_buff *skb, struc= t netlink_callback *cb, } cond_resched(); } + + if (r->idiag_states & TCPF_LISTEN) { + int i; + + for (i =3D diag_ctx->l_slot; i < INET_LHTABLE_SIZE; i++) { + struct inet_listen_hashbucket *ilb; + struct hlist_nulls_node *node; + struct sock *sk; + int num =3D 0; + + ilb =3D &tcp_hashinfo.listening_hash[i]; + + rcu_read_lock(); + spin_lock(&ilb->lock); + sk_nulls_for_each(sk, node, &ilb->nulls_head) { + const struct mptcp_subflow_context *ctx =3D mptcp_subflow_ctx(sk); + struct inet_sock *inet =3D inet_sk(sk); + int ret; + + if (num < diag_ctx->l_num) + goto next_listen; + + if (!ctx || strcmp(inet_csk(sk)->icsk_ulp_ops->name, "mptcp")) + goto next_listen; + + sk =3D ctx->conn; + if (!sk || !net_eq(sock_net(sk), net)) + goto next_listen; + + if (r->sdiag_family !=3D AF_UNSPEC && + sk->sk_family !=3D r->sdiag_family) + goto next_listen; + + if (r->id.idiag_sport !=3D inet->inet_sport && + r->id.idiag_sport) + goto next_listen; + + if (!refcount_inc_not_zero(&sk->sk_refcnt)) + goto next_listen; + + ret =3D sk_diag_dump(sk, skb, cb, r, bc, net_admin); + sock_put(sk); + + if (ret < 0) { + spin_unlock(&ilb->lock); + rcu_read_unlock(); + diag_ctx->l_slot =3D i; + diag_ctx->l_num =3D num; + return; + } + diag_ctx->l_num =3D num + 1; + num =3D 0; +next_listen: + ++num; + } + spin_unlock(&ilb->lock); + rcu_read_unlock(); + + cond_resched(); + diag_ctx->l_num =3D 0; + } + + diag_ctx->l_num =3D 0; + diag_ctx->l_slot =3D i; + } } =20 static void mptcp_diag_get_info(struct sock *sk, struct inet_diag_msg *r, --=20 2.34.1