netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] ethernet: call __skb_pull() in eth_type_trans()
@ 2010-05-03 14:12 Changli Gao
  2010-05-03 14:44 ` Eric Dumazet
  2010-05-03 19:54 ` David Miller
  0 siblings, 2 replies; 6+ messages in thread
From: Changli Gao @ 2010-05-03 14:12 UTC (permalink / raw)
  To: David Miller; +Cc: eric.dumazet, netdev, Changli Gao

call __skb_pull() in eth_type_trans().

The callers of eth_type_trans() should always feed it long enough packets. When
the length of the packet is less than ETH_ZLEN, a warning message will be shown,
and the later behaviors are undefined.

Signed-off-by: Changli Gao <xiaosuo@gmail.com>
----
 net/ethernet/eth.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c
index 61ec032..1df31cc 100644
--- a/net/ethernet/eth.c
+++ b/net/ethernet/eth.c
@@ -162,7 +162,10 @@ __be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev)
 
 	skb->dev = dev;
 	skb_reset_mac_header(skb);
-	skb_pull_inline(skb, ETH_HLEN);
+	if (unlikely(skb->len < ETH_ZLEN))
+		dev_warn(&dev->dev, "too small ethernet packet: %u bytes\n",
+			 skb->len);
+	__skb_pull(skb, ETH_HLEN);
 	eth = eth_hdr(skb);
 
 	if (unlikely(is_multicast_ether_addr(eth->h_dest))) {

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

end of thread, other threads:[~2010-05-04  6:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-03 14:12 [PATCH v2] ethernet: call __skb_pull() in eth_type_trans() Changli Gao
2010-05-03 14:44 ` Eric Dumazet
2010-05-04  2:05   ` Changli Gao
2010-05-03 19:54 ` David Miller
2010-05-04  2:34   ` Changli Gao
2010-05-04  6:16     ` 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).