]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_updgrp.h
Merge pull request #3433 from opensourcerouting/init-6.0
[mirror_frr.git] / bgpd / bgp_updgrp.h
index 52a21679b895c40a9b398629a490fcaddb4b9e6a..c1cbca6dcfe87e75516be146ab03441caa50cba3 100644 (file)
 
 #include "bgp_advertise.h"
 
-#define BGP_DEFAULT_SUBGROUP_COALESCE_TIME 200
+/*
+ * The following three heuristic constants determine how long advertisement to
+ * a subgroup will be delayed after it is created. The intent is to allow
+ * transient changes in peer state (primarily session establishment) to settle,
+ * so that more peers can be grouped together and benefit from sharing
+ * advertisement computations with the subgroup.
+ *
+ * These values have a very large impact on initial convergence time; any
+ * changes should be accompanied by careful performance testing at all scales.
+ *
+ * The coalesce time 'C' for a new subgroup within a particular BGP instance
+ * 'B' with total number of known peers 'P', established or not, is computed as
+ * follows:
+ *
+ * C = MIN(BGP_MAX_SUBGROUP_COALESCE_TIME,
+ *         BGP_DEFAULT_SUBGROUP_COALESCE_TIME +
+ *         (P*BGP_PEER_ADJUST_SUBGROUP_COALESCE_TIME))
+ */
+#define BGP_DEFAULT_SUBGROUP_COALESCE_TIME 1000
+#define BGP_MAX_SUBGROUP_COALESCE_TIME 10000
+#define BGP_PEER_ADJUST_SUBGROUP_COALESCE_TIME 50
 
 #define PEER_UPDGRP_FLAGS                                                      \
        (PEER_FLAG_LOCAL_AS_NO_PREPEND | PEER_FLAG_LOCAL_AS_REPLACE_AS)
@@ -57,7 +77,7 @@
 typedef enum { BGP_ATTR_VEC_NH = 0, BGP_ATTR_VEC_MAX } bpacket_attr_vec_type;
 
 typedef struct {
-       u_int32_t flags;
+       uint32_t flags;
        unsigned long offset;
 } bpacket_attr_vec;
 
@@ -119,19 +139,19 @@ struct update_group {
        uint64_t id;
        time_t uptime;
 
-       u_int32_t join_events;
-       u_int32_t prune_events;
-       u_int32_t merge_events;
-       u_int32_t updgrp_switch_events;
-       u_int32_t peer_refreshes_combined;
-       u_int32_t adj_count;
-       u_int32_t split_events;
-       u_int32_t merge_checks_triggered;
+       uint32_t join_events;
+       uint32_t prune_events;
+       uint32_t merge_events;
+       uint32_t updgrp_switch_events;
+       uint32_t peer_refreshes_combined;
+       uint32_t adj_count;
+       uint32_t split_events;
+       uint32_t merge_checks_triggered;
 
-       u_int32_t subgrps_created;
-       u_int32_t subgrps_deleted;
+       uint32_t subgrps_created;
+       uint32_t subgrps_deleted;
 
-       u_int32_t num_dbg_en_peers;
+       uint32_t num_dbg_en_peers;
 };
 
 /*
@@ -179,7 +199,7 @@ struct update_subgroup {
        struct stream *work;
 
        /* We use a separate stream to encode MP_REACH_NLRI for efficient
-        * NLRI packing. peer->work stores all the other attributes. The
+        * NLRI packing. peer->obuf_work stores all the other attributes. The
         * actual packet is then constructed by concatenating the two.
         */
        struct stream *scratch;
@@ -194,7 +214,7 @@ struct update_subgroup {
        struct hash *hash;
 
        struct thread *t_coalesce;
-       u_int32_t v_coalesce;
+       uint32_t v_coalesce;
 
        struct thread *t_merge_check;
 
@@ -216,25 +236,25 @@ struct update_subgroup {
                uint64_t subgroup_id;
        } split_from;
 
-       u_int32_t join_events;
-       u_int32_t prune_events;
+       uint32_t join_events;
+       uint32_t prune_events;
 
        /*
         * This is bumped up when another subgroup merges into this one.
         */
-       u_int32_t merge_events;
-       u_int32_t updgrp_switch_events;
-       u_int32_t peer_refreshes_combined;
-       u_int32_t adj_count;
-       u_int32_t split_events;
-       u_int32_t merge_checks_triggered;
+       uint32_t merge_events;
+       uint32_t updgrp_switch_events;
+       uint32_t peer_refreshes_combined;
+       uint32_t adj_count;
+       uint32_t split_events;
+       uint32_t merge_checks_triggered;
 
        uint64_t id;
 
-       u_int16_t sflags;
+       uint16_t sflags;
 
        /* Subgroup flags, see below  */
-       u_int16_t flags;
+       uint16_t flags;
 };
 
 /*
@@ -267,7 +287,6 @@ struct update_subgroup {
  */
 #define SUBGRP_DECR_STAT(subgrp, stat) SUBGRP_INCR_STAT_BY(subgrp, stat, -1)
 
