summaryrefslogtreecommitdiffstats
path: root/bgpd/bgp_updgrp.h
diff options
context:
space:
mode:
Diffstat (limited to 'bgpd/bgp_updgrp.h')
-rw-r--r--bgpd/bgp_updgrp.h705
1 files changed, 331 insertions, 374 deletions
diff --git a/bgpd/bgp_updgrp.h b/bgpd/bgp_updgrp.h
index 8f3e27bc8..9eb7ab516 100644
--- a/bgpd/bgp_updgrp.h
+++ b/bgpd/bgp_updgrp.h
@@ -32,46 +32,34 @@
#define BGP_DEFAULT_SUBGROUP_COALESCE_TIME 200
-#define PEER_UPDGRP_FLAGS (PEER_FLAG_LOCAL_AS_NO_PREPEND | \
- PEER_FLAG_LOCAL_AS_REPLACE_AS)
-
-#define PEER_UPDGRP_AF_FLAGS (PEER_FLAG_SEND_COMMUNITY | \
- PEER_FLAG_SEND_EXT_COMMUNITY | \
- PEER_FLAG_DEFAULT_ORIGINATE | \
- PEER_FLAG_REFLECTOR_CLIENT | \
- PEER_FLAG_RSERVER_CLIENT | \
- PEER_FLAG_NEXTHOP_SELF | \
- PEER_FLAG_NEXTHOP_UNCHANGED | \
- PEER_FLAG_FORCE_NEXTHOP_SELF | \
- PEER_FLAG_AS_PATH_UNCHANGED | \
- PEER_FLAG_MED_UNCHANGED | \
- PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED | \
- PEER_FLAG_REMOVE_PRIVATE_AS | \
- PEER_FLAG_REMOVE_PRIVATE_AS_ALL | \
- PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE | \
- PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE | \
- PEER_FLAG_ADDPATH_TX_ALL_PATHS | \
- PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS | \
- PEER_FLAG_AS_OVERRIDE)
+#define PEER_UPDGRP_FLAGS \
+ (PEER_FLAG_LOCAL_AS_NO_PREPEND | PEER_FLAG_LOCAL_AS_REPLACE_AS)
+
+#define PEER_UPDGRP_AF_FLAGS \
+ (PEER_FLAG_SEND_COMMUNITY | PEER_FLAG_SEND_EXT_COMMUNITY \
+ | PEER_FLAG_DEFAULT_ORIGINATE | PEER_FLAG_REFLECTOR_CLIENT \
+ | PEER_FLAG_RSERVER_CLIENT | PEER_FLAG_NEXTHOP_SELF \
+ | PEER_FLAG_NEXTHOP_UNCHANGED | PEER_FLAG_FORCE_NEXTHOP_SELF \
+ | PEER_FLAG_AS_PATH_UNCHANGED | PEER_FLAG_MED_UNCHANGED \
+ | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED | PEER_FLAG_REMOVE_PRIVATE_AS \
+ | PEER_FLAG_REMOVE_PRIVATE_AS_ALL \
+ | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE \
+ | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE \
+ | PEER_FLAG_ADDPATH_TX_ALL_PATHS \
+ | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS | PEER_FLAG_AS_OVERRIDE)
#define PEER_UPDGRP_CAP_FLAGS (PEER_CAP_AS4_RCV)
-#define PEER_UPDGRP_AF_CAP_FLAGS (PEER_CAP_ORF_PREFIX_SM_RCV | \
- PEER_CAP_ORF_PREFIX_SM_OLD_RCV |\
- PEER_CAP_ADDPATH_AF_TX_ADV |\
- PEER_CAP_ADDPATH_AF_RX_RCV |\
- PEER_CAP_ENHE_AF_NEGO)
+#define PEER_UPDGRP_AF_CAP_FLAGS \
+ (PEER_CAP_ORF_PREFIX_SM_RCV | PEER_CAP_ORF_PREFIX_SM_OLD_RCV \
+ | PEER_CAP_ADDPATH_AF_TX_ADV | PEER_CAP_ADDPATH_AF_RX_RCV \
+ | PEER_CAP_ENHE_AF_NEGO)
-typedef enum
-{
- BGP_ATTR_VEC_NH = 0,
- BGP_ATTR_VEC_MAX
-} bpacket_attr_vec_type;
+typedef enum { BGP_ATTR_VEC_NH = 0, BGP_ATTR_VEC_MAX } bpacket_attr_vec_type;
-typedef struct
-{
- u_int32_t flags;
- unsigned long offset;
+typedef struct {
+ u_int32_t flags;
+ unsigned long offset;
} bpacket_attr_vec;
#define BPKT_ATTRVEC_FLAGS_UPDATED (1 << 0)
@@ -82,28 +70,25 @@ typedef struct
#define BPKT_ATTRVEC_FLAGS_RMAP_IPV6_GNH_CHANGED (1 << 5)
#define BPKT_ATTRVEC_FLAGS_RMAP_IPV6_LNH_CHANGED (1 << 6)
-typedef struct bpacket_attr_vec_arr
-{
- bpacket_attr_vec entries[BGP_ATTR_VEC_MAX];
+typedef struct bpacket_attr_vec_arr {
+ bpacket_attr_vec entries[BGP_ATTR_VEC_MAX];
} bpacket_attr_vec_arr;
-struct bpacket
-{
- /* for being part of an update subgroup's message list */
- TAILQ_ENTRY (bpacket) pkt_train;
+struct bpacket {
+ /* for being part of an update subgroup's message list */
+ TAILQ_ENTRY(bpacket) pkt_train;
- /* list of peers (well, peer_afs) that the packet needs to be sent to */
- LIST_HEAD (pkt_peer_list, peer_af) peers;
+ /* list of peers (well, peer_afs) that the packet needs to be sent to */
+ LIST_HEAD(pkt_peer_list, peer_af) peers;
- struct stream *buffer;
- bpacket_attr_vec_arr arr;
+ struct stream *buffer;
+ bpacket_attr_vec_arr arr;
- unsigned int ver;
+ unsigned int ver;
};
-struct bpacket_queue
-{
- TAILQ_HEAD (pkt_queue, bpacket) pkts;
+struct bpacket_queue {
+ TAILQ_HEAD(pkt_queue, bpacket) pkts;
#if 0
/* A dummy packet that is used to thread all peers that have
@@ -111,149 +96,146 @@ struct bpacket_queue
struct bpacket sentinel;
#endif
- unsigned int conf_max_count;
- unsigned int curr_count;
- unsigned int hwm_count;
- unsigned int max_count_reached_count;
+ unsigned int conf_max_count;
+ unsigned int curr_count;
+ unsigned int hwm_count;
+ unsigned int max_count_reached_count;
};
-struct update_group
-{
- /* back pointer to the BGP instance */
- struct bgp *bgp;
+struct update_group {
+ /* back pointer to the BGP instance */
+ struct bgp *bgp;
- /* list of subgroups that belong to the update group */
- LIST_HEAD (subgrp_list, update_subgroup) subgrps;
+ /* list of subgroups that belong to the update group */
+ LIST_HEAD(subgrp_list, update_subgroup) subgrps;
- /* lazy way to store configuration common to all peers
- hash function will compute from this data */
- struct peer *conf;
+ /* lazy way to store configuration common to all peers
+ hash function will compute from this data */
+ struct peer *conf;
- afi_t afi;
- safi_t safi;
- int afid;
+ afi_t afi;
+ safi_t safi;
+ int afid;
- uint64_t id;
- time_t uptime;
+ 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;
+ 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;
- u_int32_t subgrps_created;
- u_int32_t subgrps_deleted;
+ u_int32_t subgrps_created;
+ u_int32_t subgrps_deleted;
- u_int32_t num_dbg_en_peers;
+ u_int32_t num_dbg_en_peers;
};
/*
* Shorthand for a global statistics counter.
*/
-#define UPDGRP_GLOBAL_STAT(updgrp, stat) \
- ((updgrp)->bgp->update_group_stats.stat)
+#define UPDGRP_GLOBAL_STAT(updgrp, stat) \
+ ((updgrp)->bgp->update_group_stats.stat)
/*
* Add the given value to a counter on an update group and the bgp
* instance.
*/
-#define UPDGRP_INCR_STAT_BY(updgrp, stat, value) \
- do { \
- (updgrp)->stat += (value); \
- UPDGRP_GLOBAL_STAT(updgrp, stat) += (value); \
- } while (0)
+#define UPDGRP_INCR_STAT_BY(updgrp, stat, value) \
+ do { \
+ (updgrp)->stat += (value); \
+ UPDGRP_GLOBAL_STAT(updgrp, stat) += (value); \
+ } while (0)
/*
* Increment a counter on a update group and its parent structures.
*/
-#define UPDGRP_INCR_STAT(subgrp, stat) \
- UPDGRP_INCR_STAT_BY(subgrp, stat, 1)
+#define UPDGRP_INCR_STAT(subgrp, stat) UPDGRP_INCR_STAT_BY(subgrp, stat, 1)
-struct update_subgroup
-{
- /* back pointer to the parent update group */
- struct update_group *update_group;
+struct update_subgroup {
+ /* back pointer to the parent update group */
+ struct update_group *update_group;
- /* list of peers that belong to the subgroup */
- LIST_HEAD (peer_list, peer_af) peers;
- int peer_count;
+ /* list of peers that belong to the subgroup */
+ LIST_HEAD(peer_list, peer_af) peers;
+ int peer_count;
- /* for being part of an update group's subgroup list */
- LIST_ENTRY (update_subgroup) updgrp_train;
+ /* for being part of an update group's subgroup list */
+ LIST_ENTRY(update_subgroup) updgrp_train;
- struct bpacket_queue pkt_queue;
+ struct bpacket_queue pkt_queue;
- /*
- * List of adj-out structures for this subgroup.
- * It essentially represents the snapshot of every prefix that
- * has been advertised to the members of the subgroup
- */
- TAILQ_HEAD (adjout_queue, bgp_adj_out) adjq;
+ /*
+ * List of adj-out structures for this subgroup.
+ * It essentially represents the snapshot of every prefix that
+ * has been advertised to the members of the subgroup
+ */
+ TAILQ_HEAD(adjout_queue, bgp_adj_out) adjq;
- /* packet buffer for update generation */
- struct stream *work;
+ /* packet buffer for update generation */
+ 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
- * actual packet is then constructed by concatenating the two.
- */
- struct stream *scratch;
+ /* We use a separate stream to encode MP_REACH_NLRI for efficient
+ * NLRI packing. peer->work stores all the other attributes. The
+ * actual packet is then constructed by concatenating the two.
+ */
+ struct stream *scratch;
- /* synchronization list and time */
- struct bgp_synchronize *sync;
+ /* synchronization list and time */
+ struct bgp_synchronize *sync;
- /* send prefix count */
- unsigned long scount;
+ /* send prefix count */
+ unsigned long scount;
- /* announcement attribute hash */
- struct hash *hash;
+ /* announcement attribute hash */
+ struct hash *hash;
- struct thread *t_coalesce;
- u_int32_t v_coalesce;
+ struct thread *t_coalesce;
+ u_int32_t v_coalesce;
- struct thread *t_merge_check;
+ struct thread *t_merge_check;
- /* table version that the subgroup has caught up to. */
- uint64_t version;
+ /* table version that the subgroup has caught up to. */
+ uint64_t version;
- /* version maintained to record adj changes */
- uint64_t adj_version;
+ /* version maintained to record adj changes */
+ uint64_t adj_version;
- time_t uptime;
+ time_t uptime;
- /*
- * Identifying information about the subgroup that this subgroup was split
- * from, if any.
- */
- struct
- {
- uint64_t update_group_id;
- uint64_t subgroup_id;
- } split_from;
+ /*
+ * Identifying information about the subgroup that this subgroup was
+ * split
+ * from, if any.
+ */
+ struct {
+ uint64_t update_group_id;
+ uint64_t subgroup_id;
+ } split_from;
- u_int32_t join_events;
- u_int32_t prune_events;
+ u_int32_t join_events;
+ u_int32_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;
+ /*
+ * 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;
- uint64_t id;
+ uint64_t id;
- u_int16_t sflags;
+ u_int16_t sflags;
- /* Subgroup flags, see below */
- u_int16_t flags;
+ /* Subgroup flags, see below */
+ u_int16_t flags;
};
/*
@@ -268,43 +250,41 @@ struct update_subgroup
* Add the given value to the specified counter on a subgroup and its
* parent structures.
*/
-#define SUBGRP_INCR_STAT_BY(subgrp, stat, value) \
- do { \
- (subgrp)->stat += (value); \
- if ((subgrp)->update_group) \
- UPDGRP_INCR_STAT_BY((subgrp)->update_group, stat, value); \
- } while (0)
+#define SUBGRP_INCR_STAT_BY(subgrp, stat, value) \
+ do { \
+ (subgrp)->stat += (value); \
+ if ((subgrp)->update_group) \
+ UPDGRP_INCR_STAT_BY((subgrp)->update_group, stat, \
+ value); \
+ } while (0)
/*
* Increment a counter on a subgroup and its parent structures.
*/
-#define SUBGRP_INCR_STAT(subgrp, stat) \
- SUBGRP_INCR_STAT_BY(subgrp, stat, 1)
+#define SUBGRP_INCR_STAT(subgrp, stat) SUBGRP_INCR_STAT_BY(subgrp, stat, 1)
/*
* Decrement a counter on a subgroup and its parent structures.
*/
-#define SUBGRP_DECR_STAT(subgrp, stat) \
- SUBGRP_INCR_STAT_BY(subgrp, stat, -1)
+#define SUBGRP_DECR_STAT(subgrp, stat) SUBGRP_INCR_STAT_BY(subgrp, stat, -1)
-typedef int (*updgrp_walkcb) (struct update_group * updgrp, void *ctx);
+typedef int (*updgrp_walkcb)(struct update_group *updgrp, void *ctx);
/* really a private structure */
-struct updwalk_context
-{
- struct vty *vty;
- struct bgp_node *rn;
- struct bgp_info *ri;
- uint64_t updgrp_id;
- uint64_t subgrp_id;
- bgp_policy_type_e policy_type;
- const char *policy_name;
- int policy_event_start_flag;
- int policy_route_update;
- updgrp_walkcb cb;
- void *context;
- u_int8_t flags;
+struct updwalk_context {
+ struct vty *vty;
+ struct bgp_node *rn;
+ struct bgp_info *ri;
+ uint64_t updgrp_id;
+ uint64_t subgrp_id;
+ bgp_policy_type_e policy_type;
+ const char *policy_name;
+ int policy_event_start_flag;
+ int policy_route_update;
+ updgrp_walkcb cb;
+ void *context;
+ u_int8_t flags;
#define UPDWALK_FLAGS_ADVQUEUE (1 << 0)
#define UPDWALK_FLAGS_ADVERTISED (1 << 1)
@@ -322,8 +302,7 @@ struct updwalk_context
#define UPDGRP_AFI(u) ((u)->afi)
#define UPDGRP_SAFI(u) ((u)->safi)
#define UPDGRP_INST(u) ((u)->bgp)
-#define UPDGRP_AFFLAGS(u) \
- ((u)->conf->af_flags[UPDGRP_AFI(u)][UPDGRP_SAFI(u)])
+#define UPDGRP_AFFLAGS(u) ((u)->conf->af_flags[UPDGRP_AFI(u)][UPDGRP_SAFI(u)])
#define UPDGRP_DBG_ON(u) ((u)->num_dbg_en_peers)
#define UPDGRP_PEER_DBG_EN(u) (((u)->num_dbg_en_peers)++)
#define UPDGRP_PEER_DBG_DIS(u) (((u)->num_dbg_en_peers)--)
@@ -342,149 +321,137 @@ struct updwalk_context
/*
* Walk all subgroups in an update group.
*/
-#define UPDGRP_FOREACH_SUBGRP(updgrp, subgrp) \
- LIST_FOREACH(subgrp, &((updgrp)->subgrps), updgrp_train)
+#define UPDGRP_FOREACH_SUBGRP(updgrp, subgrp) \
+ 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)
+#define UPDGRP_FOREACH_SUBGRP_SAFE(updgrp, subgrp, 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)
+#define SUBGRP_FOREACH_PEER(subgrp, paf) \
+ 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)
+#define SUBGRP_FOREACH_PEER_SAFE(subgrp, paf, 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)
+#define SUBGRP_FOREACH_ADJ(subgrp, adj) \
+ 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)
+#define SUBGRP_FOREACH_ADJ_SAFE(subgrp, adj, adj_temp) \
+ TAILQ_FOREACH_SAFE(adj, &(subgrp->adjq), subgrp_adj_train, adj_temp)
/* Prototypes. */
/* bgp_updgrp.c */
-extern void update_bgp_group_init (struct bgp *);
-extern void udpate_bgp_group_free (struct bgp *);
-
-extern void
-update_group_show (struct bgp *bgp, afi_t afi, safi_t safi, struct vty *vty, uint64_t subgrp_id);
-extern void update_group_show_stats (struct bgp *bgp, struct vty *vty);
-extern void update_group_adjust_peer (struct peer_af *paf);
-extern int update_group_adjust_soloness (struct peer *peer, int set);
-
-extern void
-update_subgroup_remove_peer (struct update_subgroup *, struct peer_af *);
-extern struct bgp_table *update_subgroup_rib (struct update_subgroup *);
-extern void
-update_subgroup_split_peer (struct peer_af *, struct update_group *);
-extern int
-update_subgroup_check_merge (struct update_subgroup *, const char *);
+extern void update_bgp_group_init(struct bgp *);
+extern void udpate_bgp_group_free(struct bgp *);
+
+extern void update_group_show(struct bgp *bgp, afi_t afi, safi_t safi,
+ struct vty *vty, uint64_t subgrp_id);
+extern void update_group_show_stats(struct bgp *bgp, struct vty *vty);
+extern void update_group_adjust_peer(struct peer_af *paf);
+extern int update_group_adjust_soloness(struct peer *peer, int set);
+
+extern void update_subgroup_remove_peer(struct update_subgroup *,
+ struct peer_af *);
+extern struct bgp_table *update_subgroup_rib(struct update_subgroup *);
+extern void update_subgroup_split_peer(struct peer_af *, struct update_group *);
+extern int update_subgroup_check_merge(struct update_subgroup *, const char *);
+extern int update_subgroup_trigger_merge_check(struct update_subgroup *,
+ int force);
+extern void update_group_policy_update(struct bgp *bgp, bgp_policy_type_e ptype,
+ const char *pname, int route_update,
+ int start_event);
+extern void update_group_af_walk(struct bgp *bgp, afi_t afi, safi_t safi,
+ updgrp_walkcb cb, void *ctx);
+extern void update_group_walk(struct bgp *bgp, updgrp_walkcb cb, void *ctx);
+extern void update_group_periodic_merge(struct bgp *bgp);
extern int
-update_subgroup_trigger_merge_check (struct update_subgroup *,
- int force);
-extern void update_group_policy_update (struct bgp *bgp,
- bgp_policy_type_e ptype, const char *pname,
- int route_update, int start_event);
-extern void update_group_af_walk (struct bgp *bgp, afi_t afi, safi_t safi,
- updgrp_walkcb cb, void *ctx);
-extern void update_group_walk (struct bgp *bgp, updgrp_walkcb cb, void *ctx);
-extern void update_group_periodic_merge (struct bgp *bgp);
-extern int update_group_refresh_default_originate_route_map (struct thread *thread);
-extern void update_group_start_advtimer (struct bgp *bgp);
-
-extern void update_subgroup_inherit_info (struct update_subgroup *to,
- struct update_subgroup *from);
+update_group_refresh_default_originate_route_map(struct thread *thread);
+extern void update_group_start_advtimer(struct bgp *bgp);
+
+extern void update_subgroup_inherit_info(struct update_subgroup *to,
+ struct update_subgroup *from);
/* bgp_updgrp_packet.c */
-extern struct bpacket *bpacket_alloc (void);
-extern void bpacket_free (struct bpacket *pkt);
-extern void bpacket_queue_init (struct bpacket_queue *q);
-extern void bpacket_queue_cleanup (struct bpacket_queue *q);
-extern void bpacket_queue_sanity_check (struct bpacket_queue *q);
-extern struct bpacket *bpacket_queue_add (struct bpacket_queue *q,
- struct stream *s,
- struct bpacket_attr_vec_arr
- *vecarr);
-struct bpacket *bpacket_queue_remove (struct bpacket_queue *q);
-extern struct bpacket *bpacket_queue_first (struct bpacket_queue *q);
-struct bpacket *bpacket_queue_last (struct bpacket_queue *q);
-unsigned int bpacket_queue_length (struct bpacket_queue *q);
-unsigned int bpacket_queue_hwm_length (struct bpacket_queue *q);
-int bpacket_queue_is_full (struct bgp *bgp, struct bpacket_queue *q);
-extern void bpacket_queue_advance_peer (struct peer_af *paf);
-extern void bpacket_queue_remove_peer (struct peer_af *paf);
-extern void bpacket_add_peer (struct bpacket *pkt, struct peer_af *paf);
-unsigned int bpacket_queue_virtual_length (struct peer_af *paf);
-extern void bpacket_queue_show_vty (struct bpacket_queue *q, struct vty *vty);
-int subgroup_packets_to_build (struct update_subgroup *subgrp);
-extern struct bpacket *subgroup_update_packet (struct update_subgroup *s);
-extern struct bpacket *subgroup_withdraw_packet (struct update_subgroup *s);
-extern struct stream *bpacket_reformat_for_peer (struct bpacket *pkt,
- struct peer_af *paf);
-extern void bpacket_attr_vec_arr_reset (struct bpacket_attr_vec_arr *vecarr);
-extern void bpacket_attr_vec_arr_set_vec (struct bpacket_attr_vec_arr *vecarr,
- bpacket_attr_vec_type type,
- struct stream *s,
- struct attr *attr);
-extern void
-subgroup_default_update_packet (struct update_subgroup *subgrp,
- struct attr *attr, struct peer *from);
-extern void subgroup_default_withdraw_packet (struct update_subgroup *subgrp);
+extern struct bpacket *bpacket_alloc(void);
+extern void bpacket_free(struct bpacket *pkt);
+extern void bpacket_queue_init(struct bpacket_queue *q);
+extern void bpacket_queue_cleanup(struct bpacket_queue *q);
+extern void bpacket_queue_sanity_check(struct bpacket_queue *q);
+extern struct bpacket *bpacket_queue_add(struct bpacket_queue *q,
+ struct stream *s,
+ struct bpacket_attr_vec_arr *vecarr);
+struct bpacket *bpacket_queue_remove(struct bpacket_queue *q);
+extern struct bpacket *bpacket_queue_first(struct bpacket_queue *q);
+struct bpacket *bpacket_queue_last(struct bpacket_queue *q);
+unsigned int bpacket_queue_length(struct bpacket_queue *q);
+unsigned int bpacket_queue_hwm_length(struct bpacket_queue *q);
+int bpacket_queue_is_full(struct bgp *bgp, struct bpacket_queue *q);
+extern void bpacket_queue_advance_peer(struct peer_af *paf);
+extern void bpacket_queue_remove_peer(struct peer_af *paf);
+extern void bpacket_add_peer(struct bpacket *pkt, struct peer_af *paf);
+unsigned int bpacket_queue_virtual_length(struct peer_af *paf);
+extern void bpacket_queue_show_vty(struct bpacket_queue *q, struct vty *vty);
+int subgroup_packets_to_build(struct update_subgroup *subgrp);
+extern struct bpacket *subgroup_update_packet(struct update_subgroup *s);
+extern struct bpacket *subgroup_withdraw_packet(struct update_subgroup *s);
+extern struct stream *bpacket_reformat_for_peer(struct bpacket *pkt,
+ struct peer_af *paf);
+extern void bpacket_attr_vec_arr_reset(struct bpacket_attr_vec_arr *vecarr);
+extern void bpacket_attr_vec_arr_set_vec(struct bpacket_attr_vec_arr *vecarr,
+ bpacket_attr_vec_type type,
+ struct stream *s, struct attr *attr);
+extern void subgroup_default_update_packet(struct update_subgroup *subgrp,
+ struct attr *attr,
+ struct peer *from);
+extern void subgroup_default_withdraw_packet(struct update_subgroup *subgrp);
/* bgp_updgrp_adv.c */
-extern struct bgp_advertise *bgp_advertise_clean_subgroup (struct
- update_subgroup
- *subgrp,
- struct bgp_adj_out
- *adj);
-extern void update_group_show_adj_queue (struct bgp *bgp, afi_t afi,
+extern struct bgp_advertise *
+bgp_advertise_clean_subgroup(struct update_subgroup *subgrp,
+ struct bgp_adj_out *adj);
+extern void update_group_show_adj_queue(struct bgp *bgp, afi_t afi, safi_t safi,
+ struct vty *vty, uint64_t id);
+extern void update_group_show_advertised(struct bgp *bgp, afi_t afi,
safi_t safi, struct vty *vty,
uint64_t id);
-extern void update_group_show_advertised (struct bgp *bgp, afi_t afi,
- safi_t safi, struct vty *vty,
- uint64_t id);
-extern void update_group_show_packet_queue (struct bgp *bgp, afi_t afi,
- safi_t safi, struct vty *vty,
- uint64_t id);
-extern void subgroup_announce_route (struct update_subgroup *subgrp);
-extern void subgroup_announce_all (struct update_subgroup *subgrp);
-
-extern void
-subgroup_default_originate (struct update_subgroup *subgrp, int withdraw);
-extern void
-group_announce_route (struct bgp *bgp, afi_t afi, safi_t safi,
- struct bgp_node *rn, struct bgp_info *ri);
-extern void subgroup_clear_table (struct update_subgroup *subgrp);
-extern void update_group_announce (struct bgp *bgp);
-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);
-extern void bgp_adj_out_remove_subgroup (struct bgp_node *rn,
- struct bgp_adj_out *adj,
- struct update_subgroup *subgrp);
-extern void
-bgp_adj_out_set_subgroup (struct bgp_node *rn,
- struct update_subgroup *subgrp,
- 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);
-void
-subgroup_announce_table (struct update_subgroup *subgrp,
- struct bgp_table *table);
-extern void
-subgroup_trigger_write (struct update_subgroup *subgrp);
-
-extern int
-update_group_clear_update_dbg (struct update_group *updgrp, void *arg);
+extern void update_group_show_packet_queue(struct bgp *bgp, afi_t afi,
+ safi_t safi, struct vty *vty,
+ uint64_t id);
+extern void subgroup_announce_route(struct update_subgroup *subgrp);
+extern void subgroup_announce_all(struct update_subgroup *subgrp);
+
+extern void subgroup_default_originate(struct update_subgroup *subgrp,
+ int withdraw);
+extern void group_announce_route(struct bgp *bgp, afi_t afi, safi_t safi,
+ struct bgp_node *rn, struct bgp_info *ri);
+extern void subgroup_clear_table(struct update_subgroup *subgrp);
+extern void update_group_announce(struct bgp *bgp);
+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);
+extern void bgp_adj_out_remove_subgroup(struct bgp_node *rn,
+ struct bgp_adj_out *adj,
+ struct update_subgroup *subgrp);
+extern void bgp_adj_out_set_subgroup(struct bgp_node *rn,
+ struct update_subgroup *subgrp,
+ 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);
+void subgroup_announce_table(struct update_subgroup *subgrp,
+ struct bgp_table *table);
+extern void subgroup_trigger_write(struct update_subgroup *subgrp);
+
+extern int update_group_clear_update_dbg(struct update_group *updgrp,
+ void *arg);
extern void update_bgp_group_free(struct bgp *bgp);
-extern int bgp_addpath_encode_tx (struct peer *peer, afi_t afi, safi_t safi);
-extern int bgp_addpath_tx_path (struct peer *peer, afi_t afi, safi_t safi,
- struct bgp_info *ri);
+extern int bgp_addpath_encode_tx(struct peer *peer, afi_t afi, safi_t safi);
+extern int bgp_addpath_tx_path(struct peer *peer, afi_t afi, safi_t safi,
+ struct bgp_info *ri);
/*
* Inline functions
@@ -493,18 +460,17 @@ extern int bgp_addpath_tx_path (struct peer *peer, afi_t afi, safi_t safi,
/*
* bpacket_queue_is_empty
*/
-static inline int
-bpacket_queue_is_empty (struct bpacket_queue *queue)
+static inline int bpacket_queue_is_empty(struct bpacket_queue *queue)
{
- /*
- * The packet queue is empty if it only contains a sentinel.
- */
- if (queue->curr_count != 1)
- return 0;
+ /*
+ * The packet queue is empty if it only contains a sentinel.
+ */
+ if (queue->curr_count != 1)
+ return 0;
- assert (bpacket_queue_first (queue)->buffer == NULL);
- return 1;
+ assert(bpacket_queue_first(queue)->buffer == NULL);
+ return 1;
}
/*
@@ -512,10 +478,9 @@ bpacket_queue_is_empty (struct bpacket_queue *queue)
*
* Returns the packet after the given packet in a bpacket queue.
*/
-static inline struct bpacket *
-bpacket_next (struct bpacket *pkt)
+static inline struct bpacket *bpacket_next(struct bpacket *pkt)
{
- return TAILQ_NEXT (pkt, pkt_train);
+ return TAILQ_NEXT(pkt, pkt_train);
}
/*
@@ -523,18 +488,16 @@ bpacket_next (struct bpacket *pkt)
*
* Adjust all peer_af structures for the given peer.
*/
-static inline void
-update_group_adjust_peer_afs (struct peer *peer)
+static inline void update_group_adjust_peer_afs(struct peer *peer)
{
- struct peer_af *paf;
- int afidx;
-
- for (afidx = BGP_AF_START; afidx < BGP_AF_MAX; afidx++)
- {
- paf = peer->peer_af_array[afidx];
- if (paf != NULL)
- update_group_adjust_peer (paf);
- }
+ struct peer_af *paf;
+ int afidx;
+
+ for (afidx = BGP_AF_START; afidx < BGP_AF_MAX; afidx++) {
+ paf = peer->peer_af_array[afidx];
+ if (paf != NULL)
+ update_group_adjust_peer(paf);
+ }
}
/*
@@ -542,53 +505,51 @@ update_group_adjust_peer_afs (struct peer *peer)
*
* Remove all peer_af structures for the given peer from their subgroups.
*/
-static inline void
-update_group_remove_peer_afs (struct peer *peer)
+static inline void update_group_remove_peer_afs(struct peer *peer)
{
- struct peer_af *paf;
- int afidx;
-
- for (afidx = BGP_AF_START; afidx < BGP_AF_MAX; afidx++)
- {
- paf = peer->peer_af_array[afidx];
- if (paf != NULL)
- update_subgroup_remove_peer (PAF_SUBGRP (paf), paf);
- }
+ struct peer_af *paf;
+ int afidx;
+
+ for (afidx = BGP_AF_START; afidx < BGP_AF_MAX; afidx++) {
+ paf = peer->peer_af_array[afidx];
+ if (paf != NULL)
+ update_subgroup_remove_peer(PAF_SUBGRP(paf), paf);
+ }
}
/*
* update_subgroup_needs_refresh
*/
static inline int
-update_subgroup_needs_refresh (const struct update_subgroup *subgrp)
+update_subgroup_needs_refresh(const struct update_subgroup *subgrp)
{
- if (CHECK_FLAG (subgrp->flags, SUBGRP_FLAG_NEEDS_REFRESH))
- return 1;
- else
- return 0;
+ if (CHECK_FLAG(subgrp->flags, SUBGRP_FLAG_NEEDS_REFRESH))
+ return 1;
+ else
+ return 0;
}
/*
* update_subgroup_set_needs_refresh
*/
static inline void
-update_subgroup_set_needs_refresh (struct update_subgroup *subgrp, int value)
+update_subgroup_set_needs_refresh(struct update_subgroup *subgrp, int value)
{
- if (value)
- SET_FLAG (subgrp->flags, SUBGRP_FLAG_NEEDS_REFRESH);
- else
- UNSET_FLAG (subgrp->flags, SUBGRP_FLAG_NEEDS_REFRESH);
+ if (value)
+ SET_FLAG(subgrp->flags, SUBGRP_FLAG_NEEDS_REFRESH);
+ else
+ UNSET_FLAG(subgrp->flags, SUBGRP_FLAG_NEEDS_REFRESH);
}
-static inline struct update_subgroup *
-peer_subgroup (struct peer *peer, afi_t afi, safi_t safi)
+static inline struct update_subgroup *peer_subgroup(struct peer *peer,
+ afi_t afi, safi_t safi)
{
- struct peer_af *paf;
+ struct peer_af *paf;
- paf = peer_af_find (peer, afi, safi);
- if (paf)
- return PAF_SUBGRP (paf);
- return NULL;
+ paf = peer_af_find(peer, afi, safi);
+ if (paf)
+ return PAF_SUBGRP(paf);
+ return NULL;
}
/*
@@ -596,34 +557,30 @@ peer_subgroup (struct peer *peer, afi_t afi, safi_t safi)
*
* Adjust all peer_af structures for the given peer.
*/
-static inline void
-bgp_announce_peer (struct peer *peer)
+static inline void bgp_announce_peer(struct peer *peer)
{
- struct peer_af *paf;
- int afidx;
-
- for (afidx = BGP_AF_START; afidx < BGP_AF_MAX; afidx++)
- {
- paf = peer->peer_af_array[afidx];
- if (paf != NULL)
- subgroup_announce_all (PAF_SUBGRP (paf));
- }
+ struct peer_af *paf;
+ int afidx;
+
+ for (afidx = BGP_AF_START; afidx < BGP_AF_MAX; afidx++) {
+ paf = peer->peer_af_array[afidx];
+ if (paf != NULL)
+ subgroup_announce_all(PAF_SUBGRP(paf));
+ }
}
/**
* advertise_list_is_empty
*/
-static inline int
-advertise_list_is_empty (struct update_subgroup *subgrp)
+static inline int advertise_list_is_empty(struct update_subgroup *subgrp)
{
- if (!BGP_ADV_FIFO_EMPTY (&subgrp->sync->update) ||
- !BGP_ADV_FIFO_EMPTY (&subgrp->sync->withdraw) ||
- !BGP_ADV_FIFO_EMPTY (&subgrp->sync->withdraw_low))
- {
- return 0;
- }
-
- return 1;
+ if (!BGP_ADV_FIFO_EMPTY(&subgrp->sync->update)
+ || !BGP_ADV_FIFO_EMPTY(&subgrp->sync->withdraw)
+ || !BGP_ADV_FIFO_EMPTY(&subgrp->sync->withdraw_low)) {
+ return 0;
+ }
+
+ return 1;
}
#endif /* _QUAGGA_BGP_UPDGRP_H */