mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-11-02 16:25:18 +00:00
nhrpd: convert SA list to DLIST
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
parent
811de44f34
commit
b4f3d41bfd
@ -19,14 +19,18 @@
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user