From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Jason@zx2c4.com Received: from frisell.zx2c4.com (frisell.zx2c4.com [192.95.5.64]) by krantz.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 32534097 for ; Sat, 12 Nov 2016 15:38:12 +0000 (UTC) Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 20aedc9e for ; Sat, 12 Nov 2016 15:38:12 +0000 (UTC) Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 8d9c0cca (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128:NO) for ; Sat, 12 Nov 2016 15:38:11 +0000 (UTC) Received: by mail-lf0-f50.google.com with SMTP id t196so31483136lff.3 for ; Sat, 12 Nov 2016 07:40:32 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: <31e050e2-0499-a77e-f698-86e58ad2fa6b@cumulusnetworks.com> From: "Jason A. Donenfeld" Date: Sat, 12 Nov 2016 16:40:29 +0100 Message-ID: To: David Ahern Content-Type: text/plain; charset=UTF-8 Cc: Netdev , LKML , WireGuard mailing list Subject: Re: [WireGuard] Source address fib invalidation on IPv6 List-Id: Development discussion of WireGuard List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Hi again, I've done some pretty in depth debugging now to determine exactly what the behavior of ipv6_stub->ipv6_dst_lookup is. First I'll start with ip_route_output_flow, which I believe to be well behaved, and then I'll show ipv6_stub->ipv6_dst_lookup, which seems ill-behaved: Userspace: ip addr add 192.168.1.2/24 dev eth0 Kernelspace: struct flowi4 fl = { .saddr = 192.168.1.2, .daddr = 192.168.1.99, }; rt = ip_route_output_flow(sock_net(sock), &fl, sock); // rt returns valid rt for routing to 192.168.1.99 from 192.168.1.2 using eth0 Userspace: ip addr add 192.168.1.3/24 dev eth0 ip addr del 192.168.1.2/24 dev eth0 Kernelspace: struct flowi4 fl = { .saddr = 192.168.1.2, .daddr = 192.168.1.99, }; rt = ip_route_output_flow(sock_net(sock), &fl, sock); // PTR_ERR(rt) == -EINVAL This seems correct behavior to me, since no interface has 192.168.1.2 as a source address. Now for the incorrect IPv6 behavior: Userspace: ip -6 addr add abcd::2/96 dev eth0 Kernelspace: struct flowi6 fl = { .saddr = abcd::2, .daddr = abcd::99, }; ret = ipv6_stub->ipv6_dst_lookup(sock_net(sock), sock, &dst, &fl); // ret is 0, and dst is a non-null dst routing to abcd::99 from abcd::2 using eth0 Userspace: ip -6 addr add abcd::3/96 dev eth0 ip -6 addr del abcd::2/96 dev eth0 Kernelspace: struct flowi6 fl = { .saddr = abcd::2, .daddr = abcd::99, }; ret = ipv6_stub->ipv6_dst_lookup(sock_net(sock), sock, &dst, &fl); // ret is 0, and dst is a non-null dst routing to abcd::99 from abcd::2 using eth0 **INCORRECT BEHAVIOR!** This seems *INCORRECT* behavior to me, since no interface has abcd::2 as a source address. So, to summarize, the problem is that ipv6_dst_lookup will happily return a dst even though the source IP has been removed from the interface. I hope this clarifies things. I await your response. Regards, Jason