]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Nest: proto/channel state table naming convention cleanup
authorMaria Matejka <mq@ucw.cz>
Mon, 9 Dec 2024 14:34:11 +0000 (15:34 +0100)
committerMaria Matejka <mq@ucw.cz>
Tue, 10 Dec 2024 22:41:48 +0000 (23:41 +0100)
nest/proto.c
nest/protocol.h
proto/bgp/bgp.c
proto/bmp/bmp.c
proto/mrt/mrt.c

index 4d9d5354ab2e6ce454a5c2a75dfbf4d3f8a03190..670ee50639b30f0ab0500fd0e9b7a85ae0216456 100644 (file)
@@ -260,21 +260,21 @@ proto_add_channel(struct proto *p, struct channel_config *cf)
     hmap_set(&ts->channel_id_map, c->id);
 
     /* The current channel state table may be too small */
-    if (c->id >= ts->length_channels)
+    if (c->id >= ts->channels_len)
     {
-      ea_list **l = mb_allocz(ts->pool, sizeof(ea_list*) * ts->length_channels * 2);
-      memcpy(l, ts->channels, sizeof(ea_list*) * ts->length_channels);
-      mb_free(ts->channels);
+      ea_list **l = mb_allocz(ts->pool, sizeof(ea_list*) * ts->channels_len * 2);
+      memcpy(l, ts->channel_states, sizeof(ea_list*) * ts->channels_len);
+      mb_free(ts->channel_states);
 
-      ts->channels = l;
-      ts->length_channels = ts->length_channels * 2;
+      ts->channel_states = l;
+      ts->channels_len = ts->channels_len * 2;
     }
 
-    ASSERT_DIE(c->id < ts->length_channels);
-    ASSERT_DIE(ts->channels[c->id] == NULL);
+    ASSERT_DIE(c->id < ts->channels_len);
+    ASSERT_DIE(ts->channel_states[c->id] == NULL);
 
     /* Set the channel info */
-    ts->channels[c->id] = ea_lookup_slow(ca, 0, EALS_IN_TABLE);
+    ts->channel_states[c->id] = ea_lookup_slow(ca, 0, EALS_IN_TABLE);
   }
 
   /* Update channel list in protocol state */
@@ -317,9 +317,9 @@ proto_remove_channel(struct proto *p UNUSED, struct channel *c)
    */
   PST_LOCKED(ts)
   {
-    ASSERT_DIE(c->id < ts->length_channels);
-    ea_free_later(ts->channels[c->id]);
-    ts->channels[c->id] = NULL;
+    ASSERT_DIE(c->id < ts->channels_len);
+    ea_free_later(ts->channel_states[c->id]);
+    ts->channel_states[c->id] = NULL;
     hmap_clear(&ts->channel_id_map, c->id);
   }
 
@@ -1348,15 +1348,15 @@ proto_new(struct proto_config *cf)
     p->id = hmap_first_zero(&tp->proto_id_map);
     hmap_set(&tp->proto_id_map, p->id);
 
-    if (p->id >= tp->length_states)
+    if (p->id >= tp->proto_len)
     {
       /* Grow the states array */
-      ea_list **new_states = mb_allocz(tp->pool, sizeof *new_states * tp->length_states * 2);
-      memcpy(new_states, tp->states, tp->length_states * sizeof *new_states);
+      ea_list **new_states = mb_allocz(tp->pool, sizeof *new_states * tp->proto_len * 2);
+      memcpy(new_states, tp->proto_states, tp->proto_len * sizeof *new_states);
 
-      mb_free(tp->states);
-      tp->states = new_states;
-      tp->length_states *= 2;
+      mb_free(tp->proto_states);
+      tp->proto_states = new_states;
+      tp->proto_len *= 2;
     }
   }
 
@@ -2140,15 +2140,15 @@ protos_build(void)
 
   PST_LOCKED(ts)
   {
-    ts->length_channels = 64;
-    ts->length_states = 32;
+    ts->channels_len = 64;
+    ts->proto_len = 32;
 
-    hmap_init(&ts->proto_id_map, p, ts->length_states); /* for proto ids. Value of proto id is the same as index of that proto in ptoto_state_table->attrs */
-    hmap_init(&ts->channel_id_map, p, ts->length_channels);
+    hmap_init(&ts->proto_id_map, p, ts->proto_len); /* for proto ids. Value of proto id is the same as index of that proto in ptoto_state_table->attrs */
+    hmap_init(&ts->channel_id_map, p, ts->channels_len);
 
     ts->pool = p;
-    ts->states = mb_allocz(p, sizeof(ea_list *) * ts->length_states);
-    ts->channels = mb_allocz(p, sizeof(ea_list *) * ts->length_channels * 2);
+    ts->proto_states = mb_allocz(p, sizeof(ea_list *) * ts->proto_len);
+    ts->channel_states = mb_allocz(p, sizeof(ea_list *) * ts->channels_len * 2);
   }
 
   /* Init proto state journal */
@@ -2939,7 +2939,7 @@ proto_journal_item_cleanup_(bool withdrawal, ea_list *old_attr)
   {
     u32 id = ea_get_int(old_attr, &ea_proto_id, 0);
     ASSERT_DIE(id);
-    ASSERT_DIE(tp->states[id] == NULL);
+    ASSERT_DIE(tp->proto_states[id] == NULL);
     hmap_clear(&tp->proto_id_map, id);
   }
 }
