]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: apply cond-adv policy to update group
authorQuentin Young <qlyoung@nvidia.com>
Tue, 15 Jun 2021 23:49:19 +0000 (19:49 -0400)
committerMark Stapp <mstapp@nvidia.com>
Thu, 11 Aug 2022 14:58:17 +0000 (10:58 -0400)
The new outbound filter to apply conditional advertisement policy was
not working properly due to complications with update groups. The two
routemaps were properly copied into the update group peer filter but not
the conditional advertisement state.

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
Signed-off-by: Mark Stapp <mstapp@nvidia.com>
bgpd/bgp_conditional_adv.c
bgpd/bgp_updgrp.c

index 9c2826fa13d7de2b354ac6e4d5e4566b1005d783..fc44e86cbc479c359cf4300a648bdceabbaf9c4b 100644 (file)
@@ -258,6 +258,25 @@ static void bgp_conditional_adv_timer(struct thread *t)
                                                ? UPDATE_TYPE_WITHDRAW
                                                : UPDATE_TYPE_ADVERTISE;
 
+                       /*
+                        * Update condadv update type so
+                        * subgroup_announce_check() can properly apply
+                        * outbound policy according to advertisement state
+                        */
+                       paf = peer_af_find(peer, afi, safi);
+                       if (paf && (SUBGRP_PEER(PAF_SUBGRP(paf))
+                                           ->filter[afi][safi]
+                                           .advmap.update_type !=
+                                   filter->advmap.update_type)) {
+                               /* Handle change to peer advmap */
+                               if (BGP_DEBUG(update, UPDATE_OUT))
+                                       zlog_debug(
+                                               "%s: advmap.update_type changed for peer %s, adjusting update_group.",
+                                               __func__, peer->host);
+
+                               update_group_adjust_peer(paf);
+                       }
+
                        /* Send regular update as per the existing policy.
                         * There is a change in route-map, match-rule, ACLs,
                         * or route-map filter configuration on the same peer.
@@ -270,11 +289,10 @@ static void bgp_conditional_adv_timer(struct thread *t)
                                                __func__, peer->host,
                                                get_afi_safi_str(afi, safi,
                                                                 false));
-
-                               paf = peer_af_find(peer, afi, safi);
                                if (paf) {
                                        update_subgroup_split_peer(paf, NULL);
                                        subgrp = paf->subgroup;
+
                                        if (subgrp && subgrp->update_group)
                                                subgroup_announce_table(
                                                        paf->subgroup, NULL);
index 13d5ec6b863e8a001554a3112663697e62d1a93d..f1173941a0fd369c37fb1ea23c08367ce67feb6e 100644 (file)
@@ -218,6 +218,8 @@ static void conf_copy(struct peer *dst, struct peer *src, afi_t afi,
                        MTYPE_BGP_FILTER_NAME, CONDITION_MAP_NAME(srcfilter));
                CONDITION_MAP(dstfilter) = CONDITION_MAP(srcfilter);
        }
+
+       dstfilter->advmap.update_type = srcfilter->advmap.update_type;
 }
 
 /**
@@ -389,6 +391,9 @@ static unsigned int updgrp_hash_key_make(const void *p)
                                        strlen(filter->advmap.aname), SEED1),
                                  key);
 
+       if (filter->advmap.update_type)
+               key = jhash_1word(filter->advmap.update_type, key);
+
        if (peer->default_rmap[afi][safi].name)
                key = jhash_1word(
                        jhash(peer->default_rmap[afi][safi].name,
@@ -588,6 +593,9 @@ static bool updgrp_hash_cmp(const void *p1, const void *p2)
                && strcmp(fl1->advmap.aname, fl2->advmap.aname)))
                return false;
 
+       if (fl1->advmap.update_type != fl2->advmap.update_type)
+               return false;
+
        if ((pe1->default_rmap[afi][safi].name
             && !pe2->default_rmap[afi][safi].name)
            || (!pe1->default_rmap[afi][safi].name