net: sctp: migrate cookie life from timeval to ktime
Currently, SCTP code defines its own timeval functions (since timeval is rarely used inside the kernel by others), namely tv_lt() and TIMEVAL_ADD() macros, that operate on SCTP cookie expiration. We might as well remove all those, and operate directly on ktime structures for a couple of reasons: ktime is available on all archs; complexity of ktime calculations depending on the arch is less than (reduces to a simple arithmetic operations on archs with BITS_PER_LONG == 64 or CONFIG_KTIME_SCALAR) or equal to timeval functions (other archs); code becomes more readable; macros can be thrown out. Signed-off-by: Daniel Borkmann <dborkman@redhat.com> Acked-by: Vlad Yasevich <vyasevich@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
d36f82b243
commit
52db882f3f
@@ -2910,13 +2910,8 @@ static int sctp_setsockopt_associnfo(struct sock *sk, char __user *optval, unsig
|
||||
asoc->max_retrans = assocparams.sasoc_asocmaxrxt;
|
||||
}
|
||||
|
||||
if (assocparams.sasoc_cookie_life != 0) {
|
||||
asoc->cookie_life.tv_sec =
|
||||
assocparams.sasoc_cookie_life / 1000;
|
||||
asoc->cookie_life.tv_usec =
|
||||
(assocparams.sasoc_cookie_life % 1000)
|
||||
* 1000;
|
||||
}
|
||||
if (assocparams.sasoc_cookie_life != 0)
|
||||
asoc->cookie_life = ms_to_ktime(assocparams.sasoc_cookie_life);
|
||||
} else {
|
||||
/* Set the values to the endpoint */
|
||||
struct sctp_sock *sp = sctp_sk(sk);
|
||||
@@ -5074,10 +5069,7 @@ static int sctp_getsockopt_associnfo(struct sock *sk, int len,
|
||||
assocparams.sasoc_asocmaxrxt = asoc->max_retrans;
|
||||
assocparams.sasoc_peer_rwnd = asoc->peer.rwnd;
|
||||
assocparams.sasoc_local_rwnd = asoc->a_rwnd;
|
||||
assocparams.sasoc_cookie_life = (asoc->cookie_life.tv_sec
|
||||
* 1000) +
|
||||
(asoc->cookie_life.tv_usec
|
||||
/ 1000);
|
||||
assocparams.sasoc_cookie_life = ktime_to_ms(asoc->cookie_life);
|
||||
|
||||
list_for_each(pos, &asoc->peer.transport_addr_list) {
|
||||
cnt ++;
|
||||
|
Reference in New Issue
Block a user