From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA678C282CE for ; Mon, 11 Feb 2019 15:44:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B8C1A222A7 for ; Mon, 11 Feb 2019 15:44:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549899848; bh=sodv/Vs/XZuBYXfrjz6HBZiBNnu1N7cn5xPD/BI6kxc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=wAFeljgNyIaWmpZcfCk9s/QWrb3F7BnfGLq6hlrhe7uTolQdbVKBOr9BEb14uRu8A as6gZj8vmRa/9TwSQ0BSftkV8Ad1H6eFTtpPeBoxyyDrrv8wc94UnBiOMpZTHuOBZL zrYoAQOY15e1kDeewJKPB8pH3gP06DZCzR7wjbfM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728296AbfBKPoC (ORCPT ); Mon, 11 Feb 2019 10:44:02 -0500 Received: from mail.kernel.org ([198.145.29.99]:57830 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732929AbfBKOo5 (ORCPT ); Mon, 11 Feb 2019 09:44:57 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E7C49206BA; Mon, 11 Feb 2019 14:44:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549896297; bh=sodv/Vs/XZuBYXfrjz6HBZiBNnu1N7cn5xPD/BI6kxc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sak5sob3q3XrSGrxtmQCsa75s7KrivzDZPR5RJ7jXdOtTW6945WqID2oNBIrUFvi8 BnOkxjDWLsG+er4GpDcVkXfYEFii7YZzsoPrYhxg1HqKJz7sFNl2anr14sFGfm2SBW wT8dvzSpAICVsCyV1gO0EqoaQPnHvzyWY8ofxoEI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stanislav Fomichev , Daniel Borkmann , Alexei Starovoitov , Sasha Levin Subject: [PATCH 4.19 138/313] selftests/bpf: use __bpf_constant_htons in test_prog.c Date: Mon, 11 Feb 2019 15:16:58 +0100 Message-Id: <20190211141902.891665954@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141852.749630980@linuxfoundation.org> References: <20190211141852.749630980@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ [ 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 Signed-off-by: Daniel Borkmann Signed-off-by: Alexei Starovoitov Signed-off-by: Sasha Levin --- 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 0ef68204c84b..d029cad08cbd 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 = __bpf_constant_htons(ETH_P_IP), .iph.ihl = 5, .iph.protocol = 6, - .iph.tot_len = bpf_htons(MAGIC_BYTES), + .iph.tot_len = __bpf_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 = __bpf_constant_htons(ETH_P_IPV6), .iph.nexthdr = 6, - .iph.payload_len = bpf_htons(MAGIC_BYTES), + .iph.payload_len = __bpf_constant_htons(MAGIC_BYTES), .tcp.urg_ptr = 123, }; -- 2.19.1