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)) {
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);
}
}
}
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);
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);
}
}
{
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 */