Re: [PATCH net-next 1/2] mptcp: add last time fields in mptcp_info

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Eric,

Thank you for the review!

On 05/04/2024 15:29, Eric Dumazet wrote:
> On Fri, Apr 5, 2024 at 3:06 PM Matthieu Baerts (NGI0)
> <matttbe@xxxxxxxxxx> wrote:
>>
>> From: Geliang Tang <tanggeliang@xxxxxxxxxx>
>>
>> This patch adds "last time" fields last_data_sent, last_data_recv and
>> last_ack_recv in struct mptcp_sock to record the last time data_sent,
>> data_recv and ack_recv happened. They all are initialized as
>> tcp_jiffies32 in __mptcp_init_sock(), and updated as tcp_jiffies32 too
>> when data is sent in __subflow_push_pending(), data is received in
>> __mptcp_move_skbs_from_subflow(), and ack is received in ack_update_msk().
>>
>> Similar to tcpi_last_data_sent, tcpi_last_data_recv and tcpi_last_ack_recv
>> exposed with TCP, this patch exposes the last time "an action happened" for
>> MPTCP in mptcp_info, named mptcpi_last_data_sent, mptcpi_last_data_recv and
>> mptcpi_last_ack_recv, calculated in mptcp_diag_fill_info() as the time
>> deltas between now and the newly added last time fields in mptcp_sock.
>>
>> Also add three reserved bytes in struct mptcp_info not to have holes in
>> this structure exposed to userspace.
>>
>> Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/446
>> Signed-off-by: Geliang Tang <tanggeliang@xxxxxxxxxx>
>> Reviewed-by: Mat Martineau <martineau@xxxxxxxxxx>
>> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@xxxxxxxxxx>
>> ---
>>  include/uapi/linux/mptcp.h | 4 ++++
> 
> 
>> diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c
>> index 73fdf423de44..2ec2fdf9f4af 100644
>> --- a/net/mptcp/sockopt.c
>> +++ b/net/mptcp/sockopt.c
>> @@ -896,6 +896,7 @@ static int mptcp_getsockopt_first_sf_only(struct mptcp_sock *msk, int level, int
>>  void mptcp_diag_fill_info(struct mptcp_sock *msk, struct mptcp_info *info)
>>  {
>>         struct sock *sk = (struct sock *)msk;
>> +       u32 now = tcp_jiffies32;
>>         u32 flags = 0;
>>         bool slow;
>>
>> @@ -930,6 +931,7 @@ void mptcp_diag_fill_info(struct mptcp_sock *msk, struct mptcp_info *info)
>>         info->mptcpi_snd_una = msk->snd_una;
>>         info->mptcpi_rcv_nxt = msk->ack_seq;
>>         info->mptcpi_bytes_acked = msk->bytes_acked;
>> +       info->mptcpi_last_ack_recv = jiffies_to_msecs(now - msk->last_ack_recv);
>>         mptcp_data_unlock(sk);
>>
>>         slow = lock_sock_fast(sk);
> 
>  lock_sock_fast(sk) can sleep and be quite slow...
> 
> I suggest you reload now = jiffies32;

Good point, it would make more sense to reload it after this lock!

(or defining "now" only here, under this lock_sock_fast(), and move the
block here above that is under the data spin lock, after, so all the
"time" counter are "in sync"?)

pw-bot: changes-requested

> 
> 
>> @@ -942,6 +944,8 @@ void mptcp_diag_fill_info(struct mptcp_sock *msk, struct mptcp_info *info)
>>         info->mptcpi_bytes_retrans = msk->bytes_retrans;
>>         info->mptcpi_subflows_total = info->mptcpi_subflows +
>>                 __mptcp_has_initial_subflow(msk);
>> +       info->mptcpi_last_data_sent = jiffies_to_msecs(now - msk->last_data_sent);
>> +       info->mptcpi_last_data_recv = jiffies_to_msecs(now - msk->last_data_recv);
>>         unlock_sock_fast(sk, slow);
>>  }
>>  EXPORT_SYMBOL_GPL(mptcp_diag_fill_info);
>>
>> --
>> 2.43.0
>>
> 

Cheers,
Matt
-- 
Sponsored by the NGI0 Core fund.





[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux