- n_left = nhs[0].weight;
- vlib_counter_zero (&sum);
- for (i = j = 0; i < adj->n_adj; i++)
- {
- n_left -= 1;
- vlib_get_combined_counter (&lm->adjacency_counters,
- adj_index + i, &c);
- vlib_counter_add (&sum, &c);
- /*
- * If we're done with this adj and it has actually
- * seen at least one packet, send it.
- */
- if (n_left == 0 && sum.packets > 0)
- {
-
- /* already in net byte order */
- ctrp->address = r->address.as_u32;
- ctrp->address_length = r->address_length;
- ctrp->packets = clib_host_to_net_u64 (sum.packets);
- ctrp->bytes = clib_host_to_net_u64 (sum.bytes);
- mp->count++;
- ctrp++;
-
- if (mp->count == items_this_message)
- {
- mp->count = htonl (items_this_message);
- /*
- * If the main thread's input queue is stuffed,
- * drop the data structure lock (which the main thread
- * may want), and take a pause.
- */
- unix_shared_memory_queue_lock (q);
- if (unix_shared_memory_queue_is_full (q))
- {
- dsunlock (sm);
- vl_msg_api_send_shmem_nolock (q, (u8 *) & mp);
- unix_shared_memory_queue_unlock (q);
- mp = 0;
- ip46_fib_stats_delay (sm, 0 /* sec */ ,
- STATS_RELEASE_DELAY_NS);
- goto again;
- }
- vl_msg_api_send_shmem_nolock (q, (u8 *) & mp);
- unix_shared_memory_queue_unlock (q);
-
- items_this_message = IP4_FIB_COUNTER_BATCH_SIZE;
- mp = vl_msg_api_alloc_as_if_client
- (sizeof (*mp) +
- items_this_message * sizeof (vl_api_ip4_fib_counter_t));
- mp->_vl_msg_id = ntohs (VL_API_VNET_IP4_FIB_COUNTERS);
- mp->count = 0;
- mp->vrf_id = ntohl (fib->table_id);
- ctrp = (vl_api_ip4_fib_counter_t *) mp->c;
- }
-
- j++;
- if (j < n_nhs)
- {
- n_left = nhs[j].weight;
- vlib_counter_zero (&sum);
- }
- }
- } /* for each (mp or single) adj */
- if (sm->data_structure_lock->release_hint)
- {
- start_at_fib_index = fib - im4->fibs;
- dsunlock (sm);
- ip46_fib_stats_delay (sm, 0 /* sec */ , STATS_RELEASE_DELAY_NS);
- mp->count = 0;
- ctrp = (vl_api_ip4_fib_counter_t *) mp->c;
- goto again;
- }
- } /* vec_foreach (routes) */
+ /* already in net byte order */
+ ctrp->address = r->address.as_u32;
+ ctrp->address_length = r->address_length;
+ ctrp->packets = clib_host_to_net_u64 (c.packets);
+ ctrp->bytes = clib_host_to_net_u64 (c.bytes);
+ mp->count++;
+ ctrp++;
+
+ if (mp->count == items_this_message)
+ {
+ mp->count = htonl (items_this_message);
+ /*
+ * If the main thread's input queue is stuffed,
+ * drop the data structure lock (which the main thread
+ * may want), and take a pause.
+ */
+ unix_shared_memory_queue_lock (q);
+ if (unix_shared_memory_queue_is_full (q))
+ {
+ dsunlock (sm);
+ vl_msg_api_send_shmem_nolock (q, (u8 *) & mp);
+ unix_shared_memory_queue_unlock (q);
+ mp = 0;
+ ip46_fib_stats_delay (sm, 0 /* sec */ ,
+ STATS_RELEASE_DELAY_NS);
+ goto again;
+ }
+ vl_msg_api_send_shmem_nolock (q, (u8 *) & mp);
+ unix_shared_memory_queue_unlock (q);
+
+ items_this_message = IP4_FIB_COUNTER_BATCH_SIZE;
+ mp = vl_msg_api_alloc_as_if_client
+ (sizeof (*mp) +
+ items_this_message * sizeof (vl_api_ip4_fib_counter_t));
+ mp->_vl_msg_id = ntohs (VL_API_VNET_IP4_FIB_COUNTERS);
+ mp->count = 0;
+ mp->vrf_id = ntohl (fib->ft_table_id);
+ ctrp = (vl_api_ip4_fib_counter_t *) mp->c;
+ }
+ } /* for each (mp or single) adj */
+ if (sm->data_structure_lock->release_hint)
+ {
+ start_at_fib_index = fib - im4->fibs;
+ dsunlock (sm);
+ ip46_fib_stats_delay (sm, 0 /* sec */ , STATS_RELEASE_DELAY_NS);
+ mp->count = 0;
+ ctrp = (vl_api_ip4_fib_counter_t *) mp->c;
+ goto again;
+ }
+ } /* vec_foreach (routes) */