xfrm: hold device only for the asynchronous decryption
authorJianbo Liu <jianbol@nvidia.com>
Thu, 19 Jun 2025 09:48:51 +0000 (12:48 +0300)
committerSteffen Klassert <steffen.klassert@secunet.com>
Fri, 20 Jun 2025 08:39:19 +0000 (10:39 +0200)
commitb05d42eefac737ce3cd80114d3579111023941b8
treea9aa71f463b7fc1ebbd22a4b9cae3b99d58ae2ca
parent4f4040ea5d3e4bebebbef9379f88085c8b99221c
xfrm: hold device only for the asynchronous decryption

The dev_hold() on skb->dev during packet reception was originally
added to prevent the device from being released prematurely during
asynchronous decryption operations.

As current hardware can offload decryption, this asynchronous path is
not always utilized. This often results in a pattern of dev_hold()
immediately followed by dev_put() for each packet, creating
unnecessary reference counting overhead detrimental to performance.

This patch optimizes this by skipping the dev_hold() and subsequent
dev_put() when asynchronous decryption is not being performed.

Signed-off-by: Jianbo Liu <jianbol@nvidia.com>
Reviewed-by: Cosmin Ratiu <cratiu@nvidia.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
net/xfrm/xfrm_input.c