Skip to content

Commit

Permalink
xfrm: update x->lastused for every packet
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Antony Antony authored and Steffen Klassert committed Oct 25, 2022
1 parent e91001b commit f7fe25a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
1 change: 1 addition & 0 deletions net/xfrm/xfrm_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,7 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)

x->curlft.bytes += skb->len;
x->curlft.packets++;
x->lastused = ktime_get_real_seconds();

spin_unlock(&x->lock);

Expand Down
3 changes: 1 addition & 2 deletions net/xfrm/xfrm_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit f7fe25a

Please sign in to comment.