[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b1648e8a-44de-3d9a-963f-4c79f42e4713@fb.com>
Date: Tue, 20 Apr 2021 23:37:48 -0700
From: Yonghong Song <yhs@...com>
To: Kumar Kartikeya Dwivedi <memxor@...il.com>, <bpf@...r.kernel.org>
CC: Toke Høiland-Jørgensen <toke@...hat.com>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>,
Martin KaFai Lau <kafai@...com>,
Song Liu <songliubraving@...com>,
John Fastabend <john.fastabend@...il.com>,
KP Singh <kpsingh@...nel.org>,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Jesper Dangaard Brouer <brouer@...hat.com>,
<netdev@...r.kernel.org>
Subject: Re: [PATCH bpf-next v3 1/3] libbpf: add helpers for preparing netlink
attributes
On 4/20/21 12:37 PM, Kumar Kartikeya Dwivedi wrote:
> This change introduces a few helpers to wrap open coded attribute
> preparation in netlink.c.
>
> Every nested attribute's closure must happen using the helper
> nlattr_end_nested, which sets its length properly. NLA_F_NESTED is
> enforeced using nlattr_begin_nested helper. Other simple attributes
typo: enforced
> can be added directly.
>
> The maxsz parameter corresponds to the size of the request structure
> which is being filled in, so for instance with req being:
>
> struct {
> struct nlmsghdr nh;
> struct tcmsg t;
> char buf[4096];
> } req;
>
> Then, maxsz should be sizeof(req).
>
> This change also converts the open coded attribute preparation with the
> helpers. Note that the only failure the internal call to nlattr_add
> could result in the nested helper would be -EMSGSIZE, hence that is what
> we return to our caller.
>
> Reviewed-by: Toke Høiland-Jørgensen <toke@...hat.com>
> Signed-off-by: Kumar Kartikeya Dwivedi <memxor@...il.com>
> ---
> tools/lib/bpf/netlink.c | 37 ++++++++++++++-----------------
> tools/lib/bpf/nlattr.h | 48 +++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 64 insertions(+), 21 deletions(-)
>
[...]
Powered by blists - more mailing lists