summaryrefslogtreecommitdiff
path: root/proto/babel/babel.c
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2017-12-07 13:06:01 +0100
committerOndrej Zajicek (work) <santiago@crfreenet.org>2017-12-07 13:06:01 +0100
commit153f02da3bce1f3f1a99295648679c71327e8319 (patch)
treeb7b7acf8026ba182f3a81f2d6da975b0b1524972 /proto/babel/babel.c
parent4ae3ee1200b386219673c2168eae996c6207b077 (diff)
Nest: Maintain separate IPv4, IPv6 and LLv6 preferred addresses
Also redesign preferred address selection and update protocols to use appropriate preferred address. Based on a previous work by Jan Maria Matejka.
Diffstat (limited to 'proto/babel/babel.c')
-rw-r--r--proto/babel/babel.c47
1 files changed, 17 insertions, 30 deletions
diff --git a/proto/babel/babel.c b/proto/babel/babel.c
index a0ec3629..23746155 100644
--- a/proto/babel/babel.c
+++ b/proto/babel/babel.c
@@ -1501,26 +1501,14 @@ babel_add_iface(struct babel_proto *p, struct iface *new, struct babel_iface_con
ifa->cf = ic;
ifa->pool = pool;
ifa->ifname = new->name;
+ ifa->addr = new->llv6->ip;
add_tail(&p->interfaces, NODE ifa);
- ip_addr addr4 = IPA_NONE;
- struct ifa *addr;
- WALK_LIST(addr, new->addrs)
- {
- if (ipa_is_link_local(addr->ip))
- ifa->addr = addr->ip;
-
- if (ipa_zero(addr4) && ipa_is_ip4(addr->ip))
- addr4 = addr->ip;
- }
-
+ ip_addr addr4 = new->addr4 ? new->addr4->ip : IPA_NONE;
ifa->next_hop_ip4 = ipa_nonzero(ic->next_hop_ip4) ? ic->next_hop_ip4 : addr4;
ifa->next_hop_ip6 = ipa_nonzero(ic->next_hop_ip6) ? ic->next_hop_ip6 : ifa->addr;
- if (ipa_zero(ifa->addr))
- log(L_WARN "%s: Cannot find link-local addr on %s", p->p.name, new->name);
-
if (ipa_zero(ifa->next_hop_ip4) && p->ip4_channel)
log(L_WARN "%s: Cannot find IPv4 next hop addr on %s", p->p.name, new->name);
@@ -1576,6 +1564,10 @@ babel_if_notify(struct proto *P, unsigned flags, struct iface *iface)
if (!(iface->flags & IF_MULTICAST))
return;
+ /* Ignore ifaces without link-local address */
+ if (!iface->llv6)
+ return;
+
if (ic)
babel_add_iface(p, iface, ic);
@@ -1615,21 +1607,8 @@ babel_reconfigure_iface(struct babel_proto *p, struct babel_iface *ifa, struct b
ifa->cf = new;
- if (ipa_nonzero(new->next_hop_ip4))
- ifa->next_hop_ip4 = new->next_hop_ip4;
- else
- {
- ifa->next_hop_ip4 = IPA_NONE;
-
- struct ifa *addr;
- WALK_LIST(addr, ifa->iface->addrs)
- if (ipa_is_ip4(addr->ip))
- {
- ifa->next_hop_ip4 = addr->ip;
- break;
- }
- }
-
+ ip_addr addr4 = ifa->iface->addr4 ? ifa->iface->addr4->ip : IPA_NONE;
+ ifa->next_hop_ip4 = ipa_nonzero(new->next_hop_ip4) ? new->next_hop_ip4 : addr4;
ifa->next_hop_ip6 = ipa_nonzero(new->next_hop_ip6) ? new->next_hop_ip6 : ifa->addr;
if (ipa_zero(ifa->next_hop_ip4) && p->ip4_channel)
@@ -1660,7 +1639,15 @@ babel_reconfigure_ifaces(struct babel_proto *p, struct babel_config *cf)
WALK_LIST(iface, iface_list)
{
- if (! (iface->flags & IF_UP))
+ if (!(iface->flags & IF_UP))
+ continue;
+
+ /* Ignore non-multicast ifaces */
+ if (!(iface->flags & IF_MULTICAST))
+ continue;
+
+ /* Ignore ifaces without link-local address */
+ if (!iface->llv6)
continue;
struct babel_iface *ifa = babel_find_iface(p, iface);