Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp3565725ybd; Fri, 28 Jun 2019 10:49:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqwTYotyYZGqnP/YKepAF7BaIdvrUm7gmLh/eOzP5SX6cDtD8FtaLMnBSqu7043ZlirFZKXG X-Received: by 2002:a17:902:9004:: with SMTP id a4mr13150936plp.109.1561744196352; Fri, 28 Jun 2019 10:49:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561744196; cv=none; d=google.com; s=arc-20160816; b=qYdXV7G+DGZkN9VKn53ZRhXTCPpifSyjDM7zzMClbvFjP9wvVry75s/Sj6SQPtQT0B eUo15cjGxhm5Y4kB79jnG9F0W+Gqc+IDra+CNkY5lrPGLnvJRh+vCbIz0laws1Y+HI71 QMhHhbJlNw77mtiNLil7TkIi64AbFtOdfgmm1fh7NoP5E+n3omwCbPM27MfmZS6JREfF iaNmiDrbnS78MFKRWyYB0QuqysePuuGhduibXoZPa+OEPiRdygmun5/q877N54U/zdA6 r/bvqqmfAFaWymLSKauopPbJQ0bzEBh08J8mSSwUhDEhAMac+jd8EbQ4zMIsLfNIcYBF byEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=WJsIhY4wNQryIfT9KbxiILwrE7QAS+RQBKJnSZt1T4o=; b=ajqTX6vVDLGVX6Jl2EtzJmvkKoNOFg1EVpoCbGEIzHWopxuYm3g9ARhGgSf+Z3pxyE YBRKpT+OIQ8yTLOibmYPQ8hIoOh5l2jOkKo0oTqOIuFsqMoiKREwtCqw/m+rM3id9jPR gWM9Mfk/q1ydskbwTQUbx+C2M1/zMNU+tJ/m9wjheu31enl0P1/eANH/CNLPJXPJT8dK ixwPL4Pa32vpXjYqZMFH5/QszRDikT6d1/DTzoIDiL+eh/9eqbKeinfZeR04mC+2h2Iy FVkLmFv/w+S5LQBsUpIydj2rzH/1b2wwBAO1IWFbm18WYVnhEa9RK2AwpEeSsoLi1fTs zkvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Crebc91l; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id d62si2653785pga.447.2019.06.28.10.49.40; Fri, 28 Jun 2019 10:49:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Crebc91l; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1726785AbfF1RtT (ORCPT + 99 others); Fri, 28 Jun 2019 13:49:19 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:35176 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726443AbfF1RtS (ORCPT ); Fri, 28 Jun 2019 13:49:18 -0400 Received: by mail-lj1-f195.google.com with SMTP id x25so6842990ljh.2; Fri, 28 Jun 2019 10:49:17 -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; bh=WJsIhY4wNQryIfT9KbxiILwrE7QAS+RQBKJnSZt1T4o=; b=Crebc91lCSxk7TMCY8Q1U9io2/WLQpztGqZaL+13FtcWeRi8UJXcokTcvTshRXhiAy ooXSPgCtrMzKcPJn8uvnBZ/S5mcan1t2Yp26dct8RVz4gDtlYd2umQbOrnnISeAY73Nu Yxm0bUk7a1I3jh+MICpnPG5hUhr5bkrhGgENXucWLrn6NHZdrU2go6D7juVZ2Onm2AdT Q/0m9W1o+8sEZSPPA6RjCWsVI4lB7xKMtzDt8mD0m+k0whGSPj5nCZF+JfL/h9qLVmvG Voi6r8rKzQfVmq4IDwJOEzAJ0ILefENsWuhawHj8Y0xZMcPV8wOMLiYMEjHMqZwj69IW bh/g== 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; bh=WJsIhY4wNQryIfT9KbxiILwrE7QAS+RQBKJnSZt1T4o=; b=U9Z5ToDjhEpMxLczmXzyo61zWM0Q5PCidhCAzB4CZrsAOo85/dl587khjzME+bCuUj 7qa7llJkdDPBoX2c9rcJt8SssOxVe7gILRjW7Bk3IdEACeMtOvqsI0M/oViimfxVwBYd PdxRygJN/+BrNSUwQmuK9V3FAizjxbU6BuJFI04Nv/CB6WRZ1TrUxhhxiFGpJ0ZqxWCr OH0uYiQjJGsSNyVvaDonh9kSEdp5P3aGYIGZd3BHK18tAklPvT4IOqHyb+sIu/nIQfnr 6XwyAsoNrS25eLJNBQXswyh1apNhw6QP7bSog3aSKKwgxFmPpa2ekP60iSQdjzmQLxfJ 7AxA== X-Gm-Message-State: APjAAAXpgN3dGe0Ty3dosvAmJuQq8CAMC6b7Q+adb1yI0LLWaJpaH2A1 8gOBdl29NlkIZ1Ry1MeeZPyStRb3k1s2PTm9oGI= X-Received: by 2002:a2e:6c07:: with SMTP id h7mr6983719ljc.177.1561744156739; Fri, 28 Jun 2019 10:49:16 -0700 (PDT) MIME-Version: 1.0 References: <20190627202417.33370-1-brianvv@google.com> <20190627202417.33370-3-brianvv@google.com> <20190627221253.fjsa2lzog2zs5nyz@ast-mbp.dhcp.thefacebook.com> In-Reply-To: <20190627221253.fjsa2lzog2zs5nyz@ast-mbp.dhcp.thefacebook.com> From: Brian Vazquez Date: Fri, 28 Jun 2019 10:49:05 -0700 Message-ID: Subject: Re: [RFC PATCH bpf-next v2 2/6] bpf: add BPF_MAP_DUMP command to access more than one entry per call To: Alexei Starovoitov Cc: Brian Vazquez , Alexei Starovoitov , Daniel Borkmann , "David S . Miller" , Stanislav Fomichev , Willem de Bruijn , Petar Penkov , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > Please explain the api behavior and corner cases in the commit log > or in code comments. Ack, will prepare a new version adding those. > Would it make sense to return last key back into prev_key, > so that next map_dump command doesn't need to copy it from the > buffer? Actually that's a good idea. > checkpatch.pl please. I did use the script and it didn't complain, are you seeing something? > > +next: > > + if (signal_pending(current)) { > > + err = -EINTR; > > + break; > > + } > > + > > + rcu_read_lock(); > > + err = map->ops->map_get_next_key(map, prev_key, key); > > + rcu_read_unlock(); > > + > > + if (err) > > + break; > > should probably be only for ENOENT case? Yes, this makes sense. > and other errors should be returned to user ? and what if the error happened when we had already copied some entries? Current behavior masks the error to 0 if we copied at least 1 element > > > + > > + if (bpf_map_copy_value(map, key, value, attr->dump.flags)) > > + goto next; > > only for ENOENT as well? > and instead of goto use continue and move cp_len+= to the end after prev_key=key? Right > > > + > > + if (copy_to_user(ubuf + cp_len, buf, elem_size)) > > + break; > > return error to user? > > > + > > + prev_key = key; > > + } > > + > > + if (cp_len) > > + err = 0; > > this will mask any above errors if there was at least one element copied. So in general if we copied elements and suddenly we find and error we should return that error and maybe set cp_len to 0 to 'invalidate' the data that was already copied? Yes, I think that sounds like the correct thing to do, what do you think?