netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: bridge: check the length of skb after nf_bridge_maybe_copy_header()
@ 2010-12-25 13:41 Changli Gao
  2010-12-31 19:10 ` David Miller
  0 siblings, 1 reply; 8+ messages in thread
From: Changli Gao @ 2010-12-25 13:41 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: David S. Miller, bridge, netdev, Changli Gao

Since nf_bridge_maybe_copy_header() may change the length of skb,
we should check the length of skb after it to handle the ppoe skbs.

Signed-off-by: Changli Gao <xiaosuo@gmail.com>
---
 net/bridge/br_forward.c |   16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c
index 2bd11ec..ee64287 100644
--- a/net/bridge/br_forward.c
+++ b/net/bridge/br_forward.c
@@ -41,17 +41,13 @@ static inline unsigned packet_length(const struct sk_buff *skb)
 
 int br_dev_queue_push_xmit(struct sk_buff *skb)
 {
-	/* drop mtu oversized packets except gso */
-	if (packet_length(skb) > skb->dev->mtu && !skb_is_gso(skb))
+	/* ip_fragment doesn't copy the MAC header */
+	if (nf_bridge_maybe_copy_header(skb) ||
+	    (packet_length(skb) > skb->dev->mtu && !skb_is_gso(skb))) {
 		kfree_skb(skb);
-	else {
-		/* ip_fragment doesn't copy the MAC header */
-		if (nf_bridge_maybe_copy_header(skb))
-			kfree_skb(skb);
-		else {
-			skb_push(skb, ETH_HLEN);
-			dev_queue_xmit(skb);
-		}
+	} else {
+		skb_push(skb, ETH_HLEN);
+		dev_queue_xmit(skb);
 	}
 
 	return 0;

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

* Re: [PATCH] net: bridge: check the length of skb after nf_bridge_maybe_copy_header()
  2010-12-25 13:41 [PATCH] net: bridge: check the length of skb after nf_bridge_maybe_copy_header() Changli Gao
@ 2010-12-31 19:10 ` David Miller
  2011-01-03 10:44   ` Changli Gao
  0 siblings, 1 reply; 8+ messages in thread
From: David Miller @ 2010-12-31 19:10 UTC (permalink / raw)
  To: xiaosuo; +Cc: shemminger, bridge, netdev

From: Changli Gao <xiaosuo@gmail.com>
Date: Sat, 25 Dec 2010 21:41:30 +0800

> Since nf_bridge_maybe_copy_header() may change the length of skb,
> we should check the length of skb after it to handle the ppoe skbs.
> 
> Signed-off-by: Changli Gao <xiaosuo@gmail.com>

This is really strange.

packet_length() subtracts VLAN_HLEN from the value it returns, so the
correct fix seems to be to make this function handle the PPPOE case
too.

Otherwise I suspect you have many other functions to fix as well.

I'm not applying this patch.

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

* Re: [PATCH] net: bridge: check the length of skb after nf_bridge_maybe_copy_header()
  2010-12-31 19:10 ` David Miller
@ 2011-01-03 10:44   ` Changli Gao
  2011-01-03 17:22     ` David Miller
  0 siblings, 1 reply; 8+ messages in thread
From: Changli Gao @ 2011-01-03 10:44 UTC (permalink / raw)
  To: David Miller; +Cc: shemminger, bridge, netdev

On Sat, Jan 1, 2011 at 3:10 AM, David Miller <davem@davemloft.net> wrote:
> From: Changli Gao <xiaosuo@gmail.com>
> Date: Sat, 25 Dec 2010 21:41:30 +0800
>
>> Since nf_bridge_maybe_copy_header() may change the length of skb,
>> we should check the length of skb after it to handle the ppoe skbs.
>>
>> Signed-off-by: Changli Gao <xiaosuo@gmail.com>
>
> This is really strange.
>
> packet_length() subtracts VLAN_HLEN from the value it returns, so the
> correct fix seems to be to make this function handle the PPPOE case
> too.
>

It is correct. The actual MTU of 802.1q frame is 4 bytes larger. For
example, the MTU of ethernet is normally 1500, however the actual MTU
of the 802.1Q is 1504.

