bgpd: skip reset when removing dup update-source

When 'no neighbor .. update-source' is issued for a regular peer, that
peer is always reset.  This is unnecessary if the peer is a member of a
peer-group and it inherits an identical update-source, so let's skip
the reset/Notification for that condition.

Config:
------------
router bgp 1
 neighbor PG peer-group
 neighbor PG remote-as internal
 neighbor PG update-source 100.64.0.3
 neighbor 192.168.122.99 peer-group PG
 neighbor 192.168.122.99 update-source 100.64.0.3

Before:
------------
ub20-2(config-router)# do show ip bgp sum | include .99
192.168.122.99  4          1        36        34        0    0    0 00:00:17            0        0 N/A
ub20-2(config-router)# do show ip bgp neighbors 192.168.122.99 | include Local host
Local host: 100.64.0.3, Local port: 46083
ub20-2(config-router)# no neighbor 192.168.122.99 update-source
ub20-2(config-router)# do show ip bgp sum | include .99
192.168.122.99  4          1        36        35        0    0    0 00:00:01         Idle        0 N/A
ub20-2(config-router)# do show ip bgp neighbors 192.168.122.99 | include Local host
Local host: 100.64.0.3, Local port: 39847

After:
------------
ub20-2(config-router)# do show ip bgp sum | include .99
192.168.122.99  4          1         3         3        0    0    0 00:00:20            0        0 N/A
ub20-2(config-router)# do show ip bgp neighbors 192.168.122.99 | include Local host
Local host: 100.64.0.3, Local port: 39415
ub20-2(config-router)# no neighbor 192.168.122.99 update-source
ub20-2(config-router)# do show ip bgp sum | include .99
192.168.122.99  4          1         3         3        0    0    0 00:00:28            0        0 N/A
ub20-2(config-router)# do show ip bgp neighbors 192.168.122.99 | include Local host
Local host: 100.64.0.3, Local port: 39415

Signed-off-by: Trey Aspelund <taspelund@nvidia.com>
This commit is contained in:
Trey Aspelund 2023-07-24 20:16:08 +00:00
parent 49e9bb2819
commit 62a452c47f

View File

@ -5393,16 +5393,29 @@ void peer_update_source_unset(struct peer *peer)
{
struct peer *member;
struct listnode *node, *nnode;
bool src_unchanged = false;
if (!CHECK_FLAG(peer->flags, PEER_FLAG_UPDATE_SOURCE))
return;
/* Inherit configuration from peer-group if peer is member. */
if (peer_group_active(peer)) {
/* Don't reset peer if the update_source we'll inherit from
* the peer-group matches the peer's existing update_source
*/
src_unchanged =
(peer->update_source &&
peer->group->conf->update_source &&
sockunion_cmp(peer->update_source,
peer->group->conf->update_source) == 0);
peer_flag_inherit(peer, PEER_FLAG_UPDATE_SOURCE);
PEER_SU_ATTR_INHERIT(peer, peer->group, update_source);
PEER_STR_ATTR_INHERIT(peer, peer->group, update_if,
MTYPE_PEER_UPDATE_SOURCE);
if (src_unchanged)
return;
} else {
/* Otherwise remove flag and configuration from peer. */
peer_flag_unset(peer, PEER_FLAG_UPDATE_SOURCE);