zhzh12312312 opened a new pull request, #11578:
URL: https://github.com/apache/rocketmq/pull/11578

   ### Which Issue(s) This PR Fixes
   
   - Fixes #11577
   
   ### Brief Description
   
   `RemotingHelper.ipInCIDR` computed the netmask as `0xFFFFFFFF << (32 - 
netId)`. In Java an `int` shift count is taken modulo 32, so for a `/0` prefix 
(`32 - 0 == 32`) the shift was effectively `<< 0` and produced a mask of `-1`. 
As a result `0.0.0.0/0` matched only `0.0.0.0` and rejected every other 
address, contradicting the meaning of the existing `DEFAULT_CIDR_ALL = 
"0.0.0.0/0"` constant and disagreeing with `IPAddressUtils.isIPInRange`.
   
   This change handles the `/0` prefix explicitly (mask `0`) so a catch-all 
CIDR matches every IPv4 address.
   
   The mask for `/1` .. `/32` is unchanged, and the only in-tree caller 
(`NettyRemotingClient#getProxy`) already short-circuits `DEFAULT_CIDR_ALL` 
before calling `ipInCIDR`, so there is no behaviour change on the existing code 
path.
   
   ### How Did You Test This Change?
   
   - Added `RemotingHelperTest` covering the `/0` case (regression), `/32`, 
`/24`, `/8`, and masking of host bits in the CIDR.
   - `mvn -pl remoting -am -Dtest=RemotingHelperTest -DfailIfNoTests=false 
test` — all tests pass.
   - `mvn -pl remoting checkstyle:check` — passes.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to