summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2018-07-30 14:50:47 +0200
committerDonald Sharp <sharpd@cumulusnetworks.com>2018-09-22 20:59:23 +0200
commitb1e62edd5ed63256db05af56dfc1394eea4e7b3a (patch)
tree712d8e70c84d9443c3ef6c912f20b1da42457150
parentMerge pull request #3021 from donaldsharp/more_upstream (diff)
downloadfrr-b1e62edd5ed63256db05af56dfc1394eea4e7b3a.tar.xz
frr-b1e62edd5ed63256db05af56dfc1394eea4e7b3a.zip
bgpd: Abstract aggregate retrieving/setting from info pointer
The aggregate data is stored as a void pointer in `struct bgp_node`. Abstract retrieval of this data and setting of this data into functions so that in the future we can move around what is stored in bgp_node. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
-rw-r--r--bgpd/bgp_route.c23
-rw-r--r--bgpd/bgp_table.h13
2 files changed, 26 insertions, 10 deletions
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 5c65d5e61..29c68dc6f 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -5769,13 +5769,14 @@ void bgp_aggregate_increment(struct bgp *bgp, struct prefix *p,
child = bgp_node_get(table, p);
/* Aggregate address configuration check. */
- for (rn = child; rn; rn = bgp_node_parent_nolock(rn))
- if ((aggregate = rn->info) != NULL
- && rn->p.prefixlen < p->prefixlen) {
+ for (rn = child; rn; rn = bgp_node_parent_nolock(rn)) {
+ aggregate = bgp_aggregate_get_node_info(rn);
+ if (aggregate != NULL && rn->p.prefixlen < p->prefixlen) {
bgp_aggregate_delete(bgp, &rn->p, afi, safi, aggregate);
bgp_aggregate_route(bgp, &rn->p, ri, afi, safi, NULL,
aggregate);
}
+ }
bgp_unlock_node(child);
}
@@ -5799,13 +5800,14 @@ void bgp_aggregate_decrement(struct bgp *bgp, struct prefix *p,
child = bgp_node_get(table, p);
/* Aggregate address configuration check. */
- for (rn = child; rn; rn = bgp_node_parent_nolock(rn))
- if ((aggregate = rn->info) != NULL
- && rn->p.prefixlen < p->prefixlen) {
+ for (rn = child; rn; rn = bgp_node_parent_nolock(rn)) {
+ aggregate = bgp_aggregate_get_node_info(rn);
+ if (aggregate != NULL && rn->p.prefixlen < p->prefixlen) {
bgp_aggregate_delete(bgp, &rn->p, afi, safi, aggregate);
bgp_aggregate_route(bgp, &rn->p, NULL, afi, safi, del,
aggregate);
}
+ }
bgp_unlock_node(child);
}
@@ -5838,12 +5840,12 @@ static int bgp_aggregate_unset(struct vty *vty, const char *prefix_str,
return CMD_WARNING_CONFIG_FAILED;
}
- aggregate = rn->info;
+ aggregate = bgp_aggregate_get_node_info(rn);
bgp_aggregate_delete(bgp, &p, afi, safi, aggregate);
bgp_aggregate_install(bgp, afi, safi, &p, 0, NULL, NULL, 0, aggregate);
/* Unlock aggregate address configuration. */
- rn->info = NULL;
+ bgp_aggregate_set_node_info(rn, NULL);
bgp_aggregate_free(aggregate);
bgp_unlock_node(rn);
bgp_unlock_node(rn);
@@ -5894,7 +5896,7 @@ static int bgp_aggregate_set(struct vty *vty, const char *prefix_str, afi_t afi,
aggregate->summary_only = summary_only;
aggregate->as_set = as_set;
aggregate->safi = safi;
- rn->info = aggregate;
+ bgp_aggregate_set_node_info(rn, aggregate);
/* Aggregate address insert into BGP routing table. */
bgp_aggregate_route(bgp, &p, NULL, afi, safi, NULL, aggregate);
@@ -11458,7 +11460,8 @@ void bgp_config_write_network(struct vty *vty, struct bgp *bgp, afi_t afi,
/* Aggregate-address configuration. */
for (rn = bgp_table_top(bgp->aggregate[afi][safi]); rn;
rn = bgp_route_next(rn)) {
- if ((bgp_aggregate = rn->info) == NULL)
+ bgp_aggregate = bgp_aggregate_get_node_info(rn);
+ if (bgp_aggregate == NULL)
continue;
p = &rn->p;
diff --git a/bgpd/bgp_table.h b/bgpd/bgp_table.h
index 60c2cbd4a..fc1942db5 100644
--- a/bgpd/bgp_table.h
+++ b/bgpd/bgp_table.h
@@ -313,4 +313,17 @@ static inline uint64_t bgp_table_version(struct bgp_table *table)
void bgp_table_range_lookup(const struct bgp_table *table, struct prefix *p,
uint8_t maxlen, struct list *matches);
+
+static inline struct bgp_aggregate *
+bgp_aggregate_get_node_info(struct bgp_node *node)
+{
+ return node->info;
+}
+
+static inline void bgp_aggregate_set_node_info(struct bgp_node *node,
+ struct bgp_aggregate *aggregate)
+{
+ node->info = aggregate;
+}
+
#endif /* _QUAGGA_BGP_TABLE_H */