* [PATCH bpf-next] selftests/bpf: use __bpf_constant_htons in test_prog.c for flow dissector
@ 2019-02-27 19:15 Stanislav Fomichev
2019-02-27 21:27 ` Song Liu
2019-02-28 23:58 ` Daniel Borkmann
0 siblings, 2 replies; 3+ messages in thread
From: Stanislav Fomichev @ 2019-02-27 19:15 UTC (permalink / raw)
To: netdev, bpf; +Cc: davem, ast, daniel, Stanislav Fomichev
Older GCC (<4.8) isn't smart enough to optimize !__builtin_constant_p()
branch in bpf_htons.
I recently fixed it for pkt_v4 and pkt_v6 in commit a0517a0f7ef23
("selftests/bpf: use __bpf_constant_htons in test_prog.c"), but later
added another bunch of bpf_htons in commit bf0f0fd939451 ("selftests/bpf:
add simple BPF_PROG_TEST_RUN examples for flow dissector").
Fixes: bf0f0fd939451 ("selftests/bpf: add simple BPF_PROG_TEST_RUN examples for flow dissector")
Signed-off-by: Stanislav Fomichev <sdf@google.com>
---
tools/testing/selftests/bpf/test_progs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c
index c59d2e015d16..87cde42559f7 100644
--- a/tools/testing/selftests/bpf/test_progs.c
+++ b/tools/testing/selftests/bpf/test_progs.c
@@ -1954,7 +1954,7 @@ static struct bpf_flow_keys pkt_v4_flow_keys = {
.thoff = sizeof(struct iphdr),
.addr_proto = ETH_P_IP,
.ip_proto = IPPROTO_TCP,
- .n_proto = bpf_htons(ETH_P_IP),
+ .n_proto = __bpf_constant_htons(ETH_P_IP),
};
static struct bpf_flow_keys pkt_v6_flow_keys = {
@@ -1962,7 +1962,7 @@ static struct bpf_flow_keys pkt_v6_flow_keys = {
.thoff = sizeof(struct ipv6hdr),
.addr_proto = ETH_P_IPV6,
.ip_proto = IPPROTO_TCP,
- .n_proto = bpf_htons(ETH_P_IPV6),
+ .n_proto = __bpf_constant_htons(ETH_P_IPV6),
};
static void test_flow_dissector(void)
--
2.21.0.rc2.261.ga7da99ff1b-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH bpf-next] selftests/bpf: use __bpf_constant_htons in test_prog.c for flow dissector
2019-02-27 19:15 [PATCH bpf-next] selftests/bpf: use __bpf_constant_htons in test_prog.c for flow dissector Stanislav Fomichev
@ 2019-02-27 21:27 ` Song Liu
2019-02-28 23:58 ` Daniel Borkmann
1 sibling, 0 replies; 3+ messages in thread
From: Song Liu @ 2019-02-27 21:27 UTC (permalink / raw)
To: Stanislav Fomichev
Cc: Networking, bpf, David S . Miller, Alexei Starovoitov, Daniel Borkmann
On Wed, Feb 27, 2019 at 11:16 AM Stanislav Fomichev <sdf@google.com> wrote:
>
> Older GCC (<4.8) isn't smart enough to optimize !__builtin_constant_p()
> branch in bpf_htons.
>
> I recently fixed it for pkt_v4 and pkt_v6 in commit a0517a0f7ef23
> ("selftests/bpf: use __bpf_constant_htons in test_prog.c"), but later
> added another bunch of bpf_htons in commit bf0f0fd939451 ("selftests/bpf:
> add simple BPF_PROG_TEST_RUN examples for flow dissector").
>
> Fixes: bf0f0fd939451 ("selftests/bpf: add simple BPF_PROG_TEST_RUN examples for flow dissector")
>
> Signed-off-by: Stanislav Fomichev <sdf@google.com>
Acked-by: Song Liu <songliubraving@fb.com>
> ---
> tools/testing/selftests/bpf/test_progs.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c
> index c59d2e015d16..87cde42559f7 100644
> --- a/tools/testing/selftests/bpf/test_progs.c
> +++ b/tools/testing/selftests/bpf/test_progs.c
> @@ -1954,7 +1954,7 @@ static struct bpf_flow_keys pkt_v4_flow_keys = {
> .thoff = sizeof(struct iphdr),
> .addr_proto = ETH_P_IP,
> .ip_proto = IPPROTO_TCP,
> - .n_proto = bpf_htons(ETH_P_IP),
> + .n_proto = __bpf_constant_htons(ETH_P_IP),
> };
>
> static struct bpf_flow_keys pkt_v6_flow_keys = {
> @@ -1962,7 +1962,7 @@ static struct bpf_flow_keys pkt_v6_flow_keys = {
> .thoff = sizeof(struct ipv6hdr),
> .addr_proto = ETH_P_IPV6,
> .ip_proto = IPPROTO_TCP,
> - .n_proto = bpf_htons(ETH_P_IPV6),
> + .n_proto = __bpf_constant_htons(ETH_P_IPV6),
> };
>
> static void test_flow_dissector(void)
> --
> 2.21.0.rc2.261.ga7da99ff1b-goog
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH bpf-next] selftests/bpf: use __bpf_constant_htons in test_prog.c for flow dissector
2019-02-27 19:15 [PATCH bpf-next] selftests/bpf: use __bpf_constant_htons in test_prog.c for flow dissector Stanislav Fomichev
2019-02-27 21:27 ` Song Liu
@ 2019-02-28 23:58 ` Daniel Borkmann
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Borkmann @ 2019-02-28 23:58 UTC (permalink / raw)
To: Stanislav Fomichev, netdev, bpf; +Cc: davem, ast
On 02/27/2019 08:15 PM, Stanislav Fomichev wrote:
> Older GCC (<4.8) isn't smart enough to optimize !__builtin_constant_p()
> branch in bpf_htons.
>
> I recently fixed it for pkt_v4 and pkt_v6 in commit a0517a0f7ef23
> ("selftests/bpf: use __bpf_constant_htons in test_prog.c"), but later
> added another bunch of bpf_htons in commit bf0f0fd939451 ("selftests/bpf:
> add simple BPF_PROG_TEST_RUN examples for flow dissector").
>
> Fixes: bf0f0fd939451 ("selftests/bpf: add simple BPF_PROG_TEST_RUN examples for flow dissector")
>
> Signed-off-by: Stanislav Fomichev <sdf@google.com>
Applied, thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-02-28 23:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-27 19:15 [PATCH bpf-next] selftests/bpf: use __bpf_constant_htons in test_prog.c for flow dissector Stanislav Fomichev
2019-02-27 21:27 ` Song Liu
2019-02-28 23:58 ` Daniel Borkmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).