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,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 32288CA9ECB for ; Thu, 31 Oct 2019 15:17:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EFDBB208C0 for ; Thu, 31 Oct 2019 15:17:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hLqr4Q1A" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727860AbfJaPR6 (ORCPT ); Thu, 31 Oct 2019 11:17:58 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:41678 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727721AbfJaPR6 (ORCPT ); Thu, 31 Oct 2019 11:17:58 -0400 Received: by mail-lj1-f193.google.com with SMTP id m9so7024405ljh.8; Thu, 31 Oct 2019 08:17:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=aDV+4dVJ1sP6YX3kX7oHsVxJ6a46KhnxSb+MYBaqp04=; b=hLqr4Q1ANgkj6MJS9bwmtAapdhj4C1XFb7DHs66vbUXQMdfTpPukg2zLcILv9Ghlmz xOTb0zf3M1omfIfY8YRZGF+GeY8HwQ2HrmOGwTL9FnYho2Uu7V5NyNph7+39dPak+6Pk LHbCGaey8kajrUPRK8lqVsyL+qicKEzSXUXpr+MMAwZi12SWM1fu0sjeRL706F2y8Q2d R6GSUm/eUGz/DToNPyYZ6l0sbRkKp0RiiuNxMyJ3ahl9vhzpEpV3QUQz5GT3CjiEbaUQ +XgD428T/DqlMb8MyZ4ijrOcaF2wTERIjfpb3eWKGBhJfeRq7IAyAWEi9fB/QK/4DTug KfwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=aDV+4dVJ1sP6YX3kX7oHsVxJ6a46KhnxSb+MYBaqp04=; b=XQR3vxrb9b1n8g7g4u04pk96g4YRXMFX4wN+vHL7Rx4nzeyeD/53eZ/2JfNGUyNmDx OTX7e7ZMfaVEzVjHFKQIydVSkBZ/UXIKjdns4gnINP5jXpD+aEQo56IRAnmySaCHgoVs I/wePeEfE46mSdpwS+8TLP9liY25Po7sBm1Jq2IqMdq23HcajuCGsMX5BpCXdJ9GpxRh Xed+pRxMkn19pMwNGKKeWhMCG1oPh4UsTl2uBPWy+Jcch+dO1Fo5mL1rmptg2jQzdozo cX/387YWUXbbcGXj+qf+yhRixDUZwq9tz8137/SxZ72qRT+TPcPEhvQE1CtHXG/on28g +tZw== X-Gm-Message-State: APjAAAXHNiVJ+L0yVVn7q12x1eGa77uEiN8v8LJOko6p6IvVKFxcOpxs 1Hdu4MkoLgmqrEXkin7il7+z+wAecV6whHeGZsY= X-Google-Smtp-Source: APXvYqy5RIvfHE3UDUVeKeZ4z2D8030osC0mTO6G77wHdu7xFSrg2dhSbIH0O6SKu9YJWiHete5UWppeUhGjozLxk3I= X-Received: by 2002:a2e:2e10:: with SMTP id u16mr769733lju.51.1572535074533; Thu, 31 Oct 2019 08:17:54 -0700 (PDT) MIME-Version: 1.0 References: <1571995035-21889-1-git-send-email-magnus.karlsson@intel.com> <87tv7qpdbt.fsf@toke.dk> <87lft1ngtn.fsf@toke.dk> <87imo5ng7w.fsf@toke.dk> <87d0ednf0t.fsf@toke.dk> In-Reply-To: <87d0ednf0t.fsf@toke.dk> From: Alexei Starovoitov Date: Thu, 31 Oct 2019 08:17:43 -0700 Message-ID: Subject: Re: [PATCH bpf-next v3] libbpf: fix compatibility for kernels without need_wakeup To: =?UTF-8?B?VG9rZSBIw7hpbGFuZC1Kw7hyZ2Vuc2Vu?= Cc: =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= , Magnus Karlsson , Magnus Karlsson , =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= , Alexei Starovoitov , Daniel Borkmann , Network Development , Jonathan Lemon , bpf , degeneloy@gmail.com, John Fastabend Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: bpf-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On Thu, Oct 31, 2019 at 7:52 AM Toke H=C3=B8iland-J=C3=B8rgensen wrote: > > Alexei Starovoitov writes: > > > On Thu, Oct 31, 2019 at 7:26 AM Toke H=C3=B8iland-J=C3=B8rgensen wrote: > >> > >> Alexei Starovoitov writes: > >> > >> > On Thu, Oct 31, 2019 at 7:13 AM Toke H=C3=B8iland-J=C3=B8rgensen wrote: > >> >> > >> >> 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=B8rgens= en 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 t= o 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 emulati= ng 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: libbpf > >> >> >> > > currently fails to compile on a system that has old kernel h= eaders > >> >> >> > > 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_wakeup=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 identifi= er is reported only once for each function it appears in > >> >> >> > > /usr/include/bpf/xsk.h: In function =E2=80=98xsk_umem__extra= ct_addr=E2=80=99: > >> >> >> > > /usr/include/bpf/xsk.h:173:16: error: =E2=80=98XSK_UNALIGNED= _BUF_ADDR_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__extra= ct_offset=E2=80=99: > >> >> >> > > /usr/include/bpf/xsk.h:178:17: error: =E2=80=98XSK_UNALIGNED= _BUF_OFFSET_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 be= low will fix > >> >> >> > > the compile errors, but I'm not sure it makes sense semantic= ally? > >> >> >> > > >> >> >> > Thanks Toke for finding this. Of course it should be possible = to > >> >> >> > compile this on an older kernel, but without getting any of th= e 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 bu= ilt > >> >> >> 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? > >> > > >> > why? How and whom it will help? > >> > To libbpf.rpm creating person or to end user? > >> > >> Anyone who tries to compile a new libbpf against an older kernel. You'= re > >> saying yourself that "libbpf has to be backward and forward compatible= ". > >> Surely that extends to compile time as well as runtime? > > > > how old that older kernel? > > Does it have up-to-date bpf.h in /usr/include ? > > Also consider that running kernel is often not the same > > thing as installed in /usr/include > > vmlinux and /usr/include are different packages. > > In this case, it's a constant introduced in the kernel in the current > (5.4) cycle; so currently, you can't compile libbpf with > kernel-headers-5.3. And we're discussing how to handle this in a > backwards compatible way in libbpf... you simply don't. It's not a problem to begin with.