aboutsummaryrefslogtreecommitdiffstats
path: root/include/net
diff options
context:
space:
mode:
authorDaniel Borkmann <dborkman@redhat.com>2013-06-25 12:17:27 -0400
committerDavid S. Miller <davem@davemloft.net>2013-06-25 19:33:04 -0400
commit52db882f3fc2903014e638ee91e690085fe37fdb (patch)
treeda6cd52645dca68bf16d40387421cc93fd094ea4 /include/net
parentd36f82b2435690d8742235d7bdc5bb5e878077e3 (diff)
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>
Diffstat (limited to 'include/net')
-rw-r--r--include/net/sctp/sctp.h18
-rw-r--r--include/net/sctp/structs.h6
2 files changed, 3 insertions, 21 deletions
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index 15214a825f92..e6b95bc4d8e6 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -560,24 +560,6 @@ for (pos = chunk->subh.fwdtsn_hdr->skip;\
560/* Round an int up to the next multiple of 4. */ 560/* Round an int up to the next multiple of 4. */
561#define WORD_ROUND(s) (((s)+3)&~3) 561#define WORD_ROUND(s) (((s)+3)&~3)
562 562
563/* Compare two timevals. */
564#define tv_lt(s, t) \
565 (s.tv_sec < t.tv_sec || (s.tv_sec == t.tv_sec && s.tv_usec < t.tv_usec))
566
567/* Add tv1 to tv2. */
568#define TIMEVAL_ADD(tv1, tv2) \
569({ \
570 suseconds_t usecs = (tv2).tv_usec + (tv1).tv_usec; \
571 time_t secs = (tv2).tv_sec + (tv1).tv_sec; \
572\
573 if (usecs >= 1000000) { \
574 usecs -= 1000000; \
575 secs++; \
576 } \
577 (tv2).tv_sec = secs; \
578 (tv2).tv_usec = usecs; \
579})
580
581/* External references. */ 563/* External references. */
582 564
583extern struct proto sctp_prot; 565extern struct proto sctp_prot;
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index 1bd4c4144fe8..e745c92a1532 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -54,7 +54,7 @@
54#ifndef __sctp_structs_h__ 54#ifndef __sctp_structs_h__
55#define __sctp_structs_h__ 55#define __sctp_structs_h__
56 56
57#include <linux/time.h> /* We get struct timespec. */ 57#include <linux/ktime.h>
58#include <linux/socket.h> /* linux/in.h needs this!! */ 58#include <linux/socket.h> /* linux/in.h needs this!! */
59#include <linux/in.h> /* We get struct sockaddr_in. */ 59#include <linux/in.h> /* We get struct sockaddr_in. */
60#include <linux/in6.h> /* We get struct in6_addr */ 60#include <linux/in6.h> /* We get struct in6_addr */
@@ -284,7 +284,7 @@ struct sctp_cookie {
284 __u32 peer_ttag; 284 __u32 peer_ttag;
285 285
286 /* When does this cookie expire? */ 286 /* When does this cookie expire? */
287 struct timeval expiration; 287 ktime_t expiration;
288 288
289 /* Number of inbound/outbound streams which are set 289 /* Number of inbound/outbound streams which are set
290 * and negotiated during the INIT process. 290 * and negotiated during the INIT process.
@@ -1537,7 +1537,7 @@ struct sctp_association {
1537 sctp_state_t state; 1537 sctp_state_t state;
1538 1538
1539 /* The cookie life I award for any cookie. */ 1539 /* The cookie life I award for any cookie. */
1540 struct timeval cookie_life; 1540 ktime_t cookie_life;
1541 1541
1542 /* Overall : The overall association error count. 1542 /* Overall : The overall association error count.
1543 * Error Count : [Clear this any time I get something.] 1543 * Error Count : [Clear this any time I get something.]