cache_ban: Forward compatibility for the binary ban representation #4289
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Our ban expressions (like
obj.age > 20s
) are represented in a binary format (see top ofcache_ban.h
) which allows for forward compatibility, yet at the respective places we currently just trigger an assertion failure if we hit an unknown argument or operator code.This commit brings forward compatibility such that, when bans are loaded from persistent storage into older code which does not yet support newly introduced binary codes, we no longer panic.
Ban evaluation:
For bans, evaluating an expression to
true
is always "correct" in that the cache would not deliver banned content. It might cause objects to be removed from cache, but that is at least not incorrect. So the fail safe action this code takes is to always evaluate unknown ban expressions to true.CLI
ban.list
:For unsupported ban expressions, the unknown argument or operator codes are formatted as
(0x%02x)
with the stringUNSUPPORTED
as the user-specified argument. For example:(note that here the operator
>
is supported and printed as such, and the ban contains one unsupported and one supported expression)Logging:
For each unsupported argument or operator code, an
Error
VSL is output exactly once to vxid 0.Statistics:
Whenever unsupported argument or operator codes are encountered, the newly added counters
MAIN.bans_inval_arg1
andMAIN.bans_inval_oper
are incremented, respectively.Fixes #4288