From patchwork Fri Aug 3 06:27:51 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Zhao X-Patchwork-Id: 174890 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id BE5532C007A for ; Fri, 3 Aug 2012 16:28:04 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751262Ab2HCG2D (ORCPT ); Fri, 3 Aug 2012 02:28:03 -0400 Received: from mail-gh0-f174.google.com ([209.85.160.174]:35269 "EHLO mail-gh0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750817Ab2HCG2B (ORCPT ); Fri, 3 Aug 2012 02:28:01 -0400 Received: by ghrr11 with SMTP id r11so431471ghr.19 for ; Thu, 02 Aug 2012 23:28:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=a3GPcDfE6JUkhWXM12HvSkuWZWwxIhhl7rD/aCGAr80=; b=iWu3bpC8HGBFysRq6Ljx5ybldSmYZQ2chPdDwLrbn/Td/Rr2fXLi5wkO4l2+rAoHss 9KlA03c3oNKUnvqmMq0N/TDbZrY8fEPhjsjEA9GMEau+0Kbm+0Rygz0muSnoarVhpfBc R+XPVLsFah9c5bArhmHqVDc+tMaJ8WzuvgBcx7dD2mTAee05WG0QI2r3UWhQSyi9f0KK IDgfMHrxKCJMZ9famH5A/HjUAGTpEubtcY35dOwiwTKQy5RUp2klJCJer0T0uxAG9wfT 0JSceaVj3Zgdui+4xpve6DOd+RDgvvSqhVE9y0VTpC4ZUcrNUYVap/KhmuxL5AvWIeSO yp/Q== Received: by 10.50.36.131 with SMTP id q3mr1275391igj.56.1343975279968; Thu, 02 Aug 2012 23:27:59 -0700 (PDT) Received: from localhost.localdomain ([64.104.168.84]) by mx.google.com with ESMTPS id ua2sm19082588igb.7.2012.08.02.23.27.56 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 02 Aug 2012 23:27:59 -0700 (PDT) From: Jun Zhao To: "David S. Miller" , Alexey Kuznetsov , James Morris , Hideaki YOSHIFUJI , Patrick McHardy Cc: netdev@vger.kernel.org, mypopydev@gmail.com Subject: [PATCH v2 1/1] ipv6 : ip6mr.c : Fix can't match the IPv6 multicast packets with input net device in netfilter FORWARD chain. Date: Fri, 3 Aug 2012 14:27:51 +0800 Message-Id: <1343975271-4263-1-git-send-email-mypopydev@gmail.com> X-Mailer: git-send-email 1.7.2.5 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Current kernel change the skb's net device with output device before netfilter FORWARD chain, that will lead to can't match the IPv6 multicast packets with input net device in netfilter FORWARD chain. the test case for reproduce this issue as follow: IPv6 multicast udp stream from eth0(input device) to eth1(output device) Dst Addr: Port {ff03::4}:6789 ---> Router +---------------------------+ -------> | [eth0] --FORWARD--> [eth1]| -------> +---------------------------+ ip6tables -I FORWARD -p udp -i eth0 -o eth1 --dst ff03::4 -j ACCEPT [first rules ] ip6tables -A FORWARD -p udp -i eth1 -o eth1 --dst ff03::4 -j ACCEPT [second rules] Before fix this issue, it will match the second rules not the first rules. you can used command "ip6tables -L -vnx" to check the match result. Signed-off-by: Jun Zhao --- net/ipv6/ip6mr.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c index 4532973..b099dfb 100644 --- a/net/ipv6/ip6mr.c +++ b/net/ipv6/ip6mr.c @@ -1901,6 +1901,7 @@ static int ip6mr_forward2(struct net *net, struct mr6_table *mrt, struct ipv6hdr *ipv6h; struct mif_device *vif = &mrt->vif6_table[vifi]; struct net_device *dev; + struct net_device *indev; struct dst_entry *dst; struct flowi6 fl6; @@ -1946,6 +1947,7 @@ static int ip6mr_forward2(struct net *net, struct mr6_table *mrt, * result in receiving multiple packets. */ dev = vif->dev; + indev = skb->dev; skb->dev = dev; vif->pkt_out++; vif->bytes_out += skb->len; @@ -1960,7 +1962,7 @@ static int ip6mr_forward2(struct net *net, struct mr6_table *mrt, IP6CB(skb)->flags |= IP6SKB_FORWARDED; - return NF_HOOK(NFPROTO_IPV6, NF_INET_FORWARD, skb, skb->dev, dev, + return NF_HOOK(NFPROTO_IPV6, NF_INET_FORWARD, skb, indev, dev, ip6mr_forward2_finish); out_free: