[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aef5670f-f3b8-7ea8-28eb-247c814fd005@fb.com>
Date: Wed, 21 Apr 2021 18:56:20 -0700
From: Yonghong Song <yhs@...com>
To: Kumar Kartikeya Dwivedi <memxor@...il.com>
CC: <bpf@...r.kernel.org>,
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 2/3] libbpf: add low level TC-BPF API
On 4/21/21 10:06 AM, Kumar Kartikeya Dwivedi wrote:
> On Wed, Apr 21, 2021 at 12:28:01PM IST, Yonghong Song wrote:
>>
>>
>> On 4/20/21 12:37 PM, Kumar Kartikeya Dwivedi wrote:
>>> This adds functions that wrap the netlink API used for adding,
>>> manipulating, and removing traffic control filters. These functions
>>> operate directly on the loaded prog's fd, and return a handle to the
>>> filter using an out parameter named id.
>>>
>>> The basic featureset is covered to allow for attaching and removal of
>>> filters. Some additional features like TCA_BPF_POLICE and TCA_RATE for
>>> the API have been omitted. These can added on top later by extending the
>>
>> "later" => "layer"?
>>
>
> No, I meant that other options can be added on top of this series by someone
> later. I'll reword it.
>
[...]
>>>
>>> Reviewed-by: Toke Høiland-Jørgensen <toke@...hat.com>
>>> Signed-off-by: Kumar Kartikeya Dwivedi <memxor@...il.com>
>>> ---
>>> tools/lib/bpf/libbpf.h | 44 ++++++
>>> tools/lib/bpf/libbpf.map | 3 +
>>> tools/lib/bpf/netlink.c | 319 ++++++++++++++++++++++++++++++++++++++-
>>> 3 files changed, 360 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
>>> index bec4e6a6e31d..b4ed6a41ea70 100644
>>> --- a/tools/lib/bpf/libbpf.h
>>> +++ b/tools/lib/bpf/libbpf.h
>>> @@ -16,6 +16,8 @@
>>> #include <stdbool.h>
>>> #include <sys/types.h> // for size_t
>>> #include <linux/bpf.h>
>>> +#include <linux/pkt_sched.h>
>>> +#include <linux/tc_act/tc_bpf.h>
>>> #include "libbpf_common.h"
>>> @@ -775,6 +777,48 @@ LIBBPF_API int bpf_linker__add_file(struct bpf_linker *linker, const char *filen
>>> LIBBPF_API int bpf_linker__finalize(struct bpf_linker *linker);
>>> LIBBPF_API void bpf_linker__free(struct bpf_linker *linker);
>>> +/* Convenience macros for the clsact attach hooks */
>>> +#define BPF_TC_CLSACT_INGRESS TC_H_MAKE(TC_H_CLSACT, TC_H_MIN_INGRESS)
>>> +#define BPF_TC_CLSACT_EGRESS TC_H_MAKE(TC_H_CLSACT, TC_H_MIN_EGRESS)
>>> +
>>> +struct bpf_tc_opts {
>>> + size_t sz;
>>> + __u32 handle;
>>> + __u32 class_id;
>>> + __u16 priority;
>>> + bool replace;
>>> + size_t :0;
>>
>> Did you see any error without "size_t :0"?
>>
>
> Not really, I just added this considering this recent change:
> dde7b3f5f2f4 ("libbpf: Add explicit padding to bpf_xdp_set_link_opts")
Thanks. That is fine with me then.
>
>>> +};
>>> +
>>> +#define bpf_tc_opts__last_field replace
>>> +
>>> +/* Acts as a handle for an attached filter */
>>> +struct bpf_tc_attach_id {
>>> + __u32 handle;
>>> + __u16 priority;
>>> +};
>>> +
>> [...]
>
> --
> Kartikeya
>
Powered by blists - more mailing lists