[WireGuard] Source address fib invalidation on IPv6

Jason A. Donenfeld Jason at zx2c4.com
Sun Nov 13 01:51:20 CET 2016

On Sun, Nov 13, 2016 at 1:43 AM, Jason A. Donenfeld <Jason at zx2c4.com> 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

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


More information about the WireGuard mailing list