Re: [PATCH] net: skb: move enum skb_drop_reason to uapi

From: Menglong Dong
Date: Thu Mar 10 2022 - 23:58:45 EST


On Fri, Mar 11, 2022 at 11:54 AM Jakub Kicinski <kuba@xxxxxxxxxx> wrote:
>
> On Fri, 11 Mar 2022 11:28:28 +0800 menglong8.dong@xxxxxxxxx wrote:
> > From: Menglong Dong <imagedong@xxxxxxxxxxx>
> >
> > Move the definition of 'enum skb_drop_reason' in 'skbuff.h' to the uapi
> > header 'net_dropmon.h', therefore some users, such as eBPF program, can
> > make use of it.
>
> BPF does not need an enum definition to be part of the uAPI to make use
> of it. BTF should encode the values, and CO-RE can protect from them
> changing, AFAIU. I think we need a better example user / justification.

There is something wrong with my description, it's not the eBPF, but the user
program that loads eBPF.

In my case, I'll pass the packet info (protocol, ip, port, etc) and drop reason
to user space by eBPF that is attached on the kfree_skb() tracepoint.

In the user space, I'll custom the description for drop reasons and convert them
from int to string. Therefore, I need to use 'enum skb_drop_reason' in my
user space code.

For now, I copied the definition of 'enum skb_drop_reason' to my code,
and I think it's better to make them uapi, considering someone else may
use it this way too.

Thanks
Menglong Dong