From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9171C43381 for ; Thu, 14 Feb 2019 11:19:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A5F33222B6 for ; Thu, 14 Feb 2019 11:19:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=googlemail.com header.i=@googlemail.com header.b="BOpYa0xa" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733036AbfBNLT2 (ORCPT ); Thu, 14 Feb 2019 06:19:28 -0500 Received: from mail-ed1-f67.google.com ([209.85.208.67]:40106 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727277AbfBNLT2 (ORCPT ); Thu, 14 Feb 2019 06:19:28 -0500 Received: by mail-ed1-f67.google.com with SMTP id 10so4687557eds.7 for ; Thu, 14 Feb 2019 03:19:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=a29jmNwF1Wcq3eUiKazAS3/y0Qc/3oMiFgIjDWWRpik=; b=BOpYa0xatvNR9lHgbke2vFCkbGs2WwjWjw5NY5WwNyqfxxcmjlA/HyopG6ym01nPCV /F0NJhtM3P0PPGqgB/ytHVlk1nVc9wf6IClf60f5Z7TJdxzj3GF9E/RqWfTYXoNcZ5yi 2y5ASnWNg2OVbIjLr87wI+Q68fSj54TR8YQB68F9BCGJAC2JE3RvWOqKQeU9ETFoHAwJ Ec/vXXg4Y/CY26psCS7ptq1iDEEYVvmsRnOY5tSmUcpKqWbSj428plSFVhLo1nip1dgz 3MKAleH5jifXu2lqCDHqGPmOCvm4u2rD3wJ3d5wa2LiIplE70mrNVkwOpnkllWz/0mU9 G0yQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=a29jmNwF1Wcq3eUiKazAS3/y0Qc/3oMiFgIjDWWRpik=; b=gP35YOMq/3CmExyOCjH0LBH3cRkC/njZKv0wXv9mO8xOcy6v970W6Q19FoBbtO4ZW9 rqrRD3kZLdB0AuiBzOcxL4thKwOHCts+4q+avlTfCIOa7YQ93zMyrr2yxvqw4e3rYaKU O/Fp2XXrxyfFYAgp3FdJOj+P6vZlHtkPWAj5+kwejeG22cFl0QVuQixC+P/CtBIyi/74 Eg4YxtkHniFJzT0wpWrAZ2qi3cbdFHDkMgHdzYHYeloY5sxDduBC43BCQVCnd3P3GXdJ 0uJ6aUmYHcOyvzZcMQ6qlV7Wy1lcn33yDVPKd/EDUVy5hxOqu6dc+Q0BKzJKpEX7kE9k jCjA== X-Gm-Message-State: AHQUAuZMvEd89ocSJABdp2JTuVT9Fsyp2zTGLNUk2LBA1CDbargfczQy Zp0fTsR+LCtIaUR5QxU7oO8= X-Google-Smtp-Source: AHgI3Ia63bUqiD4r9j7o1v1pnR/Vj/okowRuQvnghn9NB9u6eKWt8zjSsAlFZ4eejKii6qAS/Iq9Gw== X-Received: by 2002:a50:ad84:: with SMTP id a4mr2607355edd.253.1550143165866; Thu, 14 Feb 2019 03:19:25 -0800 (PST) Received: from riot ([2a02:810d:1500:e01:f02f:97ff:feb5:2c7d]) by smtp.gmail.com with ESMTPSA id r9sm464259ejj.70.2019.02.14.03.19.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Feb 2019 03:19:25 -0800 (PST) Date: Thu, 14 Feb 2019 12:54:14 +0100 From: Zahari Doychev To: Toshiaki Makita Cc: netdev@vger.kernel.org, bridge@lists.linux-foundation.org, nikolay@cumulusnetworks.com, roopa@cumulusnetworks.com, jhs@mojatatu.com, jiri@resnulli.us, xiyou.wangcong@gmail.com, johannes@sipsolutions.net Subject: Re: [RFC PATCH] net act_vlan: use correct len in skb_pull Message-ID: <20190214115414.GA27909@riot> References: <20190213195102.1917-1-zahari.doychev@linux.com> <19f5bdf9-c83b-c9ec-83c3-1e9a88763b30@lab.ntt.co.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <19f5bdf9-c83b-c9ec-83c3-1e9a88763b30@lab.ntt.co.jp> User-Agent: Mutt/1.11.2 (2019-01-07) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Thu, Feb 14, 2019 at 06:16:12PM +0900, Toshiaki Makita wrote: > On 2019/02/14 4:51, Zahari Doychev wrote: > > The bridge and VLAN code expects that skb->data points to the start of the > > VLAN header instead of the next (network) header. Currently after > > tcf_vlan_act() on ingress filter skb->data points to the next network > > header. In this case the Linux bridge does not forward correctly double > > tagged VLAN packets added using tc vlan action as the outer vlan tag from > > the skb is inserted at the wrong offset after the vlan tag in the payload. > > Making skb->data to point to the VLAN header in tcf_vlan_act() by using > > ETH_HLEN in skb_pull_rcsum() fixes the problem. > > > > The following commands were used for testing: > > > > ip link add name br0 type bridge vlan_filtering 1 > > ip link set dev br0 up > > > > ip link set dev net0 up > > ip link set dev net0 master br0 > > > > ip link set dev net1 up > > ip link set dev net1 master br0 > > > > bridge vlan add dev net0 vid 100 master > > bridge vlan add dev br0 vid 100 self > > bridge vlan add dev net1 vid 100 master > > > > tc qdisc add dev net0 handle ffff: clsact > > tc qdisc add dev net1 handle ffff: clsact > > > > tc filter add dev net0 ingress pref 1 protocol all flower \ > > action vlan push id 10 pipe action vlan push id 100 > > > > tc filter add dev net0 egress pref 1 protocol 802.1q flower \ > > vlan_id 100 vlan_ethtype 802.1q cvlan_id 10 \ > > action vlan pop pipe action vlan pop > > > > Signed-off-by: Zahari Doychev > > --- > > net/sched/act_vlan.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/net/sched/act_vlan.c b/net/sched/act_vlan.c > > index 93fdaf707313..308d7d89f925 100644 > > --- a/net/sched/act_vlan.c > > +++ b/net/sched/act_vlan.c > > @@ -86,7 +86,7 @@ static int tcf_vlan_act(struct sk_buff *skb, const struct tc_action *a, > > > > out: > > if (skb_at_tc_ingress(skb)) > > - skb_pull_rcsum(skb, skb->mac_len); > > + skb_pull_rcsum(skb, ETH_HLEN); > > As I said before, it would be safer to remember mac_len and use it later. > > __u16 mac_len = skb->mac_len; > ... > err = skb_vlan_push(...) > ... > if (skb_at_tc_ingress(skb)) > skb_pull_rcsum(skb, mac_len); > sorry, I misunderstood it. I will send an update. Zahari > > -- > Toshiaki Makita >