Skip to contentSkip to conversation

bridge: add ETH_HLEN to packet_length

PATCH In review Jon Mason 3 participants 4 messages Sep 14, 2006 – Sep 15, 2006

Subsystems (3)
lore
Share & tools
lore

Jon Mason

author
#0 lore raw

PATCH 1/1 bridge: add ETH_HLEN to packet_length

In br_dev_queue_push_xmit, why is the check to drop mtu oversized packets not checking for enough room for the impending ETH_HLEN size skb_push? In some code currently under development, we are seeing skb_under_panic being called from the "skb_push(skb, ETH_HLEN)" in that code. It seems to me it would be better to drop those skbs than panic. Attached is a patch to do this.

Thanks,
Jon

net/bridge/br_forward.c +2 -1
diff -r b1d36669f98d net/bridge/br_forward.c
@@ -29,7 +29,8 @@ static inline int should_deliver(const s
 
 static inline unsigned packet_length(const struct sk_buff *skb)
 {
-	return skb->len - (skb->protocol == htons(ETH_P_8021Q) ? VLAN_HLEN : 0);
+	return skb->len - ETH_HLEN - 
+		(skb->protocol == htons(ETH_P_8021Q) ? VLAN_HLEN : 0);
 }
 
 int br_dev_queue_push_xmit(struct sk_buff *skb)
#1 lore raw
Quoted 16 lines · Jon Mason

In br_dev_queue_push_xmit, why is the check to drop mtu oversized packets not checking for enough room for the impending ETH_HLEN size skb_push? In some code currently under development, we are seeing skb_under_panic being called from the "skb_push(skb, ETH_HLEN)" in that code. It seems to me it would be better to drop those skbs than panic. Attached is a patch to do this.

Thanks,
Jon

diff -r b1d36669f98d net/bridge/br_forward.c

net/bridge/br_forward.c static inline int should_deliver(const s · line 36

Quoted 9 lines
net/bridge/br_forward.c +2 -1
@@ -29,7 +29,8 @@ static inline int should_deliver(const s
 
 static inline unsigned packet_length(const struct sk_buff *skb)
 {
-	return skb->len - (skb->protocol == htons(ETH_P_8021Q) ? VLAN_HLEN : 0);
+	return skb->len - ETH_HLEN - 
+		(skb->protocol == htons(ETH_P_8021Q) ? VLAN_HLEN : 0);
 }
 
 

packet_length() is a wrong place to do that, mtu has nothing to do with skb headroom.

--Mika

author
#2 lore raw
Quoted 18 lines · Mika Penttil?
Quoted 17 lines · Jon Mason

In br_dev_queue_push_xmit, why is the check to drop mtu oversized packets not checking for enough room for the impending ETH_HLEN size skb_push? In some code currently under development, we are seeing skb_under_panic being called from the "skb_push(skb, ETH_HLEN)" in that code. It seems to me it would be better to drop those skbs than panic. Attached is a patch to do this.

Thanks,
Jon

diff -r b1d36669f98d net/bridge/br_forward.c

net/bridge/br_forward.c +0 -0
@@ -29,7 +29,8 @@ static inline int should_deliver(const s
 
Quoted 11 lines

net/bridge/br_forward.c static inline int should_deliver(const s · line 35

Quoted 9 lines
net/bridge/br_forward.c +2 -1
 static inline unsigned packet_length(const struct sk_buff *skb)
 {
-	return skb->len - (skb->protocol == htons(ETH_P_8021Q) ? VLAN_HLEN : 
 0);
+	return skb->len - ETH_HLEN - 
+		(skb->protocol == htons(ETH_P_8021Q) ? VLAN_HLEN : 0);
 }
 

packet_length() is a wrong place to do that, mtu has nothing to do with skb headroom.

Oops, you are 100% correct. So what would be the best way to handle this, as a panic is pretty nasty? Wouldn't it be better to check the packet to see if there is sufficient headroom, BUG, and then drop it (or allocate a new packet with sufficient headroom and proceed with the skb_push)?

Thanks,
Jon

Quoted 4 lines

--Mika

#3 lore raw
In reply to Jon Mason
Quoted 9 lines · On Thu, 14 Sep 2006 13:27:54 -0500 Jon Mason <[email protected]> wrote:

In br_dev_queue_push_xmit, why is the check to drop mtu oversized packets not checking for enough room for the impending ETH_HLEN size skb_push? In some code currently under development, we are seeing skb_under_panic being called from the "skb_push(skb, ETH_HLEN)" in that code. It seems to me it would be better to drop those skbs than panic. Attached is a patch to do this.

Thanks,
Jon

This is bridge code, it assumes that any device that claims to be a ethernet device has done the proper reservation. What device are you using?