Skip to content

Commit

Permalink
ktime: add ktime_after and ktime_before helper
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Daniel Borkmann authored and David S. Miller committed Jun 11, 2014
1 parent 9181a6b commit 67cb936
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
24 changes: 24 additions & 0 deletions include/linux/ktime.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,30 @@ static inline int ktime_compare(const ktime_t cmp1, const ktime_t cmp2)
return 0;
}

/**
* ktime_after - Compare if a ktime_t value is bigger than another one.
* @cmp1: comparable1
* @cmp2: comparable2
*
* Return: true if cmp1 happened after cmp2.
*/
static inline bool ktime_after(const ktime_t cmp1, const ktime_t cmp2)
{
return ktime_compare(cmp1, cmp2) > 0;
}

/**
* ktime_before - Compare if a ktime_t value is smaller than another one.
* @cmp1: comparable1
* @cmp2: comparable2
*
* Return: true if cmp1 happened before cmp2.
*/
static inline bool ktime_before(const ktime_t cmp1, const ktime_t cmp2)
{
return ktime_compare(cmp1, cmp2) < 0;
}

static inline s64 ktime_to_us(const ktime_t kt)
{
struct timeval tv = ktime_to_timeval(kt);
Expand Down
2 changes: 1 addition & 1 deletion net/sctp/sm_make_chunk.c
Original file line number Diff line number Diff line change
Expand Up @@ -1782,7 +1782,7 @@ struct sctp_association *sctp_unpack_cookie(
else
kt = ktime_get();

if (!asoc && ktime_compare(bear_cookie->expiration, kt) < 0) {
if (!asoc && ktime_before(bear_cookie->expiration, kt)) {
/*
* Section 3.3.10.3 Stale Cookie Error (3)
*
Expand Down

0 comments on commit 67cb936

Please sign in to comment.