]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: Inconsistencies in SNT counters with default-originate
authorIqra Siddiqui <imujeebsiddi@vmware.com>
Thu, 26 May 2022 06:45:57 +0000 (23:45 -0700)
committerARShreenidhi <rshreenidhi@vmware.com>
Wed, 6 Jul 2022 05:38:35 +0000 (05:38 +0000)
Description:
Change is intended for fixing the inconsistencies present
while adjusting the SNT counters with default originate.

- SNT counter gets incremented on every change of policy associated
  with default-originate, leading to inconsistencies.
- This fix has been added to ensure that the SNT counters gets
  incremented and decremented only once during the creation and
  deletion workflow of default-originate, and prevents
  incrementing the counter during update flow.

Co-authored-by: Abhinay Ramesh <rabhinay@vmware.com>
Signed-off-by: Iqra Siddiqui <imujeebsiddi@vmware.com>
bgpd/bgp_updgrp.h
bgpd/bgp_updgrp_packet.c

index e3309ab7c5c907bebabbe03c41aef468e8dfd524..473017c8098258167b5abe4e664bc2d2ea52f409 100644 (file)
@@ -252,6 +252,13 @@ struct update_subgroup {
 #define SUBGRP_STATUS_DEFAULT_ORIGINATE (1 << 0)
 #define SUBGRP_STATUS_FORCE_UPDATES (1 << 1)
 #define SUBGRP_STATUS_TABLE_REPARSING (1 << 2)
+/*
+ * This flag has been added to ensure that the SNT counters
+ * gets incremented and decremented only during the creation
+ * and deletion workflows of default originate,
+ * not during the update workflow.
+ */
+#define SUBGRP_STATUS_PEER_DEFAULT_ORIGINATED (1 << 3)
 
        uint16_t flags;
 #define SUBGRP_FLAG_NEEDS_REFRESH (1 << 0)
index c4a3ca75003d1a0ffc68ee7cf37be75aee227e80..88a81f255de86d0afbf982f1f606a8ebc6e9a7cb 100644 (file)
@@ -1142,7 +1142,12 @@ void subgroup_default_update_packet(struct update_subgroup *subgrp,
 
        (void)bpacket_queue_add(SUBGRP_PKTQ(subgrp), s, &vecarr);
        subgroup_trigger_write(subgrp);
-       subgrp->scount++;
+
+       if (!CHECK_FLAG(subgrp->sflags,
+                       SUBGRP_STATUS_PEER_DEFAULT_ORIGINATED)) {
+               subgrp->scount++;
+               SET_FLAG(subgrp->sflags, SUBGRP_STATUS_PEER_DEFAULT_ORIGINATED);
+       }
 }
 
 void subgroup_default_withdraw_packet(struct update_subgroup *subgrp)
@@ -1235,7 +1240,12 @@ void subgroup_default_withdraw_packet(struct update_subgroup *subgrp)
 
        (void)bpacket_queue_add(SUBGRP_PKTQ(subgrp), s, NULL);
        subgroup_trigger_write(subgrp);
-       subgrp->scount--;
+
+       if (CHECK_FLAG(subgrp->sflags, SUBGRP_STATUS_PEER_DEFAULT_ORIGINATED)) {
+               subgrp->scount--;
+               UNSET_FLAG(subgrp->sflags,
+                          SUBGRP_STATUS_PEER_DEFAULT_ORIGINATED);
+       }
 }
 
 static void