summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@diac24.net>2021-03-27 22:20:10 +0100
committerDavid Lamparter <equinox@opensourcerouting.org>2021-10-19 14:55:39 +0200
commit865bf787fa1213fe62d8747953c1a612b42a3984 (patch)
tree8545f77a194dfa362921f1ea0bab93b637749117
parentdoc/developer: add _member and _anywhere (diff)
downloadfrr-865bf787fa1213fe62d8747953c1a612b42a3984.tar.xz
frr-865bf787fa1213fe62d8747953c1a612b42a3984.zip
nhrpd: convert notifier list to DLIST
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
-rw-r--r--nhrpd/nhrp_cache.c4
-rw-r--r--nhrpd/nhrp_interface.c13
-rw-r--r--nhrpd/nhrp_peer.c2
-rw-r--r--nhrpd/nhrp_vc.c2
-rw-r--r--nhrpd/nhrpd.h27
5 files changed, 30 insertions, 18 deletions
diff --git a/nhrpd/nhrp_cache.c b/nhrpd/nhrp_cache.c
index c358baecb..3823464a7 100644
--- a/nhrpd/nhrp_cache.c
+++ b/nhrpd/nhrp_cache.c
@@ -315,7 +315,7 @@ static void nhrp_cache_peer_notifier(struct notifier_block *n,
static void nhrp_cache_reset_new(struct nhrp_cache *c)
{
THREAD_OFF(c->t_auth);
- if (list_hashed(&c->newpeer_notifier.notifier_entry))
+ if (notifier_list_anywhere(&c->newpeer_notifier))
nhrp_peer_notify_del(c->new.peer, &c->newpeer_notifier);
nhrp_peer_unref(c->new.peer);
memset(&c->new, 0, sizeof(c->new));
@@ -574,5 +574,5 @@ void nhrp_cache_notify_add(struct nhrp_cache *c, struct notifier_block *n,
void nhrp_cache_notify_del(struct nhrp_cache *c, struct notifier_block *n)
{
- notifier_del(n);
+ notifier_del(n, &c->notifier_list);
}
diff --git a/nhrpd/nhrp_interface.c b/nhrpd/nhrp_interface.c
index 2db8997ba..7597526f7 100644
--- a/nhrpd/nhrp_interface.c
+++ b/nhrpd/nhrp_interface.c
@@ -224,8 +224,12 @@ void nhrp_interface_update_nbma(struct interface *ifp,
nbmanifp = nbmaifp->info;
if (nbmaifp != nifp->nbmaifp) {
- if (nifp->nbmaifp)
- notifier_del(&nifp->nbmanifp_notifier);
+ if (nifp->nbmaifp) {
+ struct nhrp_interface *prev_nifp = nifp->nbmaifp->info;
+
+ notifier_del(&nifp->nbmanifp_notifier,
+ &prev_nifp->notifier_list);
+ }
nifp->nbmaifp = nbmaifp;
if (nbmaifp) {
notifier_add(&nifp->nbmanifp_notifier,
@@ -509,12 +513,15 @@ void nhrp_interface_notify_add(struct interface *ifp, struct notifier_block *n,
notifier_fn_t fn)
{
struct nhrp_interface *nifp = ifp->info;
+
notifier_add(n, &nifp->notifier_list, fn);
}
void nhrp_interface_notify_del(struct interface *ifp, struct notifier_block *n)
{
- notifier_del(n);
+ struct nhrp_interface *nifp = ifp->info;
+
+ notifier_del(n, &nifp->notifier_list);
}
void nhrp_interface_set_protection(struct interface *ifp, const char *profile,
diff --git a/nhrpd/nhrp_peer.c b/nhrpd/nhrp_peer.c
index 030f4c0ff..51cae44bd 100644
--- a/nhrpd/nhrp_peer.c
+++ b/nhrpd/nhrp_peer.c
@@ -359,7 +359,7 @@ void nhrp_peer_notify_add(struct nhrp_peer *p, struct notifier_block *n,
void nhrp_peer_notify_del(struct nhrp_peer *p, struct notifier_block *n)
{
- notifier_del(n);
+ notifier_del(n, &p->notifier_list);
nhrp_peer_check_delete(p);
}
diff --git a/nhrpd/nhrp_vc.c b/nhrpd/nhrp_vc.c
index b3b657f3f..b5de0e91c 100644
--- a/nhrpd/nhrp_vc.c
+++ b/nhrpd/nhrp_vc.c
@@ -170,7 +170,7 @@ void nhrp_vc_notify_add(struct nhrp_vc *vc, struct notifier_block *n,
void nhrp_vc_notify_del(struct nhrp_vc *vc, struct notifier_block *n)
{
- notifier_del(n);
+ notifier_del(n, &vc->notifier_list);
nhrp_vc_check_delete(vc);
}
diff --git a/nhrpd/nhrpd.h b/nhrpd/nhrpd.h
index 17abb0476..e88a4576f 100644
--- a/nhrpd/nhrpd.h
+++ b/nhrpd/nhrpd.h
@@ -42,48 +42,53 @@ struct notifier_block;
typedef void (*notifier_fn_t)(struct notifier_block *, unsigned long);
+PREDECL_DLIST(notifier_list);
+
struct notifier_block {
- struct list_head notifier_entry;
+ struct notifier_list_item notifier_entry;
notifier_fn_t action;
};
+DECLARE_DLIST(notifier_list, struct notifier_block, notifier_entry);
+
struct notifier_list {
- struct list_head notifier_head;
+ struct notifier_list_head head;
};
#define NOTIFIER_LIST_INITIALIZER(l) \
{ \
- .notifier_head = LIST_INITIALIZER((l)->notifier_head) \
+ .head = INIT_DLIST((l)->head) \
}
static inline void notifier_init(struct notifier_list *l)
{
- list_init(&l->notifier_head);
+ notifier_list_init(&l->head);
}
static inline void notifier_add(struct notifier_block *n,
struct notifier_list *l, notifier_fn_t action)
{
n->action = action;
- list_add_tail(&n->notifier_entry, &l->notifier_head);
+ notifier_list_add_tail(&l->head, n);
}
-static inline void notifier_del(struct notifier_block *n)
+static inline void notifier_del(struct notifier_block *n,
+ struct notifier_list *l)
{
- list_del(&n->notifier_entry);
+ notifier_list_del(&l->head, n);
}
static inline void notifier_call(struct notifier_list *l, int cmd)
{
- struct notifier_block *n, *nn;
- list_for_each_entry_safe(n, nn, &l->notifier_head, notifier_entry) {
+ struct notifier_block *n;
+
+ frr_each_safe (notifier_list, &l->head, n)
n->action(n, cmd);
- }
}
static inline int notifier_active(struct notifier_list *l)
{
- return !list_empty(&l->notifier_head);
+ return notifier_list_count(&l->head) > 0;
}
extern struct hash *nhrp_gre_list;