Skip to content

Commit 9f8550e

Browse files
ebirgerklassert
authored andcommitted
xfrm: fix disable_xfrm sysctl when used on xfrm interfaces
The disable_xfrm flag signals that xfrm should not be performed during routing towards a device before reaching device xmit. For xfrm interfaces this is usually desired as they perform the outbound policy lookup as part of their xmit using their if_id. Before this change enabling this flag on xfrm interfaces prevented them from xmitting as xfrm_lookup_with_ifid() would not perform a policy lookup in case the original dst had the DST_NOXFRM flag. This optimization is incorrect when the lookup is done by the xfrm interface xmit logic. Fix by performing policy lookup when invoked by xfrmi as if_id != 0. Similarly it's unlikely for the 'no policy exists on net' check to yield any performance benefits when invoked from xfrmi. Fixes: f203b76 ("xfrm: Add virtual xfrm interfaces") Signed-off-by: Eyal Birger <[email protected]> Signed-off-by: Steffen Klassert <[email protected]>
1 parent 56ce7c2 commit 9f8550e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

net/xfrm/xfrm_policy.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3078,8 +3078,8 @@ struct dst_entry *xfrm_lookup_with_ifid(struct net *net,
30783078
xflo.flags = flags;
30793079

30803080
/* To accelerate a bit... */
3081-
if ((dst_orig->flags & DST_NOXFRM) ||
3082-
!net->xfrm.policy_count[XFRM_POLICY_OUT])
3081+
if (!if_id && ((dst_orig->flags & DST_NOXFRM) ||
3082+
!net->xfrm.policy_count[XFRM_POLICY_OUT]))
30833083
goto nopol;
30843084

30853085
xdst = xfrm_bundle_lookup(net, fl, family, dir, &xflo, if_id);

0 commit comments

Comments
 (0)