* [PATCH][bpf-next] bpf: return EOPNOTSUPP when invalid map type in __bpf_tx_xdp_map
@ 2020-01-03 6:25 Li RongQing
2020-01-03 19:27 ` Song Liu
2020-01-08 17:17 ` Daniel Borkmann
0 siblings, 2 replies; 4+ messages in thread
From: Li RongQing @ 2020-01-03 6:25 UTC (permalink / raw)
To: netdev, bpf
a negative value -EOPNOTSUPP should be returned if map->map_type
is invalid although that seems unlikely now, then the caller will
continue to handle buffer, or else the buffer will be leaked
Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
net/core/filter.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/core/filter.c b/net/core/filter.c
index 1cbac34a4e11..40fa5905321c 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -3512,7 +3512,7 @@ static int __bpf_tx_xdp_map(struct net_device *dev_rx, void *fwd,
case BPF_MAP_TYPE_XSKMAP:
return __xsk_map_redirect(fwd, xdp);
default:
- break;
+ return -EOPNOTSUPP;
}
return 0;
}
--
2.16.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH][bpf-next] bpf: return EOPNOTSUPP when invalid map type in __bpf_tx_xdp_map
2020-01-03 6:25 [PATCH][bpf-next] bpf: return EOPNOTSUPP when invalid map type in __bpf_tx_xdp_map Li RongQing
@ 2020-01-03 19:27 ` Song Liu
2020-01-08 17:17 ` Daniel Borkmann
1 sibling, 0 replies; 4+ messages in thread
From: Song Liu @ 2020-01-03 19:27 UTC (permalink / raw)
To: Li RongQing; +Cc: Networking, bpf
On Thu, Jan 2, 2020 at 10:26 PM Li RongQing <lirongqing@baidu.com> wrote:
>
> a negative value -EOPNOTSUPP should be returned if map->map_type
> is invalid although that seems unlikely now, then the caller will
> continue to handle buffer, or else the buffer will be leaked
>
> Signed-off-by: Li RongQing <lirongqing@baidu.com>
Acked-by: Song Liu <songliubraving@fb.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][bpf-next] bpf: return EOPNOTSUPP when invalid map type in __bpf_tx_xdp_map
2020-01-03 6:25 [PATCH][bpf-next] bpf: return EOPNOTSUPP when invalid map type in __bpf_tx_xdp_map Li RongQing
2020-01-03 19:27 ` Song Liu
@ 2020-01-08 17:17 ` Daniel Borkmann
2020-01-09 10:24 ` 答复: " Li,Rongqing
1 sibling, 1 reply; 4+ messages in thread
From: Daniel Borkmann @ 2020-01-08 17:17 UTC (permalink / raw)
To: Li RongQing; +Cc: netdev, bpf, brouer
On 1/3/20 7:25 AM, Li RongQing wrote:
> a negative value -EOPNOTSUPP should be returned if map->map_type
> is invalid although that seems unlikely now, then the caller will
> continue to handle buffer, or else the buffer will be leaked
>
> Signed-off-by: Li RongQing <lirongqing@baidu.com>
> ---
> net/core/filter.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/core/filter.c b/net/core/filter.c
> index 1cbac34a4e11..40fa5905321c 100644
> --- a/net/core/filter.c
> +++ b/net/core/filter.c
> @@ -3512,7 +3512,7 @@ static int __bpf_tx_xdp_map(struct net_device *dev_rx, void *fwd,
> case BPF_MAP_TYPE_XSKMAP:
> return __xsk_map_redirect(fwd, xdp);
> default:
> - break;
> + return -EOPNOTSUPP;
So in case of generic XDP we return with -EBADRQC in xdp_do_generic_redirect_map().
I would suggest we adapt the same error code here as well, so it's consistent for
the tracepoint output and not to be confused with -EOPNOTSUPP from other locations
like dev_map_enqueue() when ndo_xdp_xmit is missing or such.
> }
> return 0;
> }
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* 答复: [PATCH][bpf-next] bpf: return EOPNOTSUPP when invalid map type in __bpf_tx_xdp_map
2020-01-08 17:17 ` Daniel Borkmann
@ 2020-01-09 10:24 ` Li,Rongqing
0 siblings, 0 replies; 4+ messages in thread
From: Li,Rongqing @ 2020-01-09 10:24 UTC (permalink / raw)
To: Daniel Borkmann; +Cc: netdev, bpf, brouer
> -----邮件原件-----
> 发件人: Daniel Borkmann [mailto:daniel@iogearbox.net]
> 发送时间: 2020年1月9日 1:18
> 收件人: Li,Rongqing <lirongqing@baidu.com>
> 抄送: netdev@vger.kernel.org; bpf@vger.kernel.org; brouer@redhat.com
> 主题: Re: [PATCH][bpf-next] bpf: return EOPNOTSUPP when invalid map type in
> __bpf_tx_xdp_map
>
> On 1/3/20 7:25 AM, Li RongQing wrote:
> > a negative value -EOPNOTSUPP should be returned if map->map_type is
> > invalid although that seems unlikely now, then the caller will
> > continue to handle buffer, or else the buffer will be leaked
> >
> > Signed-off-by: Li RongQing <lirongqing@baidu.com>
> > ---
> > net/core/filter.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/net/core/filter.c b/net/core/filter.c index
> > 1cbac34a4e11..40fa5905321c 100644
> > --- a/net/core/filter.c
> > +++ b/net/core/filter.c
> > @@ -3512,7 +3512,7 @@ static int __bpf_tx_xdp_map(struct net_device
> *dev_rx, void *fwd,
> > case BPF_MAP_TYPE_XSKMAP:
> > return __xsk_map_redirect(fwd, xdp);
> > default:
> > - break;
> > + return -EOPNOTSUPP;
>
> So in case of generic XDP we return with -EBADRQC in
> xdp_do_generic_redirect_map().
> I would suggest we adapt the same error code here as well, so it's consistent
> for the tracepoint output and not to be confused with -EOPNOTSUPP from other
> locations like dev_map_enqueue() when ndo_xdp_xmit is missing or such.
Ok, I will send v2
Thanks
-Li
>
> > }
> > return 0;
> > }
> >
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-01-09 11:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-03 6:25 [PATCH][bpf-next] bpf: return EOPNOTSUPP when invalid map type in __bpf_tx_xdp_map Li RongQing
2020-01-03 19:27 ` Song Liu
2020-01-08 17:17 ` Daniel Borkmann
2020-01-09 10:24 ` 答复: " Li,Rongqing
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).