net: use jiffies_to_msecs to replace EXPIRES_IN_MS in inet/sctp_diag
authorXin Long <lucien.xin@gmail.com>
Tue, 19 Apr 2016 07:10:01 +0000 (15:10 +0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 21 Apr 2016 17:55:33 +0000 (13:55 -0400)
EXPIRES_IN_MS macro comes from net/ipv4/inet_diag.c and dates
back to before jiffies_to_msecs() has been introduced.

Now we can remove it and use jiffies_to_msecs().

Suggested-by: Jakub Sitnicki <jkbs@redhat.com>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Acked-by: Jakub Sitnicki <jkbs@redhat.com>
Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/inet_diag.c
net/sctp/sctp_diag.c

index 70212bddf0f8460f5b416c2aa609a6f111e34860..ad7956fa659a51ba4e22b5e81a53fb7860970ed3 100644 (file)
@@ -197,27 +197,27 @@ int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk,
                goto out;
        }
 
-#define EXPIRES_IN_MS(tmo)  DIV_ROUND_UP((tmo - jiffies) * 1000, HZ)
-
        if (icsk->icsk_pending == ICSK_TIME_RETRANS ||
            icsk->icsk_pending == ICSK_TIME_EARLY_RETRANS ||
            icsk->icsk_pending == ICSK_TIME_LOSS_PROBE) {
                r->idiag_timer = 1;
                r->idiag_retrans = icsk->icsk_retransmits;
-               r->idiag_expires = EXPIRES_IN_MS(icsk->icsk_timeout);
+               r->idiag_expires =
+                       jiffies_to_msecs(icsk->icsk_timeout - jiffies);
        } else if (icsk->icsk_pending == ICSK_TIME_PROBE0) {
                r->idiag_timer = 4;
                r->idiag_retrans = icsk->icsk_probes_out;
-               r->idiag_expires = EXPIRES_IN_MS(icsk->icsk_timeout);
+               r->idiag_expires =
+                       jiffies_to_msecs(icsk->icsk_timeout - jiffies);
        } else if (timer_pending(&sk->sk_timer)) {
                r->idiag_timer = 2;
                r->idiag_retrans = icsk->icsk_probes_out;
-               r->idiag_expires = EXPIRES_IN_MS(sk->sk_timer.expires);
+               r->idiag_expires =
+                       jiffies_to_msecs(sk->sk_timer.expires - jiffies);
        } else {
                r->idiag_timer = 0;
                r->idiag_expires = 0;
        }
-#undef EXPIRES_IN_MS
 
        if ((ext & (1 << (INET_DIAG_INFO - 1))) && handler->idiag_info_size) {
                attr = nla_reserve(skb, INET_DIAG_INFO,
index 98ecd16da0c91e868609b1cfd6634c296db31fa4..bb2d8d9608e95c62d6e0a42ef2a87c1315fb4d6b 100644 (file)
@@ -48,10 +48,8 @@ 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;
-#define EXPIRES_IN_MS(tmo)  DIV_ROUND_UP((tmo - jiffies) * 1000, HZ)
-       r->idiag_expires =
-               EXPIRES_IN_MS(asoc->timeouts[SCTP_EVENT_TIMEOUT_T3_RTX]);
-#undef EXPIRES_IN_MS
+       r->idiag_expires = jiffies_to_msecs(
+               asoc->timeouts[SCTP_EVENT_TIMEOUT_T3_RTX] - jiffies);
 }
 
 static int inet_diag_msg_sctpladdrs_fill(struct sk_buff *skb,