/* all unlocked in bgp_processq_del */
bgp_table_lock(bgp_node_table(rn));
pqnode->rn = bgp_lock_node(rn);
- pqnode->bgp = bgp;
- bgp_lock(bgp);
+ pqnode->bgp = bgp_lock(bgp);
pqnode->afi = afi;
pqnode->safi = safi;
work_queue_add(bm->process_main_queue, pqnode);
peer->status = Idle;
peer->ostatus = Idle;
peer->cur_event = peer->last_event = peer->last_major_event = 0;
- peer->bgp = bgp;
+ peer->bgp = bgp_lock(bgp);
peer = peer_lock(peer); /* initial reference */
- bgp_lock(bgp);
peer->password = NULL;
/* Set default flags. */
return 0;
}
-static void bgp_free(struct bgp *);
-
-void bgp_lock(struct bgp *bgp)
-{
- ++bgp->lock;
-}
-
-void bgp_unlock(struct bgp *bgp)
-{
- assert(bgp->lock > 0);
- if (--bgp->lock == 0)
- bgp_free(bgp);
-}
-
-static void bgp_free(struct bgp *bgp)
+void bgp_free(struct bgp *bgp)
{
afi_t afi;
safi_t safi;
extern int bgp_flag_unset(struct bgp *, int);
extern int bgp_flag_check(struct bgp *, int);
-extern void bgp_lock(struct bgp *);
-extern void bgp_unlock(struct bgp *);
-
extern void bgp_router_id_zebra_bump(vrf_id_t, const struct prefix *);
extern int bgp_router_id_static_set(struct bgp *, struct in_addr);
extern int peer_af_delete(struct peer *, afi_t, safi_t);
extern void bgp_close(void);
+extern void bgp_free(struct bgp *);
+
+static inline struct bgp *bgp_lock(struct bgp *bgp)
+{
+ bgp->lock++;
+ return bgp;
+}
+
+static inline void bgp_unlock(struct bgp *bgp)
+{
+ assert(bgp->lock > 0);
+ if (--bgp->lock == 0)
+ bgp_free(bgp);
+}
static inline int afindex(afi_t afi, safi_t safi)
{
static inline void bgp_vrf_link(struct bgp *bgp, struct vrf *vrf)
{
bgp->vrf_id = vrf->vrf_id;
- if (vrf->info != (void *)bgp) {
- bgp_lock(bgp);
- vrf->info = (void *)bgp;
- }
+ if (vrf->info != (void *)bgp)
+ vrf->info = (void *)bgp_lock(bgp);
}
/* Unlink BGP instance from VRF. */