From c2d58d6d0fde69318f7518e96725b276190adcd8 Mon Sep 17 00:00:00 2001 From: vivek Date: Tue, 17 Nov 2015 13:57:56 -0800 Subject: [PATCH] BGP: Handle router-id correctly in config and display. BGP is currently displaying the in-use router-id in the config. This is conditional on a CONFIG flag, however, that flag is set even when there is no configured router-id and the router-id learnt from Zebra is in-use. The CONFIG flag for router-id is redundant since there is a separate variable for the configured value, so use that and deprecate the CONFIG flag. This also makes BGP behave like OSPF. Signed-off-by: Vivek Venkatraman Reviewed-by: Donald Sharp Reviewed-by: Daniel Walton Ticket: CM-8077, CM-8220 Reviewed By: CCR-3793 Testing Done: Manual verification (in 2.5-br) Note: Imported from 2.5-br patch bgpd-fix-router-id-config-display.patch --- bgpd/bgp_vty.c | 3 +++ bgpd/bgpd.c | 10 ++++------ bgpd/bgpd.h | 5 ++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index de6f4d8b56..53448da349 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -738,6 +738,9 @@ DEFUN (bgp_router_id, return CMD_WARNING; } + if (IPV4_ADDR_SAME (&bgp->router_id_static, &id)) + return CMD_SUCCESS; + bgp->router_id_static = id; bgp_router_id_set (bgp, &id); diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 3ad59ff0c1..0c92532ba0 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -210,12 +210,10 @@ bgp_router_id_set (struct bgp *bgp, struct in_addr *id) struct peer *peer; struct listnode *node, *nnode; - if (bgp_config_check (bgp, BGP_CONFIG_ROUTER_ID) - && IPV4_ADDR_SAME (&bgp->router_id, id)) + if (IPV4_ADDR_SAME (&bgp->router_id, id)) return 0; IPV4_ADDR_COPY (&bgp->router_id, id); - bgp_config_set (bgp, BGP_CONFIG_ROUTER_ID); /* Set all peer's local identifier with this value. */ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) @@ -6787,9 +6785,9 @@ bgp_config_write (struct vty *vty) vty_out (vty, " no bgp fast-external-failover%s", VTY_NEWLINE); /* BGP router ID. */ - if (CHECK_FLAG (bgp->config, BGP_CONFIG_ROUTER_ID)) - vty_out (vty, " bgp router-id %s%s", inet_ntoa (bgp->router_id), - VTY_NEWLINE); + if (bgp->router_id_static.s_addr != 0) + vty_out (vty, " bgp router-id %s%s", + inet_ntoa (bgp->router_id_static), VTY_NEWLINE); /* BGP log-neighbor-changes. */ if (!bgp_flag_check (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES)) diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index 76486a4290..f64866aed5 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -178,9 +178,8 @@ struct bgp /* BGP configuration. */ u_int16_t config; -#define BGP_CONFIG_ROUTER_ID (1 << 0) -#define BGP_CONFIG_CLUSTER_ID (1 << 1) -#define BGP_CONFIG_CONFEDERATION (1 << 2) +#define BGP_CONFIG_CLUSTER_ID (1 << 0) +#define BGP_CONFIG_CONFEDERATION (1 << 1) /* BGP router identifier. */ struct in_addr router_id; -- 2.39.5