&& sockunion_family(proto_addr) != afi2family(afi))
return NHRP_ERR_PROTOCOL_ADDRESS_MISMATCH;
- list_for_each_entry(nhs, &nifp->afi[afi].nhslist_head, nhslist_entry)
- {
+ frr_each (nhrp_nhslist, &nifp->afi[afi].nhslist_head, nhs) {
if (sockunion_family(&nhs->proto_addr) != AF_UNSPEC
&& sockunion_family(proto_addr) != AF_UNSPEC
&& sockunion_same(&nhs->proto_addr, proto_addr))
.nbma_fqdn = strdup(nbma_fqdn),
.reglist_head = LIST_INITIALIZER(nhs->reglist_head),
};
- list_add_tail(&nhs->nhslist_entry, &nifp->afi[afi].nhslist_head);
+ nhrp_nhslist_add_tail(&nifp->afi[afi].nhslist_head, nhs);
thread_add_timer_msec(master, nhrp_nhs_resolve, nhs, 1000,
&nhs->t_resolve);
const char *nbma_fqdn)
{
struct nhrp_interface *nifp = ifp->info;
- struct nhrp_nhs *nhs, *nnhs;
+ struct nhrp_nhs *nhs;
int ret = NHRP_ERR_ENTRY_NOT_FOUND;
if (sockunion_family(proto_addr) != AF_UNSPEC
&& sockunion_family(proto_addr) != afi2family(afi))
return NHRP_ERR_PROTOCOL_ADDRESS_MISMATCH;
- list_for_each_entry_safe(nhs, nnhs, &nifp->afi[afi].nhslist_head,
- nhslist_entry)
- {
+ frr_each_safe (nhrp_nhslist, &nifp->afi[afi].nhslist_head, nhs) {
if (!sockunion_same(&nhs->proto_addr, proto_addr))
continue;
if (strcmp(nhs->nbma_fqdn, nbma_fqdn) != 0)
continue;
- nhrp_nhs_free(nhs);
+ nhrp_nhs_free(nifp, afi, nhs);
ret = NHRP_OK;
}
return ret;
}
-int nhrp_nhs_free(struct nhrp_nhs *nhs)
+int nhrp_nhs_free(struct nhrp_interface *nifp, afi_t afi, struct nhrp_nhs *nhs)
{
struct nhrp_registration *r, *rn;
list_for_each_entry_safe(r, rn, &nhs->reglist_head, reglist_entry)
nhrp_reg_delete(r);
THREAD_OFF(nhs->t_resolve);
- list_del(&nhs->nhslist_entry);
+ nhrp_nhslist_del(&nifp->afi[afi].nhslist_head, nhs);
free((void *)nhs->nbma_fqdn);
XFREE(MTYPE_NHRP_NHS, nhs);
return 0;
void nhrp_nhs_interface_del(struct interface *ifp)
{
struct nhrp_interface *nifp = ifp->info;
- struct nhrp_nhs *nhs, *tmp;
+ struct nhrp_nhs *nhs;
afi_t afi;
for (afi = 0; afi < AFI_MAX; afi++) {
- debugf(NHRP_DEBUG_COMMON, "Cleaning up nhs entries (%d)",
- !list_empty(&nifp->afi[afi].nhslist_head));
+ debugf(NHRP_DEBUG_COMMON, "Cleaning up nhs entries (%zu)",
+ nhrp_nhslist_count(&nifp->afi[afi].nhslist_head));
- list_for_each_entry_safe(nhs, tmp, &nifp->afi[afi].nhslist_head,
- nhslist_entry)
- {
- nhrp_nhs_free(nhs);
- }
+ frr_each_safe (nhrp_nhslist, &nifp->afi[afi].nhslist_head, nhs)
+ nhrp_nhs_free(nifp, afi, nhs);
}
}
struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp;
struct nhrp_interface *nifp;
- struct nhrp_nhs *nhs, *tmp;
+ struct nhrp_nhs *nhs;
afi_t afi;
FOR_ALL_INTERFACES (vrf, ifp) {
nifp = ifp->info;
for (afi = 0; afi < AFI_MAX; afi++) {
- list_for_each_entry_safe(
- nhs, tmp, &nifp->afi[afi].nhslist_head,
- nhslist_entry) nhrp_nhs_free(nhs);
+ frr_each_safe (nhrp_nhslist,
+ &nifp->afi[afi].nhslist_head, nhs)
+ nhrp_nhs_free(nifp, afi, nhs);
}
}
}
struct nhrp_nhs *nhs;
struct nhrp_registration *reg;
- list_for_each_entry(nhs, &nifp->afi[afi].nhslist_head, nhslist_entry)
- {
+ frr_each (nhrp_nhslist, &nifp->afi[afi].nhslist_head, nhs) {
if (!list_empty(&nhs->reglist_head)) {
list_for_each_entry(reg, &nhs->reglist_head,
reglist_entry) cb(nhs, reg, ctx);
struct nhrp_registration *reg;
for (i = 0; i < AFI_MAX; i++) {
- list_for_each_entry(nhs, &nifp->afi[i].nhslist_head,
- nhslist_entry)
- {
- if (!list_empty(&nhs->reglist_head)) {
- list_for_each_entry(reg, &nhs->reglist_head,
- reglist_entry)
- {
- if (!sockunion_cmp(
- in_ip,
- ®->peer->vc->remote
- .nbma))
- return 1;
- }
+ frr_each (nhrp_nhslist, &nifp->afi[i].nhslist_head, nhs) {
+ if (!nhrp_reglist_count(&nhs->reglist_head))
+ continue;
+
+ frr_each (nhrp_reglist, &nhs->reglist_head, reg) {
+ if (!sockunion_cmp(in_ip,
+ ®->peer->vc->remote.nbma))
+ return 1;
}
}
}
struct notifier_block cache_notifier;
};
+PREDECL_DLIST(nhrp_nhslist);
+
struct nhrp_nhs {
struct interface *ifp;
- struct list_head nhslist_entry;
+ struct nhrp_nhslist_item nhslist_entry;
unsigned hub : 1;
afi_t afi;
struct list_head reglist_head;
};
+DECLARE_DLIST(nhrp_nhslist, struct nhrp_nhs, nhslist_entry);
+
struct nhrp_multicast {
struct interface *ifp;
struct list_head list_entry;
short configured_mtu;
unsigned short mtu;
unsigned int holdtime;
- struct list_head nhslist_head;
+ struct nhrp_nhslist_head nhslist_head;
struct list_head mcastlist_head;
} afi[AFI_MAX];
};
const char *nbma_fqdn);
int nhrp_nhs_del(struct interface *ifp, afi_t afi, union sockunion *proto_addr,
const char *nbma_fqdn);
-int nhrp_nhs_free(struct nhrp_nhs *nhs);
+int nhrp_nhs_free(struct nhrp_interface *nifp, afi_t afi, struct nhrp_nhs *nhs);
void nhrp_nhs_terminate(void);
void nhrp_nhs_foreach(struct interface *ifp, afi_t afi,
void (*cb)(struct nhrp_nhs *, struct nhrp_registration *,