From: Matthieu Baerts <matttbe@kernel.org>
To: Gang Yan <yangang@kylinos.cn>, mptcp@lists.linux.dev
Subject: Re: [mptcp-next v4 1/2] selftests: mptcp: Add a tool to get specific msk_info
Date: Mon, 24 Feb 2025 13:13:46 +0100 [thread overview]
Message-ID: <3aab4781-d63a-4ee2-a099-db023f6886b7@kernel.org> (raw)
In-Reply-To: <4b060bd673858f11981e91956a34d1a42478b869.1740385876.git.yangang@kylinos.cn>
Hi Gang Yan,
On 24/02/2025 10:02, Gang Yan wrote:
> This patch enables the retrieval of the mptcp_info structure corresponding
> to a specified MPTCP socket (msk). When multiple MPTCP connections are
> present, specific information can be obtained for a given connection
> through the 'mptcp_diag_dump_one' by using the 'token' associated with
> the msk.
(...)
> diff --git a/tools/testing/selftests/net/mptcp/mptcp_diag.c b/tools/testing/selftests/net/mptcp/mptcp_diag.c
> new file mode 100644
> index 000000000000..6dc53ab867c5
> --- /dev/null
> +++ b/tools/testing/selftests/net/mptcp/mptcp_diag.c
> @@ -0,0 +1,271 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/* Copyright (c) 2025, Kylin Software */
> +
> +#include <linux/sock_diag.h>
> +#include <linux/rtnetlink.h>
> +#include <linux/inet_diag.h>
> +#include <linux/netlink.h>
> +#include <sys/socket.h>
> +#include <netinet/in.h>
> +#include <linux/tcp.h>
> +
> +#include <unistd.h>
> +#include <stdlib.h>
> +#include <string.h>
> +#include <errno.h>
> +#include <stdio.h>
> +
> +#ifndef IPPROTO_MPTCP
> +#define IPPROTO_MPTCP 262
> +#endif
> +
> +struct mptcp_info {
> + __u8 mptcpi_subflows;
> + __u8 mptcpi_add_addr_signal;
> + __u8 mptcpi_add_addr_accepted;
> + __u8 mptcpi_subflows_max;
> + __u8 mptcpi_add_addr_signal_max;
> + __u8 mptcpi_add_addr_accepted_max;
> + __u32 mptcpi_flags;
> + __u32 mptcpi_token;
> + __u64 mptcpi_write_seq;
> + __u64 mptcpi_snd_una;
> + __u64 mptcpi_rcv_nxt;
> + __u8 mptcpi_local_addr_used;
> + __u8 mptcpi_local_addr_max;
> + __u8 mptcpi_csum_enabled;
> + __u32 mptcpi_retransmits;
> + __u64 mptcpi_bytes_retrans;
> + __u64 mptcpi_bytes_sent;
> + __u64 mptcpi_bytes_received;
> + __u64 mptcpi_bytes_acked;
> + __u8 mptcpi_subflows_total;
> + __u8 reserved[3];
> + __u32 mptcpi_last_data_sent;
> + __u32 mptcpi_last_data_recv;
> + __u32 mptcpi_last_ack_recv;
Small detail: some fields are aligned with spaces, others with tabs. Can
you pick only one please? tabs?
(...)
> +static void print_info_msg(struct mptcp_info *info)
> +{
> + printf("Token & Flags\n");
> + printf("token: %x\n", info->mptcpi_token);
> + printf("flags: %x\n", info->mptcpi_flags);
> + printf("csum_enabled: %u\n", info->mptcpi_csum_enabled);
> +
> + printf("\nBasic Info\n");
> + printf("subflows: %u\n", info->mptcpi_subflows);
> + printf("subflows_max: %u\n", info->mptcpi_subflows_max);
> + printf("subflows_total: %u\n", info->mptcpi_subflows_total);
> + printf("local_addr_used: %u\n", info->mptcpi_local_addr_used);
> + printf("local_addr_max: %u\n", info->mptcpi_local_addr_max);
> + printf("add_addr_signal: %u\n", info->mptcpi_add_addr_signal);
> + printf("add_addr_accepted: %u\n", info->mptcpi_add_addr_accepted);
> + printf("add_addr_signal_max: %u\n", info->mptcpi_add_addr_signal_max);
> + printf("add_addr_accepted_max: %u\n", info->mptcpi_add_addr_accepted_max);
> +
> + printf("\nTransmission Info\n");
> + printf("write_seq: %llx\n", info->mptcpi_write_seq);
> + printf("snd_una: %llx\n", info->mptcpi_snd_una);
> + printf("rcv_nxt: %llx\n", info->mptcpi_rcv_nxt);
> + printf("last_data_sent: %x\n", info->mptcpi_last_data_sent);
> + printf("last_data_recv: %x\n", info->mptcpi_last_data_recv);
> + printf("last_ack_recv: %x\n", info->mptcpi_last_ack_recv);
> + printf("retransmits: %u\n", info->mptcpi_retransmits);
> + printf("retransmit bytes: %llu\n", info->mptcpi_bytes_retrans);
> + printf("bytes_sent: %llu\n", info->mptcpi_bytes_sent);
> + printf("bytes_received: %llu\n", info->mptcpi_bytes_received);
> + printf("bytes_acked: %llu\n", info->mptcpi_bytes_acked);
Small detail: probably best to do the alignment only with spaces and not
a mix of both because I don't think it would look nice depending on how
the tabs are being printed.
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.
next prev parent reply other threads:[~2025-02-24 12:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-24 9:02 [mptcp-next v4 0/2] selftests: mptcp: add tests for increasing Gang Yan
2025-02-24 9:02 ` [mptcp-next v4 1/2] selftests: mptcp: Add a tool to get specific msk_info Gang Yan
2025-02-24 12:13 ` Matthieu Baerts [this message]
2025-02-24 9:02 ` [mptcp-next v4 2/2] selftests: mptcp: add a test for mptcp_diag_dump_one Gang Yan
2025-02-24 10:06 ` [mptcp-next v4 0/2] selftests: mptcp: add tests for increasing MPTCP CI
2025-02-24 12:13 ` Matthieu Baerts
2025-02-24 12:23 ` Matthieu Baerts
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3aab4781-d63a-4ee2-a099-db023f6886b7@kernel.org \
--to=matttbe@kernel.org \
--cc=mptcp@lists.linux.dev \
--cc=yangang@kylinos.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.