Skip to content

Commit

Permalink
cgen: dump the codegen after it has been updated
Browse files Browse the repository at this point in the history
On bf_cgen_update(), the codegen is dumped (if verbose is enabled) very
early in the function, meaning the old (to be replaced) chain is
printed.

Dump the codegen at the end of the function, when the chain replacement
occurred, so the new chain is printed.
  • Loading branch information
qdeslandes committed Jan 31, 2025
1 parent bfe3b5e commit 4ec5f07
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/bpfilter/cgen/cgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,6 @@ int bf_cgen_update(struct bf_cgen *cgen, struct bf_chain **new_chain)

bf_assert(cgen && new_chain);

if (bf_opts_is_verbose(BF_VERBOSE_DEBUG))
bf_cgen_dump(cgen, EMPTY_PREFIX);

r = bf_program_new(&new_prog, (*new_chain)->hook, cgen->front, *new_chain);
if (r < 0)
return bf_err_r(r, "failed to create a new bf_program");
Expand All @@ -264,5 +261,8 @@ int bf_cgen_update(struct bf_cgen *cgen, struct bf_chain **new_chain)
bf_swap(cgen->program, new_prog);
bf_swap(cgen->chain, *new_chain);

if (bf_opts_is_verbose(BF_VERBOSE_DEBUG))
bf_cgen_dump(cgen, EMPTY_PREFIX);

return 0;
}

0 comments on commit 4ec5f07

Please sign in to comment.