]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/qobj.c
Merge pull request #13649 from donaldsharp/unlock_the_node_or_else
[mirror_frr.git] / lib / qobj.c
index 1e48b541dc07db950c0c375773ae1e2d61ddd783..b9630e7547133f4d479070b1c1c8c429e79eeaed 100644 (file)
@@ -1,31 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * Copyright (c) 2015-16  David Lamparter, for NetDEF, Inc.
  *
  * This file is part of Quagga
- *
- * Quagga is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * Quagga is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include <zebra.h>
 
-#include "thread.h"
+#include "frrevent.h"
 #include "memory.h"
 #include "hash.h"
 #include "log.h"
 #include "qobj.h"
 #include "jhash.h"
+#include "network.h"
 
 static uint32_t qobj_hash(const struct qobj_node *node)
 {
@@ -42,7 +30,7 @@ static int qobj_cmp(const struct qobj_node *na, const struct qobj_node *nb)
 }
 
 DECLARE_HASH(qobj_nodes, struct qobj_node, nodehash,
-                       qobj_cmp, qobj_hash)
+                       qobj_cmp, qobj_hash);
 
 static pthread_rwlock_t nodes_lock;
 static struct qobj_nodes_head nodes = { };
@@ -53,8 +41,8 @@ void qobj_reg(struct qobj_node *node, const struct qobj_nodetype *type)
        node->type = type;
        pthread_rwlock_wrlock(&nodes_lock);
        do {
-               node->nid = (uint64_t)random();
-               node->nid ^= (uint64_t)random() << 32;
+               node->nid = (uint64_t)frr_weak_random();
+               node->nid ^= (uint64_t)frr_weak_random() << 32;
        } while (!node->nid || qobj_nodes_find(&nodes, node));
        qobj_nodes_add(&nodes, node);
        pthread_rwlock_unlock(&nodes_lock);