From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexei Starovoitov Subject: Re: [PATCH bpf] bpf: fix bpffs non-array map seq_show issue Date: Wed, 8 Aug 2018 19:25:31 -0700 Message-ID: <20180809022530.yprizizentv7frmt@ast-mbp> References: <20180809012519.3534824-1-yhs@fb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: ast@fb.com, daniel@iogearbox.net, netdev@vger.kernel.org, kernel-team@fb.com To: Yonghong Song Return-path: Received: from mail-pg1-f194.google.com ([209.85.215.194]:43929 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725757AbeHIEsb (ORCPT ); Thu, 9 Aug 2018 00:48:31 -0400 Received: by mail-pg1-f194.google.com with SMTP id a14-v6so1974272pgv.10 for ; Wed, 08 Aug 2018 19:26:04 -0700 (PDT) Content-Disposition: inline In-Reply-To: <20180809012519.3534824-1-yhs@fb.com> Sender: netdev-owner@vger.kernel.org List-ID: On Wed, Aug 08, 2018 at 06:25:19PM -0700, Yonghong Song wrote: > In function map_seq_next() of kernel/bpf/inode.c, > the first key will be the "0" regardless of the map type. > This works for array. But for hash type, if it happens > key "0" is in the map, the bpffs map show will miss > some items if the key "0" is not the first element of > the first bucket. > > This patch fixed the issue by guaranteeing to get > the first element, if the seq_show is just started, > by passing NULL pointer key to map_get_next_key() callback. > This way, no missing elements will occur for > bpffs hash table show even if key "0" is in the map. > > Fixes: a26ca7c982cb5 ("bpf: btf: Add pretty print support to the basic arraymap") > Signed-off-by: Yonghong Song Acked-by: Alexei Starovoitov