]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: skip reset when removing dup update-source
authorTrey Aspelund <taspelund@nvidia.com>
Mon, 24 Jul 2023 20:16:08 +0000 (20:16 +0000)
committerTrey Aspelund <taspelund@nvidia.com>
Fri, 28 Jul 2023 16:34:55 +0000 (16:34 +0000)
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>
bgpd/bgpd.c

index 28c1a9da6bdc9283926e858ade6b4d0a8017cb7d..84890da8c1cc515d0a4c4c47b3d236a81276445d 100644 (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);