-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add ip_subnet_max/min [5/n] #11515
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for meta-velox canceled.
|
This pull request was exported from Phabricator. Differential Revision: D65833249 |
Summary: Add ip_subnet and ip_subnetmax. Split from facebookincubator#11407 Differential Revision: D65833249
5198043
to
fb57c78
Compare
This pull request was exported from Phabricator. Differential Revision: D65833249 |
Summary: Add ip_subnet and ip_subnetmax. Split from facebookincubator#11407 Differential Revision: D65833249
fb57c78
to
72f28a7
Compare
This pull request was exported from Phabricator. Differential Revision: D65833249 |
Summary: Add ip_subnet and ip_subnetmax. Split from facebookincubator#11407 Differential Revision: D65833249
72f28a7
to
51361cd
Compare
This pull request was exported from Phabricator. Differential Revision: D65833249 |
51361cd
to
8216001
Compare
Summary: Add ip_subnet and ip_subnetmax. Split from facebookincubator#11407 Differential Revision: D65833249
This pull request was exported from Phabricator. Differential Revision: D65833249 |
8216001
to
4cecdb3
Compare
Summary: Add ip_subnet and ip_subnetmax. Split from facebookincubator#11407 Differential Revision: D65833249
This pull request was exported from Phabricator. Differential Revision: D65833249 |
Summary: Add ip_subnet and ip_subnetmax. Split from facebookincubator#11407 Differential Revision: D65833249
Summary: Add ip_subnet and ip_subnetmax. Split from facebookincubator#11407 Differential Revision: D65833249
Summary: Add ip_subnet and ip_subnetmax. Split from facebookincubator#11407 Differential Revision: D65833249
4cecdb3
to
6e6fa66
Compare
This pull request was exported from Phabricator. Differential Revision: D65833249 |
6e6fa66
to
69aaeb7
Compare
Summary: Add ip_subnet and ip_subnetmax. Split from facebookincubator#11407 Differential Revision: D65833249
This pull request was exported from Phabricator. Differential Revision: D65833249 |
Summary: Add ip_subnet and ip_subnetmax. Split from facebookincubator#11407 Differential Revision: D65833249
cc @mohsaka |
b4d473c
to
a1284e9
Compare
Summary: Add ip_subnet and ip_subnetmax. Split from facebookincubator#11407 Differential Revision: D65833249
This pull request was exported from Phabricator. Differential Revision: D65833249 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
a1284e9
to
aacbe26
Compare
Summary: Add ip_subnet and ip_subnetmax. Split from facebookincubator#11407 Differential Revision: D65833249
This pull request was exported from Phabricator. Differential Revision: D65833249 |
Summary: Add ip_subnet and ip_subnetmax. Split from facebookincubator#11407 Differential Revision: D65833249
aacbe26
to
37281a0
Compare
This pull request was exported from Phabricator. Differential Revision: D65833249 |
Summary: Add ip_subnet and ip_subnetmax. Split from facebookincubator#11407 Differential Revision: D65833249
37281a0
to
751d03f
Compare
This pull request was exported from Phabricator. Differential Revision: D65833249 |
Summary: Add ip_subnet and ip_subnetmax. Split from facebookincubator#11407 Differential Revision: D65833249
751d03f
to
7b49216
Compare
This pull request was exported from Phabricator. Differential Revision: D65833249 |
Summary: Add ip_subnet and ip_subnetmax. Split from facebookincubator#11407 Differential Revision: D65833249
7b49216
to
8b8ad76
Compare
This pull request was exported from Phabricator. Differential Revision: D65833249 |
Summary: Add ip_subnet and ip_subnetmax. Split from facebookincubator#11407 Differential Revision: D65833249
8b8ad76
to
4995804
Compare
This pull request was exported from Phabricator. Differential Revision: D65833249 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yuandagits thanks for the change % minors
|
||
private: | ||
static int128_t getIPSubnetMax(int128_t ip, uint8_t prefix) { | ||
auto tryIsIpv4 = ipaddress::tryIpPrefixLengthFromIPAddressType(ip); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/tryIsIpv4/tryIpv4/
auto tryIsIpv4 = ipaddress::tryIpPrefixLengthFromIPAddressType(ip); | ||
// This check should never fail because we're taking a pre-existing | ||
// IPPrefix. | ||
VELOX_DCHECK(tryIsIpv4.hasValue()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add VELOX_CHECK here and it is not on hotpath.
} | ||
|
||
// Special case: Overflow to all 0 subtracting 1 does not work. | ||
if (prefix == 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we check prefix first or ipv4 allows 0 prefix for subnet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ipv4 is okay because ip |= (mask << (ipaddress::kIPV4Bits - prefix)) - 1;
won't overflow where as for ipv6 it will
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am curious in protocol, does ipv4 allows a subnet with zero prefix? The prefix here is number of bits used for subnet? Thanks!
Summary: Add ip_subnet and ip_subnetmax. Split from facebookincubator#11407 Differential Revision: D65833249
4995804
to
2ba025d
Compare
This pull request was exported from Phabricator. Differential Revision: D65833249 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yuandagits LGTM. Thanks for the update!
} | ||
|
||
// Special case: Overflow to all 0 subtracting 1 does not work. | ||
if (prefix == 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am curious in protocol, does ipv4 allows a subnet with zero prefix? The prefix here is number of bits used for subnet? Thanks!
Summary:
Add ip_subnet and ip_subnetmax.
Split from #11407
Differential Revision: D65833249