netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Milan Dadok <milan@dadok.name>
Cc: kaber@trash.net, uaca@alumni.uv.es, johann.baudy@gnu-log.net,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH] 1/1 net: packet: Keep 802.1Q VLAN tag in packet on SOCK_DGRAM socket - resend
Date: Mon, 04 Jan 2010 11:36:50 +0100	[thread overview]
Message-ID: <4B41C4C2.3030404@gmail.com> (raw)
In-Reply-To: <001801ca8d1d$90c68de0$b253a9a0$@name>

Le 04/01/2010 10:09, Milan Dadok a écrit :
> Keep 802.1Q VLAN tag on non HW vlan accelerated network card received to SOCK_DGRAM socket.
> 
> Signed-off-by: Milan Dadok <milan@dadok.name>
> 
> ---
> diff -urN af_packet.c.orig af_packet.c
> --- af_packet.c.orig    2009-12-26 12:34:15.000000000 +0100
> +++ af_packet.c 2009-12-28 14:31:14.000000000 +0100
> @@ -57,6 +57,8 @@
>  #include <linux/inet.h>
>  #include <linux/netdevice.h>
>  #include <linux/if_packet.h>
> +#include <linux/if_vlan.h>
> +#include "../8021q/vlan.h"

This is ugly, please move is_vlan_dev() in if_vlan.h instead ?

>  #include <linux/wireless.h>
>  #include <linux/kernel.h>
>  #include <linux/kmod.h>
> @@ -680,8 +682,28 @@
>                 if (sk->sk_type != SOCK_DGRAM)
>                         skb_push(skb, skb->data - skb_mac_header(skb));
>                 else if (skb->pkt_type == PACKET_OUTGOING) {
> -                       /* Special case: outgoing packets have ll header at head */
> -                       skb_pull(skb, skb_network_offset(skb));
> +                       /* Special case: outgoing packets have ll header at head
> +                        * but we must leave 802.1Q encapsulation etc. (only for non HW vlan accelerated)
> +                        * encasulation len = actual header_len minus hard_header_len
> +                        * packet outgoing from vlan1@eth0 on eth0 have skb_network_offset=18, hard_header_len=14
> +                        */
> +                       int hard_header_len;
> +                       struct net_device *pdev;
> +                       hard_header_len = dev->hard_header_len;
> +                       pdev = dev;
> +                       /* if dev is vlan device, hard_header_len contains 802.1Q encap, subtract it, recursively
> +                        * ie. vlan3@vlan2@vlan1@eth0
> +                        */
> +                       while (is_vlan_dev(pdev)) {
> +                               struct net_device *real_dev = vlan_dev_info(pdev)->real_dev;
A new line after variable definition is welcomed.
> +                               hard_header_len -= pdev->hard_header_len - real_dev->hard_header_len;
> +                               pdev = real_dev;
> +                       }
> +
> +                       skb_pull(skb, skb_network_offset(skb) -
> +                            (skb_network_offset(skb) - hard_header_len>0 ? skb_network_offset(skb) - hard_header_len : 0));
>                 }
>         }

I find this logic a bit hard to read, you might use this instead :

if (skb_network_offset(skb) > hard_header_len)
	skb_pull(skb, hard_header_len);
else
	skb_pull(skb, skb_network_offset(skb));




Also, could you please read Documentation/SubmittingPatches and
Documentation/email-clients.txt

Your patch has at least two problems :

1) It is not an unified diff
2) It has garbled tabulations (they are replaced by spaces)

It is not applicable as is.

Thank you

  reply	other threads:[~2010-01-04 10:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-04  9:09 [PATCH] 1/1 net: packet: Keep 802.1Q VLAN tag in packet on SOCK_DGRAM socket - resend Milan Dadok
2010-01-04 10:36 ` Eric Dumazet [this message]
2010-01-04 13:52 ` Patrick McHardy
2010-01-04 15:28   ` Milan Dadok
2010-01-04 16:29     ` Patrick McHardy
2010-01-04 17:11       ` Milan Dadok
2010-01-05  5:17         ` Patrick McHardy

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=4B41C4C2.3030404@gmail.com \
    --to=eric.dumazet@gmail.com \
    --cc=johann.baudy@gnu-log.net \
    --cc=kaber@trash.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=milan@dadok.name \
    --cc=netdev@vger.kernel.org \
    --cc=uaca@alumni.uv.es \
    /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 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).