Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp224051ybh; Mon, 20 Jul 2020 15:05:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx82PPAPgidT4Qf8NPfQHUdS+sSVJymtoAmOBuod1PbTPgi7BBdqwOEHy30iyMqL1tTJZ63 X-Received: by 2002:a17:906:1f94:: with SMTP id t20mr22008559ejr.233.1595282710244; Mon, 20 Jul 2020 15:05:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595282710; cv=none; d=google.com; s=arc-20160816; b=h3jL2gt8vemoegp+UeUfM42cnHu9aX9k2JMWK9GKTpWNQ4TBZ0jon1wGvg4wb8aW/W Zr0S5O84nmN5J8m7yHKkiVNXAfy33bIuxHVgb+uXIfI3cFsnc7eLn6ugFy6Zlk7kVSL2 FVkrICV2YSn+xyDCsJafInENpf0n3PnRNvOyownMpXHVp0NR4JzehjI1dS3nIenKLB4s vMHbR61Tj0mvb6yqLfITKbzTI8RRjWgC3ayGWtSzuqkYLO3j3ZVQNwwyl7ATHMDQ1EbH uetnBWbmJaWo0pcInQMrdSwL+LsOaQBCAEqkkHiJD1Un+keuOmzb5INeZSTyWbekrgft ozJA== 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=V0iCeeBn/xMelvFGdtIIBtJ/o5/aaD9RE8EBgqxRkgA=; b=n6Ba/pPGrsCzhNFIjeB3jg4I0spfbBHb8Y8nCACkqBaSj3aE/4jEWG19hTr27Gh83R cf2lLA0NSPJI4XRkZ56lFWXOxl+Sly4Pgr9eoeVLUS1YvGK29a4UL+ofm9Y+Z7Df4LTI BhRe1uan/G4I0c9y+lu/sNApUb2EdlNwGpx80rPkxan+P0csld3GrBGVlwxm4xV014mX VzFBe3j4RH1fokq0D/h52fjxjpt9MXbLZ9g2Axr2Q/uiAIsGryOjIzdcNFjQqbSsg92S IvpEmRp/8KfZFov+KZT1Uvj+2XA56bm5mMUKBEeSotwIjutJ4lF5FPegc8XOq8pQ/Dz3 0iIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@networkplumber-org.20150623.gappssmtp.com header.s=20150623 header.b=2Rf0bhhl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v12si10963573eja.379.2020.07.20.15.04.46; Mon, 20 Jul 2020 15:05:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@networkplumber-org.20150623.gappssmtp.com header.s=20150623 header.b=2Rf0bhhl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726918AbgGTWDu (ORCPT + 99 others); Mon, 20 Jul 2020 18:03:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726046AbgGTWDu (ORCPT ); Mon, 20 Jul 2020 18:03:50 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB618C061794 for ; Mon, 20 Jul 2020 15:03:49 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id t6so9338623plo.3 for ; Mon, 20 Jul 2020 15:03:49 -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=V0iCeeBn/xMelvFGdtIIBtJ/o5/aaD9RE8EBgqxRkgA=; b=2Rf0bhhlUQW7lcvw2BhGFb24Z0q+GSPEmBcrloaWqV2XKjqi3MNXmxQGC2C8tvnGFi he8Wj3PuX7wH5i/cNJGvzpgDM92WEGdNur1uzLGdkDdqKdr5r6Dn/1I5yBlDWtg/B+da 2Bl/oZzTrq+hE0MfDOIW9WTTy+Lc28h7nBLLoKCANLc1uurpH1ERqIKhvIDTma0T3lWs aT1wk3zkmIZeWKWUPmC2aJJM69Dd/JBlj1DDpY1flwXdcKjZzxntUMtjAoaXM5iTJ9Hr DlCRJGdLnxo6FVgGQTRDPqDvn1suDVewyuuW++NTDtBaaHzJhPGrNXsImeAGBJZOLeyG gBZQ== 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=V0iCeeBn/xMelvFGdtIIBtJ/o5/aaD9RE8EBgqxRkgA=; b=fYpaAquu16rViNPfFxiIMBO2kuBgNlyrsmzCuiTbDZ4f49gIEGMdTi/waWraVqVXs3 Iu2ZamqpspGbeZn63h2svcs39Anw/wtU7auFV6tJWnXOMyj9t/PZ3wSYQa8c2loAM9Im J39sqEAa94q6JiL1/rkBcIQOFE5EsPhgIFGr1EkSQ7r5ZHSdYkbhP5UjGS9/CUb72Ebm fqUXBf1GvgX6jWFZdFvWUqdop3AlnPT3h3m9ZTF/Rydq2hVG5xs1dskSKPvZWN+zd7Td mFBr15+viqGmlcdeIP8Nj+J+zvbF7qffKCIas/ugvMI9uTAWZK1PPFmiXzDYuKhTHaeD mEdw== X-Gm-Message-State: AOAM531pfKqCcdDL4vpMAT4Ju3hifyeaNYH6U1XLKvQMerds9v2y7Zl9 MJDocPFft3Ec0Da1gQCC6Asohg== X-Received: by 2002:a17:90a:3523:: with SMTP id q32mr1298324pjb.185.1595282627317; Mon, 20 Jul 2020 15:03:47 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id j3sm17309851pfe.102.2020.07.20.15.03.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2020 15:03:47 -0700 (PDT) Date: Mon, 20 Jul 2020 15:03:38 -0700 From: Stephen Hemminger To: Willem de Bruijn Cc: "Sriram Krishnan (srirakr2)" , Andrew Morton , "xe-linux-external(mailer list)" , "David S. Miller" , Jakub Kicinski , Network Development , linux-kernel , Stephen Hemminger , "Malcolm Bumgardner (mbumgard)" Subject: Re: [PATCH v2] AF_PACKET doesnt strip VLAN information Message-ID: <20200720150338.35e5e70e@hermes.lan> In-Reply-To: References: <20200718091732.8761-1-srirakr2@cisco.com> <20200720135650.1939665b@hermes.lan> 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, 20 Jul 2020 17:22:49 -0400 Willem de Bruijn wrote: > On Mon, Jul 20, 2020 at 4:57 PM Stephen Hemminger > wrote: > > > > On Mon, 20 Jul 2020 09:52:27 -0400 > > Willem de Bruijn wrote: > > > > > On Mon, Jul 20, 2020 at 12:27 AM Sriram Krishnan (srirakr2) > > > wrote: > > > > > > > > +Stephen Hemminger > > > > > > > > Hi Willem, > > > > Thanks for looking into the code, I understand that this is more of a generic problem wherein many of the filtering functions assume the vlan tag to be in the skb rather than in the packet. Hence we moved the fix from the driver to the common AF packet that our solution uses. > > > > > > > > I recall from the v1 of the patch you had mentioned other common areas where this fix might be relevant (such as tap/tun), but I'm afraid I cant comprehensively test those patches out. Please let me know your thoughts > > > > > > Please use plain text to respond. HTML replies do not reach the list. > > > > > > Can you be more precise in which other code besides the hyper-v driver > > > is affected? Do you have an example? > > > > > > This is a resubmit of the original patch. My previous > > > questions/concerns remain valid: > > > > > > - if the function can now fail, all callers must be updated to detect > > > and handle that > > > > > > - any solution should probably address all inputs into the tx path: > > > packet sockets, tuntap, virtio-net > > > > > > - this only addresses packet sockets with ETH_P_ALL/ETH_P_NONE. Not > > > sockets that set ETH_P_8021Q > > > > > > - which code in the transmit stack requires the tag to be in the skb, > > > and does this problem after this patch still persist for Q-in-Q? > > > > It matters because the problem is generic, not just to the netvsc driver. > > For example, BPF programs and netfilter rules will see different packets > > when send is through AF_PACKET than they would see for sends from the > > kernel stack. > > > > Presenting uniform data to the lower layers makes sense. > > Are all forwarded and locally generated packets guaranteed to always > have VLAN information in the tag (so that this is indeed only an issue > with input from userspace, through tuntap, virtio and packet sockets)? > > I guess the first might be assured due to this in __netif_receive_skb_core: > > if (skb->protocol == cpu_to_be16(ETH_P_8021Q) || > skb->protocol == cpu_to_be16(ETH_P_8021AD)) { > skb = skb_vlan_untag(skb); > if (unlikely(!skb)) > goto out; > } > > and the second by this in vlan_dev_hard_start_xmit: > > if (veth->h_vlan_proto != vlan->vlan_proto || > vlan->flags & VLAN_FLAG_REORDER_HDR) { > u16 vlan_tci; > vlan_tci = vlan->vlan_id; > vlan_tci |= vlan_dev_get_egress_qos_mask(dev, skb->priority); > __vlan_hwaccel_put_tag(skb, vlan->vlan_proto, vlan_tci); > } > > But I don't know this code very well, so that is based on a very > cursory glance only. Might well be missing other paths. (update: I > think pktgen is another example.) > > Netfilter and BPF still need to handle tags in the packet for Q-in-Q, > right? So does this actually simplify their logic? > > If the above holds and Q-in-Q is not a problem, then doing the same on > ingress from userspace may make sense. I don't know the kind of BPF > or netfilter programs what would be affected, and how. > > Then it would be good to all those inputs at once to really plug the hole. > See also virtio_net_hdr_to_skb for another example of code that > applies to all of tuntap, virtio, pf_packet and uml. Older versions of Linux used to handle outer VLAN differentl based on what the driver supported. It was a mess. Some drivers and code paths would strip and put in meta-data, some would leave it in skb data. But in recent (like 5 yrs), the kernel has tried to be more uniform and only have vlan as skb tag. It looks like AF_PACKET was overlooked at that time.