]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
af_packet: simplify VLAN frame check in packet_snd
authorPhil Sutter <phil@nwl.cc>
Fri, 2 Aug 2013 09:37:41 +0000 (11:37 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 2 Aug 2013 21:58:32 +0000 (14:58 -0700)
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>
net/packet/af_packet.c

index 2b1470de9e1603f2934b178084649e9c99e60d97..0c0f6c9a90e74107e3c60f12b7020f0c546e68bc 100644 (file)
@@ -2333,23 +2333,16 @@ static int packet_snd(struct socket *sock,
 
        if (dev->type == ARPHRD_ETHER) {
                skb->protocol = eth_type_trans(skb, dev);
+               if (skb->protocol == htons(ETH_P_8021Q))
+                       reserve += VLAN_HLEN;
        } else {
                skb->protocol = proto;
                skb->dev = dev;
        }
 
        if (!gso_type && (len > dev->mtu + reserve + extra_len)) {
-               /* Earlier code assumed this would be a VLAN pkt,
-                * double-check this now that we have the actual
-                * packet in hand.
-                */
-               struct ethhdr *ehdr;
-               skb_reset_mac_header(skb);
-               ehdr = eth_hdr(skb);
-               if (ehdr->h_proto != htons(ETH_P_8021Q)) {
-                       err = -EMSGSIZE;
-                       goto out_free;
-               }
+               err = -EMSGSIZE;
+               goto out_free;
        }
 
        skb->priority = sk->sk_priority;