Skip to content

Commit c0f2102

Browse files
rleonklassert
authored andcommitted
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: 585b64f ("xfrm: delay initialization of offload path till its actually requested") Reported-by: Sabrina Dubroca <[email protected]> Closes: https://lore.kernel.org/all/aEGW_5HfPqU1rFjl@krikkit Signed-off-by: Leon Romanovsky <[email protected]> Signed-off-by: Steffen Klassert <[email protected]>
1 parent 766f6a7 commit c0f2102

File tree

4 files changed

+4
-6
lines changed

4 files changed

+4
-6
lines changed

include/net/xfrm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ struct xfrm_type_offload {
474474

475475
int xfrm_register_type_offload(const struct xfrm_type_offload *type, unsigned short family);
476476
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);
478478
static inline void xfrm_unset_type_offload(struct xfrm_state *x)
479479
{
480480
if (!x->type_offload)

net/xfrm/xfrm_device.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,6 @@ int xfrm_dev_state_add(struct net *net, struct xfrm_state *x,
305305
return -EINVAL;
306306
}
307307

308-
xfrm_set_type_offload(x);
309308
if (!x->type_offload) {
310309
NL_SET_ERR_MSG(extack, "Type doesn't support offload");
311310
dev_put(dev);

net/xfrm/xfrm_state.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -424,11 +424,10 @@ void xfrm_unregister_type_offload(const struct xfrm_type_offload *type,
424424
}
425425
EXPORT_SYMBOL(xfrm_unregister_type_offload);
426426

427-
void xfrm_set_type_offload(struct xfrm_state *x)
427+
void xfrm_set_type_offload(struct xfrm_state *x, bool try_load)
428428
{
429429
const struct xfrm_type_offload *type = NULL;
430430
struct xfrm_state_afinfo *afinfo;
431-
bool try_load = true;
432431

433432
retry:
434433
afinfo = xfrm_state_get_afinfo(x->props.family);
@@ -607,6 +606,7 @@ static void ___xfrm_state_destroy(struct xfrm_state *x)
607606
kfree(x->coaddr);
608607
kfree(x->replay_esn);
609608
kfree(x->preplay_esn);
609+
xfrm_unset_type_offload(x);
610610
if (x->type) {
611611
x->type->destructor(x);
612612
xfrm_put_type(x->type);
@@ -780,8 +780,6 @@ void xfrm_dev_state_free(struct xfrm_state *x)
780780
struct xfrm_dev_offload *xso = &x->xso;
781781
struct net_device *dev = READ_ONCE(xso->dev);
782782

783-
xfrm_unset_type_offload(x);
784-
785783
if (dev && dev->xfrmdev_ops) {
786784
spin_lock_bh(&xfrm_state_dev_gc_lock);
787785
if (!hlist_unhashed(&x->dev_gclist))

net/xfrm/xfrm_user.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,7 @@ static struct xfrm_state *xfrm_state_construct(struct net *net,
977977
/* override default values from above */
978978
xfrm_update_ae_params(x, attrs, 0);
979979

980+
xfrm_set_type_offload(x, attrs[XFRMA_OFFLOAD_DEV]);
980981
/* configure the hardware if offload is requested */
981982
if (attrs[XFRMA_OFFLOAD_DEV]) {
982983
err = xfrm_dev_state_add(net, x,

0 commit comments

Comments
 (0)