]> git.puffer.fish Git - mirror/frr.git/commitdiff
nhrpd: convert notifier list to DLIST
authorDavid Lamparter <equinox@diac24.net>
Sat, 27 Mar 2021 21:20:10 +0000 (22:20 +0100)
committerDavid Lamparter <equinox@opensourcerouting.org>
Tue, 19 Oct 2021 12:55:39 +0000 (14:55 +0200)
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
nhrpd/nhrp_cache.c
nhrpd/nhrp_interface.c
nhrpd/nhrp_peer.c
nhrpd/nhrp_vc.c
nhrpd/nhrpd.h

index c358baecb27c3fb1c7f51d5594bd7e1554960629..3823464a73edf741aa064c51d3fcfbf722c5ff18 100644 (file)
@@ -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);
 }
index 2db8997bad4e918c639fcee2053c267c33a0dc0a..7597526f736f19125485cd102078164faa91419b 100644 (file)
@@ -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,
index 030f4c0ff3350498cb32e3bd4101b9e120e8d5f7..51cae44bd1b2bd0f0593b53580beb1c6de196062 100644 (file)
@@ -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);
 }
 
index b3b657f3fada9ea6172e8f9490977b370385a8f5..b5de0e91c497dfc6ccd21fc928a3287b795575bd 100644 (file)
@@ -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);
 }
 
index 17abb04762aa021dcf8d362968b04aba99b3a4c7..e88a4576fb6b4d46d15835c55e3ae33272727c6a 100644 (file)
@@ -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;