diff options
author | Phil Sutter <phil@nwl.cc> | 2013-08-02 05:37:41 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-08-02 17:58:32 -0400 |
commit | c483e02614551e44ced3fe6eedda8e36d3277ccc (patch) | |
tree | 7d171a5c01d8212921cd2557aa0749fa81263893 | |
parent | cbd89acb9eb257ed3b2be867142583fdcf7fdc5b (diff) |
af_packet: simplify VLAN frame check in packet_snd
For ethernet frames, eth_type_trans() already parses the header, so one
can skip this when checking the frame size.
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/packet/af_packet.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 2b1470de9e16..0c0f6c9a90e7 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c | |||
@@ -2333,23 +2333,16 @@ static int packet_snd(struct socket *sock, | |||
2333 | 2333 | ||
2334 | if (dev->type == ARPHRD_ETHER) { | 2334 | if (dev->type == ARPHRD_ETHER) { |
2335 | skb->protocol = eth_type_trans(skb, dev); | 2335 | skb->protocol = eth_type_trans(skb, dev); |
2336 | if (skb->protocol == htons(ETH_P_8021Q)) | ||
2337 | reserve += VLAN_HLEN; | ||
2336 | } else { | 2338 | } else { |
2337 | skb->protocol = proto; | 2339 | skb->protocol = proto; |
2338 | skb->dev = dev; | 2340 | skb->dev = dev; |
2339 | } | 2341 | } |
2340 | 2342 | ||
2341 | if (!gso_type && (len > dev->mtu + reserve + extra_len)) { | 2343 | if (!gso_type && (len > dev->mtu + reserve + extra_len)) { |
2342 | /* Earlier code assumed this would be a VLAN pkt, | 2344 | err = -EMSGSIZE; |
2343 | * double-check this now that we have the actual | 2345 | goto out_free; |
2344 | * packet in hand. | ||
2345 | */ | ||
2346 | struct ethhdr *ehdr; | ||
2347 | skb_reset_mac_header(skb); | ||
2348 | ehdr = eth_hdr(skb); | ||
2349 | if (ehdr->h_proto != htons(ETH_P_8021Q)) { | ||
2350 | err = -EMSGSIZE; | ||
2351 | goto out_free; | ||
2352 | } | ||
2353 | } | 2346 | } |
2354 | 2347 | ||
2355 | skb->priority = sk->sk_priority; | 2348 | skb->priority = sk->sk_priority; |