diff options
author | Daniel Borkmann <dborkman@redhat.com> | 2014-06-11 12:19:28 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-06-11 15:23:17 -0400 |
commit | 67cb9366ff5f99868100198efba5ca88aaa6ad25 (patch) | |
tree | 0e95142623a1bee9d773489ef0c126af91021724 | |
parent | 9181a6bd18009bf417bc865fd862075c335cc1dd (diff) |
ktime: add ktime_after and ktime_before helper
Add two minimal helper functions analogous to time_before() and
time_after() that will later on both be needed by SCTP code.
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/linux/ktime.h | 24 | ||||
-rw-r--r-- | net/sctp/sm_make_chunk.c | 2 |
2 files changed, 25 insertions, 1 deletions
diff --git a/include/linux/ktime.h b/include/linux/ktime.h index 31c0cd1c941a..de9e46e6bcc9 100644 --- a/include/linux/ktime.h +++ b/include/linux/ktime.h | |||
@@ -304,6 +304,30 @@ static inline int ktime_compare(const ktime_t cmp1, const ktime_t cmp2) | |||
304 | return 0; | 304 | return 0; |
305 | } | 305 | } |
306 | 306 | ||
307 | /** | ||
308 | * ktime_after - Compare if a ktime_t value is bigger than another one. | ||
309 | * @cmp1: comparable1 | ||
310 | * @cmp2: comparable2 | ||
311 | * | ||
312 | * Return: true if cmp1 happened after cmp2. | ||
313 | */ | ||
314 | static inline bool ktime_after(const ktime_t cmp1, const ktime_t cmp2) | ||
315 | { | ||
316 | return ktime_compare(cmp1, cmp2) > 0; | ||
317 | } | ||
318 | |||
319 | /** | ||
320 | * ktime_before - Compare if a ktime_t value is smaller than another one. | ||
321 | * @cmp1: comparable1 | ||
322 | * @cmp2: comparable2 | ||
323 | * | ||
324 | * Return: true if cmp1 happened before cmp2. | ||
325 | */ | ||
326 | static inline bool ktime_before(const ktime_t cmp1, const ktime_t cmp2) | ||
327 | { | ||
328 | return ktime_compare(cmp1, cmp2) < 0; | ||
329 | } | ||
330 | |||
307 | static inline s64 ktime_to_us(const ktime_t kt) | 331 | static inline s64 ktime_to_us(const ktime_t kt) |
308 | { | 332 | { |
309 | struct timeval tv = ktime_to_timeval(kt); | 333 | struct timeval tv = ktime_to_timeval(kt); |
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c index fee5552ddf92..ae0e616a7ca5 100644 --- a/net/sctp/sm_make_chunk.c +++ b/net/sctp/sm_make_chunk.c | |||
@@ -1782,7 +1782,7 @@ no_hmac: | |||
1782 | else | 1782 | else |
1783 | kt = ktime_get(); | 1783 | kt = ktime_get(); |
1784 | 1784 | ||
1785 | if (!asoc && ktime_compare(bear_cookie->expiration, kt) < 0) { | 1785 | if (!asoc && ktime_before(bear_cookie->expiration, kt)) { |
1786 | /* | 1786 | /* |
1787 | * Section 3.3.10.3 Stale Cookie Error (3) | 1787 | * Section 3.3.10.3 Stale Cookie Error (3) |
1788 | * | 1788 | * |