Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp2271361pxm; Fri, 4 Mar 2022 12:48:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJxOm3sNkvwcV8+y5OpQGrCZYY97dE/a0pOHjKO1qfkDg7uH28WhkLLSUl5HEov5pzGM8Kc8 X-Received: by 2002:a63:8742:0:b0:37c:94b7:4fba with SMTP id i63-20020a638742000000b0037c94b74fbamr160601pge.507.1646426906507; Fri, 04 Mar 2022 12:48:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646426906; cv=none; d=google.com; s=arc-20160816; b=ecmYTe6WJ3DjvqhDyYrsZM69tPuJX5Gi7B3BPe7jod/skhpIYkS/8OKw8aMs2mgcxm fvEay9Cu6ttyLmUKWmafmdBJtusq9PqHorGukc7donOPTjMT8tkzeGPU3qxdKqbksaa8 AfNJDvV/orPI1bpUr16PyguXdm7EiyZiUcZsXM03xKVk2R+o0n3/1nmTATV4g9z9QTNY gCgn0sWhwohVMylHMzO6gJqMyEg5SqIAn/RDld4w4XqXo8m/xzg3f/nXUOXaactRhpiX YqCjYRaCd7bpAW7I8vlo/nPLUAL6AxqsYL0yC0sPd0efbs0w0HC4aCBaawJwBKIsMf+S LE+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=tMObxS5tQRpIXhdLuaKHnJPSIqtS75Y/Ea33zVnrFrA=; b=C5x6lrhCyUvKb9J9J/MSmXdarPB+DdmP8M7Gt7NffqfSuMnEdMn+XHLRpnf6qHZFbB fAuGN4GHHbR8N63dnhKxhNEm7BionJSX+uRmdbRqQFxurLoU9OSNRfXAzzlR+O9qY6HT k5Czj3H7YHrA+YKRaGqiHU288fS4TxIa6AarV6ymIfx7V+H/sMv/tLbmaLaG78KE0iFo b6iUv5y4ix5FFocme/+BngKlDI0muJWPjiF9CfYShw0/Xk0zX/7gpvzoLRl87yOz2ZNW vqSPMv9kljAHg2dw+8uamkRPt6RNJpA+LYMeZK8qmFB/fkT6dcdXnpm+0AVtlKcdcKGR Yz1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=mZ5QM5j8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id md4-20020a17090b23c400b001bd14e030b8si431711pjb.144.2022.03.04.12.48.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 12:48:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=mZ5QM5j8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E1A6A2FA6B5; Fri, 4 Mar 2022 11:49:22 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231391AbiCDTC0 (ORCPT + 99 others); Fri, 4 Mar 2022 14:02:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229447AbiCDTCZ (ORCPT ); Fri, 4 Mar 2022 14:02:25 -0500 Received: from mail-il1-x12f.google.com (mail-il1-x12f.google.com [IPv6:2607:f8b0:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CB811DCCD4; Fri, 4 Mar 2022 11:01:37 -0800 (PST) Received: by mail-il1-x12f.google.com with SMTP id h3so1837782ila.3; Fri, 04 Mar 2022 11:01:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=tMObxS5tQRpIXhdLuaKHnJPSIqtS75Y/Ea33zVnrFrA=; b=mZ5QM5j86JbxeNUsctNPJs2h5GM3K2Dw9kts6l+FcBUQZ3Qy0g3dP158Z7pNgMtVAM uvcWl5dyCZzSiwI1UZFPLKbclf+afc8fUxvXgF8blVMmGvkU/8cRPkElhhDBoe9bBG34 MvxsaAzYXvBLIquu0/jyTf9DCeQmDK+8QuPe+6/NYQUUvAFciOA39l2vh6HjXltzl4lP 5HjFIleTs9dPvHzCfnjgKjPjzphUsnmmwFFsChv/xS+74xNUUWS+TtpozWUgv60qyYUD Rax4zk+DMvIYJWfsH5JBVgn3L/eyxGJHAAFSFEZq7fbcMKH02LLpC3wboyjO3qKl3HPY nWEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=tMObxS5tQRpIXhdLuaKHnJPSIqtS75Y/Ea33zVnrFrA=; b=o9ZGsKhIQkgGxttC+iC+y5g2LL7sUZwiMeI/ESTHZcirhxjlRfEBo5ftImDdB/zxJx vjmyd8rseY4vb332itRe8sCWmLOHm7s8IwTYJgoOEOo3GQbt0WdINhvHQ+xN5/nhZepi dW56trn7vZHhXX4dkYV/IACVycs3ebi7c2KREJdIVdsvSE5NHNj+BnFXHrOGexj81Rpq xZLaSXHn3yDFMesSnGxX/2QaXG0m3mmMaNYdKtGLU6RO56IRRBRzOQXa0m0tj0CiUwsL VTxUx0LIDN68e01sNWS0W8Cggh/hZUuTWulciN3nn77cIZBGoFSNKGMYqoLloH5P1IdS lC5w== X-Gm-Message-State: AOAM533+Rd8ywW2pEHOwVV1UW+QN1YzMGTRtK3s3WCGCj0FevGrEc8vx Q/w8CfGTTDzBN0qcOy3/TM2eP8nfo+y6m/XE6+Y= X-Received: by 2002:a92:ca0d:0:b0:2c2:a846:b05a with SMTP id j13-20020a92ca0d000000b002c2a846b05amr51270ils.252.1646420496912; Fri, 04 Mar 2022 11:01:36 -0800 (PST) MIME-Version: 1.0 References: <20220227142551.2349805-1-james.hilliard1@gmail.com> <6af1530a-a4bf-dccf-947d-78ce235a4414@iogearbox.net> In-Reply-To: <6af1530a-a4bf-dccf-947d-78ce235a4414@iogearbox.net> From: Andrii Nakryiko Date: Fri, 4 Mar 2022 11:01:26 -0800 Message-ID: Subject: Re: [PATCH 1/1] libbpf: ensure F_DUPFD_CLOEXEC is defined To: Daniel Borkmann Cc: James Hilliard , bpf , Alexei Starovoitov , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Networking , open list Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 28, 2022 at 7:00 AM Daniel Borkmann wrote: > > Hi James, > > On 2/27/22 3:25 PM, James Hilliard wrote: > > This definition seems to be missing from some older toolchains. > > > > Note that the fcntl.h in libbpf_internal.h is not a kernel header > > but rather a toolchain libc header. > > > > Fixes: > > libbpf_internal.h:521:18: error: 'F_DUPFD_CLOEXEC' undeclared (first use in this function); did you mean 'FD_CLOEXEC'? > > fd = fcntl(fd, F_DUPFD_CLOEXEC, 3); > > ^~~~~~~~~~~~~~~ > > FD_CLOEXEC > > > > Signed-off-by: James Hilliard > > Do you have some more info on your env (e.g. libc)? Looks like F_DUPFD_CLOEXEC > was added back in 2.6.24 kernel. When did libc add it? It seems like it's guarded by __USE_XOPEN2K8 in glibc (from a quick glance at glibc code). But it's been there since 2010 or so, at the very least. > > Should we instead just add an include for to libbpf_internal.h > (given it defines F_DUPFD_CLOEXEC as well)? yep, this is UAPI header so we can use it easily (we'll need to sync it into Github repo, but that's not a problem) > > > --- > > tools/lib/bpf/libbpf_internal.h | 4 ++++ > > 1 file changed, 4 insertions(+) > > > > diff --git a/tools/lib/bpf/libbpf_internal.h b/tools/lib/bpf/libbpf_internal.h > > index 4fda8bdf0a0d..d2a86b5a457a 100644 > > --- a/tools/lib/bpf/libbpf_internal.h > > +++ b/tools/lib/bpf/libbpf_internal.h > > @@ -31,6 +31,10 @@ > > #define EM_BPF 247 > > #endif > > > > +#ifndef F_DUPFD_CLOEXEC > > +#define F_DUPFD_CLOEXEC 1030 > > +#endif > > + > > #ifndef R_BPF_64_64 > > #define R_BPF_64_64 1 > > #endif > > > > Thanks, > Daniel