netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net/ipv6/route.c: packets originating on device match lo
@ 2012-06-25  6:50 David McCullough
  2012-06-25 23:28 ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: David McCullough @ 2012-06-25  6:50 UTC (permalink / raw)
  To: netdev; +Cc: david_mccullough


Hi all,

Seems like the special case of "iif lo" when using rules to control packets
is broken for IPv6 traffic.  The section from the ip man page is:

   iif NAME
          select  the incoming device to match.  If the interface is loop‐
          back, the rule only matches packets originating from this  host.
          This  means that you may create separate routing tables for for‐
          warded and local packets and, hence, completely segregate them.

If I run the following configuration:

    ifconfig eth0 192.168.0.1 netmask 255.255.255.0
    ip addr add fec0:0:0:2::1/64 dev eth0

    ip route add table 200 unreachable default
    ip -6 route add table 200 unreachable default

    ip rule add to 192.168.0.2 table 200 iif lo
    ip -6 rule add to fec0:0:0:2::2 table 200 iif lo

and then test with:

    # ping 192.168.0.2
    connect: Network is unreachable
    # ping6 fec0:0:0:2::2
    PING fec0:0:0:2::2(fec0:0:0:2::2) 56 data bytes
    64 bytes from fec0:0:0:2::2: icmp_seq=1 ttl=64 time=0.648 ms
    ...

The patch below is against linux-3.4.  I am not sure if its the best
solution but it appears to fix the case above:

    # ping6 fec0:0:0:2::2
    connect: Network is unreachable

and does not appear to affect forwarded packets is the few cases I have
tried.  Tested on linux-3.4 and iproute2-3.4.0, Feedback appreciated :-)

Thanks,
Davidm

Signed-off-by: David McCullough <david_mccullough@mcafee.com>

diff -p -u -r1.1.1.59 route.c
--- linux-3.4/net/ipv6/route.c	21 May 2012 23:15:01 -0000	1.1.1.59
+++ linux-3.4/net/ipv6/route.c	25 Jun 2012 05:43:50 -0000
@@ -931,6 +931,9 @@ struct dst_entry * ip6_route_output(stru
 {
 	int flags = 0;
 
+	if (fl6->flowi6_iif == 0)
+		fl6->flowi6_iif = net->loopback_dev->ifindex;
+		
 	if ((sk && sk->sk_bound_dev_if) || rt6_need_strict(&fl6->daddr))
 		flags |= RT6_LOOKUP_F_IFACE;
 

-- 
David McCullough,      david_mccullough@mcafee.com,  Ph:+61 734352815
McAfee - SnapGear      http://www.mcafee.com         http://www.uCdot.org

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

* Re: [PATCH] net/ipv6/route.c: packets originating on device match lo
  2012-06-25  6:50 [PATCH] net/ipv6/route.c: packets originating on device match lo David McCullough
@ 2012-06-25 23:28 ` David Miller
  2012-06-26  1:38   ` David McCullough
  0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2012-06-25 23:28 UTC (permalink / raw)
  To: david_mccullough; +Cc: netdev

From: David McCullough <david_mccullough@mcafee.com>
Date: Mon, 25 Jun 2012 16:50:30 +1000

> @@ -931,6 +931,9 @@ struct dst_entry * ip6_route_output(stru
>  {
>  	int flags = 0;
>  
> +	if (fl6->flowi6_iif == 0)
> +		fl6->flowi6_iif = net->loopback_dev->ifindex;
> +		

Like ipv4, you should make this assignment unconditionally.

Thanks.

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

* Re: [PATCH] net/ipv6/route.c: packets originating on device match lo
  2012-06-25 23:28 ` David Miller
@ 2012-06-26  1:38   ` David McCullough
  0 siblings, 0 replies; 3+ messages in thread
From: David McCullough @ 2012-06-26  1:38 UTC (permalink / raw)
  To: David Miller; +Cc: netdev


Jivin David Miller lays it down ...
> From: David McCullough <david_mccullough@mcafee.com>
> Date: Mon, 25 Jun 2012 16:50:30 +1000
> 
> > @@ -931,6 +931,9 @@ struct dst_entry * ip6_route_output(stru
> >  {
> >  	int flags = 0;
> >  
> > +	if (fl6->flowi6_iif == 0)
> > +		fl6->flowi6_iif = net->loopback_dev->ifindex;
> > +		
> 
> Like ipv4, you should make this assignment unconditionally.

No problems, will resend,  I wasn't so sure that I could do that safely
with the flowi getting passed into IPv6 rather than created as it is in
IPv4.  Did some extra testing,  looks good so patch to follow,

Thanks,
Davidm

-- 
David McCullough,      david_mccullough@mcafee.com,  Ph:+61 734352815
McAfee - SnapGear      http://www.mcafee.com         http://www.uCdot.org

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

end of thread, other threads:[~2012-06-26  1:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-25  6:50 [PATCH] net/ipv6/route.c: packets originating on device match lo David McCullough
2012-06-25 23:28 ` David Miller
2012-06-26  1:38   ` David McCullough

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).