All of lore.kernel.org
 help / color / mirror / Atom feed
From: Craig Gallek <kraigatgoog@gmail.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: netdev@vger.kernel.org, David Miller <davem@davemloft.net>
Subject: Re: [PATCH net-next] soreuseport: change consume_skb to kfree_skb in error case
Date: Tue, 5 Jan 2016 12:47:44 -0500	[thread overview]
Message-ID: <CAEfhGiyu0iRJcnOUiippoOtRZzUwoSihGVb3240G9hBSh0t5bw@mail.gmail.com> (raw)
In-Reply-To: <1452015516.8255.106.camel@edumazet-glaptop2.roam.corp.google.com>

On Tue, Jan 5, 2016 at 12:38 PM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> On Tue, 2016-01-05 at 10:57 -0500, Craig Gallek wrote:
>> From: Craig Gallek <kraig@google.com>
>>
>> Fixes: 538950a1b752 ("soreuseport: setsockopt SO_ATTACH_REUSEPORT_[CE]BPF")
>> Suggested-by: Daniel Borkmann <daniel@iogearbox.net>
>> Signed-off-by: Craig Gallek <kraig@google.com>
>> ---
>>  net/core/sock_reuseport.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/net/core/sock_reuseport.c b/net/core/sock_reuseport.c
>> index ae0969c0fc2e..1df98c557440 100644
>> --- a/net/core/sock_reuseport.c
>> +++ b/net/core/sock_reuseport.c
>> @@ -173,7 +173,7 @@ static struct sock *run_bpf(struct sock_reuseport *reuse, u16 socks,
>>
>>       /* temporarily advance data past protocol header */
>>       if (!pskb_pull(skb, hdr_len)) {
>> -             consume_skb(nskb);
>> +             kfree_skb(nskb);
>>               return NULL;
>>       }
>>       index = bpf_prog_run_save_cb(prog, skb);
>
> Note that we always call reuseport_select_sock() after pulling the
> headers in skb->head anyway, so the pskb_pull() can never fail.
>
> It really could be __skb_pull()
>
> BTW, why UDP calls reuseport_select_sock() with hdr_len == 0 sometimes ?
hdr_len only matters when you have an skb to work with.  In both of
the call sites of your suggested patch, NULL is passed for the skb
parameter so hdr_len is never used.  When no skb is available, the
code falls back to the hash-based method used in the non-BPF case.

> I believe the following patch is needed.
>
> diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
> index 835378365f25..52387096dbba 100644
> --- a/net/ipv4/udp.c
> +++ b/net/ipv4/udp.c
> @@ -514,7 +514,8 @@ begin:
>                                 struct sock *sk2;
>                                 hash = udp_ehashfn(net, daddr, hnum,
>                                                    saddr, sport);
> -                               sk2 = reuseport_select_sock(sk, hash, NULL, 0);
> +                               sk2 = reuseport_select_sock(sk, hash, NULL,
> +                                                           sizeof(struct udphdr));
>                                 if (sk2) {
>                                         result = sk2;
>                                         goto found;
> diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
> index 56fcb55fda31..da0a5fa02b0f 100644
> --- a/net/ipv6/udp.c
> +++ b/net/ipv6/udp.c
> @@ -272,7 +272,8 @@ begin:
>                                 struct sock *sk2;
>                                 hash = udp6_ehashfn(net, daddr, hnum,
>                                                     saddr, sport);
> -                               sk2 = reuseport_select_sock(sk, hash, NULL, 0);
> +                               sk2 = reuseport_select_sock(sk, hash, NULL,
> +                                                           sizeof(struct udphdr));
>                                 if (sk2) {
>                                         result = sk2;
>                                         goto found;
>
>

  reply	other threads:[~2016-01-05 17:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-05 15:57 [PATCH net-next] soreuseport: change consume_skb to kfree_skb in error case Craig Gallek
2016-01-05 16:39 ` Daniel Borkmann
2016-01-05 17:38 ` Eric Dumazet
2016-01-05 17:47   ` Craig Gallek [this message]
2016-01-05 18:31     ` Eric Dumazet
2016-01-05 19:12       ` Craig Gallek
2016-01-05 19:34         ` Eric Dumazet
2016-01-06  6:31 ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAEfhGiyu0iRJcnOUiippoOtRZzUwoSihGVb3240G9hBSh0t5bw@mail.gmail.com \
    --to=kraigatgoog@gmail.com \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.