diff mbox series

[net] xfrm: Fix xfrm offload fallback fail case

Message ID 20210622035531.3780-1-ayush.sawal@chelsio.com (mailing list archive)
State Awaiting Upstream
Delegated to: Netdev Maintainers
Headers show
Series [net] xfrm: Fix xfrm offload fallback fail case | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net
netdev/subject_prefix success Link
netdev/cc_maintainers warning 1 maintainers not CCed: herbert@gondor.apana.org.au
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 1 this patch: 1
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 7 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 1 this patch: 1
netdev/header_inline success Link

Commit Message

Ayush Sawal June 22, 2021, 3:55 a.m. UTC
In case of xfrm offload, if xdo_dev_state_add() of driver returns
-EOPNOTSUPP, xfrm offload fallback is failed.
In xfrm state_add() both xso->dev and xso->real_dev are initialized to
dev and when err(-EOPNOTSUPP) is returned only xso->dev is set to null.

So in this scenario the condition in func validate_xmit_xfrm(),
if ((x->xso.dev != dev) && (x->xso.real_dev == dev))
                return skb;
returns true, due to which skb is returned without calling esp_xmit()
below which has fallback code. Hence the CRYPTO_FALLBACK is failing.

So fixing this with by keeping x->xso.real_dev as NULL when err is
returned in func xfrm_dev_state_add().

Fixes: bdfd2d1fa79a ("bonding/xfrm: use real_dev instead of slave_dev")
Signed-off-by: Ayush Sawal <ayush.sawal@chelsio.com>
---
 net/xfrm/xfrm_device.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Steffen Klassert June 23, 2021, 6:46 a.m. UTC | #1
On Tue, Jun 22, 2021 at 09:25:31AM +0530, Ayush Sawal wrote:
> In case of xfrm offload, if xdo_dev_state_add() of driver returns
> -EOPNOTSUPP, xfrm offload fallback is failed.
> In xfrm state_add() both xso->dev and xso->real_dev are initialized to
> dev and when err(-EOPNOTSUPP) is returned only xso->dev is set to null.
> 
> So in this scenario the condition in func validate_xmit_xfrm(),
> if ((x->xso.dev != dev) && (x->xso.real_dev == dev))
>                 return skb;
> returns true, due to which skb is returned without calling esp_xmit()
> below which has fallback code. Hence the CRYPTO_FALLBACK is failing.
> 
> So fixing this with by keeping x->xso.real_dev as NULL when err is
> returned in func xfrm_dev_state_add().
> 
> Fixes: bdfd2d1fa79a ("bonding/xfrm: use real_dev instead of slave_dev")
> Signed-off-by: Ayush Sawal <ayush.sawal@chelsio.com>

Applied, thanks Ayush!
diff mbox series

Patch

diff --git a/net/xfrm/xfrm_device.c b/net/xfrm/xfrm_device.c
index 6d6917b68856..e843b0d9e2a6 100644
--- a/net/xfrm/xfrm_device.c
+++ b/net/xfrm/xfrm_device.c
@@ -268,6 +268,7 @@  int xfrm_dev_state_add(struct net *net, struct xfrm_state *x,
 		xso->num_exthdrs = 0;
 		xso->flags = 0;
 		xso->dev = NULL;
+		xso->real_dev = NULL;
 		dev_put(dev);
 
 		if (err != -EOPNOTSUPP)