Skip to content

Commit 67cb936

Browse files
Daniel Borkmanndavem330
authored andcommitted
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9181a6b commit 67cb936

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

include/linux/ktime.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,30 @@ static inline int ktime_compare(const ktime_t cmp1, const ktime_t cmp2)
304304
return 0;
305305
}
306306

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+
307331
static inline s64 ktime_to_us(const ktime_t kt)
308332
{
309333
struct timeval tv = ktime_to_timeval(kt);

net/sctp/sm_make_chunk.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1782,7 +1782,7 @@ struct sctp_association *sctp_unpack_cookie(
17821782
else
17831783
kt = ktime_get();
17841784

1785-
if (!asoc && ktime_compare(bear_cookie->expiration, kt) < 0) {
1785+
if (!asoc && ktime_before(bear_cookie->expiration, kt)) {
17861786
/*
17871787
* Section 3.3.10.3 Stale Cookie Error (3)
17881788
*

0 commit comments

Comments
 (0)