From mboxrd@z Thu Jan 1 00:00:00 1970 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 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 From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Jason A. Donenfeld" Subject: Re: Source address fib invalidation on IPv6 Date: Sun, 13 Nov 2016 01:51:20 +0100 Message-ID: References: <31e050e2-0499-a77e-f698-86e58ad2fa6b@cumulusnetworks.com> <0dbf5deb-bffb-4878-a268-1adb17c47676@cumulusnetworks.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: Netdev , Hannes Frederic Sowa , LKML , WireGuard mailing list , YOSHIFUJI Hideaki To: David Ahern Return-path: In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: wireguard-bounces@lists.zx2c4.com Sender: "WireGuard" List-Id: netdev.vger.kernel.org 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 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 cc3d2f48 for ; Sun, 13 Nov 2016 00:49:01 +0000 (UTC) Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 7c1173ff for ; Sun, 13 Nov 2016 00:49:00 +0000 (UTC) Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 2d0b4607 (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128:NO) for ; Sun, 13 Nov 2016 00:48:59 +0000 (UTC) Received: by mail-lf0-f47.google.com with SMTP id b14so36035369lfg.2 for ; Sat, 12 Nov 2016 16:51:22 -0800 (PST) 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 Message-ID: To: David Ahern Content-Type: text/plain; charset=UTF-8 Cc: Netdev , Hannes Frederic Sowa , LKML , WireGuard mailing list , YOSHIFUJI Hideaki 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: , 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