[PATCH] babel: Don't send routes with empty next hops

Toke Høiland-Jørgensen toke at toke.dk
Sun Jun 10 15:58:39 CEST 2018


If an interface has no configured v4 address, no valid next hop will be
found for v4 routes. Rather than send them with an invalid next hop (which
will just cause parse errors at the receiver), skip such routes entirely
when sending updates. Also, amend the warning on configure to make it clear
that v4 routes will not work if there is no v4 address on the interface.

Signed-off-by: Toke Høiland-Jørgensen <toke at toke.dk>
---
 proto/babel/babel.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/proto/babel/babel.c b/proto/babel/babel.c
index 44c6adb8..d3b5b841 100644
--- a/proto/babel/babel.c
+++ b/proto/babel/babel.c
@@ -951,8 +951,13 @@ babel_send_update_(struct babel_iface *ifa, btime changed, struct fib *rtable)
 
     msg.update.next_hop = ((e->n.addr->type == NET_IP4) ?
 			   ifa->next_hop_ip4 : ifa->next_hop_ip6);
-
-    babel_enqueue(&msg, ifa);
+    /*
+     * We may get empty next hop addresses here if no v4 address is configured
+     * on the interface. These will just cause parsing errors at the receiver,
+     * so don't send them.
+     */
+    if (!ipa_zero(msg.update.next_hop))
+      babel_enqueue(&msg, ifa);
 
     /* Update feasibility distance for redistributed routes */
     if (e->router_id != p->router_id)
@@ -1580,7 +1585,8 @@ babel_add_iface(struct babel_proto *p, struct iface *new, struct babel_iface_con
   ifa->next_hop_ip6 = ipa_nonzero(ic->next_hop_ip6) ? ic->next_hop_ip6 : ifa->addr;
 
   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);
+    log(L_WARN "%s: Cannot find IPv4 next hop addr on %s. "
+        "v4 routes will not work!", p->p.name, new->name);
 
   init_list(&ifa->neigh_list);
   ifa->hello_seqno = 1;
@@ -1682,7 +1688,8 @@ babel_reconfigure_iface(struct babel_proto *p, struct babel_iface *ifa, struct b
   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)
-    log(L_WARN "%s: Cannot find IPv4 next hop addr on %s", p->p.name, ifa->ifname);
+    log(L_WARN "%s: Cannot find IPv4 next hop addr on %s. "
+        "v4 routes will not work!", p->p.name, ifa->ifname);
 
   if (ifa->next_hello > (current_time() + new->hello_interval))
     ifa->next_hello = current_time() + (random() % new->hello_interval);
-- 
2.17.1



More information about the Bird-users mailing list