fix: bit shifting for 64bit bridge port mask #56
+1
−1
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.
Problem
During bridge input processing, there is conditional logic to check if the bridge interface itself should receive the packet (ie. forward to CPU). The existing bitwise logic fails when
BRIDGEIF_MAX_PORTS
>= 32 because the literal1
is implicitly a 32-bit integer. When shifting this value byBRIDGEIF_MAX_PORTS
bits (which can be up to 63), it triggers undefined behaviour due to the shift count exceeding the width of the type.Fix
Explicitly cast
1
tobridgeif_portmask_t
to ensure that the shift operation is performed on a 64-bit value when necessary. This works because whenBRIDGEIF_MAX_PORTS >= 32
,bridgeif_portmask_t
is defined as au64_t
type:lwip/src/include/netif/bridgeif.h
Lines 51 to 61 in 554e104