From 81489b79e07d448f30434a0c1d22f8f744f0fda8 Mon Sep 17 00:00:00 2001 From: "Ondrej Zajicek (work)" Date: Thu, 8 Nov 2018 20:43:04 +0100 Subject: Nest: Improve keeping track of IPv6 link-local addresses Most protocols in IPv6 mode use link-local source addresses and expect that there is one on each active interface. The old code depended on assumption that if there is some IPv6 address on iface, there is also an IPv6 link-local address on that iface (added by kernel when the iface went up). Unfortunately, that is not generally true, as a configured global address sometimes ceases to be tentative (finishes DOD) before a link-local address on the same iface. In such case a protocol iface (namely RAdv and Babel) is activated, but fails to found link-local address and stays in failed state. The patch fixes that by tracking 'primary' IPv6 link-local address, sending iface restart notifications when it changes and making protocols ignore iface-up notifications when no such address is selected for an iface. --- nest/iface.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'nest/iface.c') diff --git a/nest/iface.c b/nest/iface.c index 56de1f5c..7acadc7d 100644 --- a/nest/iface.c +++ b/nest/iface.c @@ -470,10 +470,24 @@ struct ifa *kif_choose_primary(struct iface *i); static int ifa_recalc_primary(struct iface *i) { - struct ifa *a = kif_choose_primary(i); + struct ifa *a; + int c = 0; + +#ifdef IPV6 + struct ifa *ll = NULL; + + WALK_LIST(a, i->addrs) + if (ipa_is_link_local(a->ip) && (!ll || (a == i->llv6))) + ll = a; + + c = (ll != i->llv6); + i->llv6 = ll; +#endif + + a = kif_choose_primary(i); if (a == i->addr) - return 0; + return c; if (i->addr) i->addr->flags &= ~IA_PRIMARY; @@ -577,7 +591,7 @@ ifa_delete(struct ifa *a) b->flags &= ~IF_UP; ifa_notify_change(IF_CHANGE_DOWN, b); } - if (b->flags & IA_PRIMARY) + if ((b->flags & IA_PRIMARY) || (b == ifa_llv6(i))) { if_change_flags(i, i->flags | IF_TMP_DOWN); ifa_recalc_primary(i); -- cgit v1.2.3