-
 typedef int (*updgrp_walkcb)(struct update_group *updgrp, void *ctx);
 
 /* really a private structure */
@@ -283,7 +302,7 @@ struct updwalk_context {
        int policy_route_update;
        updgrp_walkcb cb;
        void *context;
-       u_int8_t flags;
+       uint8_t flags;
 
 #define UPDWALK_FLAGS_ADVQUEUE   (1 << 0)
 #define UPDWALK_FLAGS_ADVERTISED (1 << 1)
@@ -321,23 +340,23 @@ struct updwalk_context {
  * Walk all subgroups in an update group.
  */
 #define UPDGRP_FOREACH_SUBGRP(updgrp, subgrp)                                  \
-       LIST_FOREACH(subgrp, &((updgrp)->subgrps), updgrp_train)
+       LIST_FOREACH (subgrp, &((updgrp)->subgrps), updgrp_train)
 
 #define UPDGRP_FOREACH_SUBGRP_SAFE(updgrp, subgrp, tmp_subgrp)                 \
-       LIST_FOREACH_SAFE(subgrp, &((updgrp)->subgrps), updgrp_train,          \
-                         tmp_subgrp)
+       LIST_FOREACH_SAFE (subgrp, &((updgrp)->subgrps), updgrp_train,         \
+                          tmp_subgrp)
 
 #define SUBGRP_FOREACH_PEER(subgrp, paf)                                       \
-       LIST_FOREACH(paf, &(subgrp->peers), subgrp_train)
+       LIST_FOREACH (paf, &(subgrp->peers), subgrp_train)
 
 #define SUBGRP_FOREACH_PEER_SAFE(subgrp, paf, temp_paf)                        \
-       LIST_FOREACH_SAFE(paf, &(subgrp->peers), subgrp_train, temp_paf)
+       LIST_FOREACH_SAFE (paf, &(subgrp->peers), subgrp_train, temp_paf)
 
 #define SUBGRP_FOREACH_ADJ(subgrp, adj)                                        \
-       TAILQ_FOREACH(adj, &(subgrp->adjq), subgrp_adj_train)
+       TAILQ_FOREACH (adj, &(subgrp->adjq), subgrp_adj_train)
 
 #define SUBGRP_FOREACH_ADJ_SAFE(subgrp, adj, adj_temp)                         \
-       TAILQ_FOREACH_SAFE(adj, &(subgrp->adjq), subgrp_adj_train, adj_temp)
+       TAILQ_FOREACH_SAFE (adj, &(subgrp->adjq), subgrp_adj_train, adj_temp)
 
 /* Prototypes.  */
 /* bgp_updgrp.c */
@@ -430,7 +449,7 @@ extern void update_group_announce_rrclients(struct bgp *bgp);
 extern void peer_af_announce_route(struct peer_af *paf, int combine);
 extern struct bgp_adj_out *bgp_adj_out_alloc(struct update_subgroup *subgrp,
                                             struct bgp_node *rn,
-                                            u_int32_t addpath_tx_id);
+                                            uint32_t addpath_tx_id);
 extern void bgp_adj_out_remove_subgroup(struct bgp_node *rn,
                                        struct bgp_adj_out *adj,
                                        struct update_subgroup *subgrp);
@@ -439,7 +458,7 @@ extern void bgp_adj_out_set_subgroup(struct bgp_node *rn,
                                     struct attr *attr, struct bgp_info *binfo);
 extern void bgp_adj_out_unset_subgroup(struct bgp_node *rn,
                                       struct update_subgroup *subgrp,
-                                      char withdraw, u_int32_t addpath_tx_id);
+                                      char withdraw, uint32_t addpath_tx_id);
 void subgroup_announce_table(struct update_subgroup *subgrp,
                             struct bgp_table *table);
 extern void subgroup_trigger_write(struct update_subgroup *subgrp);