Skip to contentSkip to conversation

xfrm: Indicate xfrm_state offload errors

PATCH In review [email protected] 2 participants 2 messages Apr 30, 2017 – May 1, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfrm: Indicate xfrm_state offload errors

From: Ilan Tayari <[email protected]>

Current code silently ignores driver errors when configuring IPSec offload xfrm_state, and falls back to host-based crypto.

Fail the xfrm_state creation if the driver has an error, because the NIC offloading was explicitly requested by the user program.

This will communicate back to the user that there was an error.

Fixes d77e38e612a0 ("xfrm: Add an IPsec hardware offloading API")
---
 net/xfrm/xfrm_user.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
net/xfrm/xfrm_user.c +6 -3
index ba74e5eeeeef..c4cceddac9db 100644
@@ -595,9 +595,12 @@ static struct xfrm_state *xfrm_state_construct(struct net *net,
 			goto error;
 	}
 
-	if (attrs[XFRMA_OFFLOAD_DEV] &&
-	    xfrm_dev_state_add(net, x, nla_data(attrs[XFRMA_OFFLOAD_DEV])))
-		goto error;
+	if (attrs[XFRMA_OFFLOAD_DEV]) {
+		err = xfrm_dev_state_add(net, x,
+					 nla_data(attrs[XFRMA_OFFLOAD_DEV]));
+		if (err)
+			goto error;
+	}
 
 	if ((err = xfrm_alloc_replay_state_esn(&x->replay_esn, &x->preplay_esn,
 					       attrs[XFRMA_REPLAY_ESN_VAL])))
Signature · 1 line
2.11.0
maintainer
#1 lore raw

From: <[email protected]>
Date: Sun, 30 Apr 2017 16:51:19 +0300

Quoted 5 lines

From: Ilan Tayari <[email protected]>

Current code silently ignores driver errors when configuring IPSec offload xfrm_state, and falls back to host-based crypto.

Quoted 7 lines

Fail the xfrm_state creation if the driver has an error, because the NIC offloading was explicitly requested by the user program.

This will communicate back to the user that there was an error.

Fixes d77e38e612a0 ("xfrm: Add an IPsec hardware offloading API")

Also applied.

Steffen, I apologize for taking these directly but I really wanted to make sure these fixes made it into the pull request I plan to send to Linus for the merge window soon.

Thanks.