[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1272895972-13799-1-git-send-email-xiaosuo@gmail.com>
Date: Mon, 3 May 2010 22:12:52 +0800
From: Changli Gao <xiaosuo@...il.com>
To: David Miller <davem@...emloft.net>
Cc: eric.dumazet@...il.com, netdev@...r.kernel.org,
Changli Gao <xiaosuo@...il.com>
Subject: [PATCH v2] ethernet: call __skb_pull() in eth_type_trans()
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@...il.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))) {
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists