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=-0.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED 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 ED68CCA9ECB for ; Thu, 31 Oct 2019 14:13:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B99C520873 for ; Thu, 31 Oct 2019 14:13:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="h43OEy8L" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727841AbfJaONr (ORCPT ); Thu, 31 Oct 2019 10:13:47 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:45218 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726540AbfJaONr (ORCPT ); Thu, 31 Oct 2019 10:13:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572531225; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1JaIAZ4/4WxzbjuKpsBwY8dHaK9iBrR7/hmLOLhE1JQ=; b=h43OEy8LD/ApMj0gSu8lbeAu4lnkEomU69s2eWEXwnXJ/cgND/6DVsMSGV3IA56c+tsfk3 GVjx7h4y4TwovEkKDyBCoQ8Ta8do0mYUuqd+652UZ+/MQLheOcedPsiwi/2AODGucxXVD4 /3fdacNjZhjFQks1lF7Jruq04qOGOjs= Received: from mail-lj1-f200.google.com (mail-lj1-f200.google.com [209.85.208.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-352-mhrzTP9JOMeztKRXTz1sag-1; Thu, 31 Oct 2019 10:13:44 -0400 Received: by mail-lj1-f200.google.com with SMTP id 62so1006634ljj.19 for ; Thu, 31 Oct 2019 07:13:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version:content-transfer-encoding; bh=1JaIAZ4/4WxzbjuKpsBwY8dHaK9iBrR7/hmLOLhE1JQ=; b=qmnpFtkTH7COOcOM9GlqqwZ37Dtg4kHOd3utLJpJH2ilXy+TU+MaM+y+Yvb+6MAnA6 2mCHXVo1UuzJHR7MWBE4x6Tqv8jw3mfgDRLA7xrVxdqt8Ti7YgUrt0w1bo8vkiF88jDq zqmCeTDIeYwyA15ZdcEXeLi8fiTKMMRySvcw1Kdp3Hv2vLKTi8DR1CevYm+jGFCTS6z5 NtSG/XUjr+lv0v/4ZraFHem868KWZ/KtPqb+lnCo9JjyRQGjNdb8N48Kc4Lc/6U71i3j c9uZdasSJjN00OZYrjFjA7wu4OJQ6ZRbgMCcYkTGIEPOWTo0B6RW0d5hGMi06Cc76Lk/ sVBg== X-Gm-Message-State: APjAAAVBHzc8J/qt6DAqtgpDmqapT21IQf7dXNyZlHv50xwe7+UzS8UR RhedGptXg/oIQuXxGZD+9WhNHBSXvw7Oua+gttOMQkkiLftWobTwEJP1mkiOeLDNplz8NGrxbYp 77yOkfSvJMf+1f2HD X-Received: by 2002:a2e:b4ba:: with SMTP id q26mr4370318ljm.60.1572531222984; Thu, 31 Oct 2019 07:13:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqzxcrvUEbp2MzgR0pqTNG+cm0wXiNlrT3g+rQZ0fRCzx7+wgXY1DZttCG8Gk45Btxyv5oO5rQ== X-Received: by 2002:a2e:b4ba:: with SMTP id q26mr4370303ljm.60.1572531222812; Thu, 31 Oct 2019 07:13:42 -0700 (PDT) Received: from alrua-x1.borgediget.toke.dk (borgediget.toke.dk. [85.204.121.218]) by smtp.gmail.com with ESMTPSA id z13sm1364660ljj.34.2019.10.31.07.13.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2019 07:13:42 -0700 (PDT) Received: by alrua-x1.borgediget.toke.dk (Postfix, from userid 1000) id C48C81818B5; Thu, 31 Oct 2019 15:13:40 +0100 (CET) From: Toke =?utf-8?Q?H=C3=B8iland-J=C3=B8rgensen?= To: Alexei Starovoitov , =?utf-8?B?QmrDtnJu?= =?utf-8?B?IFTDtnBlbA==?= Cc: Magnus Karlsson , Magnus Karlsson , =?utf-8?B?QmrDtnJuIFTDtnBlbA==?= , Alexei Starovoitov , Daniel Borkmann , Network Development , Jonathan Lemon , bpf , degeneloy@gmail.com, John Fastabend Subject: Re: [PATCH bpf-next v3] libbpf: fix compatibility for kernels without need_wakeup In-Reply-To: References: <1571995035-21889-1-git-send-email-magnus.karlsson@intel.com> <87tv7qpdbt.fsf@toke.dk> X-Clacks-Overhead: GNU Terry Pratchett Date: Thu, 31 Oct 2019 15:13:40 +0100 Message-ID: <87lft1ngtn.fsf@toke.dk> MIME-Version: 1.0 X-MC-Unique: mhrzTP9JOMeztKRXTz1sag-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Alexei Starovoitov writes: > On Thu, Oct 31, 2019 at 1:03 AM Bj=C3=B6rn T=C3=B6pel wrote: >> >> On Thu, 31 Oct 2019 at 08:17, Magnus Karlsson wrote: >> > >> > On Wed, Oct 30, 2019 at 2:36 PM Toke H=C3=B8iland-J=C3=B8rgensen wrote: >> > > >> > > Magnus Karlsson writes: >> > > >> > > > When the need_wakeup flag was added to AF_XDP, the format of the >> > > > XDP_MMAP_OFFSETS getsockopt was extended. Code was added to the >> > > > kernel to take care of compatibility issues arrising from running >> > > > applications using any of the two formats. However, libbpf was >> > > > not extended to take care of the case when the application/libbpf >> > > > uses the new format but the kernel only supports the old >> > > > format. This patch adds support in libbpf for parsing the old >> > > > format, before the need_wakeup flag was added, and emulating a >> > > > set of static need_wakeup flags that will always work for the >> > > > application. >> > > >> > > Hi Magnus >> > > >> > > While you're looking at backwards compatibility issues with xsk: lib= bpf >> > > currently fails to compile on a system that has old kernel headers >> > > installed (this is with kernel-headers 5.3): >> > > >> > > $ echo "#include " | gcc -x c - >> > > In file included from :1: >> > > /usr/include/bpf/xsk.h: In function =E2=80=98xsk_ring_prod__needs_wa= keup=E2=80=99: >> > > /usr/include/bpf/xsk.h:82:21: error: =E2=80=98XDP_RING_NEED_WAKEUP= =E2=80=99 undeclared (first use in this function) >> > > 82 | return *r->flags & XDP_RING_NEED_WAKEUP; >> > > | ^~~~~~~~~~~~~~~~~~~~ >> > > /usr/include/bpf/xsk.h:82:21: note: each undeclared identifier is re= ported only once for each function it appears in >> > > /usr/include/bpf/xsk.h: In function =E2=80=98xsk_umem__extract_addr= =E2=80=99: >> > > /usr/include/bpf/xsk.h:173:16: error: =E2=80=98XSK_UNALIGNED_BUF_ADD= R_MASK=E2=80=99 undeclared (first use in this function) >> > > 173 | return addr & XSK_UNALIGNED_BUF_ADDR_MASK; >> > > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ >> > > /usr/include/bpf/xsk.h: In function =E2=80=98xsk_umem__extract_offse= t=E2=80=99: >> > > /usr/include/bpf/xsk.h:178:17: error: =E2=80=98XSK_UNALIGNED_BUF_OFF= SET_SHIFT=E2=80=99 undeclared (first use in this function) >> > > 178 | return addr >> XSK_UNALIGNED_BUF_OFFSET_SHIFT; >> > > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> > > >> > > >> > > >> > > How would you prefer to handle this? A patch like the one below will= fix >> > > the compile errors, but I'm not sure it makes sense semantically? >> > >> > Thanks Toke for finding this. Of course it should be possible to >> > compile this on an older kernel, but without getting any of the newer >> > functionality that is not present in that older kernel. >> >> Is the plan to support source compatibility for the headers only, or >> the whole the libbpf itself? Is the usecase here, that you've built >> libbpf.so with system headers X, and then would like to use the >> library on a system with older system headers X~10? XDP sockets? BTF? > > libbpf has to be backward and forward compatible. > Once compiled it has to run on older and newer kernels. > Conditional compilation is not an option obviously. So what do we do, then? Redefine the constants in libbpf/xsh.h if they're not in the kernel header file? -Toke