{
nhrp_peer_notify_del(r->peer, &r->peer_notifier);
nhrp_peer_unref(r->peer);
- list_del(&r->reglist_entry);
+ nhrp_reglist_del(&r->nhs->reglist_head, r);
THREAD_OFF(r->t_register);
XFREE(MTYPE_NHRP_REGISTRATION, r);
}
{
struct nhrp_registration *r;
- list_for_each_entry(
- r, &nhs->reglist_head,
- reglist_entry) if (sockunion_same(&r->peer->vc->remote.nbma,
- nbma_addr)) return r;
+ frr_each (nhrp_reglist, &nhs->reglist_head, r)
+ if (sockunion_same(&r->peer->vc->remote.nbma, nbma_addr))
+ return r;
return NULL;
}
{
struct nhrp_nhs *nhs = container_of(q, struct nhrp_nhs, dns_resolve);
struct nhrp_interface *nifp = nhs->ifp->info;
- struct nhrp_registration *reg, *regn;
+ struct nhrp_registration *reg;
int i;
if (n < 0) {
thread_add_timer(master, nhrp_nhs_resolve, nhs, 2 * 60 * 60,
&nhs->t_resolve);
- list_for_each_entry(reg, &nhs->reglist_head, reglist_entry) reg->mark =
- 1;
+ frr_each (nhrp_reglist, &nhs->reglist_head, reg)
+ reg->mark = 1;
nhs->hub = 0;
for (i = 0; i < n; i++) {
reg->peer = nhrp_peer_get(nhs->ifp, &addrs[i]);
reg->nhs = nhs;
reg->timeout = 1;
- list_init(®->reglist_entry);
- list_add_tail(®->reglist_entry, &nhs->reglist_head);
+ nhrp_reglist_add_tail(&nhs->reglist_head, reg);
nhrp_peer_notify_add(reg->peer, ®->peer_notifier,
nhrp_reg_peer_notify);
thread_add_timer_msec(master, nhrp_reg_send_req, reg, 50,
®->t_register);
}
- list_for_each_entry_safe(reg, regn, &nhs->reglist_head, reglist_entry)
- {
+ frr_each_safe (nhrp_reglist, &nhs->reglist_head, reg)
if (reg->mark)
nhrp_reg_delete(reg);
- }
}
static int nhrp_nhs_resolve(struct thread *t)
.ifp = ifp,
.proto_addr = *proto_addr,
.nbma_fqdn = strdup(nbma_fqdn),
- .reglist_head = LIST_INITIALIZER(nhs->reglist_head),
+ .reglist_head = INIT_DLIST(nhs->reglist_head),
};
nhrp_nhslist_add_tail(&nifp->afi[afi].nhslist_head, nhs);
thread_add_timer_msec(master, nhrp_nhs_resolve, nhs, 1000,
int nhrp_nhs_free(struct nhrp_interface *nifp, afi_t afi, struct nhrp_nhs *nhs)
{
- struct nhrp_registration *r, *rn;
+ struct nhrp_registration *r;
- list_for_each_entry_safe(r, rn, &nhs->reglist_head, reglist_entry)
+ frr_each_safe (nhrp_reglist, &nhs->reglist_head, r)
nhrp_reg_delete(r);
THREAD_OFF(nhs->t_resolve);
nhrp_nhslist_del(&nifp->afi[afi].nhslist_head, nhs);
struct nhrp_registration *reg;
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);
+ if (nhrp_reglist_count(&nhs->reglist_head)) {
+ frr_each (nhrp_reglist, &nhs->reglist_head, reg)
+ cb(nhs, reg, ctx);
} else
cb(nhs, 0, ctx);
}
PREDECL_DLIST(nhrp_nhslist);
PREDECL_DLIST(nhrp_mcastlist);
+PREDECL_DLIST(nhrp_reglist);
struct nhrp_nhs {
struct interface *ifp;
struct thread *t_resolve;
struct resolver_query dns_resolve;
- struct list_head reglist_head;
+ struct nhrp_reglist_head reglist_head;
};
DECLARE_DLIST(nhrp_nhslist, struct nhrp_nhs, nhslist_entry);
DECLARE_DLIST(nhrp_mcastlist, struct nhrp_multicast, mcastlist_entry);
struct nhrp_registration {
- struct list_head reglist_entry;
+ struct nhrp_reglist_item reglist_entry;
struct thread *t_register;
struct nhrp_nhs *nhs;
struct nhrp_reqid reqid;
struct notifier_block peer_notifier;
};
+DECLARE_DLIST(nhrp_reglist, struct nhrp_registration, reglist_entry);
+
#define NHRP_IFF_SHORTCUT 0x0001
#define NHRP_IFF_REDIRECT 0x0002
#define NHRP_IFF_REG_NO_UNIQUE 0x0100