]> git.puffer.fish Git - mirror/frr.git/commitdiff
nhrpd: convert SA list to DLIST
authorDavid Lamparter <equinox@diac24.net>
Sat, 27 Mar 2021 21:41:44 +0000 (22:41 +0100)
committerDavid Lamparter <equinox@opensourcerouting.org>
Tue, 19 Oct 2021 12:58:51 +0000 (14:58 +0200)
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
nhrpd/nhrp_vc.c

index b5de0e91c497dfc6ccd21fc928a3287b795575bd..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);
        }
 
@@ -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);
        }
 }