Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

xfrm: always initialize offload path

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>

authored by

Leon Romanovsky and committed by
Steffen Klassert
c0f21029 766f6a78

+4 -6
+1 -1
include/net/xfrm.h
··· 474 474 475 475 int xfrm_register_type_offload(const struct xfrm_type_offload *type, unsigned short family); 476 476 void xfrm_unregister_type_offload(const struct xfrm_type_offload *type, unsigned short family); 477 - void xfrm_set_type_offload(struct xfrm_state *x); 477 + void xfrm_set_type_offload(struct xfrm_state *x, bool try_load); 478 478 static inline void xfrm_unset_type_offload(struct xfrm_state *x) 479 479 { 480 480 if (!x->type_offload)
-1
net/xfrm/xfrm_device.c
··· 305 305 return -EINVAL; 306 306 } 307 307 308 - xfrm_set_type_offload(x); 309 308 if (!x->type_offload) { 310 309 NL_SET_ERR_MSG(extack, "Type doesn't support offload"); 311 310 dev_put(dev);
+2 -4
net/xfrm/xfrm_state.c
··· 424 424 } 425 425 EXPORT_SYMBOL(xfrm_unregister_type_offload); 426 426 427 - void xfrm_set_type_offload(struct xfrm_state *x) 427 + void xfrm_set_type_offload(struct xfrm_state *x, bool try_load) 428 428 { 429 429 const struct xfrm_type_offload *type = NULL; 430 430 struct xfrm_state_afinfo *afinfo; 431 - bool try_load = true; 432 431 433 432 retry: 434 433 afinfo = xfrm_state_get_afinfo(x->props.family); ··· 606 607 kfree(x->coaddr); 607 608 kfree(x->replay_esn); 608 609 kfree(x->preplay_esn); 610 + xfrm_unset_type_offload(x); 609 611 if (x->type) { 610 612 x->type->destructor(x); 611 613 xfrm_put_type(x->type); ··· 779 779 { 780 780 struct xfrm_dev_offload *xso = &x->xso; 781 781 struct net_device *dev = READ_ONCE(xso->dev); 782 - 783 - xfrm_unset_type_offload(x); 784 782 785 783 if (dev && dev->xfrmdev_ops) { 786 784 spin_lock_bh(&xfrm_state_dev_gc_lock);
+1
net/xfrm/xfrm_user.c
··· 977 977 /* override default values from above */ 978 978 xfrm_update_ae_params(x, attrs, 0); 979 979 980 + xfrm_set_type_offload(x, attrs[XFRMA_OFFLOAD_DEV]); 980 981 /* configure the hardware if offload is requested */ 981 982 if (attrs[XFRMA_OFFLOAD_DEV]) { 982 983 err = xfrm_dev_state_add(net, x,