netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
To: Phil Sutter <phil@nwl.cc>
Cc: David Miller <davem@davemloft.net>,
	Xin Long <lucien.xin@gmail.com>,
	netdev@vger.kernel.org
Subject: Re: [PATCH v2 2/3] sctp_diag: export timer value only if it is active
Date: Wed, 3 Aug 2016 18:51:15 -0300	[thread overview]
Message-ID: <20160803215115.GE2954@localhost.localdomain> (raw)
In-Reply-To: <1470259393-22861-3-git-send-email-phil@nwl.cc>

On Wed, Aug 03, 2016 at 11:23:12PM +0200, Phil Sutter wrote:
> Since it is exported as unsigned value, userspace has no way detecting
> whether it is negative or just very large. Therefore do this in kernel
> space where it is a simple comparison.
> 
> Signed-off-by: Phil Sutter <phil@nwl.cc>
> ---
> Changes since v1:
> - Introduce local variable to shorten long lines.
> - Use timer_pending() to decide whether to export the timer value.
> - Export the primary path's value instead of garbage.

This is now the most important change on the patch IMO. Can we mention
it on changelog itself?

A Fixes tag is welcomed too, as previous values were incorrect.

> - If not exporting, zero fields to not confuse userspace.
> ---
>  net/sctp/sctp_diag.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/net/sctp/sctp_diag.c b/net/sctp/sctp_diag.c
> index f69edcf219e51..f728ef04a7b2d 100644
> --- a/net/sctp/sctp_diag.c
> +++ b/net/sctp/sctp_diag.c
> @@ -13,6 +13,7 @@ static void inet_diag_msg_sctpasoc_fill(struct inet_diag_msg *r,
>  {
>  	union sctp_addr laddr, paddr;
>  	struct dst_entry *dst;
> +	struct timer_list *t3_rtx = &asoc->peer.primary_path->T3_rtx_timer;
>  
>  	laddr = list_entry(asoc->base.bind_addr.address_list.next,
>  			   struct sctp_sockaddr_entry, list)->a;
> @@ -40,10 +41,15 @@ static void inet_diag_msg_sctpasoc_fill(struct inet_diag_msg *r,
>  	}
>  
>  	r->idiag_state = asoc->state;
> -	r->idiag_timer = SCTP_EVENT_TIMEOUT_T3_RTX;
> -	r->idiag_retrans = asoc->rtx_data_chunks;
> -	r->idiag_expires = jiffies_to_msecs(
> -		asoc->timeouts[SCTP_EVENT_TIMEOUT_T3_RTX] - jiffies);
> +	if (timer_pending(t3_rtx)) {
> +		r->idiag_timer = SCTP_EVENT_TIMEOUT_T3_RTX;
> +		r->idiag_retrans = asoc->rtx_data_chunks;
> +		r->idiag_expires = jiffies_to_msecs(t3_rtx->expires - jiffies);
> +	} else {
> +		r->idiag_timer = 0;
> +		r->idiag_retrans = 0;
> +		r->idiag_expires = 0;
> +	}
>  }
>  
>  static int inet_diag_msg_sctpladdrs_fill(struct sk_buff *skb,
> -- 
> 2.8.2
> 

  reply	other threads:[~2016-08-03 21:51 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-03 21:23 [PATCH v2 0/3] sctp_diag: A bunch of fixes for upcoming 'ss' support Phil Sutter
2016-08-03 21:23 ` [PATCH v2 1/3] sctp: Export struct sctp_info to userspace Phil Sutter
2016-08-04  9:13   ` David Laight
2016-08-04  9:27     ` Phil Sutter
2016-08-04 12:16       ` Xin Long
2016-08-03 21:23 ` [PATCH v2 2/3] sctp_diag: export timer value only if it is active Phil Sutter
2016-08-03 21:51   ` Marcelo Ricardo Leitner [this message]
2016-08-03 23:39     ` Phil Sutter
2016-08-03 21:23 ` [PATCH v2 3/3] sctp_diag: Respect ss adding TCPF_CLOSE to idiag_states Phil Sutter

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=20160803215115.GE2954@localhost.localdomain \
    --to=marcelo.leitner@gmail.com \
    --cc=davem@davemloft.net \
    --cc=lucien.xin@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=phil@nwl.cc \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).