Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp619983pxj; Fri, 14 May 2021 11:16:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVGkzyydBDyxQPCqKxP9pFiNMsB0v8HXe3qGcgYH2Jjo74l5EDRb3AkCI+enXDb4rBcKxP X-Received: by 2002:a17:906:3411:: with SMTP id c17mr13990898ejb.332.1621016210041; Fri, 14 May 2021 11:16:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621016210; cv=none; d=google.com; s=arc-20160816; b=QN8tGY69U8b3XP0F+dsThFbjA2gHqbp3vpkI7swcIlq+CYeOVlE67/y2/PPu0d0Biz wzCYpd7Q9Rme1jonVjFtKmRiDuzuEbLqjFwoIsFCBfxOnHqUI6MQtda19F+EETdW47xo ZuRT6xqoXC4FyN0TrYmhLyNgGUK87MsabUJ9RB8jTtfXyJ5pHRR5sCVX5dtW+xaJP1Vo +LzSlKKG14JaKrPLWCjEYo5deUIic8thOPnoQz3vsLAwD9dyPC+wp97FrK18cv2M3ulS sOh6OiHXbZfWpqyEgr0moC3IbhL7Z9B3w7hyZh+s9NeO2vWRbiYvo5wKZkhHe7xDlNuw wLRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=2cTYvHuHAN0WL1Zhu+AnGEld65eYHPpP/ykq20D4jMk=; b=g6tlhFWlgiICFaPZ7E7nxOogTjyX4D9Vdt14CwKNtyB1N1QxF4xUsmIkrNSqYAHiVa pRrUXHKQ9ynmT/85TWWRXHOQytQn7UYaAUpPQVqBzFP8Wg3ao98zQQF80Oxon+LcnWnL XzQ49RmFvoqGWOzl+P0wC57baXq+OAwsmvy1aV/ykkyU4fBstTPdFAzbFMELCNPjGAU6 S0TcPjiEu7YyIkXDN3XcWmjBNe86lYJgnj7TYDbJVfhmBqFA7lDnAwtwjyhfK+1SRLDL /dfZiPLn3DaeWQyRjNugPqE9QR7Ui6vL0P0BGW44niN7tiUP8tyy7JvZuKupfR4sAUxc bTHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Z8EInJ2m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b11si6945722ejq.727.2021.05.14.11.16.26; Fri, 14 May 2021 11:16:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Z8EInJ2m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233315AbhENMWK (ORCPT + 99 others); Fri, 14 May 2021 08:22:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232963AbhENMWJ (ORCPT ); Fri, 14 May 2021 08:22:09 -0400 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23595C061574; Fri, 14 May 2021 05:20:58 -0700 (PDT) Received: by mail-ed1-x52f.google.com with SMTP id l7so34524660edb.1; Fri, 14 May 2021 05:20:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:reply-to:references:mime-version :content-disposition:in-reply-to; bh=2cTYvHuHAN0WL1Zhu+AnGEld65eYHPpP/ykq20D4jMk=; b=Z8EInJ2m0tdGAt3ZCC2KcPw3j/xM16a3OROzGvAEc0kIsNWeUNy7prAAPbNVVSSPXH vqqyJt1dJKTFawpJY0JU1ezpARyUC+oZfs73nSxSA72CsWbwiA0+bKVdYncweFeCmvza hP8XNdk+CXJ1yKGKUFs9JXFTZfwk/9sBFGgJt8de34FGASEfWMZA15VkM5ptvSe1Ykqv 8CpVQma1WynB6gRyHUIb5/bS9/TW2HkR21zbWIe230gT0+1QVkXjCRpT//kSzCH8A4l0 HGSdzQ3g9bkqOINI9N+P3fBun4sy/hTYHr4Kte2uM+hBWIxUAyC5fOjF7UgoN5bjqWHj 7JdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:reply-to :references:mime-version:content-disposition:in-reply-to; bh=2cTYvHuHAN0WL1Zhu+AnGEld65eYHPpP/ykq20D4jMk=; b=dbnYU+Cy4K9H6YBcH260vfKyrZWhj1ME3Vr5kJUkHvpibtbRuh7b5AU1RFu3A1mXFI SoBTCjfVgtNjCqRl4BjyWqXXMK0mkiyS/gw723UgiyfFH+Za2032twbox3y5aSgVnhqz Ib2xmO2KkSgL30NdHA9u18L+uaCqF/9l89jGs7uJ4eU7CTBQxjrkM0onWlTKDYKUIsq0 70FJitKsIFSzCoT/rM4Dd9/voOgdsslbrQUoBqvULzhi+0qOOLlEKcYGy9sq7h5sGUix fy/HGDbatH/ODFj7YedmuhKxwdKB/rnqtWAE7+q7O56wFugJh2AbBm2bGF9ecYI6qgGd nhPg== X-Gm-Message-State: AOAM532zdM9YH2C89ZQFqWgEt2LY/P6LAGNfjFu3CNzHvVBfTERnanlC Tiw3qf5RA5DUzkYyQMJXvHs= X-Received: by 2002:a05:6402:2712:: with SMTP id y18mr58311789edd.41.1620994856893; Fri, 14 May 2021 05:20:56 -0700 (PDT) Received: from pevik ([62.201.25.198]) by smtp.gmail.com with ESMTPSA id k9sm3746438eje.102.2021.05.14.05.20.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 May 2021 05:20:56 -0700 (PDT) Date: Fri, 14 May 2021 14:20:53 +0200 From: Petr Vorel To: Heiko Thiery Cc: David Ahern , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stephen@networkplumber.org, Dmitry Yakunin Subject: Re: [PATCH iproute2-next v3] lib/fs: fix issue when {name,open}_to_handle_at() is not implemented Message-ID: Reply-To: Petr Vorel References: <20210508064925.8045-1-heiko.thiery@gmail.com> <6ba0adf4-5177-c50a-e921-bee898e3fdb9@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > Hi David, > Am Mo., 10. Mai 2021 um 00:20 Uhr schrieb David Ahern : > > On 5/8/21 12:49 AM, Heiko Thiery wrote: > > > With commit d5e6ee0dac64 the usage of functions name_to_handle_at() and > > > open_by_handle_at() are introduced. But these function are not available > > > e.g. in uclibc-ng < 1.0.35. To have a backward compatibility check for the > > > availability in the configure script and in case of absence do a direct > > > syscall. > > > Fixes: d5e6ee0dac64 ("ss: introduce cgroup2 cache and helper functions") > > > Cc: Dmitry Yakunin > > > Cc: Petr Vorel > > > Signed-off-by: Heiko Thiery > > > --- > > > v3: > > > - use correct syscall number (thanks to Petr Vorel) > > > - add #include (thanks to Petr Vorel) > > > - remove bogus parameters (thanks to Petr Vorel) > > > - fix #ifdef (thanks to Petr Vorel) > > > - added Fixes tag (thanks to David Ahern) > > > - build test with buildroot 2020.08.3 using uclibc 1.0.34 > > > v2: > > > - small correction to subject > > > - removed IP_CONFIG_HANDLE_AT:=y option since it is not required > > > - fix indentation in check function > > > - removed empty lines (thanks to Petr Vorel) > > > - add #define _GNU_SOURCE in check (thanks to Petr Vorel) > > > - check only for name_to_handle_at (thanks to Petr Vorel) > > > configure | 28 ++++++++++++++++++++++++++++ > > > lib/fs.c | 25 +++++++++++++++++++++++++ > > > 2 files changed, 53 insertions(+) > > > diff --git a/configure b/configure > > > index 2c363d3b..179eae08 100755 > > > --- a/configure > > > +++ b/configure > > > @@ -202,6 +202,31 @@ EOF > > > rm -f $TMPDIR/setnstest.c $TMPDIR/setnstest > > > } > > > +check_name_to_handle_at() > > > +{ > > > + cat >$TMPDIR/name_to_handle_at_test.c < > > +#define _GNU_SOURCE > > > +#include > > > +#include > > > +#include > > > +int main(int argc, char **argv) > > > +{ > > > + struct file_handle *fhp; > > > + int mount_id, flags, dirfd; > > > + char *pathname; > > > + name_to_handle_at(dirfd, pathname, fhp, &mount_id, flags); > > > + return 0; > > > +} > > > +EOF > > > + if $CC -I$INCLUDE -o $TMPDIR/name_to_handle_at_test $TMPDIR/name_to_handle_at_test.c >/dev/null 2>&1; then > > > + echo "yes" > > > + echo "CFLAGS += -DHAVE_HANDLE_AT" >>$CONFIG > > > + else > > > + echo "no" > > > + fi > > > + rm -f $TMPDIR/name_to_handle_at_test.c $TMPDIR/name_to_handle_at_test > > > +} > > > + > > > check_ipset() > > > { > > > cat >$TMPDIR/ipsettest.c < > > @@ -492,6 +517,9 @@ fi > > > echo -n "libc has setns: " > > > check_setns > > > +echo -n "libc has name_to_handle_at: " > > > +check_name_to_handle_at > > > + > > > echo -n "SELinux support: " > > > check_selinux > > > diff --git a/lib/fs.c b/lib/fs.c > > > index f161d888..05697a7e 100644 > > > --- a/lib/fs.c > > > +++ b/lib/fs.c > > > @@ -25,11 +25,36 @@ > > > #include "utils.h" > > > +#ifndef HAVE_HANDLE_AT > > > +# include > > > +#endif > > > + > > > #define CGROUP2_FS_NAME "cgroup2" > > > /* if not already mounted cgroup2 is mounted here for iproute2's use */ > > > #define MNT_CGRP2_PATH "/var/run/cgroup2" > > > + > > > +#ifndef HAVE_HANDLE_AT > > > +struct file_handle { > > > + unsigned handle_bytes; > > > + int handle_type; > > > + unsigned char f_handle[]; > > > +}; > > > + > > > +static int name_to_handle_at(int dirfd, const char *pathname, > > > + struct file_handle *handle, int *mount_id, int flags) > > > +{ > > > + return syscall(__NR_name_to_handle_at, dirfd, pathname, handle, > > > + mount_id, flags); > > > +} > > > + > > > +static int open_by_handle_at(int mount_fd, struct file_handle *handle, int flags) > > > +{ > > > + return syscall(__NR_open_by_handle_at, mount_fd, handle, flags); > > > +} > > > +#endif > > > + > > > /* return mount path of first occurrence of given fstype */ > > > static char *find_fs_mount(const char *fs_to_find) > > > { > > This causes compile failures if anyone is reusing a tree. It would be > > good to require config.mk to be updated if configure is newer. > Do you mean the config.mk should have a dependency to configure in the > Makefile? Wouldn't that be better as a separate patch? I guess it should be a separate patch. I'm surprised it wasn't needed before. Kind regards, Petr > Thanks