Repository navigation
etas: reject extended frames for a filter with "extended": False - #2177
Merged
zariiii9003 merged 1 commit intoDec 1, 2026
Merged
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary of Changes
This pull request fixes
EtasBus._apply_filtersincan/interfaces/etas/__init__.pyso receive filters with"extended": Falsereject extended (29-bit) frames.Previously, an ETAS receive filter such as
{"can_id": 0x123, "can_mask": 0x7FF, "extended": False}still let extended frames through when their ID matchedcan_idandcan_mask. For example, an extended frame with ID0x123or0x18FF0123(0x18FF0123 & 0x7FF == 0x123) passed through. TheBusABC.set_filtersdocstring states that whenextendedis set, a filter matches only messages where<received_is_extended> == extended.BusABC._matches_filtersimplements that rule.EtasBus._recv_internalreturns(msg, True), meaning the frames are already filtered, soBusABC.recvdoes not run_matches_filters. The BOA filter installed by_apply_filtersis the only filter._apply_filterspreviously checkedif filter_.get("extended"):before settingOCI_CAN_MSG_FLAG_EXTENDEDinflagsValueandflagsMask. For"extended": False, the extended bit was left out offlagsMask, so the BOA filter ignored the extended flag. With this fix, the extended bit goes intoflagsMaskwhenever"extended"is present in the filter, and it goes intoflagsValueonly when the value is true. This matches howpack_filtersincan/interfaces/socketcan/utils.pyhandlesCAN_EFF_FLAG. Filters without"extended"and filters with"extended": Trueinstall the exact same values as before.A new test,
test_extended_false_filter_rejects_extended_frames, intest/test_etas.pyuses the existing stub BOA library and expects the installed filter(0x123, 0x7FF, 0, OCI_CAN_MSG_FLAG_SELFRECEPTION | OCI_CAN_MSG_FLAG_EXTENDED). Onmain, it fails with[(291, 2047, 0, 4)] != [(291, 2047, 0, 5)]. With this fix, all four tests intest/test_etas.pypass. They also pass with agc.collect()forced before the stub reads the filters (the PyPy case from #2171).A script built an
EtasBusthrough the same stub for five filters: standard0x123/0x7FFwithextendedabsent,True, orFalse, and0x18FF0000/0x1FFF0000withextendedTrueorFalse. It applied BOA's value/mask rule to five messages and compared each verdict againstBusABC._matches_filters. Onmain, 3 of 25 verdicts differ, all withextended=Falseand an extended frame:With this fix, 0 differ.
This pull request adds the news fragment
doc/changelog.d/2177.fixed.rst.Related Issues / Pull Requests
This pull request follows up on #2167 and #2171. The
"extended": Falsecase was noted in Additional Notes as a separate issue. There is no open issue for it.Type of Change
Checklist
tox).Additional Notes
A filter with
"extended": Falseon ETAS now stops receiving extended frames, which is what theBusABC.set_filtersdocstring promises.These checks were not run on ETAS hardware; the BOA libraries are Windows-only. The checks run at the OCI call boundary through the stub.