Route counters in the stats segment
[vpp.git] / src / vnet / dpo / load_balance.c
index 8074555..37f8ca1 100644 (file)
@@ -21,7 +21,7 @@
 #include <vnet/adj/adj.h>
 #include <vnet/adj/adj_internal.h>
 #include <vnet/fib/fib_urpf_list.h>
-#include <vnet/bier/bier_hdr_inlines.h>
+#include <vnet/bier/bier_fwd.h>
 
 /*
  * distribution error tolerance for load-balancing
@@ -53,7 +53,16 @@ load_balance_t *load_balance_pool;
 /**
  * The one instance of load-balance main
  */
-load_balance_main_t load_balance_main;
+load_balance_main_t load_balance_main = {
+    .lbm_to_counters = {
+        .name = "route-to",
+        .stat_segment_name = "/net/route/to",
+    },
+    .lbm_via_counters = {
+        .name = "route-via",
+        .stat_segment_name = "/net/route/via",
+    }
+};
 
 f64
 load_balance_get_multipath_tolerance (void)
@@ -240,6 +249,16 @@ load_balance_is_drop (const dpo_id_t *dpo)
     return (0);
 }
 
+u16
+load_balance_n_buckets (index_t lbi)
+{
+    load_balance_t *lb;
+
+    lb = load_balance_get(lbi);
+
+    return (lb->lb_n_buckets);
+}
+
 void
 load_balance_set_fib_entry_flags (index_t lbi,
                                   fib_entry_flag_t flags)
@@ -989,7 +1008,7 @@ load_balance_inline (vlib_main_t * vm,
          {
              /* it's BIER */
              const bier_hdr_t *bh0 = vlib_buffer_get_current(b0);
-             vnet_buffer(b0)->ip.flow_hash = bier_hdr_get_entropy(bh0);
+             vnet_buffer(b0)->ip.flow_hash = bier_compute_flow_hash(bh0);
          }
 
          dpo0 = load_balance_get_bucket_i(lb0,