All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] bpf: fix errno code for unsupported batch ops
@ 2021-04-18 20:02 Pedro Tammela
  2021-04-18 22:55 ` Alexei Starovoitov
  0 siblings, 1 reply; 4+ messages in thread
From: Pedro Tammela @ 2021-04-18 20:02 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, netdev, bpf, linux-kernel
  Cc: Pedro Tammela

ENOTSUPP is not a valid userland errno[1], which is annoying for
userland applications that implement a fallback to iterative, report
errors via 'strerror()' or both.

The batched ops return this errno whenever an operation
is not implemented for kernels that implement batched ops.

In older kernels, pre batched ops, it returns EINVAL as the arguments
are not supported in the syscall.

[1] https://lore.kernel.org/netdev/20200511165319.2251678-1-kuba@kernel.org/

Signed-off-by: Pedro Tammela <pctammela@mojatatu.com>
---
 kernel/bpf/syscall.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index fd495190115e..88fe19c0aeb1 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -3961,7 +3961,7 @@ static int bpf_task_fd_query(const union bpf_attr *attr,
 #define BPF_DO_BATCH(fn)			\
 	do {					\
 		if (!fn) {			\
-			err = -ENOTSUPP;	\
+			err = -EOPNOTSUPP;	\
 			goto err_put;		\
 		}				\
 		err = fn(map, attr, uattr);	\
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] bpf: fix errno code for unsupported batch ops
  2021-04-18 20:02 [PATCH] bpf: fix errno code for unsupported batch ops Pedro Tammela
@ 2021-04-18 22:55 ` Alexei Starovoitov
  2021-04-19 13:52   ` Pedro Tammela
  0 siblings, 1 reply; 4+ messages in thread
From: Alexei Starovoitov @ 2021-04-18 22:55 UTC (permalink / raw)
  To: Pedro Tammela
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Network Development, bpf, LKML, Pedro Tammela

On Sun, Apr 18, 2021 at 1:03 PM Pedro Tammela <pctammela@gmail.com> wrote:
>
> ENOTSUPP is not a valid userland errno[1], which is annoying for
> userland applications that implement a fallback to iterative, report
> errors via 'strerror()' or both.
>
> The batched ops return this errno whenever an operation
> is not implemented for kernels that implement batched ops.
>
> In older kernels, pre batched ops, it returns EINVAL as the arguments
> are not supported in the syscall.
>
> [1] https://lore.kernel.org/netdev/20200511165319.2251678-1-kuba@kernel.org/
>
> Signed-off-by: Pedro Tammela <pctammela@mojatatu.com>
> ---
>  kernel/bpf/syscall.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> index fd495190115e..88fe19c0aeb1 100644
> --- a/kernel/bpf/syscall.c
> +++ b/kernel/bpf/syscall.c
> @@ -3961,7 +3961,7 @@ static int bpf_task_fd_query(const union bpf_attr *attr,
>  #define BPF_DO_BATCH(fn)                       \
>         do {                                    \
>                 if (!fn) {                      \
> -                       err = -ENOTSUPP;        \
> +                       err = -EOPNOTSUPP;      \

$ git grep EOPNOTSUPP kernel/bpf/|wc -l
11
$ git grep ENOTSUPP kernel/bpf/|wc -l
51

For new code EOPNOTSUPP is better, but I don't think changing all 51 case
is a good idea. Something might depend on it already.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] bpf: fix errno code for unsupported batch ops
  2021-04-18 22:55 ` Alexei Starovoitov
@ 2021-04-19 13:52   ` Pedro Tammela
  2021-04-19 14:32     ` Alexei Starovoitov
  0 siblings, 1 reply; 4+ messages in thread
From: Pedro Tammela @ 2021-04-19 13:52 UTC (permalink / raw)
  To: Alexei Starovoitov
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Network Development, bpf, LKML, Pedro Tammela

