Ensure worker-local fw_state reflects cleared global firewall state #250
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.
The clearFWState() function clears global firewall state by invalidating all entries in the fw4_state and fw6_state hashtables via the clear() method. However, the worker-local fw_state, which caches firewall states for each worker, was not being updated to reflect these cleared entries. This led to inconsistencies where stale firewall state entries remained in the worker's fw_state cache, even though they had been cleared globally.
The issue arose because the handle_acl_gc() function only removed entries from fw_state based on timeout conditions. Entries that were invalidated by clearFWState() were skipped during garbage collection, as gc() only processes valid entries.
Updated handle_acl_gc() to explicitly check for invalidated entries (i.e., entries where the valid_mask has been cleared) during the gc() process. When such invalid entries are encountered, they are now added to fw_state_remove_stack, ensuring they are removed from the worker's fw_state cache.