static unsigned int nhrp_vc_key(void *peer_data)
{
struct nhrp_vc *vc = peer_data;
- return jhash_2words(
- sockunion_hash(&vc->local.nbma),
- sockunion_hash(&vc->remote.nbma),
- 0);
+ return jhash_2words(sockunion_hash(&vc->local.nbma),
+ sockunion_hash(&vc->remote.nbma), 0);
}
static int nhrp_vc_cmp(const void *cache_data, const void *key_data)
{
const struct nhrp_vc *a = cache_data;
const struct nhrp_vc *b = key_data;
- return sockunion_same(&a->local.nbma, &b->local.nbma) &&
- sockunion_same(&a->remote.nbma, &b->remote.nbma);
+ return sockunion_same(&a->local.nbma, &b->local.nbma)
+ && sockunion_same(&a->remote.nbma, &b->remote.nbma);
}
static void *nhrp_vc_alloc(void *data)
struct nhrp_vc *vc, *key = data;
vc = XMALLOC(MTYPE_NHRP_VC, sizeof(struct nhrp_vc));
- if (vc) {
- *vc = (struct nhrp_vc) {
- .local.nbma = key->local.nbma,
- .remote.nbma = key->remote.nbma,
- .notifier_list = NOTIFIER_LIST_INITIALIZER(&vc->notifier_list),
- };
- }
+
+ *vc = (struct nhrp_vc){
+ .local.nbma = key->local.nbma,
+ .remote.nbma = key->remote.nbma,
+ .notifier_list =
+ NOTIFIER_LIST_INITIALIZER(&vc->notifier_list),
+ };
return vc;
}
XFREE(MTYPE_NHRP_VC, data);
}
-struct nhrp_vc *nhrp_vc_get(const union sockunion *src, const union sockunion *dst, int create)
+struct nhrp_vc *nhrp_vc_get(const union sockunion *src,
+ const union sockunion *dst, int create)
{
struct nhrp_vc key;
key.local.nbma = *src;
uint32_t child_hash = child_id % ZEBRA_NUM_OF(childlist_head);
int abort_migration = 0;
- list_for_each_entry(lsa, &childlist_head[child_hash], childlist_entry) {
+ list_for_each_entry(lsa, &childlist_head[child_hash], childlist_entry)
+ {
if (lsa->id == child_id) {
sa = lsa;
break;
}
if (!sa) {
- if (!vc) return 0;
+ if (!vc)
+ return 0;
sa = XMALLOC(MTYPE_NHRP_VC, sizeof(struct child_sa));
- if (!sa) return 0;
- *sa = (struct child_sa) {
+ *sa = (struct child_sa){
.id = child_id,
- .childlist_entry = LIST_INITIALIZER(sa->childlist_entry),
+ .childlist_entry =
+ LIST_INITIALIZER(sa->childlist_entry),
.vc = NULL,
};
- list_add_tail(&sa->childlist_entry, &childlist_head[child_hash]);
+ list_add_tail(&sa->childlist_entry,
+ &childlist_head[child_hash]);
}
if (sa->vc == vc)
/* Notify old VC of migration */
sa->vc->abort_migration = 0;
debugf(NHRP_DEBUG_COMMON, "IPsec NBMA change of %s to %s",
- sockunion2str(&sa->vc->remote.nbma, buf[0], sizeof buf[0]),
- sockunion2str(&vc->remote.nbma, buf[1], sizeof buf[1]));
+ sockunion2str(&sa->vc->remote.nbma, buf[0],
+ sizeof buf[0]),
+ sockunion2str(&vc->remote.nbma, buf[1], sizeof buf[1]));
nhrp_vc_update(sa->vc, NOTIFY_VC_IPSEC_UPDATE_NBMA);
abort_migration = sa->vc->abort_migration;
}
if (sa->vc) {
/* Deattach old VC */
sa->vc->ipsec--;
- if (!sa->vc->ipsec) nhrp_vc_ipsec_reset(sa->vc);
+ if (!sa->vc->ipsec)
+ nhrp_vc_ipsec_reset(sa->vc);
nhrp_vc_update(sa->vc, NOTIFY_VC_IPSEC_CHANGED);
}
return abort_migration;
}
-void nhrp_vc_notify_add(struct nhrp_vc *vc, struct notifier_block *n, notifier_fn_t action)
+void nhrp_vc_notify_add(struct nhrp_vc *vc, struct notifier_block *n,
+ notifier_fn_t action)
{
notifier_add(n, &vc->notifier_list, action);
}
void nhrp_vc_foreach(void (*cb)(struct nhrp_vc *, void *), void *ctx)
{
struct nhrp_vc_iterator_ctx ic = {
- .cb = cb,
- .ctx = ctx,
+ .cb = cb, .ctx = ctx,
};
hash_iterate(nhrp_vc_hash, nhrp_vc_iterator, &ic);
}
{
size_t i;
- nhrp_vc_hash = hash_create(nhrp_vc_key, nhrp_vc_cmp, NULL);
+ nhrp_vc_hash = hash_create(nhrp_vc_key, nhrp_vc_cmp, "NHRP VC hash");
for (i = 0; i < ZEBRA_NUM_OF(childlist_head); i++)
list_init(&childlist_head[i]);
}
size_t i;
for (i = 0; i < ZEBRA_NUM_OF(childlist_head); i++) {
- list_for_each_entry_safe(sa, n, &childlist_head[i], childlist_entry)
+ list_for_each_entry_safe(sa, n, &childlist_head[i],
+ childlist_entry)
nhrp_vc_ipsec_updown(sa->id, 0);
}
}