Skip to content

Commit

Permalink
cli: set the rules index
Browse files Browse the repository at this point in the history
If rule->index is not set by the front-end (as nftables and iptables
does), all the rules will count packets towards the first entry of the
BPF counters map.
  • Loading branch information
qdeslandes committed Sep 1, 2024
1 parent f44b114 commit b1b7ca1
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/cli/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,17 @@ int main(int argc, char *argv[])
return EXIT_FAILURE;
}

// Set rules indexes
bf_list_foreach (&chains, chain_node) {
struct bf_chain *chain = bf_list_node_get_data(chain_node);
uint32_t index = 0;

bf_list_foreach (&chain->rules, rule_node) {
struct bf_rule *rule = bf_list_node_get_data(rule_node);
rule->index = index++;
}
}

bf_list_foreach (&chains, chain_node) {
struct bf_chain *chain = bf_list_node_get_data(chain_node);
_cleanup_bf_request_ struct bf_request *request = NULL;
Expand Down

0 comments on commit b1b7ca1

Please sign in to comment.