OSDN Git Service

s390/qeth: robustify qeth_get_ip_version()
authorJulian Wiedmann <jwi@linux.vnet.ibm.com>
Wed, 20 Dec 2017 19:11:03 +0000 (20:11 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 20 Dec 2017 20:23:45 +0000 (15:23 -0500)
Instead of assuming that skb->data points to the Ethernet header, use
the right helper and struct to access the Ethertype field.

Signed-off-by: Julian Wiedmann <jwi@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/s390/net/qeth_core.h

index f5ee62c..af9d1ef 100644 (file)
@@ -847,14 +847,16 @@ static inline int qeth_get_micros(void)
 
 static inline int qeth_get_ip_version(struct sk_buff *skb)
 {
-       __be16 *p = &((struct ethhdr *)skb->data)->h_proto;
+       struct vlan_ethhdr *veth = vlan_eth_hdr(skb);
+       __be16 prot = veth->h_vlan_proto;
 
-       if (be16_to_cpu(*p) == ETH_P_8021Q)
-               p += 2;
-       switch (be16_to_cpu(*p)) {
-       case ETH_P_IPV6:
+       if (prot == htons(ETH_P_8021Q))
+               prot = veth->h_vlan_encapsulated_proto;
+
+       switch (prot) {
+       case htons(ETH_P_IPV6):
                return 6;
-       case ETH_P_IP:
+       case htons(ETH_P_IP):
                return 4;
        default:
                return 0;