ktime: add ktime_after and ktime_before helper
authorDaniel Borkmann <dborkman@redhat.com>
Wed, 11 Jun 2014 16:19:28 +0000 (18:19 +0200)
committerDavid S. Miller <davem@davemloft.net>
Wed, 11 Jun 2014 19:23:17 +0000 (12:23 -0700)
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>
include/linux/ktime.h
net/sctp/sm_make_chunk.c

index 31c0cd1c941a6c122506cc3158be203391617460..de9e46e6bcc97aa66b3500cad82bcdaf14402556 100644 (file)
@@ -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);
index fee5552ddf929e40f702e1d0b86ead2cb0630f97..ae0e616a7ca5ed64ee9e7e09cab08a13caf7bff7 100644 (file)
@@ -1782,7 +1782,7 @@ no_hmac:
        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)
                 *