From d188b08f3027b466ae9e3476f340469c5f9052c9 Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Mon, 30 Jan 2023 23:23:38 +0200 Subject: [PATCH] bgpd: Vanish FQDN capability hostname/domainname before handling new BGP OPEN Before this, if the peer disables sending FQDN capability, the old hostname still (STALE) exists and is misleading in the outputs of `show bgp ...`. Especially when using with `bgp default show-hostname`, etc. Signed-off-by: Donatas Abraitis --- bgpd/bgp_fsm.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c index c57e148ef8..9624adfbe2 100644 --- a/bgpd/bgp_fsm.c +++ b/bgpd/bgp_fsm.c @@ -279,22 +279,20 @@ static struct peer *peer_xfer_conn(struct peer *from_peer) } } + if (peer->hostname) { + XFREE(MTYPE_BGP_PEER_HOST, peer->hostname); + peer->hostname = NULL; + } if (from_peer->hostname != NULL) { - if (peer->hostname) { - XFREE(MTYPE_BGP_PEER_HOST, peer->hostname); - peer->hostname = NULL; - } - peer->hostname = from_peer->hostname; from_peer->hostname = NULL; } + if (peer->domainname) { + XFREE(MTYPE_BGP_PEER_HOST, peer->domainname); + peer->domainname = NULL; + } if (from_peer->domainname != NULL) { - if (peer->domainname) { - XFREE(MTYPE_BGP_PEER_HOST, peer->domainname); - peer->domainname = NULL; - } - peer->domainname = from_peer->domainname; from_peer->domainname = NULL; } -- 2.39.5