• E
    xfrm: fix disable_xfrm sysctl when used on xfrm interfaces · 2aa7cdb6
    Eyal Birger 提交于
    stable inclusion
    from stable-5.10.13
    commit 2f7ecc841daac6394bdd9b3bea69a87c25226c50
    bugzilla: 47995
    
    --------------------------------
    
    [ Upstream commit 9f8550e4 ]
    
    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: f203b76d ("xfrm: Add virtual xfrm interfaces")
    Signed-off-by: NEyal Birger <eyal.birger@gmail.com>
    Signed-off-by: NSteffen Klassert <steffen.klassert@secunet.com>
    Signed-off-by: NSasha Levin <sashal@kernel.org>
    Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
    Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
    2aa7cdb6
xfrm_policy.c 106.1 KB