]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
xfrm: update x->lastused for every packet
authorAntony Antony <antony.antony@secunet.com>
Fri, 21 Oct 2022 13:42:01 +0000 (15:42 +0200)
committerSteffen Klassert <steffen.klassert@secunet.com>
Tue, 25 Oct 2022 08:24:08 +0000 (10:24 +0200)
x->lastused was only updated for outgoing mobile IPv6 packet.
With this fix update it for every, in and out, packet.

This is useful to check if the a SA is still in use, or when was
the last time an SA was used. lastused time of in SA can used
to check IPsec path is functional.

Signed-off-by: Antony Antony <antony.antony@secunet.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
net/xfrm/xfrm_input.c
net/xfrm/xfrm_output.c

index 97074f6f2bdee947b7691be123389d68eca9d828..c06e54a105405b645ac49613ac15cda9d2b071ee 100644 (file)
@@ -671,6 +671,7 @@ resume:
 
                x->curlft.bytes += skb->len;
                x->curlft.packets++;
+               x->lastused = ktime_get_real_seconds();
 
                spin_unlock(&x->lock);
 
index 9a5e79a38c6797e86648178090601471c2e68584..78cb8d0a6a1800a24aa804dc29c25a8b022bee37 100644 (file)
@@ -209,8 +209,6 @@ static int xfrm6_ro_output(struct xfrm_state *x, struct sk_buff *skb)
        __skb_pull(skb, hdr_len);
        memmove(ipv6_hdr(skb), iph, hdr_len);
 
-       x->lastused = ktime_get_real_seconds();
-
        return 0;
 #else
        WARN_ON_ONCE(1);
@@ -534,6 +532,7 @@ static int xfrm_output_one(struct sk_buff *skb, int err)
 
                x->curlft.bytes += skb->len;
                x->curlft.packets++;
+               x->lastused = ktime_get_real_seconds();
 
                spin_unlock_bh(&x->lock);