Please see this patch:
http://git.kernel.org/?p=linux/kernel/git/davem/net-next-2.6.git;a=commitdiff;h=c893b8066c7bf6156e4d760e5acaf4c148e37190;hp=3c0fef0b7d36e5f8d3ea3731a8228102274e3c23

> Otherwise I suspect you have many other functions to fix as well.
>
> I'm not applying this patch.
>



-- 
Regards,
Changli Gao(xiaosuo@gmail.com)

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

* Re: [PATCH] net: bridge: check the length of skb after nf_bridge_maybe_copy_header()
  2011-01-03 10:44   ` Changli Gao
@ 2011-01-03 17:22     ` David Miller
  2011-01-03 18:15       ` Stephen Hemminger
  0 siblings, 1 reply; 8+ messages in thread
From: David Miller @ 2011-01-03 17:22 UTC (permalink / raw)
  To: xiaosuo; +Cc: shemminger, bridge, netdev

From: Changli Gao <xiaosuo@gmail.com>
Date: Mon, 3 Jan 2011 18:44:59 +0800

> On Sat, Jan 1, 2011 at 3:10 AM, David Miller <davem@davemloft.net> wrote:
>> From: Changli Gao <xiaosuo@gmail.com>
>> Date: Sat, 25 Dec 2010 21:41:30 +0800
>>
>>> Since nf_bridge_maybe_copy_header() may change the length of skb,
>>> we should check the length of skb after it to handle the ppoe skbs.
>>>
>>> Signed-off-by: Changli Gao <xiaosuo@gmail.com>
>>
>> This is really strange.
>>
>> packet_length() subtracts VLAN_HLEN from the value it returns, so the
>> correct fix seems to be to make this function handle the PPPOE case
>> too.
>>
> 
> It is correct. The actual MTU of 802.1q frame is 4 bytes larger. For
> example, the MTU of ethernet is normally 1500, however the actual MTU
> of the 802.1Q is 1504.

Yes, I understand this, but I don't see why packet_length() cannot
simply account for PPPOE's encapsulation overhead just as it does for
VLAN's special MTU considerations.

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

* Re: [PATCH] net: bridge: check the length of skb after nf_bridge_maybe_copy_header()
  2011-01-03 17:22     ` David Miller
@ 2011-01-03 18:15       ` Stephen Hemminger
  2011-01-03 20:13         ` David Miller
  0 siblings, 1 reply; 8+ messages in thread
From: Stephen Hemminger @ 2011-01-03 18:15 UTC (permalink / raw)
  To: David Miller; +Cc: xiaosuo, bridge, netdev

On Mon, 03 Jan 2011 09:22:14 -0800 (PST)
David Miller <davem@davemloft.net> wrote:

> From: Changli Gao <xiaosuo@gmail.com>
> Date: Mon, 3 Jan 2011 18:44:59 +0800
> 
> > On Sat, Jan 1, 2011 at 3:10 AM, David Miller <davem@davemloft.net> wrote:
> >> From: Changli Gao <xiaosuo@gmail.com>
> >> Date: Sat, 25 Dec 2010 21:41:30 +0800
> >>
> >>> Since nf_bridge_maybe_copy_header() may change the length of skb,
> >>> we should check the length of skb after it to handle the ppoe skbs.
> >>>
> >>> Signed-off-by: Changli Gao <xiaosuo@gmail.com>
> >>
> >> This is really strange.
> >>
> >> packet_length() subtracts VLAN_HLEN from the value it returns, so the
> >> correct fix seems to be to make this function handle the PPPOE case
> >> too.
> >>
> > 
> > It is correct. The actual MTU of 802.1q frame is 4 bytes larger. For
> > example, the MTU of ethernet is normally 1500, however the actual MTU
> > of the 802.1Q is 1504.
> 
> Yes, I understand this, but I don't see why packet_length() cannot
> simply account for PPPOE's encapsulation overhead just as it does for
> VLAN's special MTU considerations.

Because PPPOE happens afterwards and is not part the calculation.
The check should be moved until after skb has reached final form.

-- 

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

