• P
    selftests: xfrm: fix test return value override issue in xfrm_policy.sh · 28b30d4b
    Po-Hsu Lin 提交于
    stable inclusion
    from stable-5.10.13
    commit 8ea899803bb5c9d3cfb60d75d0c40f68f8227abe
    bugzilla: 47995
    
    --------------------------------
    
    [ Upstream commit f6e9ceb7 ]
    
    When running this xfrm_policy.sh test script, even with some cases
    marked as FAIL, the overall test result will still be PASS:
    
    $ sudo ./xfrm_policy.sh
    PASS: policy before exception matches
    FAIL: expected ping to .254 to fail (exceptions)
    PASS: direct policy matches (exceptions)
    PASS: policy matches (exceptions)
    FAIL: expected ping to .254 to fail (exceptions and block policies)
    PASS: direct policy matches (exceptions and block policies)
    PASS: policy matches (exceptions and block policies)
    FAIL: expected ping to .254 to fail (exceptions and block policies after hresh changes)
    PASS: direct policy matches (exceptions and block policies after hresh changes)
    PASS: policy matches (exceptions and block policies after hresh changes)
    FAIL: expected ping to .254 to fail (exceptions and block policies after hthresh change in ns3)
    PASS: direct policy matches (exceptions and block policies after hthresh change in ns3)
    PASS: policy matches (exceptions and block policies after hthresh change in ns3)
    FAIL: expected ping to .254 to fail (exceptions and block policies after htresh change to normal)
    PASS: direct policy matches (exceptions and block policies after htresh change to normal)
    PASS: policy matches (exceptions and block policies after htresh change to normal)
    PASS: policies with repeated htresh change
    $ echo $?
    0
    
    This is because the $lret in check_xfrm() is not a local variable.
    Therefore when a test failed in check_exceptions(), the non-zero $lret
    will later get reset to 0 when the next test calls check_xfrm().
    
    With this fix, the final return value will be 1. Make it easier for
    testers to spot this failure.
    
    Fixes: 39aa6928 ("xfrm: policy: fix netlink/pf_key policy lookups")
    Signed-off-by: NPo-Hsu Lin <po-hsu.lin@canonical.com>
    Acked-by: NFlorian Westphal <fw@strlen.de>
    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>
    28b30d4b
xfrm_policy.sh 13.3 KB