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>
This commit is contained in:
parent
cbd89acb9e
commit
c483e02614
@ -2333,23 +2333,16 @@ static int packet_snd(struct socket *sock,
|
|||||||
|
|
||||||
if (dev->type == ARPHRD_ETHER) {
|
if (dev->type == ARPHRD_ETHER) {
|
||||||
skb->protocol = eth_type_trans(skb, dev);
|
skb->protocol = eth_type_trans(skb, dev);
|
||||||
|
if (skb->protocol == htons(ETH_P_8021Q))
|
||||||
|
reserve += VLAN_HLEN;
|
||||||
} else {
|
} else {
|
||||||
skb->protocol = proto;
|
skb->protocol = proto;
|
||||||
skb->dev = dev;
|
skb->dev = dev;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gso_type && (len > dev->mtu + reserve + extra_len)) {
|
if (!gso_type && (len > dev->mtu + reserve + extra_len)) {
|
||||||
/* Earlier code assumed this would be a VLAN pkt,
|
err = -EMSGSIZE;
|
||||||
* double-check this now that we have the actual
|
goto out_free;
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
skb->priority = sk->sk_priority;
|
skb->priority = sk->sk_priority;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user