bgpd: conditional default-originate using route-map
Incorporate a patch by Svetozar Mihailov which implements
default-originate route-maps to behave as expected, i.e. allowing
the default route to be advertised conditionally, depending on a
criterion given by the route-map.
I am aware that the performance attributes of the following implementation
are far from optimal. However, this affects only code paths belonging to
a feature that is broken without this patch, therefore, it seems reasonable
to me to have this in the mainline for now.
Cc: Svetozar Mihailov <quagga@j.zarhi.com>
Reported-by: Sébastien Cramatte <scramatte@gmail.com>
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c
index 0e56d36..d469236 100644
--- a/bgpd/bgp_nexthop.c
+++ b/bgpd/bgp_nexthop.c
@@ -506,6 +506,16 @@
else if (afi == AFI_IP6)
zlog_debug ("scanning IPv6 Unicast routing tables");
}
+
+ /* Reevaluate default-originate route-maps and announce/withdraw
+ * default route if neccesary. */
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
+ {
+ if (peer->status == Established
+ && CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)
+ && peer->default_rmap[afi][safi].name)
+ bgp_default_originate (peer, afi, safi, 0);
+ }
}
/* BGP scan thread. This thread check nexthop reachability. */