* Re: [PATCH] net: bridge: check the length of skb after nf_bridge_maybe_copy_header()
  2011-01-03 18:15       ` Stephen Hemminger
@ 2011-01-03 20:13         ` David Miller
  2011-01-05 13:37           ` Changli Gao
  0 siblings, 1 reply; 8+ messages in thread
From: David Miller @ 2011-01-03 20:13 UTC (permalink / raw)
  To: shemminger; +Cc: xiaosuo, bridge, netdev

From: Stephen Hemminger <shemminger@linux-foundation.org>
Date: Mon, 3 Jan 2011 10:15:33 -0800

> On Mon, 03 Jan 2011 09:22:14 -0800 (PST)
> David Miller <davem@davemloft.net> wrote:
> 
>> From: Changli Gao <xiaosuo@gmail.com>
>> Date: Mon, 3 Jan 2011 18:44:59 +0800
>> 
>> > On Sat, Jan 1, 2011 at 3:10 AM, David Miller <davem@davemloft.net> wrote:
>> >> From: Changli Gao <xiaosuo@gmail.com>
>> >> Date: Sat, 25 Dec 2010 21:41:30 +0800
>> >>
>> >>> Since nf_bridge_maybe_copy_header() may change the length of skb,
>> >>> we should check the length of skb after it to handle the ppoe skbs.
>> >>>
>> >>> Signed-off-by: Changli Gao <xiaosuo@gmail.com>
>> >>
>> >> This is really strange.
>> >>
>> >> packet_length() subtracts VLAN_HLEN from the value it returns, so the
>> >> correct fix seems to be to make this function handle the PPPOE case
>> >> too.
>> >>
>> > 
>> > It is correct. The actual MTU of 802.1q frame is 4 bytes larger. For
>> > example, the MTU of ethernet is normally 1500, however the actual MTU
>> > of the 802.1Q is 1504.
>> 
>> Yes, I understand this, but I don't see why packet_length() cannot
>> simply account for PPPOE's encapsulation overhead just as it does for
>> VLAN's special MTU considerations.
> 
> Because PPPOE happens afterwards and is not part the calculation.
> The check should be moved until after skb has reached final form.

That works for me.

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

* Re: [PATCH] net: bridge: check the length of skb after nf_bridge_maybe_copy_header()
  2011-01-03 20:13         ` David Miller
@ 2011-01-05 13:37           ` Changli Gao
  2011-01-06 19:33             ` David Miller
  0 siblings, 1 reply; 8+ messages in thread
From: Changli Gao @ 2011-01-05 13:37 UTC (permalink / raw)
  To: David Miller; +Cc: shemminger, bridge, netdev

On Tue, Jan 4, 2011 at 4:13 AM, David Miller <davem@davemloft.net> wrote:
> From: Stephen Hemminger <shemminger@linux-foundation.org>
>>
>> Because PPPOE happens afterwards and is not part the calculation.
>> The check should be moved until after skb has reached final form.
>
> That works for me.
>

So, is my patch acceptable?

-- 
Regards,
Changli Gao(xiaosuo@gmail.com)

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

* Re: [PATCH] net: bridge: check the length of skb after nf_bridge_maybe_copy_header()
  2011-01-05 13:37           ` Changli Gao
@ 2011-01-06 19:33             ` David Miller
  0 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2011-01-06 19:33 UTC (permalink / raw)
  To: xiaosuo; +Cc: shemminger, bridge, netdev

From: Changli Gao <xiaosuo@gmail.com>
Date: Wed, 5 Jan 2011 21:37:28 +0800

> On Tue, Jan 4, 2011 at 4:13 AM, David Miller <davem@davemloft.net> wrote:
>> From: Stephen Hemminger <shemminger@linux-foundation.org>
>>>
>>> Because PPPOE happens afterwards and is not part the calculation.
>>> The check should be moved until after skb has reached final form.
>>
>> That works for me.
>>
> 
> So, is my patch acceptable?

Yes, I've applied it, thank you.

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

end of thread, other threads:[~2011-01-06 19:32 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-25 13:41 [PATCH] net: bridge: check the length of skb after nf_bridge_maybe_copy_header() Changli Gao
2010-12-31 19:10 ` David Miller
2011-01-03 10:44   ` Changli Gao
2011-01-03 17:22     ` David Miller
2011-01-03 18:15       ` Stephen Hemminger
2011-01-03 20:13         ` David Miller
2011-01-05 13:37           ` Changli Gao
2011-01-06 19:33             ` 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).