bgpd: divorce router-id logic from CLI & zebra
Logic for determining the router-id was spread out over bgp_zebra.c and
bgp_vty.c. Move to bgpd/bgpd.c and have these two call more properly
encapsulated functions.
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index 9521927..db952c7 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -160,7 +160,7 @@
}
/* Set BGP router identifier. */
-int
+static int
bgp_router_id_set (struct bgp *bgp, struct in_addr *id)
{
struct peer *peer;
@@ -188,6 +188,27 @@
return 0;
}
+void
+bgp_router_id_zebra_bump (void)
+{
+ struct listnode *node, *nnode;
+ struct bgp *bgp;
+
+ for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
+ {
+ if (!bgp->router_id_static.s_addr)
+ bgp_router_id_set (bgp, &router_id_zebra);
+ }
+}
+
+int
+bgp_router_id_static_set (struct bgp *bgp, struct in_addr id)
+{
+ bgp->router_id_static = id;
+ bgp_router_id_set (bgp, id.s_addr ? &id : &router_id_zebra);
+ return 0;
+}
+
/* BGP's cluster-id control. */
int
bgp_cluster_id_set (struct bgp *bgp, struct in_addr *cluster_id)