]> git.proxmox.com Git - mirror_frr.git/blobdiff - nhrpd/nhrp_vc.c
Merge pull request #12681 from pguibert6WIND/vpnv6_encode_plus
[mirror_frr.git] / nhrpd / nhrp_vc.c
index b3b657f3fada9ea6172e8f9490977b370385a8f5..4b45389dadd08dce35bd6fd8330a46806a478110 100644 (file)
 
 DEFINE_MTYPE_STATIC(NHRPD, NHRP_VC, "NHRP virtual connection");
 
+PREDECL_DLIST(childlist);
+
 struct child_sa {
        uint32_t id;
        struct nhrp_vc *vc;
-       struct list_head childlist_entry;
+       struct childlist_item childlist_entry;
 };
 
+DECLARE_DLIST(childlist, struct child_sa, childlist_entry);
+
 static struct hash *nhrp_vc_hash;
-static struct list_head childlist_head[512];
+static struct childlist_head childlist_head[512];
 
 static unsigned int nhrp_vc_key(const void *peer_data)
 {
@@ -104,8 +108,7 @@ int nhrp_vc_ipsec_updown(uint32_t child_id, struct nhrp_vc *vc)
        uint32_t child_hash = child_id % array_size(childlist_head);
        int abort_migration = 0;
 
-       list_for_each_entry(lsa, &childlist_head[child_hash], childlist_entry)
-       {
+       frr_each (childlist, &childlist_head[child_hash], lsa) {
                if (lsa->id == child_id) {
                        sa = lsa;
                        break;
@@ -120,12 +123,9 @@ int nhrp_vc_ipsec_updown(uint32_t child_id, struct nhrp_vc *vc)
 
                *sa = (struct child_sa){
                        .id = child_id,
-                       .childlist_entry =
-                               LIST_INITIALIZER(sa->childlist_entry),
                        .vc = NULL,
                };
-               list_add_tail(&sa->childlist_entry,
-                             &childlist_head[child_hash]);
+               childlist_add_tail(&childlist_head[child_hash], sa);
        }
 
        if (sa->vc == vc)
@@ -155,7 +155,7 @@ int nhrp_vc_ipsec_updown(uint32_t child_id, struct nhrp_vc *vc)
        /* Update */
        sa->vc = vc;
        if (!vc) {
-               list_del(&sa->childlist_entry);
+               childlist_del(&childlist_head[child_hash], sa);
                XFREE(MTYPE_NHRP_VC, sa);
        }
 
@@ -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);
 }
 
@@ -200,17 +200,16 @@ void nhrp_vc_init(void)
 
        nhrp_vc_hash = hash_create(nhrp_vc_key, nhrp_vc_cmp, "NHRP VC hash");
        for (i = 0; i < array_size(childlist_head); i++)
-               list_init(&childlist_head[i]);
+               childlist_init(&childlist_head[i]);
 }
 
 void nhrp_vc_reset(void)
 {
-       struct child_sa *sa, *n;
+       struct child_sa *sa;
        size_t i;
 
        for (i = 0; i < array_size(childlist_head); i++) {
-               list_for_each_entry_safe(sa, n, &childlist_head[i],
-                                        childlist_entry)
+               frr_each_safe (childlist, &childlist_head[i], sa)
                        nhrp_vc_ipsec_updown(sa->id, 0);
        }
 }