]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: inline bgp_lock()/bgp_unlock()
authorJorge Boncompte <jbonor@gmail.com>
Mon, 7 Aug 2017 11:40:10 +0000 (13:40 +0200)
committerJorge Boncompte <jbonor@gmail.com>
Thu, 17 Aug 2017 15:47:07 +0000 (17:47 +0200)
Signed-off-by: Jorge Boncompte <jbonor@gmail.com>
bgpd/bgp_route.c
bgpd/bgpd.c
bgpd/bgpd.h

index 35f793f8612b61a24dee0699fde8afceef0e54d2..741fa5ceeb0ebc5aab06bdef97b6419527b6cf28 100644 (file)
@@ -2248,8 +2248,7 @@ void bgp_process(struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi)
        /* 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);
index d7733fbacd3db1a70602abb44f36b811445ab186..9d7c38c8716d498b65b1645a90189a1d626698f9 100644 (file)
@@ -1116,9 +1116,8 @@ struct peer *peer_new(struct bgp *bgp)
        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.  */
@@ -3106,21 +3105,7 @@ int bgp_delete(struct bgp *bgp)
        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;
index bfdddc69b1e93bb901bbcbfa48cc4a65c943aa93..f6e7b2277f9501636a9ef31f198e87ab30c030b8 100644 (file)
@@ -1252,9 +1252,6 @@ extern int bgp_flag_set(struct bgp *, int);
 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);
 
@@ -1395,6 +1392,20 @@ extern struct peer_af *peer_af_find(struct peer *, afi_t, safi_t);
 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)
 {
@@ -1540,10 +1551,8 @@ static inline struct vrf *bgp_vrf_lookup_by_instance_type(struct bgp *bgp)
 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. */