summaryrefslogtreecommitdiffstats
path: root/nhrpd
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2021-09-29 23:16:17 +0200
committerDavid Lamparter <equinox@opensourcerouting.org>2021-10-19 14:58:47 +0200
commitdb4db2bbdabf172b11013f268082e37832298c6e (patch)
tree34794c7eab58a717ed2490b312eaa204f06140f5 /nhrpd
parentnhrpd: convert nhs list to DLIST (diff)
downloadfrr-db4db2bbdabf172b11013f268082e37832298c6e.tar.xz
frr-db4db2bbdabf172b11013f268082e37832298c6e.zip
nhrpd: convert mcast list to DLIST
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'nhrpd')
-rw-r--r--nhrpd/nhrp_interface.c2
-rw-r--r--nhrpd/nhrp_multicast.c30
-rw-r--r--nhrpd/nhrp_vty.c4
-rw-r--r--nhrpd/nhrpd.h7
4 files changed, 20 insertions, 23 deletions
diff --git a/nhrpd/nhrp_interface.c b/nhrpd/nhrp_interface.c
index 0211bdd50..94cec0281 100644
--- a/nhrpd/nhrp_interface.c
+++ b/nhrpd/nhrp_interface.c
@@ -80,7 +80,7 @@ static int nhrp_if_new_hook(struct interface *ifp)
struct nhrp_afi_data *ad = &nifp->afi[afi];
ad->holdtime = NHRPD_DEFAULT_HOLDTIME;
nhrp_nhslist_init(&ad->nhslist_head);
- list_init(&ad->mcastlist_head);
+ nhrp_mcastlist_init(&ad->mcastlist_head);
}
return 0;
diff --git a/nhrpd/nhrp_multicast.c b/nhrpd/nhrp_multicast.c
index 339b6dfab..d8372ae8a 100644
--- a/nhrpd/nhrp_multicast.c
+++ b/nhrpd/nhrp_multicast.c
@@ -219,7 +219,9 @@ void netlink_mcast_set_nflog_group(int nlgroup)
static int nhrp_multicast_free(struct interface *ifp,
struct nhrp_multicast *mcast)
{
- list_del(&mcast->list_entry);
+ struct nhrp_interface *nifp = ifp->info;
+
+ nhrp_mcastlist_del(&nifp->afi[mcast->afi].mcastlist_head, mcast);
XFREE(MTYPE_NHRP_MULTICAST, mcast);
return 0;
}
@@ -230,8 +232,7 @@ int nhrp_multicast_add(struct interface *ifp, afi_t afi,
struct nhrp_interface *nifp = ifp->info;
struct nhrp_multicast *mcast;
- list_for_each_entry(mcast, &nifp->afi[afi].mcastlist_head, list_entry)
- {
+ frr_each (nhrp_mcastlist, &nifp->afi[afi].mcastlist_head, mcast) {
if (sockunion_same(&mcast->nbma_addr, nbma_addr))
return NHRP_ERR_ENTRY_EXISTS;
}
@@ -241,7 +242,7 @@ int nhrp_multicast_add(struct interface *ifp, afi_t afi,
*mcast = (struct nhrp_multicast){
.afi = afi, .ifp = ifp, .nbma_addr = *nbma_addr,
};
- list_add_tail(&mcast->list_entry, &nifp->afi[afi].mcastlist_head);
+ nhrp_mcastlist_add_tail(&nifp->afi[afi].mcastlist_head, mcast);
debugf(NHRP_DEBUG_COMMON, "Adding multicast entry (%pSU)", nbma_addr);
@@ -252,11 +253,9 @@ int nhrp_multicast_del(struct interface *ifp, afi_t afi,
union sockunion *nbma_addr)
{
struct nhrp_interface *nifp = ifp->info;
- struct nhrp_multicast *mcast, *tmp;
+ struct nhrp_multicast *mcast;
- list_for_each_entry_safe(mcast, tmp, &nifp->afi[afi].mcastlist_head,
- list_entry)
- {
+ frr_each_safe (nhrp_mcastlist, &nifp->afi[afi].mcastlist_head, mcast) {
if (!sockunion_same(&mcast->nbma_addr, nbma_addr))
continue;
@@ -274,17 +273,15 @@ int nhrp_multicast_del(struct interface *ifp, afi_t afi,
void nhrp_multicast_interface_del(struct interface *ifp)
{
struct nhrp_interface *nifp = ifp->info;
- struct nhrp_multicast *mcast, *tmp;
+ struct nhrp_multicast *mcast;
afi_t afi;
for (afi = 0; afi < AFI_MAX; afi++) {
- debugf(NHRP_DEBUG_COMMON,
- "Cleaning up multicast entries (%d)",
- !list_empty(&nifp->afi[afi].mcastlist_head));
+ debugf(NHRP_DEBUG_COMMON, "Cleaning up multicast entries (%zu)",
+ nhrp_mcastlist_count(&nifp->afi[afi].mcastlist_head));
- list_for_each_entry_safe(
- mcast, tmp, &nifp->afi[afi].mcastlist_head, list_entry)
- {
+ frr_each_safe (nhrp_mcastlist, &nifp->afi[afi].mcastlist_head,
+ mcast) {
nhrp_multicast_free(ifp, mcast);
}
}
@@ -297,8 +294,7 @@ void nhrp_multicast_foreach(struct interface *ifp, afi_t afi,
struct nhrp_interface *nifp = ifp->info;
struct nhrp_multicast *mcast;
- list_for_each_entry(mcast, &nifp->afi[afi].mcastlist_head, list_entry)
- {
+ frr_each (nhrp_mcastlist, &nifp->afi[afi].mcastlist_head, mcast) {
cb(mcast, ctx);
}
}
diff --git a/nhrpd/nhrp_vty.c b/nhrpd/nhrp_vty.c
index c6f9a1725..0dfabcf6a 100644
--- a/nhrpd/nhrp_vty.c
+++ b/nhrpd/nhrp_vty.c
@@ -1210,9 +1210,7 @@ static int interface_config_write(struct vty *vty)
vty_out(vty, " nbma %s\n", nhs->nbma_fqdn);
}
- list_for_each_entry(mcast, &ad->mcastlist_head,
- list_entry)
- {
+ frr_each (nhrp_mcastlist, &ad->mcastlist_head, mcast) {
vty_out(vty, " %s nhrp map multicast ", aficmd);
if (sockunion_family(&mcast->nbma_addr)
== AF_UNSPEC)
diff --git a/nhrpd/nhrpd.h b/nhrpd/nhrpd.h
index 7e4a86cd5..2eab3614d 100644
--- a/nhrpd/nhrpd.h
+++ b/nhrpd/nhrpd.h
@@ -269,6 +269,7 @@ struct nhrp_shortcut {
};
PREDECL_DLIST(nhrp_nhslist);
+PREDECL_DLIST(nhrp_mcastlist);
struct nhrp_nhs {
struct interface *ifp;
@@ -288,11 +289,13 @@ DECLARE_DLIST(nhrp_nhslist, struct nhrp_nhs, nhslist_entry);
struct nhrp_multicast {
struct interface *ifp;
- struct list_head list_entry;
+ struct nhrp_mcastlist_item mcastlist_entry;
afi_t afi;
union sockunion nbma_addr; /* IP-address */
};
+DECLARE_DLIST(nhrp_mcastlist, struct nhrp_multicast, mcastlist_entry);
+
struct nhrp_registration {
struct list_head reglist_entry;
struct thread *t_register;
@@ -340,7 +343,7 @@ struct nhrp_interface {
unsigned short mtu;
unsigned int holdtime;
struct nhrp_nhslist_head nhslist_head;
- struct list_head mcastlist_head;
+ struct nhrp_mcastlist_head mcastlist_head;
} afi[AFI_MAX];
};