netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Ahern <dsahern@gmail.com>
To: Alexander Mikhalitsyn <alexander.mikhalitsyn@virtuozzo.com>,
	netdev@vger.kernel.org
Cc: David Ahern <dsahern@kernel.org>,
	Stephen Hemminger <stephen@networkplumber.org>,
	Andrei Vagin <avagin@gmail.com>,
	Alexander Mikhalitsyn <alexander@mihalicyn.com>
Subject: Re: [PATCH iproute2] ip route: ignore ENOENT during save if RT_TABLE_MAIN is being dumped
Date: Wed, 23 Jun 2021 09:36:29 -0600	[thread overview]
Message-ID: <042c0ec6-f347-8b82-2bb2-c4ea87cf4a6d@gmail.com> (raw)
In-Reply-To: <20210622150330.28014-1-alexander.mikhalitsyn@virtuozzo.com>

On 6/22/21 9:03 AM, Alexander Mikhalitsyn wrote:
> We started to use in-kernel filtering feature which allows to get only needed
> tables (see iproute_dump_filter()). From the kernel side it's implemented in
> net/ipv4/fib_frontend.c (inet_dump_fib), net/ipv6/ip6_fib.c (inet6_dump_fib).
> The problem here is that behaviour of "ip route save" was changed after
> c7e6371bc ("ip route: Add protocol, table id and device to dump request").
> If filters are used, then kernel returns ENOENT error if requested table is absent,
> but in newly created net namespace even RT_TABLE_MAIN table doesn't exist.
> It is really allocated, for instance, after issuing "ip l set lo up".
> 
> Reproducer is fairly simple:
> $ unshare -n ip route save > dump
> Error: ipv4: FIB table does not exist.
> Dump terminated

The above command on 5.4 kernel with corresponding iproute2 does not
show that error. Is your kernel compiled with CONFIG_IP_MULTIPLE_TABLES
enabled?

> 
> Expected result here is to get empty dump file (as it was before this change).
> 
> This affects on CRIU [1] because we use ip route save in dump process, to workaround
> problem in tests we just put loopback interface up in each net namespace.
> Other users also met this problem [2].
> 
> Links:
> [1] https://github.com/checkpoint-restore/criu/issues/747
> [2] https://www.spinics.net/lists/netdev/msg559739.html
> 
> Fixes: c7e6371bc ("ip route: Add protocol, table id and device to dump request")
> 
> Cc: David Ahern <dsahern@kernel.org>
> Cc: Stephen Hemminger <stephen@networkplumber.org>
> Cc: Andrei Vagin <avagin@gmail.com>
> Cc: Alexander Mikhalitsyn <alexander@mihalicyn.com>
> Signed-off-by: Alexander Mikhalitsyn <alexander.mikhalitsyn@virtuozzo.com>
> ---
>  ip/iproute.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/ip/iproute.c b/ip/iproute.c
> index 5853f026..b70acc00 100644
> --- a/ip/iproute.c
> +++ b/ip/iproute.c
> @@ -1734,6 +1734,7 @@ static int iproute_list_flush_or_save(int argc, char **argv, int action)
>  	char *od = NULL;
>  	unsigned int mark = 0;
>  	rtnl_filter_t filter_fn;
> +	int ret;
>  
>  	if (action == IPROUTE_SAVE) {
>  		if (save_route_prep())
> @@ -1939,7 +1940,11 @@ static int iproute_list_flush_or_save(int argc, char **argv, int action)
>  
>  	new_json_obj(json);
>  
> -	if (rtnl_dump_filter(&rth, filter_fn, stdout) < 0) {
> +	ret = rtnl_dump_filter(&rth, filter_fn, stdout);
> +
> +	/* Let's ignore ENOENT error if we want to dump RT_TABLE_MAIN table */
> +	if (ret < 0 &&

ret temp variable is not needed; just add the extra checks.

> +	    !(errno == ENOENT && filter.tb == RT_TABLE_MAIN)) {
>  		fprintf(stderr, "Dump terminated\n");
>  		return -2;
>  	}
> 

This looks fine to me, but I want clarification on the kernel config. As
I recall with multiple tables and fib rules tables are created when net
namespace is created.

  reply	other threads:[~2021-06-23 15:36 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-22 15:03 [PATCH iproute2] ip route: ignore ENOENT during save if RT_TABLE_MAIN is being dumped Alexander Mikhalitsyn
2021-06-23 15:36 ` David Ahern [this message]
2021-06-23 16:11   ` Alexander Mikhalitsyn
2021-06-24 15:28 ` [PATCHv2 " Alexander Mikhalitsyn
2021-06-24 15:36   ` Stephen Hemminger
2021-06-24 15:40     ` Alexander Mikhalitsyn
2021-06-25 10:59     ` Alexander Mikhalitsyn
2021-06-25 10:44   ` [PATCHv3 " Alexander Mikhalitsyn
2021-06-27 21:54     ` Stephen Hemminger
2021-06-28  6:31       ` Alexander Mikhalitsyn
2021-06-28 17:17         ` Stephen Hemminger
2021-06-28 17:21           ` Alexander Mikhalitsyn
2021-06-29 15:51     ` [PATCHv4 " Alexander Mikhalitsyn
2021-07-06  7:47       ` Alexander Mikhalitsyn
2021-07-06 15:34       ` Stephen Hemminger
2021-07-06 15:44         ` Alexander Mikhalitsyn
2021-07-06 16:18           ` Stephen Hemminger
2021-07-06 17:17             ` Alexander Mikhalitsyn
2021-07-07  0:05               ` Stephen Hemminger
2021-07-07 12:22                 ` Alexander Mikhalitsyn
2021-07-07 14:31                   ` Stephen Hemminger
2021-07-07 14:32                     ` Alexander Mikhalitsyn
2021-07-07 12:09     ` [PATCHv5 " Alexander Mikhalitsyn
2021-07-07 12:22     ` Alexander Mikhalitsyn
2021-07-07 14:35       ` Stephen Hemminger
2021-07-07 14:38         ` Alexander Mikhalitsyn
2021-07-07 14:50       ` patchwork-bot+netdevbpf
2021-07-11 10:59         ` Roi Dayan
2021-07-11 11:09           ` Roi Dayan
2021-07-11 11:12             ` Alexander Mihalicyn
  -- strict thread matches above, loose matches on Subject: below --
2021-06-22 14:44 [PATCH " Alexander Mikhalitsyn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=042c0ec6-f347-8b82-2bb2-c4ea87cf4a6d@gmail.com \
    --to=dsahern@gmail.com \
    --cc=alexander.mikhalitsyn@virtuozzo.com \
    --cc=alexander@mihalicyn.com \
    --cc=avagin@gmail.com \
    --cc=dsahern@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).