Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp8484938ybn; Tue, 1 Oct 2019 08:45:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqyEUr39QKEwC6Q+gvNEzc482c2w0NE2tdW2Kq0C/L+4vz7iR0mZhXe5UmT+jeFm/LS6iLyc X-Received: by 2002:a50:f78a:: with SMTP id h10mr26496981edn.161.1569944738451; Tue, 01 Oct 2019 08:45:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569944738; cv=none; d=google.com; s=arc-20160816; b=Wge9S8/V5LLLfJeFPI2lusdCJlJ+sSVvp56esJakdwODKNFfxOLXUVAyMOD9UWwwxw ODSLxNAQFvyfi65Au0EwECTbdYaRyIoXog6idmvee8Tesg19sMUD8BsvomDL7rkzPM6E /fAmp14HicsVoahH21cssEKDKW70ovR6pIMNampvqxWlOm1byn+6F+uCIDb+RGVnLFCg hDysO9+UwoQfeqAB04wOnVbQyBYUMl1khGrwK9BLFCi2yWHpTUkl6i2c5KCefQ4hRBpn 4wpBVeyYeIHxfwyN/tZqKJq2SveZCn89JN6Ikh59RRa90YHDz8VMPXaTAe/I7DiEj/1V KxPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=3RxnDGRr7B1XTJFunDM7ZNbXmbQskGnoRCYVHzPDhjY=; b=tRIqG7Sh08j98w8c2iN6/QG7/mDCj7MmPl5Vu4GMPcvHRUtjGwL2yXbi+CPUrw8kpx sMOu2Rukr3PWjEghhmv5/EdOCc8KeNDojjosF9p5GMj3/eT48tZuM3Ne/2CCiCyMCkYO fZo18zfCpzbVc3mDNfFL22ldu5QeyH7tXKEYQEH54xVMqHSEbKaTY6UwcdDDrhPQecAn 0YE04nu95Lr6Y5mT0Rmcp2VYqsKHSzQmiPNUg97GzwXpuEacg/zPYuuWBv5EDw5+xrij VsnadB+Fshe8KJrmk/+qSCAR1FoqNbKw7giZkZrVOl+78ZlDIRGvZvHaPu4+8EVVM4+L okTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@networkplumber-org.20150623.gappssmtp.com header.s=20150623 header.b=aaXHJnyI; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r1si9198086eji.94.2019.10.01.08.45.13; Tue, 01 Oct 2019 08:45:38 -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=@networkplumber-org.20150623.gappssmtp.com header.s=20150623 header.b=aaXHJnyI; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389501AbfJAPoh (ORCPT + 99 others); Tue, 1 Oct 2019 11:44:37 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:42871 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726309AbfJAPoh (ORCPT ); Tue, 1 Oct 2019 11:44:37 -0400 Received: by mail-pf1-f194.google.com with SMTP id q12so8268847pff.9 for ; Tue, 01 Oct 2019 08:44:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3RxnDGRr7B1XTJFunDM7ZNbXmbQskGnoRCYVHzPDhjY=; b=aaXHJnyItKtapP/eT7bgV/RWcyFHwp4VhYihtj48vumdyUhczhQsttZcV7NVVOnK/G bA0s4p9tepc1VmsRkQQ5CQML0vT+xCOsgbuaWoLtVVaFijXVrlx1DMR1wGOCjdFdgdrc ZgvEtbd23AuEK8wDpfL/qIoLrUUGbeMRcwenVT+WV8JqrWPao1UWc8J6T1QjmQof0Ue7 pC2pPoOxrWe6FNsXNsRVMzR3O1osZ6JF9B98kOxXht0KlPseHc2BedqgSnEqmIK+Wfg0 v6qkpF5ICEM8hJgvHXeS85jUZ1gtI97Ll1NkBXbp9Vjxs0FtyJ+wtWhnMuDTboj/IaSY KwXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3RxnDGRr7B1XTJFunDM7ZNbXmbQskGnoRCYVHzPDhjY=; b=VD9/yMbUTCr+5PdIHfr8/I7uNqM9Iz2dTe+ovFQNDpLUraqhpVN+h/lYOtPG+4sxOM okv+Gxhjplwk7xCh9iFhQ5hllDcP4DSbQ5B40f0ty8ySBkjXOgTW8ZB0cukfatfHmdBR EOIlfDD+Nrt7FpWmFJPGFwXiHzqZTSlSwpRimSp1/gPuF1sVnqjcmww6W4BAzC78jNl2 QIGo1qR3OpWqCk8ThFm3TfB4lTxz3n1uPhEJbkCzhPllYuCv/tVA3CB586GQq2/r3qpU XDTL/+mvzH51y/tvDC7R46rCLNeep2BBbHoTcOZJy3tnVFmnEoHjTFjCIQdYn+jzwk5N +Ntw== X-Gm-Message-State: APjAAAWvyOAwelixNKz0V9ggZ6vizhFDS3tdaOuF48JvzzAjtVKAoGBL KK1Pk1Gmki7bC0Pd62jjq23oEuk8Lut4eA== X-Received: by 2002:a63:350f:: with SMTP id c15mr27311143pga.225.1569944674989; Tue, 01 Oct 2019 08:44:34 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id p88sm5938164pjp.22.2019.10.01.08.44.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2019 08:44:34 -0700 (PDT) Date: Tue, 1 Oct 2019 08:44:27 -0700 From: Stephen Hemminger To: Willem de Bruijn Cc: Sriram Krishnan , Andrew Morton , xe-linux-external@cisco.com, "David S. Miller" , Network Development , linux-kernel Subject: Re: [PATCH] AF_PACKET doesnt strip VLAN information Message-ID: <20191001084427.73f130c0@hermes.lan> In-Reply-To: References: <1569646705-10585-1-git-send-email-srirakr2@cisco.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 30 Sep 2019 11:16:14 -0400 Willem de Bruijn wrote: > On Mon, Sep 30, 2019 at 1:24 AM Sriram Krishnan wrote: > > > > 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. > > This sounds like behavior that needs to be addressed in the driver, instead? This was what we did first, but the problem was more general. For example, many filtering functions assume that vlan tag is in skb meta data, not the packet data itself. Therefore AF_PACKET would get around any filter rules. > > > 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) { > > If inside this branch, may miss packets with skb->protocol set to one > of the VLAN Ethertypes. > > > + __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); > > What happens with multiple tags (QinQ)? Same as multiple tags in a normal sent packet. The second tag is in the packet itself. > > > + } > > + > > 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; > > This only tests the new return value in one of three callers of > packet_sendmsg_spkt.