Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753743AbcKMAv3 (ORCPT ); Sat, 12 Nov 2016 19:51:29 -0500 Received: from frisell.zx2c4.com ([192.95.5.64]:56943 "EHLO frisell.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753311AbcKMAv0 (ORCPT ); Sat, 12 Nov 2016 19:51:26 -0500 MIME-Version: 1.0 In-Reply-To: References: <31e050e2-0499-a77e-f698-86e58ad2fa6b@cumulusnetworks.com> <0dbf5deb-bffb-4878-a268-1adb17c47676@cumulusnetworks.com> From: "Jason A. Donenfeld" Date: Sun, 13 Nov 2016 01:51:20 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Source address fib invalidation on IPv6 To: David Ahern Cc: Netdev , WireGuard mailing list , LKML , YOSHIFUJI Hideaki , Hannes Frederic Sowa Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1606 Lines: 48 On Sun, Nov 13, 2016 at 1:43 AM, Jason A. Donenfeld wrote: > In perusing through the v6 FIB code, I don't even see an analog of > __ip_dev_find... Hm? Of all places, the iscsi code actually has a nice side-by-side comparison. So far as I can see, the other protocols just omit this check in the v6 case, which I believe to be errant behavior. For example, grep for ip_dev_find in the sctp v4 code. The equivalent v6 code is missing the dev check. Ugly! Here's the block I found in cxgbit_cm.c: static struct net_device *cxgbit_ipv4_netdev(__be32 saddr) { struct net_device *ndev; ndev = __ip_dev_find(&init_net, saddr, false); if (!ndev) return NULL; return cxgbit_get_real_dev(ndev); } static struct net_device *cxgbit_ipv6_netdev(struct in6_addr *addr6) { struct net_device *ndev = NULL; bool found = false; if (IS_ENABLED(CONFIG_IPV6)) { for_each_netdev_rcu(&init_net, ndev) if (ipv6_chk_addr(&init_net, addr6, ndev, 1)) { found = true; break; } } if (!found) return NULL; return cxgbit_get_real_dev(ndev); } It seems like __ip6_dev_find could be made out of that inner loop. Then existing uses like that iscsi code can be replaced with that helper function, and the existing ip6 route tail function can be augmented in the manner you recommended. Seem like a decent implementation strategy? I might submit some patches, unless you beat me to it. Jason