On Tue, Jan 5, 2016 at 12:38 PM, Eric Dumazet <eric.duma...@gmail.com> wrote:
> On Tue, 2016-01-05 at 10:57 -0500, Craig Gallek wrote:
>> From: Craig Gallek <kr...@google.com>
>>
>> Fixes: 538950a1b752 ("soreuseport: setsockopt SO_ATTACH_REUSEPORT_[CE]BPF")
>> Suggested-by: Daniel Borkmann <dan...@iogearbox.net>
>> Signed-off-by: Craig Gallek <kr...@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;
>
>
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to