Just spoke w/ David to recap the conversation: bgpd.c is a grab bag of unrelated code and he agree's that it should be broken up along functional lines. This patch needs to happen independent of that though. We should work towards breaking it up more.
Because of that: Acked-by: Donald Sharp <[email protected]> On Tue, Jun 7, 2016 at 7:40 AM, Donald Sharp <[email protected]> wrote: > David - > > I agree having the router-id set all over the place is not great, but > hasn't bgpd.c become enough of a dumping ground for code? Might this be a > good chance to break this up a bit more intelligently? > > donald > > On Tue, May 24, 2016 at 12:58 PM, David Lamparter < > [email protected]> wrote: > >> 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 <[email protected]> >> --- >> bgpd/bgp_vty.c | 9 +++------ >> bgpd/bgp_zebra.c | 9 +-------- >> bgpd/bgp_zebra.h | 1 + >> bgpd/bgpd.c | 23 ++++++++++++++++++++++- >> bgpd/bgpd.h | 3 ++- >> 5 files changed, 29 insertions(+), 16 deletions(-) >> >> diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c >> index 6db3dcb..6b3deb3 100644 >> --- a/bgpd/bgp_vty.c >> +++ b/bgpd/bgp_vty.c >> @@ -51,8 +51,6 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, >> Boston, MA >> #include "bgpd/bgp_vty.h" >> #include "bgpd/bgp_mpath.h" >> >> -extern struct in_addr router_id_zebra; >> - >> /* Utility function to get address family from current node. */ >> afi_t >> bgp_node_afi (struct vty *vty) >> @@ -489,8 +487,7 @@ DEFUN (bgp_router_id, >> return CMD_WARNING; >> } >> >> - bgp->router_id_static = id; >> - bgp_router_id_set (bgp, &id); >> + bgp_router_id_static_set (bgp, id); >> >> return CMD_SUCCESS; >> } >> @@ -524,8 +521,8 @@ DEFUN (no_bgp_router_id, >> } >> } >> >> - bgp->router_id_static.s_addr = 0; >> - bgp_router_id_set (bgp, &router_id_zebra); >> + id.s_addr = 0; >> + bgp_router_id_static_set (bgp, id); >> >> return CMD_SUCCESS; >> } >> diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c >> index d0b9216..55a534e 100644 >> --- a/bgpd/bgp_zebra.c >> +++ b/bgpd/bgp_zebra.c >> @@ -53,8 +53,6 @@ bgp_router_id_update (int command, struct zclient >> *zclient, zebra_size_t length, >> vrf_id_t vrf_id) >> { >> struct prefix router_id; >> - struct listnode *node, *nnode; >> - struct bgp *bgp; >> >> zebra_router_id_update_read(zclient->ibuf,&router_id); >> >> @@ -67,12 +65,7 @@ bgp_router_id_update (int command, struct zclient >> *zclient, zebra_size_t length, >> >> router_id_zebra = router_id.u.prefix4; >> >> - for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) >> - { >> - if (!bgp->router_id_static.s_addr) >> - bgp_router_id_set (bgp, &router_id.u.prefix4); >> - } >> - >> + bgp_router_id_zebra_bump (); >> return 0; >> } >> >> diff --git a/bgpd/bgp_zebra.h b/bgpd/bgp_zebra.h >> index e69a0bc..2565158 100644 >> --- a/bgpd/bgp_zebra.h >> +++ b/bgpd/bgp_zebra.h >> @@ -24,6 +24,7 @@ Boston, MA 02111-1307, USA. */ >> #define BGP_NEXTHOP_BUF_SIZE (8 * sizeof (struct in_addr *)) >> >> extern struct stream *bgp_nexthop_buf; >> +extern struct in_addr router_id_zebra; >> >> extern void bgp_zebra_init (struct thread_master *master); >> extern void bgp_zebra_destroy (void); >> diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c >> index cadca11..5886cc6 100644 >> --- a/bgpd/bgpd.c >> +++ b/bgpd/bgpd.c >> @@ -160,7 +160,7 @@ bgp_config_check (struct bgp *bgp, int config) >> } >> >> /* 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 @@ bgp_router_id_set (struct bgp *bgp, struct in_addr >> *id) >> 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) >> diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h >> index 25bb1e8..96da8b5 100644 >> --- a/bgpd/bgpd.h >> +++ b/bgpd/bgpd.h >> @@ -884,7 +884,8 @@ extern int bgp_flag_check (struct bgp *, int); >> extern void bgp_lock (struct bgp *); >> extern void bgp_unlock (struct bgp *); >> >> -extern int bgp_router_id_set (struct bgp *, struct in_addr *); >> +extern void bgp_router_id_zebra_bump (void); >> +extern int bgp_router_id_static_set (struct bgp *, struct in_addr); >> >> extern int bgp_cluster_id_set (struct bgp *, struct in_addr *); >> extern int bgp_cluster_id_unset (struct bgp *); >> -- >> 2.3.6 >> >> >> _______________________________________________ >> Quagga-dev mailing list >> [email protected] >> https://lists.quagga.net/mailman/listinfo/quagga-dev >> > >
_______________________________________________ Quagga-dev mailing list [email protected] https://lists.quagga.net/mailman/listinfo/quagga-dev
