From: Stanislav Fomichev Subject: [PATCH bpf-next] selftests/bpf: don't use bpf helpers in non-bpf environment Date: Tue, 11 Dec 2018 13:28:07 -0800 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Cc: davem@davemloft.net, ast@kernel.org, daniel@iogearbox.net, Stanislav Fomichev To: netdev@vger.kernel.org Return-path: Received: from mail-pf1-f201.google.com ([209.85.210.201]:33112 "EHLO mail-pf1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726136AbeLKV2Q (ORCPT ); Tue, 11 Dec 2018 16:28:16 -0500 Received: by mail-pf1-f201.google.com with SMTP id d18so13720261pfe.0 for ; Tue, 11 Dec 2018 13:28:15 -0800 (PST) Sender: netdev-owner@vger.kernel.org List-ID: We're using bpf_htons in test_progs.c to initialize some static global data and I think I hit some weird case on an older compiler which doesn't have __builtin_bswap16 (and __builtin_constant_p expands to false). In this case I see: error: implicit declaration of function '__builtin_bswap16' Let's explicitly use __constant_htons which should be exposed by the linux/byteorder.h uapi header. Signed-off-by: Stanislav Fomichev --- tools/testing/selftests/bpf/test_progs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c index 26f1fdf3e2bf..61593d319c0e 100644 --- a/tools/testing/selftests/bpf/test_progs.c +++ b/tools/testing/selftests/bpf/test_progs.c @@ -51,10 +51,10 @@ static struct { struct iphdr iph; struct tcphdr tcp; } __packed pkt_v4 = { - .eth.h_proto = bpf_htons(ETH_P_IP), + .eth.h_proto = __constant_htons(ETH_P_IP), .iph.ihl = 5, .iph.protocol = 6, - .iph.tot_len = bpf_htons(MAGIC_BYTES), + .iph.tot_len = __constant_htons(MAGIC_BYTES), .tcp.urg_ptr = 123, }; @@ -64,9 +64,9 @@ static struct { struct ipv6hdr iph; struct tcphdr tcp; } __packed pkt_v6 = { - .eth.h_proto = bpf_htons(ETH_P_IPV6), + .eth.h_proto = __constant_htons(ETH_P_IPV6), .iph.nexthdr = 6, - .iph.payload_len = bpf_htons(MAGIC_BYTES), + .iph.payload_len = __constant_htons(MAGIC_BYTES), .tcp.urg_ptr = 123, }; -- 2.20.0.rc2.403.gdbc3b29805-goog