netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/1] ipv6 : ip6mr.c : Fix can't match the IPv6 multicast packets with input net device in netfilter FORWARD chain.
@ 2012-08-03  6:27 Jun Zhao
  2012-08-03  6:43 ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Jun Zhao @ 2012-08-03  6:27 UTC (permalink / raw)
  To: David S. Miller, Alexey Kuznetsov, James Morris,
	Hideaki YOSHIFUJI, Patrick McHardy
  Cc: netdev, mypopydev

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 <mypopydev@gmail.com>
---
 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:
-- 
1.7.2.5

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 1/1] ipv6 : ip6mr.c : Fix can't match the IPv6 multicast packets with input net device in netfilter FORWARD chain.
  2012-08-03  6:27 [PATCH v2 1/1] ipv6 : ip6mr.c : Fix can't match the IPv6 multicast packets with input net device in netfilter FORWARD chain Jun Zhao
@ 2012-08-03  6:43 ` David Miller
  2012-08-03  7:10   ` Jun Zhao
  0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2012-08-03  6:43 UTC (permalink / raw)
  To: mypopydev; +Cc: kuznet, jmorris, yoshfuji, kaber, netdev

From: Jun Zhao <mypopydev@gmail.com>
Date: Fri,  3 Aug 2012 14:27:51 +0800

> @@ -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);
>  

This patch has the same problem I mentioned, it means someone who is
now matching on the VIF device will now fail to do son.

You have to understand that you simply cannot change the behavior
here without breaking something for someone.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 1/1] ipv6 : ip6mr.c : Fix can't match the IPv6 multicast packets with input net device in netfilter FORWARD chain.
  2012-08-03  6:43 ` David Miller
@ 2012-08-03  7:10   ` Jun Zhao
  0 siblings, 0 replies; 3+ messages in thread
From: Jun Zhao @ 2012-08-03  7:10 UTC (permalink / raw)
  To: David Miller; +Cc: kuznet, jmorris, yoshfuji, kaber, netdev

On Thu, 2012-08-02 at 23:43 -0700, David Miller wrote:
> From: Jun Zhao <mypopydev@gmail.com>
> Date: Fri,  3 Aug 2012 14:27:51 +0800
> 
> > @@ -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);
> >  
> 
> This patch has the same problem I mentioned, it means someone who is
> now matching on the VIF device will now fail to do son.
> 
> You have to understand that you simply cannot change the behavior
> here without breaking something for someone.

Hi, David:

Can you give me some more details what I break in this fix?

As my understanding, in the ip6mr_forward2(), vifi is the VIF index for
output, we can get the output device used vif->dev and record input
device before change skb->dev; then used FORWARD chain match the rules. 

Tks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-08-03  7:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-03  6:27 [PATCH v2 1/1] ipv6 : ip6mr.c : Fix can't match the IPv6 multicast packets with input net device in netfilter FORWARD chain Jun Zhao
2012-08-03  6:43 ` David Miller
2012-08-03  7:10   ` Jun Zhao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).