]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_keepalives.c
bgpd: reuse bgp_path_info_extra_free() routing in rfapi
[mirror_frr.git] / bgpd / bgp_keepalives.c
index 3216683a54878d264f7ba17742031d778a02716e..50aad70ddc56fd70eb5ea32d4292e8b13cd29d33 100644 (file)
@@ -123,10 +123,11 @@ static void peer_process(struct hash_backet *hb, void *arg)
                *next_update = diff;
 }
 
-static int peer_hash_cmp(const void *f, const void *s)
+static bool peer_hash_cmp(const void *f, const void *s)
 {
        const struct pkat *p1 = f;
        const struct pkat *p2 = s;
+
        return p1->peer == p2->peer;
 }
 
@@ -180,11 +181,7 @@ void *bgp_keepalives_start(void *arg)
        pthread_cond_init(peerhash_cond, &attrs);
        pthread_condattr_destroy(&attrs);
 
-#ifdef GNU_LINUX
-       pthread_setname_np(fpt->thread, "bgpd_ka");
-#elif defined(OPEN_BSD)
-       pthread_set_name_np(fpt->thread, "bgpd_ka");
-#endif
+       frr_pthread_set_name(fpt, NULL, "bgpd_ka");
 
        /* initialize peer hashtable */
        peerhash = hash_create_size(2048, peer_hash_key, peer_hash_cmp, NULL);
@@ -233,16 +230,16 @@ void bgp_keepalives_on(struct peer *peer)
        if (CHECK_FLAG(peer->thread_flags, PEER_THREAD_KEEPALIVES_ON))
                return;
 
-       struct frr_pthread *fpt = frr_pthread_get(PTHREAD_KEEPALIVES);
+       struct frr_pthread *fpt = bgp_pth_ka;
        assert(fpt->running);
 
        /* placeholder bucket data to use for fast key lookups */
        static struct pkat holder = {0};
 
-       if (!peerhash_mtx) {
-               zlog_warn("%s: call bgp_keepalives_init() first", __func__);
-               return;
-       }
+       /*
+        * We need to ensure that bgp_keepalives_init was called first
+        */
+       assert(peerhash_mtx);
 
        pthread_mutex_lock(peerhash_mtx);
        {
@@ -263,16 +260,16 @@ void bgp_keepalives_off(struct peer *peer)
        if (!CHECK_FLAG(peer->thread_flags, PEER_THREAD_KEEPALIVES_ON))
                return;
 
-       struct frr_pthread *fpt = frr_pthread_get(PTHREAD_KEEPALIVES);
+       struct frr_pthread *fpt = bgp_pth_ka;
        assert(fpt->running);
 
        /* placeholder bucket data to use for fast key lookups */
        static struct pkat holder = {0};
 
-       if (!peerhash_mtx) {
-               zlog_warn("%s: call bgp_keepalives_init() first", __func__);
-               return;
-       }
+       /*
+        * We need to ensure that bgp_keepalives_init was called first
+        */
+       assert(peerhash_mtx);
 
        pthread_mutex_lock(peerhash_mtx);
        {