Closed dpino closed 9 years ago
Hum, interesting. I guess we lose then the ability to compare the integer result to libpcap, and the ability to use BPF for non-packet-filtering purposes, but it's probably a good idea for the packet-filtering use case to make this change. LGTM.
There's an inconsistency between the value returned in the BPF pipeline if the function is compiled directly or if it's printed as source code and later loaded. In the first case, the function returns a boolean:
In the second case, the function returns an integer. The user of this function must remember to compared the result of this function against zero.
This creates an inconsistency while running
pflua-match
, as it doesn't make a difference between whether the function was compiled or was loaded from a file. For instance:One solution is to tweak
pflua-match
and check whether the result returned is of type integer, and in that case compare against zero. Another solution, is to modify the returned function compiled by the BPF pipeline, so it returns true or false directly. I prefer the second solution, so it's consistent with the Lua pipeline and users don't have to remember this fact.