fib: format deleted LB 30/40130/3
authorNathan Skrzypczak <nathan.skrzypczak@gmail.com>
Thu, 21 Dec 2023 10:35:30 +0000 (11:35 +0100)
committerNathan Skrzypczak <nathan.skrzypczak@gmail.com>
Thu, 21 Dec 2023 10:39:08 +0000 (11:39 +0100)
This patch allows the formatting of deleted Load-balancer
objects. This is needed in the case a trace references a DPO
that went away in the interim.

Type: improvement

Change-Id: I6d67519b8d62f69aafde3c8fe3065bc85a7adbde
Signed-off-by: Nathan Skrzypczak <nathan.skrzypczak@gmail.com>
src/vnet/dpo/load_balance.c
src/vnet/dpo/load_balance.h

index fae7c1d..8f2a0de 100644 (file)
@@ -149,7 +149,13 @@ load_balance_format (index_t lbi,
     dpo_id_t *buckets;
     u32 i;
 
-    lb = load_balance_get(lbi);
+    lb = load_balance_get_or_null(lbi);
+    if (lb == NULL)
+      {
+       s = format(s, "DELETED lb:%u", lbi);
+       return (s);
+      }
+
     vlib_get_combined_counter(&(load_balance_main.lbm_to_counters), lbi, &to);
     vlib_get_combined_counter(&(load_balance_main.lbm_via_counters), lbi, &via);
     buckets = load_balance_get_buckets(lb);
index 3605d82..eee073f 100644 (file)
@@ -232,6 +232,14 @@ load_balance_get (index_t lbi)
     return (pool_elt_at_index(load_balance_pool, lbi));
 }
 
+static inline load_balance_t *
+load_balance_get_or_null (index_t lbi)
+{
+  if (pool_is_free_index (load_balance_pool, lbi))
+    return 0;
+  return (pool_elt_at_index (load_balance_pool, lbi));
+}
+
 #define LB_HAS_INLINE_BUCKETS(_lb)             \
     ((_lb)->lb_n_buckets <= LB_NUM_INLINE_BUCKETS)