]> git.proxmox.com Git - mirror_frr.git/blobdiff - nhrpd/nhrp_vc.c
*: fix source file headers & includes for errcodes
[mirror_frr.git] / nhrpd / nhrp_vc.c
index a5547a7a7e6b22572b4aeb52e781dd721f4021e2..41a87d4adbc181c0170ae450da8d633158b53354 100644 (file)
@@ -31,18 +31,16 @@ static struct list_head childlist_head[512];
 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)
@@ -50,13 +48,13 @@ 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;
 }
@@ -66,7 +64,8 @@ static void nhrp_vc_free(void *data)
        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;
@@ -105,7 +104,8 @@ int nhrp_vc_ipsec_updown(uint32_t child_id, struct nhrp_vc *vc)
        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;
@@ -113,17 +113,19 @@ int nhrp_vc_ipsec_updown(uint32_t child_id, struct nhrp_vc *vc)
        }
 
        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)
@@ -138,15 +140,17 @@ int nhrp_vc_ipsec_updown(uint32_t child_id, struct nhrp_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);
        }
 
@@ -160,7 +164,8 @@ int nhrp_vc_ipsec_updown(uint32_t child_id, struct nhrp_vc *vc)
        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);
 }
@@ -186,8 +191,7 @@ static void nhrp_vc_iterator(struct hash_backet *b, void *ctx)
 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);
 }
@@ -196,7 +200,7 @@ void nhrp_vc_init(void)
 {
        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]);
 }
@@ -207,7 +211,8 @@ void nhrp_vc_reset(void)
        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);
        }
 }