Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp6517460ybn; Sun, 29 Sep 2019 22:24:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqxZ97hMjeFXH+sfP6yiXdOkWBF0aqlHLWgN0XIf9TrYKmC12V07G4WQ1MmU/Vo+mtn876bB X-Received: by 2002:a17:906:4990:: with SMTP id p16mr18108576eju.9.1569821099375; Sun, 29 Sep 2019 22:24:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569821099; cv=none; d=google.com; s=arc-20160816; b=m94YM9pqc27Zdqnhwl8YrwPCHZvKcStGsCMnw3VqANEMUSlxYc4+mOVTF9dUZ8d0RA zZbgllpA7YG0xTvXiJiTwRFHYAliqA6Rn2TlB8rAD3zRiH7Ar6YuuE4OY61kBG6D9M1U 4lzs3254sgFj5gG5zXdlhoAdiQ0XJr6HPdeP1OFn0+3Y2BR6XpcD2z4f1iUVKSIyctNl iejWJ803i6lfclY3N+3xX26saVRX6iQCJ+Ip/mnNJvwIU/DQFJdPLl3IwUh9wEQRn7Z9 mkksTkQ4ZfR5YXKu9CMoSFbDCWiSwXZTy+tSWy4UfLBvWHAPMPiT+Hn1eLx+sxL/y6Vi Ku4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=fcK6Iz9IusfDx2vbU6dBpqpaBt3xfoX2dR/RSgUaeaU=; b=ar+uL1zeA5CQK8N0bj9zmOeGsuil8ZIz5jkIkfwvn5ZNHqXVhxz2ACo+CIfBRK44Hq K8xp9DxLKQW8fKiD816GOrnQ5y/fvqhcgwU9yjnEEtwZe1/5I1Q3cvLN/ZpzzWm15rPj vmd5sSa/yJMPHNKUAGl7evbfT3MsGnLev/IzCeqmJQffA4O4kidQ2674Hx9RJIAlB2Lt /9dlQ8hgCkNTBurztnIgdPGB6mLJuEmIvmS+cNmccwoITVkEV3WgLhWBiiphnl9Osrk3 X1bTTpNodO821fha9BLG03ihb3WgxnhMgafvfLhaJ/I+Zb+1bKwwOyQbj1e4ucAsllFu Cf/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cisco.com header.s=iport header.b=ZH1r+kg1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=cisco.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y49si6128032edb.138.2019.09.29.22.24.34; Sun, 29 Sep 2019 22:24:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@cisco.com header.s=iport header.b=ZH1r+kg1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=cisco.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729534AbfI3FYB (ORCPT + 99 others); Mon, 30 Sep 2019 01:24:01 -0400 Received: from bgl-iport-1.cisco.com ([72.163.197.25]:64454 "EHLO bgl-iport-1.cisco.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725767AbfI3FYB (ORCPT ); Mon, 30 Sep 2019 01:24:01 -0400 X-Greylist: delayed 430 seconds by postgrey-1.27 at vger.kernel.org; Mon, 30 Sep 2019 01:24:00 EDT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=1841; q=dns/txt; s=iport; t=1569821040; x=1571030640; h=from:to:cc:subject:date:message-id; bh=G+siyYRdHd2n4HbLETGj+hla7mCl53/mKPxeUkMl8FQ=; b=ZH1r+kg1Yvfm7x2IUvxrT3n7yAg/rzGTU+bkkIPUa2+IQ3TxO9mPMaUR c8rYKLkniXtQ96bcnrbj/13lrWd4NaMrIhdBuzROne/HMiq1GukpKR1hm 1/+gJNA2/oOSsuTJQIF90C/Z96zXD35mvlhTfQ3/YE0TRvuGglf7/dqHo o=; X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0AsAQA7jpFd/xjFo0hmHAEBAQQBAQwEA?= =?us-ascii?q?QGBVAYBAQsBg10gEiqNHoZEBQGBMol5jy+BewkBAQEOLwEBhECDXzUIDgIMAQE?= =?us-ascii?q?EAQEBAgEFBG2FOYV5UimBFQsIgyKBdxSqd4F0M4hzgUgUgSABhzSFaYEHjwgEg?= =?us-ascii?q?S8BlRyWSwaCJpULAhmZNQEtpzuBUwE2gVhNI4FugU5QEBSBWheOKjkDMJEOAQE?= X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="119743880" Received: from vla196-nat.cisco.com (HELO bgl-core-4.cisco.com) ([72.163.197.24]) by bgl-iport-1.cisco.com with ESMTP/TLS/DHE-RSA-SEED-SHA; 30 Sep 2019 05:16:45 +0000 Received: from ubuntuServ16.cisco.com ([10.142.88.17]) by bgl-core-4.cisco.com (8.15.2/8.15.2) with ESMTP id x8U5Gih6001012; Mon, 30 Sep 2019 05:16:45 GMT From: Sriram Krishnan To: Andrew Morton Cc: xe-linux-external@cisco.com, "David S. Miller" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] AF_PACKET doesnt strip VLAN information Date: Sat, 28 Sep 2019 10:28:24 +0530 Message-Id: <1569646705-10585-1-git-send-email-srirakr2@cisco.com> X-Mailer: git-send-email 2.7.4 X-Auto-Response-Suppress: DR, OOF, AutoReply X-Outbound-SMTP-Client: 10.142.88.17, [10.142.88.17] X-Outbound-Node: bgl-core-4.cisco.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When an application sends with AF_PACKET and places a vlan header on the raw packet; then the AF_PACKET needs to move the tag into the skb so that it gets processed normally through the rest of the transmit path. This is particularly a problem on Hyper-V where the host only allows vlan in the offload info. Cc: xe-linux-external@cisco.com --- net/packet/af_packet.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index e2742b0..cfe0904 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -1849,15 +1849,35 @@ static int packet_rcv_spkt(struct sk_buff *skb, struct net_device *dev, return 0; } -static void packet_parse_headers(struct sk_buff *skb, struct socket *sock) +static int packet_parse_headers(struct sk_buff *skb, struct socket *sock) { if ((!skb->protocol || skb->protocol == htons(ETH_P_ALL)) && sock->type == SOCK_RAW) { + __be16 ethertype; + skb_reset_mac_header(skb); + + ethertype = eth_hdr(skb)->h_proto; + /* + * If Vlan tag is present in the packet + * move it to skb + */ + if (eth_type_vlan(ethertype)) { + int err; + __be16 vlan_tci; + + err = __skb_vlan_pop(skb, &vlan_tci); + if (unlikely(err)) + return err; + + __vlan_hwaccel_put_tag(skb, ethertype, vlan_tci); + } + skb->protocol = dev_parse_header_protocol(skb); } skb_probe_transport_header(skb); + return 0; } /* @@ -1979,7 +1999,9 @@ static int packet_sendmsg_spkt(struct socket *sock, struct msghdr *msg, if (unlikely(extra_len == 4)) skb->no_fcs = 1; - packet_parse_headers(skb, sock); + err = packet_parse_headers(skb, sock); + if (err) + goto out_unlock; dev_queue_xmit(skb); rcu_read_unlock(); -- 2.7.4