@@ -2955,7 +2955,7 @@ proto_journal_item_cleanup(struct lfjour * journal UNUSED, struct lfjour_item *i
 /*
  * Protocol state announcement.
  *
- * The authoritative protocol state is always stored in ts->states[p->id]
+ * The authoritative protocol state is always stored in ts->proto_states[p->id]
  * and it holds a reference. But sometimes it's too clumsy to announce all
  * protocol changes happening in a fast succession, so there is a
  * state-to-be-announced stored in the protocol itself, in p->ea_state.
@@ -3014,15 +3014,15 @@ proto_announce_state_locked(struct proto_state_table_private* ts, struct proto *
   }
 
   /* Then we check the public state */
-  ASSERT_DIE(p->id < ts->length_states);
-  ea_list *old_state = ts->states[p->id];
+  ASSERT_DIE(p->id < ts->proto_len);
+  ea_list *old_state = ts->proto_states[p->id];
 
   /* Nothing has changed? */
   if (p->ea_state == old_state)
     return;
 
   /* Set the new state */
-  ts->states[p->id] = p->ea_state ? ea_ref(p->ea_state) : NULL;
+  ts->proto_states[p->id] = p->ea_state ? ea_ref(p->ea_state) : NULL;
 
   /* Announce the new state */
   struct lfjour_item *li = lfjour_push_prepare(&proto_state_table_pub.journal);
@@ -3094,9 +3094,9 @@ channel_get_state(int id)
 {
   PST_LOCKED(ts)
   {
-    ASSERT_DIE((u32) id < ts->length_channels);
-    if (ts->channels[id])
-      return ea_ref_tmp(ts->channels[id]);
+    ASSERT_DIE((u32) id < ts->channels_len);
+    if (ts->channel_states[id])
+      return ea_ref_tmp(ts->channel_states[id]);
   }
   return NULL;
 }
@@ -3107,8 +3107,8 @@ proto_get_state(int id)
   ea_list *eal;
   PST_LOCKED(ts)
   {
-    ASSERT_DIE((u32)id < ts->length_states);
-    eal = ts->states[id];
+    ASSERT_DIE((u32)id < ts->proto_len);
+    eal = ts->proto_states[id];
   }
   if (eal)
     return ea_ref_tmp(eal);
index 43fabdea3703f9d61d8b1fa39456830ade6099f7..5526d48f3396cc6c6ffc75147ff804bb6f2739f3 100644 (file)
@@ -412,10 +412,10 @@ struct proto_state_table_private {
     PROTO_STATE_TABLE_PUBLIC;
   };
   struct proto_state_table_private **locked_at;
-  ea_list ** states;
-  ea_list ** channels;
-  u32 length_states;
-  u32 length_channels;
+  ea_list ** proto_states;
+  ea_list ** channel_states;
+  u32 proto_len;
+  u32 channels_len;
   struct hmap proto_id_map;
   struct hmap channel_id_map;
   pool *pool;
index db5eb6c5de5e2b411527a925156d80fa6e75a0e7..e87ec2879b00befe0ab95cf966311ce69bf6ba82 100644 (file)
@@ -2025,9 +2025,9 @@ bgp_channel_init(struct channel *C, struct channel_config *CF)
 
   PST_LOCKED(ts)
   {
-    ea_list *eal = ea_free_later(ts->channels[c->c.id]);
+    ea_list *eal = ea_free_later(ts->channel_states[c->c.id]);
     ea_set_attr(&eal, EA_LITERAL_EMBEDDED(&ea_bgp_afi, 0, c->afi));
-    ts->channels[c->c.id] = ea_lookup_slow(eal, 0, EALS_IN_TABLE);
+    ts->channel_states[c->c.id] = ea_lookup_slow(eal, 0, EALS_IN_TABLE);
   }
 
 }
index ee0eea5961b0bdca2012939054e05141502808e9..e38b976495042eb3eb547729d671586f5c05135d 100644 (file)
@@ -702,7 +702,7 @@ bmp_add_peer(struct bmp_proto *p, ea_list *bgp_attr)
   {
     ea_list *chan_attr;
     PST_LOCKED(ts)
-      chan_attr = ts->channels[chann_ids[i]];
+      chan_attr = ts->channel_states[chann_ids[i]];
 
     if (chan_attr == NULL)
       continue;
@@ -1117,7 +1117,7 @@ bmp_startup(struct bmp_proto *p)
   /* Send Peer Up messages */
   u32 length;
   PST_LOCKED(ts) /* The size of protos field will never decrease, the inconsistency caused by growing is not important */
-    length = ts->length_states;
+    length = ts->proto_len;
 
   /* Subscribe to protocol state changes */
   p->proto_state_reader = (struct lfjour_recipient) {
index 31e46d91727d4aa28e08d90e0d4c16cf72088779..ff3b022794d0c4de576da53ac42069899e7013da 100644 (file)
@@ -335,9 +335,9 @@ mrt_peer_table_dump(struct mrt_table_dump_state *s)
 #ifdef CONFIG_BGP
   PST_LOCKED(ts)
   {
-    for(u32 i = 0; i < ts->length_states; i++)
+    for(u32 i = 0; i < ts->proto_len; i++)
     {
-      ea_list *eal = ts->states[i];
+      ea_list *eal = ts->proto_states[i];
       if (eal)
         ea_free_later(ea_ref(eal));
       else