Skip to content

Commit d53dda2

Browse files
Cosmin Ratiuklassert
authored andcommitted
xfrm: Remove unneeded device check from validate_xmit_xfrm
validate_xmit_xfrm checks whether a packet already passed through it on the master device (xso.dev) and skips processing the skb again on the slave device (xso.real_dev). This check was added in commit [1] to avoid tx packets on a bond device pass through xfrm twice and get two sets of headers, but the check was soon obsoleted by commit [2], which was added around the same time to fix a similar but unrelated problem. Commit [3] set XFRM_XMIT only when packets are hw offloaded. xso.dev is usually equal to xso.real_dev, unless bonding is used, in which case the bonding driver uses xso.real_dev to manage offloaded xfrm states. Since commit [3], the check added in commit [1] is unused on all cases, since packets going through validate_xmit_xfrm twice bail out on the check added in commit [2]. Here's a breakdown of relevant scenarios: 1. ESP offload off: validate_xmit_xfrm returns early on !xo. 2. ESP offload on, no bond: skb->dev == xso.real_dev == xso.dev. 3. ESP offload on, bond, xs on bond dev: 1st pass adds XFRM_XMIT, 2nd pass returns early on XFRM_XMIT. 3. ESP offload on, bond, xs on slave dev: 1st pass returns early on !xo, 2nd pass adds XFRM_XMIT. 4. ESP offload on, bond, xs on both bond AND slave dev: only 1 offload possible in secpath. Either 1st pass adds XFRM_XMIT and 2nd pass returns early on XFRM_XMIT, or 1st pass is sw and returns early on !xo. 6. ESP offload on, crypto fallback triggered in esp_xmit/esp6_xmit: 1st pass does sw crypto & secpath_reset, 2nd pass returns on !xo. This commit removes the unnecessary check, so xso.real_dev becomes what it is in practice: a private field managed by bonding driver. The check immediately below that can be simplified as well. [1] commit 272c233 ("xfrm: bail early on slave pass over skb") [2] commit 94579ac ("xfrm: Fix double ESP trailer insertion in IPsec crypto offload.") [3] commit c7dbf4c ("xfrm: Provide private skb extensions for segmented and hw offloaded ESP packets") Signed-off-by: Cosmin Ratiu <[email protected]> Reviewed-by: Leon Romanovsky <[email protected]> Reviewed-by: Nikolay Aleksandrov <[email protected]> Signed-off-by: Steffen Klassert <[email protected]>
1 parent 25ac138 commit d53dda2

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

net/xfrm/xfrm_device.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,6 @@ struct sk_buff *validate_xmit_xfrm(struct sk_buff *skb, netdev_features_t featur
145145
return NULL;
146146
}
147147

148-
/* This skb was already validated on the upper/virtual dev */
149-
if ((x->xso.dev != dev) && (x->xso.real_dev == dev))
150-
return skb;
151-
152148
local_irq_save(flags);
153149
sd = this_cpu_ptr(&softnet_data);
154150
err = !skb_queue_empty(&sd->xfrm_backlog);
@@ -159,8 +155,7 @@ struct sk_buff *validate_xmit_xfrm(struct sk_buff *skb, netdev_features_t featur
159155
return skb;
160156
}
161157

162-
if (skb_is_gso(skb) && (unlikely(x->xso.dev != dev) ||
163-
unlikely(xmit_xfrm_check_overflow(skb)))) {
158+
if (skb_is_gso(skb) && unlikely(xmit_xfrm_check_overflow(skb))) {
164159
struct sk_buff *segs;
165160

166161
/* Packet got rerouted, fixup features and segment it. */

0 commit comments

Comments
 (0)