From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julian Wiedmann Subject: [PATCH net-next 09/15] s390/qeth: robustify qeth_get_ip_version() Date: Wed, 20 Dec 2017 20:11:03 +0100 Message-ID: <20171220191109.90487-10-jwi@linux.vnet.ibm.com> References: <20171220191109.90487-1-jwi@linux.vnet.ibm.com> Cc: , , Martin Schwidefsky , Heiko Carstens , Stefan Raspl , Ursula Braun , Julian Wiedmann To: David Miller Return-path: Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:34070 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756328AbdLTTLd (ORCPT ); Wed, 20 Dec 2017 14:11:33 -0500 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vBKJ9a36040548 for ; Wed, 20 Dec 2017 14:11:33 -0500 Received: from e06smtp10.uk.ibm.com (e06smtp10.uk.ibm.com [195.75.94.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 2eyvepbuxg-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 20 Dec 2017 14:11:33 -0500 Received: from localhost by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 20 Dec 2017 19:11:30 -0000 In-Reply-To: <20171220191109.90487-1-jwi@linux.vnet.ibm.com> Sender: netdev-owner@vger.kernel.org List-ID: 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 --- drivers/s390/net/qeth_core.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/s390/net/qeth_core.h b/drivers/s390/net/qeth_core.h index f5ee62c98011..af9d1efd2e78 100644 --- a/drivers/s390/net/qeth_core.h +++ b/drivers/s390/net/qeth_core.h @@ -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; -- 2.13.5