From: Donatas Abraitis Date: Mon, 30 Jan 2023 21:23:38 +0000 (+0200) Subject: bgpd: Vanish FQDN capability hostname/domainname before handling new BGP OPEN X-Git-Tag: base_8.5~20^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=refs%2Fpull%2F12710%2Fhead;p=mirror%2Ffrr.git 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 --- 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; }