]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
selftests/bpf: use __bpf_constant_htons in test_prog.c
authorStanislav Fomichev <sdf@google.com>
Wed, 12 Dec 2018 03:20:52 +0000 (19:20 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 12 Feb 2019 19:02:19 +0000 (20:02 +0100)
commit7d8fa6594beb07955cc473c069b764a1fbe8e897
tree8f5e5580e6fb7a44176ad3d4df902148994f0711
parent4d604c6f3e39558418e9090ea2a1c73fbba0800d
selftests/bpf: use __bpf_constant_htons in test_prog.c

[ Upstream commit a0517a0f7ef23550b4484c37e2b9c2d32abebf64 ]

For some reason, my older GCC (< 4.8) isn't smart enough to optimize the
!__builtin_constant_p() branch in bpf_htons, I see:
  error: implicit declaration of function '__builtin_bswap16'

Let's use __bpf_constant_htons as suggested by Daniel Borkmann.

I tried to use simple htons, but it produces the following:
  test_progs.c:54:17: error: braced-group within expression allowed only
  inside a function
    .eth.h_proto = htons(ETH_P_IP),

Signed-off-by: Stanislav Fomichev <sdf@google.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/testing/selftests/bpf/test_progs.c