Skip to content
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

Support IPv6 in in_private_net function, reduce noise on errors #157

Merged
merged 3 commits into from
Oct 14, 2020

Conversation

kroepke
Copy link
Member

@kroepke kroepke commented Mar 23, 2020

The in_private_net function now supports unique local addresses in IPv6 (entire FC00::/7 subnet)

When something else than an IP address is passed in, the function is now less chatty and does not log the stacktrace anymore. For IP addresses it should never log anything.

fixes #156
fixes Graylog2/graylog2-server#4624
related to #33

@dennisoelkers
Copy link
Member

/rebase

extended the ip subnet check to ignore all IPv6 addresses be returning "false" for all of them, even unique local addresses
subnet check is not faster
only non-IP addresses will lead to a log message now, IPv6 checks will be silent

fixes #156
fixes Graylog2/graylog2-server#4624
related to #33
Copy link
Contributor

@mpfz0r mpfz0r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see inline comments

if(!InetAddresses.isInetAddress(ip)) {
InetAddress inetAddress = InetAddresses.forString(ip);
if (inetAddress instanceof Inet6Address) {
// we don't deal with IPv6 unique local addresses currently.
return false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we should be doing this, since it changes the behavior of the lookup function.
If we can't or won't answer the question if a v6 address is private, we shouldn't return a boolean value.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about we return a boxed Boolean here, and keep returning null for v6 addresses?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

null could be an option, but I'd like to avoid doing it if possible.
An alternative is to use https://www.rfc-editor.org/rfc/rfc4193.txt ranges (FC00::/7), which I think is technically correct, but probably rarely used in practice.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's what isSiteLocalAddress would be doing for v6. But I'm wondering if it wouldn't be more practical to also include link local addresses fe80::/10 as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think link-local addresses are out of scope for this function: the original version also didn't consider link-local IPv4 address, because they shouldn't be routed anyway.

For the purposes of this function, I'll now update the PR to include the unique local addresses in IPv6 and properly return true for those.

@kroepke kroepke changed the title reduce error log noise by suppressing the stacktrace Support IPv6 in is_private_net function, reduce noise on errors Oct 9, 2020
@kroepke kroepke requested a review from mpfz0r October 9, 2020 11:42
@kroepke
Copy link
Member Author

kroepke commented Oct 9, 2020

Updated the description and code. Please have another look.

@kroepke kroepke changed the title Support IPv6 in is_private_net function, reduce noise on errors Support IPv6 in in_private_net function, reduce noise on errors Oct 9, 2020
Copy link
Contributor

@mpfz0r mpfz0r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@mpfz0r mpfz0r merged commit 53b8a33 into master Oct 14, 2020
@mpfz0r mpfz0r deleted the issue-156 branch October 14, 2020 13:35
@mpfz0r
Copy link
Contributor

mpfz0r commented Oct 14, 2020

@kroepke do we still want a 3.3 backport of this?

@kroepke
Copy link
Member Author

kroepke commented Oct 14, 2020

I guess it doesn't hurt to backport it, in case we do another release, yes.
Probably wouldn't release 3.3.9 because of this, but hey

@mpfz0r
Copy link
Contributor

mpfz0r commented Oct 14, 2020

ok, i'll update my existing backport pr then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

reduce logs by in_private_net with ipv6 Pipeline function "in_private_net" cannot parse IPV6
3 participants