penfree opened a new issue #6471: URL: https://github.com/apache/incubator-doris/issues/6471
**Describe the bug** priority_networks cannot specify cidr with subnet of 31/32, like 192.168.1.128/32 or 192.168.1.128/31 **To Reproduce** 1. in fe.conf, set priority_networks = 192.168.1.128/32 # the real ip of host 2. start fe and you can find something like this in the log, because 192.168.1.128 is not contained by 192.168.1.128/32 in doris 2021-08-19 03:15:35,113 INFO (main|1) [FrontendOptions.init():89] local address: /127.0.0.1. **Expected behavior** when set priority_networks = 192.168.1.128/32, the address chosen should be 192.168.1.128 **Additional context** the problem is due to fe/fe-core/src/main/java/org/apache/doris/common/CIDR.java, low() and high() determine the first and last address of cidr, but when the subnet is 32, they all return 0. ```java private int low() { int network = (address & netmask); return broadcastLong() - networkLong() > 1 ? (network + 1) : 0; } private int high() { int network = (address & netmask); int broadcast = network | ~(netmask); return broadcastLong() - networkLong() > 1 ? (broadcast - 1) : 0; } private boolean contains(int ipInt) { long addrLong = ipInt & UNSIGNED_INT_MASK; long lowLong = low() & UNSIGNED_INT_MASK; long highLong = high() & UNSIGNED_INT_MASK; return addrLong >= lowLong && addrLong <= highLong; } ``` solution: there is no need to discard broadcast address and the network address from cidr, so the contains method should be ```java private boolean contains(int ipInt) { long addrLong = ipInt & UNSIGNED_INT_MASK; return addrLong >= networkLong() && addrLong <= broadcastLong(); } ``` -- 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: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org