Subject: Re: [PATCH net-next v4] IPv6: use anycast addresses as source addresses in echo reply

From: Hannes Frederic Sowa <[email-masked]>
Date: Tue, 7 Jan 2014 14:01:01 +0100

On Tue, Jan 07, 2014 at 04:38:22AM -0800, François-Xavier Le Bail wrote:
> On Mon, 1/6/14, Hannes Frederic Sowa <[email-masked]> wrote:
> 
> 
> > > > I think we should pass a valid device in unless it
> > > > breaks something obvious.
> 
> > > The problem is that "saddr" is not necessarily an address on "skb->dev"
> > > in icmpv6_echo_reply(). It may be an address on another interface.
>  
> > Maybe you're right, but then I don't get it. Could you make
> > an example?
> 
> Yes :
> box with eth1, eth2, forwarding enable.
> 
> echo request arrives on eth2
> -------------------------------> eth2 (2a01:3::1)  {forwarding enable}   eth1 (2a01:2::1)
> 
> if dest == 2a01:3::
> Jan  7 10:36:36 localhost kernel: [   59.155376] icmpv6_echo_reply: saddr == 2a01:3::
> Jan  7 10:36:36 localhost kernel: [   59.155395] icmpv6_echo_reply: skb->dev->name == eth2
> Jan  7 10:36:36 localhost kernel: [   59.155398] icmpv6_echo_reply: ipv6_chk_acast_addr(net, skb->dev, saddr) == 1
> Jan  7 10:36:36 localhost kernel: [   59.155400] icmpv6_echo_reply: ipv6_chk_acast_addr(net, NULL, saddr) == 1
> if dest == 2a01:2::
> Jan  7 10:36:46 localhost kernel: [   68.807565] icmpv6_echo_reply: saddr == 2a01:2::
> Jan  7 10:36:46 localhost kernel: [   68.807580] icmpv6_echo_reply: skb->dev->name == eth2
> Jan  7 10:36:46 localhost kernel: [   68.807583] icmpv6_echo_reply: ipv6_chk_acast_addr(net, skb->dev, saddr) == 0
> Jan  7 10:36:46 localhost kernel: [   68.807586] icmpv6_echo_reply: ipv6_chk_acast_addr(net, NULL, saddr) == 1
> 
> So, as 2a01:2:: is a address on eth1, ipv6_chk_acast_addr(net, skb->dev, saddr) with dev == eth2 return 0.
> 
> It is the reason why I use dev == NULL.
> 
> Do your tests show something different ?

I haven't tested this particular setup.

> 
> Anyway, although I think that this solution is valid, I am testing another way to do this change.

Ok, thanks for explaining, I see now, of course.

Maybe we could just do (ipv6_addr_type(addr) & IPV6_ADDR_LINKLOCAL) ? skb->dev
: NULL?

I guess the NULL solution would be ok now, too. You can decide. I just
think we can be a bit more defensive here with no additional cost. Routing
table behaviour is pretty complicated and maybe can change in future.

Thank you,

  Hannes