netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2 v2] network: Allow af_packet to transmit +4 bytes for VLAN packets.
@ 2011-02-11 19:35 greearb
  2011-02-11 22:18 ` Eric Dumazet
  0 siblings, 1 reply; 3+ messages in thread
From: greearb @ 2011-02-11 19:35 UTC (permalink / raw)
  To: netdev; +Cc: Ben Greear

From: Ben Greear <greearb@candelatech.com>

This allows user-space to send a '1500' MTU VLAN packet on a
1500 MTU ethernet frame.  The extra 4 bytes of a VLAN header is
not usually charged against the MTU when other parts of the
network stack is transmitting vlans...

Signed-off-by: Ben Greear <greearb@candelatech.com>
---

v2:  Fix ETH_HLEN to be VLAN_HLEN

:100644 100644 91cb1d7... eb39d70... M	net/packet/af_packet.c
 net/packet/af_packet.c |   31 +++++++++++++++++++++++++++++--
 1 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 91cb1d7..eb39d70 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -466,7 +466,7 @@ retry:
 	 */
 
 	err = -EMSGSIZE;
-	if (len > dev->mtu + dev->hard_header_len)
+	if (len > dev->mtu + dev->hard_header_len + VLAN_HLEN)
 		goto out_unlock;
 
 	if (!skb) {
@@ -497,6 +497,19 @@ retry:
 		goto retry;
 	}
 
+	if (len > (dev->mtu + dev->hard_header_len)) {
+		/* Earlier code assumed this would be a VLAN pkt,
+		 * double-check this now that we have the actual
+		 * packet in hand.
+		 */
+		struct ethhdr *ehdr;
+		skb_reset_mac_header(skb);
+		ehdr = eth_hdr(skb);
+		if (ehdr->h_proto != htons(ETH_P_8021Q)) {
+			err = -EMSGSIZE;
+			goto out_unlock;
+		}
+	}
 
 	skb->protocol = proto;
 	skb->dev = dev;
@@ -1200,7 +1213,7 @@ static int packet_snd(struct socket *sock,
 	}
 
 	err = -EMSGSIZE;
-	if (!gso_type && (len > dev->mtu+reserve))
+	if (!gso_type && (len > dev->mtu + reserve + VLAN_HLEN))
 		goto out_unlock;
 
 	err = -ENOBUFS;
@@ -1225,6 +1238,20 @@ static int packet_snd(struct socket *sock,
 	if (err < 0)
 		goto out_free;
 
+	if (!gso_type && (len > dev->mtu + reserve)) {
+		/* Earlier code assumed this would be a VLAN pkt,
+		 * double-check this now that we have the actual
+		 * packet in hand.
+		 */
+		struct ethhdr *ehdr;
+		skb_reset_mac_header(skb);
+		ehdr = eth_hdr(skb);
+		if (ehdr->h_proto != htons(ETH_P_8021Q)) {
+			err = -EMSGSIZE;
+			goto out_free;
+		}
+	}
+
 	skb->protocol = proto;
 	skb->dev = dev;
 	skb->priority = sk->sk_priority;
-- 
1.7.2.3


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

* Re: [PATCH 2/2 v2] network: Allow af_packet to transmit +4 bytes for VLAN packets.
  2011-02-11 19:35 [PATCH 2/2 v2] network: Allow af_packet to transmit +4 bytes for VLAN packets greearb
@ 2011-02-11 22:18 ` Eric Dumazet
  2011-02-12  5:26   ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Dumazet @ 2011-02-11 22:18 UTC (permalink / raw)
  To: greearb; +Cc: netdev

Le vendredi 11 février 2011 à 11:35 -0800, greearb@candelatech.com a
écrit :
> From: Ben Greear <greearb@candelatech.com>
> 
> This allows user-space to send a '1500' MTU VLAN packet on a
> 1500 MTU ethernet frame.  The extra 4 bytes of a VLAN header is
> not usually charged against the MTU when other parts of the
> network stack is transmitting vlans...
> 
> Signed-off-by: Ben Greear <greearb@candelatech.com>
> ---

Reviewed-by: Eric Dumazet <eric.dumazet@gmail.com>



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

* Re: [PATCH 2/2 v2] network: Allow af_packet to transmit +4 bytes for VLAN packets.
  2011-02-11 22:18 ` Eric Dumazet
@ 2011-02-12  5:26   ` David Miller
  0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2011-02-12  5:26 UTC (permalink / raw)
  To: eric.dumazet; +Cc: greearb, netdev

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Fri, 11 Feb 2011 23:18:38 +0100

> Le vendredi 11 février 2011 à 11:35 -0800, greearb@candelatech.com a
> écrit :
>> From: Ben Greear <greearb@candelatech.com>
>> 
>> This allows user-space to send a '1500' MTU VLAN packet on a
>> 1500 MTU ethernet frame.  The extra 4 bytes of a VLAN header is
>> not usually charged against the MTU when other parts of the
>> network stack is transmitting vlans...
>> 
>> Signed-off-by: Ben Greear <greearb@candelatech.com>
>> ---
> 
> Reviewed-by: Eric Dumazet <eric.dumazet@gmail.com>

Applied to net-next-2.6, thanks.

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

end of thread, other threads:[~2011-02-12  5:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-11 19:35 [PATCH 2/2 v2] network: Allow af_packet to transmit +4 bytes for VLAN packets greearb
2011-02-11 22:18 ` Eric Dumazet
2011-02-12  5:26   ` David Miller

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