mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-03 09:41:54 +09:00
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
@@ -560,24 +560,6 @@ for (pos = chunk->subh.fwdtsn_hdr->skip;\
|
||||
/* Round an int up to the next multiple of 4. */
|
||||
#define WORD_ROUND(s) (((s)+3)&~3)
|
||||
|
||||
/* Compare two timevals. */
|
||||
#define tv_lt(s, t) \
|
||||
(s.tv_sec < t.tv_sec || (s.tv_sec == t.tv_sec && s.tv_usec < t.tv_usec))
|
||||
|
||||
/* Add tv1 to tv2. */
|
||||
#define TIMEVAL_ADD(tv1, tv2) \
|
||||
({ \
|
||||
suseconds_t usecs = (tv2).tv_usec + (tv1).tv_usec; \
|
||||
time_t secs = (tv2).tv_sec + (tv1).tv_sec; \
|
||||
\
|
||||
if (usecs >= 1000000) { \
|
||||
usecs -= 1000000; \
|
||||
secs++; \
|
||||
} \
|
||||
(tv2).tv_sec = secs; \
|
||||
(tv2).tv_usec = usecs; \
|
||||
})
|
||||
|
||||
/* External references. */
|
||||
|
||||
extern struct proto sctp_prot;
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
#ifndef __sctp_structs_h__
|
||||
#define __sctp_structs_h__
|
||||
|
||||
#include <linux/time.h> /* We get struct timespec. */
|
||||
#include <linux/ktime.h>
|
||||
#include <linux/socket.h> /* linux/in.h needs this!! */
|
||||
#include <linux/in.h> /* We get struct sockaddr_in. */
|
||||
#include <linux/in6.h> /* We get struct in6_addr */
|
||||
@@ -284,7 +284,7 @@ struct sctp_cookie {
|
||||
__u32 peer_ttag;
|
||||
|
||||
/* When does this cookie expire? */
|
||||
struct timeval expiration;
|
||||
ktime_t expiration;
|
||||
|
||||
/* Number of inbound/outbound streams which are set
|
||||
* and negotiated during the INIT process.
|
||||
@@ -1537,7 +1537,7 @@ struct sctp_association {
|
||||
sctp_state_t state;
|
||||
|
||||
/* The cookie life I award for any cookie. */
|
||||
struct timeval cookie_life;
|
||||
ktime_t cookie_life;
|
||||
|
||||
/* Overall : The overall association error count.
|
||||
* Error Count : [Clear this any time I get something.]
|
||||
|
||||
Reference in New Issue
Block a user