]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Abstract bgp_connected_ref retrieving/setting from info pointer
authorDonald Sharp <sharpd@cumulusnetworks.com>
Mon, 30 Jul 2018 14:46:00 +0000 (10:46 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Sat, 22 Sep 2018 18:59:23 +0000 (14:59 -0400)
The bgp_connected_ref 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>
bgpd/bgp_nexthop.c
bgpd/bgp_table.h

index 76bfa73feeb143f559e25f4eac79aff61c3be40a..e092313d7dd86e68979b2df2eda0fec851b32c0e 100644 (file)
@@ -278,14 +278,14 @@ void bgp_connected_add(struct bgp *bgp, struct connected *ifc)
 
                rn = bgp_node_get(bgp->connected_table[AFI_IP],
                                  (struct prefix *)&p);
-               if (rn->info) {
-                       bc = rn->info;
+               bc = bgp_connected_get_node_info(rn);
+               if (bc)
                        bc->refcnt++;
-               else {
+               else {
                        bc = XCALLOC(MTYPE_BGP_CONN,
                                     sizeof(struct bgp_connected_ref));
                        bc->refcnt = 1;
-                       rn->info = bc;
+                       bgp_connected_set_node_info(rn, bc);
                }
 
                for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) {
@@ -310,14 +310,15 @@ void bgp_connected_add(struct bgp *bgp, struct connected *ifc)
 
                rn = bgp_node_get(bgp->connected_table[AFI_IP6],
                                  (struct prefix *)&p);
-               if (rn->info) {
-                       bc = rn->info;
+
+               bc = bgp_connected_get_node_info(rn);
+               if (bc)
                        bc->refcnt++;
-               else {
+               else {
                        bc = XCALLOC(MTYPE_BGP_CONN,
                                     sizeof(struct bgp_connected_ref));
                        bc->refcnt = 1;
-                       rn->info = bc;
+                       bgp_connected_set_node_info(rn, bc);
                }
        }
 }
@@ -354,11 +355,11 @@ void bgp_connected_delete(struct bgp *bgp, struct connected *ifc)
        if (!rn)
                return;
 
-       bc = rn->info;
+       bc = bgp_connected_get_node_info(rn);
        bc->refcnt--;
        if (bc->refcnt == 0) {
                XFREE(MTYPE_BGP_CONN, bc);
-               rn->info = NULL;
+               bgp_connected_set_node_info(rn, NULL);
        }
        bgp_unlock_node(rn);
        bgp_unlock_node(rn);
@@ -368,15 +369,16 @@ static void bgp_connected_cleanup(struct route_table *table,
                                  struct route_node *rn)
 {
        struct bgp_connected_ref *bc;
+       struct bgp_node *bn = bgp_node_from_rnode(rn);
 
-       bc = rn->info;
+       bc = bgp_connected_get_node_info(bn);
        if (!bc)
                return;
 
        bc->refcnt--;
        if (bc->refcnt == 0) {
                XFREE(MTYPE_BGP_CONN, bc);
-               rn->info = NULL;
+               bgp_connected_set_node_info(bn, NULL);
        }
 }
 
index e7206cf4e8bb62f1d1c3853cce6b7be2b4ec1b08..f60265b51b6205cc08adf84c8115598cf7385605 100644 (file)
@@ -347,4 +347,17 @@ static inline void bgp_static_set_node_info(struct bgp_node *node,
 {
        node->info = bgp_static;
 }
+
+static inline struct bgp_connected_ref *
+bgp_connected_get_node_info(struct bgp_node *node)
+{
+       return node->info;
+}
+
+static inline void bgp_connected_set_node_info(struct bgp_node *node,
+                                              struct bgp_connected_ref *bc)
+{
+       node->info = bc;
+}
+
 #endif /* _QUAGGA_BGP_TABLE_H */