]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
xfrm: always initialize offload path
authorLeon Romanovsky <leonro@nvidia.com>
Sun, 8 Jun 2025 07:42:53 +0000 (10:42 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 1 Aug 2025 08:51:24 +0000 (09:51 +0100)
[ Upstream commit c0f21029f123d1b15f8eddc8e3976bf0c8781c43 ]

Offload path is used for GRO with SW IPsec, and not just for HW
offload. So initialize it anyway.

Fixes: 585b64f5a620 ("xfrm: delay initialization of offload path till its actually requested")
Reported-by: Sabrina Dubroca <sd@queasysnail.net>
Closes: https://lore.kernel.org/all/aEGW_5HfPqU1rFjl@krikkit
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
include/net/xfrm.h
net/xfrm/xfrm_device.c
net/xfrm/xfrm_state.c
net/xfrm/xfrm_user.c

index 1f1861c57e2ad0fbf659ede958f7ca2691af2e18..29a0759d5582c8a83b9ad4e81cae3213b524f078 100644 (file)
@@ -474,7 +474,7 @@ struct xfrm_type_offload {
 
 int xfrm_register_type_offload(const struct xfrm_type_offload *type, unsigned short family);
 void xfrm_unregister_type_offload(const struct xfrm_type_offload *type, unsigned short family);
-void xfrm_set_type_offload(struct xfrm_state *x);
+void xfrm_set_type_offload(struct xfrm_state *x, bool try_load);
 static inline void xfrm_unset_type_offload(struct xfrm_state *x)
 {
        if (!x->type_offload)
index f46a9e5764f014b5ab696db2a9a7477aaba7a738..a2d3a5f3b4852c1dc6972620d774f443a06b006e 100644 (file)
@@ -305,7 +305,6 @@ int xfrm_dev_state_add(struct net *net, struct xfrm_state *x,
                return -EINVAL;
        }
 
-       xfrm_set_type_offload(x);
        if (!x->type_offload) {
                NL_SET_ERR_MSG(extack, "Type doesn't support offload");
                dev_put(dev);
index cef8d3c20f65287d39b047fde40e93fbffffd59a..0cf516b4e6d92959c54f8862670eb2ecedb3fcd0 100644 (file)
@@ -424,11 +424,10 @@ void xfrm_unregister_type_offload(const struct xfrm_type_offload *type,
 }
 EXPORT_SYMBOL(xfrm_unregister_type_offload);
 
-void xfrm_set_type_offload(struct xfrm_state *x)
+void xfrm_set_type_offload(struct xfrm_state *x, bool try_load)
 {
        const struct xfrm_type_offload *type = NULL;
        struct xfrm_state_afinfo *afinfo;
-       bool try_load = true;
 
 retry:
        afinfo = xfrm_state_get_afinfo(x->props.family);
@@ -607,6 +606,7 @@ static void ___xfrm_state_destroy(struct xfrm_state *x)
        kfree(x->coaddr);
        kfree(x->replay_esn);
        kfree(x->preplay_esn);
+       xfrm_unset_type_offload(x);
        if (x->type) {
                x->type->destructor(x);
                xfrm_put_type(x->type);
@@ -780,8 +780,6 @@ void xfrm_dev_state_free(struct xfrm_state *x)
        struct xfrm_dev_offload *xso = &x->xso;
        struct net_device *dev = READ_ONCE(xso->dev);
 
-       xfrm_unset_type_offload(x);
-
        if (dev && dev->xfrmdev_ops) {
                spin_lock_bh(&xfrm_state_dev_gc_lock);
                if (!hlist_unhashed(&x->dev_gclist))
index 614b58cb26ab71c44571c023d03a370c15f52bc0..d17ea437a1587de324b863a92eaa7adcb72efa71 100644 (file)
@@ -977,6 +977,7 @@ static struct xfrm_state *xfrm_state_construct(struct net *net,
        /* override default values from above */
        xfrm_update_ae_params(x, attrs, 0);
 
+       xfrm_set_type_offload(x, attrs[XFRMA_OFFLOAD_DEV]);
        /* configure the hardware if offload is requested */
        if (attrs[XFRMA_OFFLOAD_DEV]) {
                err = xfrm_dev_state_add(net, x,