bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf] bpf: sockmap: don't attach programs to UDP sockets
@ 2020-06-11 17:25 Lorenz Bauer
  2020-06-12 10:17 ` Jakub Sitnicki
  0 siblings, 1 reply; 3+ messages in thread
From: Lorenz Bauer @ 2020-06-11 17:25 UTC (permalink / raw)
  To: John Fastabend, Daniel Borkmann, Jakub Sitnicki, Lorenz Bauer,
	David S. Miller, Jakub Kicinski, Alexei Starovoitov
  Cc: kernel-team, netdev, bpf, linux-kernel

The stream parser infrastructure isn't set up to deal with UDP
sockets, so we mustn't try to attach programs to them.

I remember making this change at some point, but I must have lost
it while rebasing or something similar.

Fixes: 7b98cd42b049 ("bpf: sockmap: Add UDP support")
Signed-off-by: Lorenz Bauer <lmb@cloudflare.com>
---
 net/core/sock_map.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/net/core/sock_map.c b/net/core/sock_map.c
index 00a26cf2cfe9..35cea36f3892 100644
--- a/net/core/sock_map.c
+++ b/net/core/sock_map.c
@@ -424,10 +424,7 @@ static int sock_map_get_next_key(struct bpf_map *map, void *key, void *next)
 	return 0;
 }
 
-static bool sock_map_redirect_allowed(const struct sock *sk)
-{
-	return sk->sk_state != TCP_LISTEN;
-}
+static bool sock_map_redirect_allowed(const struct sock *sk);
 
 static int sock_map_update_common(struct bpf_map *map, u32 idx,
 				  struct sock *sk, u64 flags)
@@ -508,6 +505,11 @@ static bool sk_is_udp(const struct sock *sk)
 	       sk->sk_protocol == IPPROTO_UDP;
 }
 
+static bool sock_map_redirect_allowed(const struct sock *sk)
+{
+	return sk_is_tcp(sk) && sk->sk_state != TCP_LISTEN;
+}
+
 static bool sock_map_sk_is_suitable(const struct sock *sk)
 {
 	return sk_is_tcp(sk) || sk_is_udp(sk);
-- 
2.25.1


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

* Re: [PATCH bpf] bpf: sockmap: don't attach programs to UDP sockets
  2020-06-11 17:25 [PATCH bpf] bpf: sockmap: don't attach programs to UDP sockets Lorenz Bauer
@ 2020-06-12 10:17 ` Jakub Sitnicki
  2020-06-12 22:54   ` John Fastabend
  0 siblings, 1 reply; 3+ messages in thread
From: Jakub Sitnicki @ 2020-06-12 10:17 UTC (permalink / raw)
  To: Lorenz Bauer
  Cc: John Fastabend, Daniel Borkmann, David S. Miller, Jakub Kicinski,
	Alexei Starovoitov, kernel-team, netdev, bpf, linux-kernel

On Thu, 11 Jun 2020 18:25:20 +0100
Lorenz Bauer <lmb@cloudflare.com> wrote:

> The stream parser infrastructure isn't set up to deal with UDP
> sockets, so we mustn't try to attach programs to them.
> 
> I remember making this change at some point, but I must have lost
> it while rebasing or something similar.
> 
> Fixes: 7b98cd42b049 ("bpf: sockmap: Add UDP support")
> Signed-off-by: Lorenz Bauer <lmb@cloudflare.com>
> ---
>  net/core/sock_map.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/net/core/sock_map.c b/net/core/sock_map.c
> index 00a26cf2cfe9..35cea36f3892 100644
> --- a/net/core/sock_map.c
> +++ b/net/core/sock_map.c
> @@ -424,10 +424,7 @@ static int sock_map_get_next_key(struct bpf_map *map, void *key, void *next)
>  	return 0;
>  }
>  
> -static bool sock_map_redirect_allowed(const struct sock *sk)
> -{
> -	return sk->sk_state != TCP_LISTEN;
> -}
> +static bool sock_map_redirect_allowed(const struct sock *sk);
>  
>  static int sock_map_update_common(struct bpf_map *map, u32 idx,
>  				  struct sock *sk, u64 flags)
> @@ -508,6 +505,11 @@ static bool sk_is_udp(const struct sock *sk)
>  	       sk->sk_protocol == IPPROTO_UDP;
>  }
>  
> +static bool sock_map_redirect_allowed(const struct sock *sk)
> +{
> +	return sk_is_tcp(sk) && sk->sk_state != TCP_LISTEN;
> +}
> +
>  static bool sock_map_sk_is_suitable(const struct sock *sk)
>  {
>  	return sk_is_tcp(sk) || sk_is_udp(sk);

Acked-by: Jakub Sitnicki <jakub@cloudflare.com>

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

* Re: [PATCH bpf] bpf: sockmap: don't attach programs to UDP sockets
  2020-06-12 10:17 ` Jakub Sitnicki
