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=-4.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=no 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 5C0A4C433E1 for ; Tue, 30 Jun 2020 15:21:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2B6222074F for ; Tue, 30 Jun 2020 15:21:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=fb.com header.i=@fb.com header.b="WMy7ktzc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389352AbgF3PVk (ORCPT ); Tue, 30 Jun 2020 11:21:40 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:1148 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389334AbgF3PVj (ORCPT ); Tue, 30 Jun 2020 11:21:39 -0400 Received: from pps.filterd (m0044012.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 05UFKi5k020568 for ; Tue, 30 Jun 2020 08:21:38 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=facebook; bh=79DW+AY1pvpDA6CMc72gmYJEflgUxY5S4rkR/g9Qhas=; b=WMy7ktzcfzaozsVAQlMjfG4JBj7TvBWSsSv+G03F8tvqlVi73yOIK2jlFpQMECRXDku4 p3aM+A+2toVN6T/kP7/sq0S9KBKFl6nuumNkY1BDFpT8kfrOUU7SBEWGNWoo3zbg0d9W JuIGdA0TG5O1U+Z49RTenKuua2y5RxIG54U= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com with ESMTP id 31xpcntav6-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Tue, 30 Jun 2020 08:21:38 -0700 Received: from intmgw004.03.ash8.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:82::f) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Tue, 30 Jun 2020 08:21:34 -0700 Received: by devbig012.ftw2.facebook.com (Postfix, from userid 137359) id 4E72C2EC2FB6; Tue, 30 Jun 2020 08:21:28 -0700 (PDT) Smtp-Origin-Hostprefix: devbig From: Andrii Nakryiko Smtp-Origin-Hostname: devbig012.ftw2.facebook.com To: , , , CC: , , Andrii Nakryiko Smtp-Origin-Cluster: ftw2c04 Subject: [PATCH v3 bpf-next 0/2] Make bpf_endian.h compatible with vmlinux.h Date: Tue, 30 Jun 2020 08:21:23 -0700 Message-ID: <20200630152125.3631920-1-andriin@fb.com> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-FB-Internal: Safe Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-06-30_06:2020-06-30,2020-06-30 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 phishscore=0 mlxscore=0 lowpriorityscore=0 clxscore=1015 malwarescore=0 spamscore=0 impostorscore=0 bulkscore=0 cotscore=-2147483648 suspectscore=8 priorityscore=1501 mlxlogscore=630 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006300112 X-FB-Internal: deliver Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Change libbpf's bpf_endian.h header to be compatible when used with syste= m headers and when using just vmlinux.h. This is a frequent request for use= rs writing BPF CO-RE applications. Do this by re-implementing byte swap compile-time macros. Also add simple tests validating correct results bot= h for byte-swapping built-ins and macros. v2->v3: - explicit zero-initialization of global variables (Daniel); v1->v2: - reimplement byte swapping macros (Alexei). Andrii Nakryiko (2): libbpf: make bpf_endian co-exist with vmlinux.h selftests/bpf: add byte swapping selftest tools/lib/bpf/bpf_endian.h | 43 ++++++++++++--- .../testing/selftests/bpf/prog_tests/endian.c | 53 +++++++++++++++++++ .../testing/selftests/bpf/progs/test_endian.c | 37 +++++++++++++ 3 files changed, 125 insertions(+), 8 deletions(-) create mode 100644 tools/testing/selftests/bpf/prog_tests/endian.c create mode 100644 tools/testing/selftests/bpf/progs/test_endian.c --=20 2.24.1