Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3631656imu; Mon, 28 Jan 2019 08:08:41 -0800 (PST) X-Google-Smtp-Source: ALg8bN58MVOAVJsrKhuMN1dK6rhqbia9n4ombNJdEXjLdz0bzvKhQW4hlU6BDNcmMdDUkBUeaia5 X-Received: by 2002:a17:902:6a8c:: with SMTP id n12mr22494376plk.85.1548691721299; Mon, 28 Jan 2019 08:08:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548691721; cv=none; d=google.com; s=arc-20160816; b=E/2IRGBRH3ha3gLAtwi3i3EYeC2nTSGS++IUzwi67JgBMa1ynrMLZH6if593a7PeSS ghKPVGcMD3rYhZh3WWhIn+zqxWMz1v9Wwbch2XiiPRlY+LP36BQDN4Y8CzkA3S6EPedc ACtnq8fgJ3x7vaVgXq9v9oYQNo11L9WXitjQQCa/60o/Z8BqYz17DdPY5dQoclfDONve kitIw2tih3ZoQt4I9OLnn6g6yo8KkVv02cilAJ6rZ3stwYzqz2eJAWIKYMP+cbFByOIn NleEggSoicw3Mo4F0lKU96fNFuKnsTxK1YmybLCQf4Y5R+6yjas9QWR938nE4wQqytbL zd4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=AE+hZvbm3gEHI7pXQdHfE7PSjSQqBLsLMTnrgP/fcg0=; b=XrofYyyi8P3hNS8MLP0JcczHHuQTJhivdXevPFt0LGLH7+qVBnMi8Gw6Q2a3p6EsBp pgmwB5pZ3fgz3HL1PJvm4D+s29lSK8LniVfOoIc52refv4P57pY38E8yBC7s0j9TcFsU TuyKn6hSxsxZry0fG/OPkiaiQzhUZA44J8sPq+4iGtiNc+ErwtfS50lHSAvX1zpKxoDA ByTmrDjw2jMYJQc2Ot21e9IQWg1+UiKgik9XIswVW0s+1agbxsGRQr5ej3LiClIBATpn WMNadS5o1swGvL8EOUnOhkJ7R5L+lfEllPFHHeoqdePeZPFz0dK35JxKy4XmYeC8Yyz8 j1Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SzLjUxEs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 86si3792316pfl.46.2019.01.28.08.08.26; Mon, 28 Jan 2019 08:08:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SzLjUxEs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732004AbfA1QGQ (ORCPT + 99 others); Mon, 28 Jan 2019 11:06:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:54498 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731969AbfA1QGL (ORCPT ); Mon, 28 Jan 2019 11:06:11 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 533D620989; Mon, 28 Jan 2019 16:06:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691570; bh=TX2RVyBpNtJhgxBzPH4bVXlcdgCrdL+sNEHjEdklIHM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SzLjUxEsnW2+O47copvfaD6p4z29J3VbWAR4iE6o3FUgrnRlNeEgEbI329N4p172+ yMHOIn9T1eogZSL6Ep3MPKnyA78pCidO4gf3VWsxm+HSXu3LBphcPW0SlMQqVxav3C jvCfFHaTRR7ccTgPMhDV3d/tkU4RM0OepwwPDoXk= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Stanislav Fomichev , Daniel Borkmann , Alexei Starovoitov , Sasha Levin , netdev@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 146/258] selftests/bpf: use __bpf_constant_htons in test_prog.c Date: Mon, 28 Jan 2019 10:57:32 -0500 Message-Id: <20190128155924.51521-146-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128155924.51521-1-sashal@kernel.org> References: <20190128155924.51521-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stanislav Fomichev [ 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