Em dom., 18 de abr. de 2021 às 19:56, Alexei Starovoitov
<alexei.starovoitov@gmail.com> escreveu:
>
> On Sun, Apr 18, 2021 at 1:03 PM Pedro Tammela <pctammela@gmail.com> wrote:
> >
> > ENOTSUPP is not a valid userland errno[1], which is annoying for
> > userland applications that implement a fallback to iterative, report
> > errors via 'strerror()' or both.
> >
> > The batched ops return this errno whenever an operation
> > is not implemented for kernels that implement batched ops.
> >
> > In older kernels, pre batched ops, it returns EINVAL as the arguments
> > are not supported in the syscall.
> >
> > [1] https://lore.kernel.org/netdev/20200511165319.2251678-1-kuba@kernel.org/
> >
> > Signed-off-by: Pedro Tammela <pctammela@mojatatu.com>
> > ---
> >  kernel/bpf/syscall.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> > index fd495190115e..88fe19c0aeb1 100644
> > --- a/kernel/bpf/syscall.c
> > +++ b/kernel/bpf/syscall.c
> > @@ -3961,7 +3961,7 @@ static int bpf_task_fd_query(const union bpf_attr *attr,
> >  #define BPF_DO_BATCH(fn)                       \
> >         do {                                    \
> >                 if (!fn) {                      \
> > -                       err = -ENOTSUPP;        \
> > +                       err = -EOPNOTSUPP;      \
>
> $ git grep EOPNOTSUPP kernel/bpf/|wc -l
> 11
> $ git grep ENOTSUPP kernel/bpf/|wc -l
> 51
>
> For new code EOPNOTSUPP is better, but I don't think changing all 51 case
> is a good idea. Something might depend on it already.

OK, makes sense.

Perhaps, handle this errno in 'libbpf_strerror()'? So language
bindings don't get lost when dealing with this errno.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] bpf: fix errno code for unsupported batch ops
  2021-04-19 13:52   ` Pedro Tammela
@ 2021-04-19 14:32     ` Alexei Starovoitov
  0 siblings, 0 replies; 4+ messages in thread
From: Alexei Starovoitov @ 2021-04-19 14:32 UTC (permalink / raw)
  To: Pedro Tammela
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Network Development, bpf, LKML, Pedro Tammela

On Mon, Apr 19, 2021 at 6:52 AM Pedro Tammela <pctammela@gmail.com> wrote:
>
> Em dom., 18 de abr. de 2021 às 19:56, Alexei Starovoitov
> <alexei.starovoitov@gmail.com> escreveu:
> >
> > On Sun, Apr 18, 2021 at 1:03 PM Pedro Tammela <pctammela@gmail.com> wrote:
> > >
> > > ENOTSUPP is not a valid userland errno[1], which is annoying for
> > > userland applications that implement a fallback to iterative, report
> > > errors via 'strerror()' or both.
> > >
> > > The batched ops return this errno whenever an operation
> > > is not implemented for kernels that implement batched ops.
> > >
> > > In older kernels, pre batched ops, it returns EINVAL as the arguments
> > > are not supported in the syscall.
> > >
> > > [1] https://lore.kernel.org/netdev/20200511165319.2251678-1-kuba@kernel.org/
> > >
> > > Signed-off-by: Pedro Tammela <pctammela@mojatatu.com>
> > > ---
> > >  kernel/bpf/syscall.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> > > index fd495190115e..88fe19c0aeb1 100644
> > > --- a/kernel/bpf/syscall.c
> > > +++ b/kernel/bpf/syscall.c
> > > @@ -3961,7 +3961,7 @@ static int bpf_task_fd_query(const union bpf_attr *attr,
> > >  #define BPF_DO_BATCH(fn)                       \
> > >         do {                                    \
> > >                 if (!fn) {                      \
> > > -                       err = -ENOTSUPP;        \
> > > +                       err = -EOPNOTSUPP;      \
> >
> > $ git grep EOPNOTSUPP kernel/bpf/|wc -l
> > 11
> > $ git grep ENOTSUPP kernel/bpf/|wc -l
> > 51
> >
> > For new code EOPNOTSUPP is better, but I don't think changing all 51 case
> > is a good idea. Something might depend on it already.
>
> OK, makes sense.
>
> Perhaps, handle this errno in 'libbpf_strerror()'?

That's a good idea.

> So language
> bindings don't get lost when dealing with this errno.

I'm not sure what you mean by "language bindings".
In general, strerror is not that useful. The kernel aliases
multiple conditions into the same error code. The error string
is too generic in practice to be useful.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-04-19 14:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-18 20:02 [PATCH] bpf: fix errno code for unsupported batch ops Pedro Tammela
2021-04-18 22:55 ` Alexei Starovoitov
2021-04-19 13:52   ` Pedro Tammela
2021-04-19 14:32     ` Alexei Starovoitov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.