@ 2020-06-12 22:54   ` John Fastabend
  0 siblings, 0 replies; 3+ messages in thread
From: John Fastabend @ 2020-06-12 22:54 UTC (permalink / raw)
  To: Jakub Sitnicki, Lorenz Bauer
  Cc: John Fastabend, Daniel Borkmann, David S. Miller, Jakub Kicinski,
	Alexei Starovoitov, kernel-team, netdev, bpf, linux-kernel

Jakub Sitnicki wrote:
> On Thu, 11 Jun 2020 18:25:20 +0100
> Lorenz Bauer <lmb@cloudflare.com> wrote:
> 
> > The stream parser infrastructure isn't set up to deal with UDP
> > sockets, so we mustn't try to attach programs to them.
> > 
> > I remember making this change at some point, but I must have lost
> > it while rebasing or something similar.
> > 
> > Fixes: 7b98cd42b049 ("bpf: sockmap: Add UDP support")
> > Signed-off-by: Lorenz Bauer <lmb@cloudflare.com>
> > ---
> >  net/core/sock_map.c | 10 ++++++----
> >  1 file changed, 6 insertions(+), 4 deletions(-)
> > 
> > diff --git a/net/core/sock_map.c b/net/core/sock_map.c
> > index 00a26cf2cfe9..35cea36f3892 100644
> > --- a/net/core/sock_map.c
> > +++ b/net/core/sock_map.c
> > @@ -424,10 +424,7 @@ static int sock_map_get_next_key(struct bpf_map *map, void *key, void *next)
> >  	return 0;
> >  }
> >  
> > -static bool sock_map_redirect_allowed(const struct sock *sk)
> > -{
> > -	return sk->sk_state != TCP_LISTEN;
> > -}
> > +static bool sock_map_redirect_allowed(const struct sock *sk);
> >  
> >  static int sock_map_update_common(struct bpf_map *map, u32 idx,
> >  				  struct sock *sk, u64 flags)
> > @@ -508,6 +505,11 @@ static bool sk_is_udp(const struct sock *sk)
> >  	       sk->sk_protocol == IPPROTO_UDP;
> >  }
> >  
> > +static bool sock_map_redirect_allowed(const struct sock *sk)
> > +{
> > +	return sk_is_tcp(sk) && sk->sk_state != TCP_LISTEN;
> > +}
> > +
> >  static bool sock_map_sk_is_suitable(const struct sock *sk)
> >  {
> >  	return sk_is_tcp(sk) || sk_is_udp(sk);
> 
> Acked-by: Jakub Sitnicki <jakub@cloudflare.com>

Thanks.

Acked-by: John Fastabend <john.fastabend@gmail.com>

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

end of thread, other threads:[~2020-06-12 22:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-11 17:25 [PATCH bpf] bpf: sockmap: don't attach programs to UDP sockets Lorenz Bauer
2020-06-12 10:17 ` Jakub Sitnicki
2020-06-12 22:54   ` John Fastabend

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).