Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1740686

Re: [PATCH v2] tun: bail out from tun_get_user() if the skb is empty

From Eric Dumazet <eric.dumazet@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH v2] tun: bail out from tun_get_user() if the skb is empty
Date 2017-09-27 14:50 +0200
Message-ID <uujWP-2Bu-25@gated-at.bofh.it> (permalink)
References <uujtN-2gN-33@gated-at.bofh.it> <uujWO-2Bu-15@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Wed, 2017-09-27 at 05:42 -0700, Eric Dumazet wrote:

> Or something cleaner to avoid copy/paste and focus on proper
> skb->data[0] access and meaning.
> 
> Thanks.
> 
> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> index 3c9985f299503ea65dad7eb3b47e2ab3bef87800..8ddb840687c1bdb24e4182612abc9e362624c3e9 100644
> --- a/drivers/net/tun.c
> +++ b/drivers/net/tun.c
> @@ -1496,11 +1496,13 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
>  	switch (tun->flags & TUN_TYPE_MASK) {
>  	case IFF_TUN:
>  		if (tun->flags & IFF_NO_PI) {
> -			switch (skb->data[0] & 0xf0) {
> -			case 0x40:
> +			u8 ip_proto = skb->len ? (skb->data[0] >> 4) : 0;

And name this variable ip_version ;)

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2] tun: bail out from tun_get_user() if the skb is empty Alexander Potapenko <glider@google.com> - 2017-09-27 14:20 +0200
  Re: [PATCH v2] tun: bail out from tun_get_user() if the skb is empty Eric Dumazet <eric.dumazet@gmail.com> - 2017-09-27 14:50 +0200
    Re: [PATCH v2] tun: bail out from tun_get_user() if the skb is empty Eric Dumazet <eric.dumazet@gmail.com> - 2017-09-27 14:50 +0200
      Re: [PATCH v2] tun: bail out from tun_get_user() if the skb is empty Alexander Potapenko <glider@google.com> - 2017-09-27 15:00 +0200
        Re: [PATCH v2] tun: bail out from tun_get_user() if the skb is empty Eric Dumazet <edumazet@google.com> - 2017-09-27 15:30 +0200
          Re: [PATCH v2] tun: bail out from tun_get_user() if the skb is empty Alexander Potapenko <glider@google.com> - 2017-09-27 16:40 +0200

csiph-web