Skip to content

Conversation

infrastation
Copy link
Member

Yet another unfinished piece from my working copy. This one looks mostly complete, but I could not quickly verify that the new revision works as expected in every case. Requires a bit more work.

The for loop that rewrites the filter program in fix_program() does not
need to test handlep->cooked at every iteration because the value stays
the same.  Also in this context handlep->cooked == 1 means the handle is
either DLT_LINUX_SLL or DLT_LINUX_SLL2, and fix_offset() almost entirely
is two independent functions multiplexed on these two DLTs, so it is two
separate cases disguised as one.

To make this code easier to follow, split fix_offset() into one function
for DLT_LINUX_SLL and another for DLT_LINUX_SLL2, factor the "cooked"
for loop out of fix_program() into a new fix_cooked() function and
provide the latter with a pointer to one of the new two instruction
fixer functions.  Also in fix_cooked() rejig the switch block cases to
spell only the valid combinations of BPF instruction class and mode.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant