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

JDK-8319382: com/sun/jdi/JdwpAllowTest.java shows failures on AIX if prefixLen of mask is larger than 32 in IPv6 case #16561

Closed
wants to merge 1 commit into from

Conversation

MBaesken
Copy link
Member

@MBaesken MBaesken commented Nov 8, 2023

In parseAllowedMask (file socketTransport.c) , prefixLen of mask is compared with a maxValue (32 for IPv4, 128 otherwise). This fails on AIX if it is larger than 32, because getaddrinfo seems to often (always ?) detect IPv4 family, even for IPv6 addresses, so we take the wrong maxValue.
Probably we have to adjust the allowed maxValue on AIX, or adjust the IPv6 check.

Example:
images/jdk/bin/java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:0,allow=0:0:0:0:0:0:10:0/106
Error in allow option: '106'
ERROR: transport error 103: invalid netmask in allow option
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8319382: com/sun/jdi/JdwpAllowTest.java shows failures on AIX if prefixLen of mask is larger than 32 in IPv6 case (Bug - P4)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/16561/head:pull/16561
$ git checkout pull/16561

Update a local copy of the PR:
$ git checkout pull/16561
$ git pull https://git.openjdk.org/jdk.git pull/16561/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 16561

View PR using the GUI difftool:
$ git pr show -t 16561

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/16561.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 8, 2023

👋 Welcome back mbaesken! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label Nov 8, 2023
@openjdk
Copy link

openjdk bot commented Nov 8, 2023

@MBaesken The following label will be automatically applied to this pull request:

  • serviceability

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the serviceability serviceability-dev@openjdk.org label Nov 8, 2023
@mlbridge
Copy link

mlbridge bot commented Nov 8, 2023

Webrevs

Comment on lines +463 to +468
// on AIX we might get IPv6 detected (by getaddrinfo) as IPv4,
// so the default maxValue does not always work
#if defined(_AIX)
maxValue = 128;
#endif

Copy link
Contributor

Choose a reason for hiding this comment

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

IIUC, this code would work for any port, but is only required for AIX. And since it is a hack to work around an AIX issue, you didn't want to subject all ports to it. The downside of this change is that it will cause the option parsing code to not properly produce an error if an IPv4 mask prefix between 32 and 128 is given.

Copy link
Member Author

Choose a reason for hiding this comment

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

The downside of this change is that it will cause the option parsing code to not properly produce an error if an IPv4 mask prefix between 32 and 128 is given.

Yes this is true; maybe we should not unconditionally increase the maxValue on AIX .

@alexmenkov
Copy link

The fix looks wrong.
The problem is not with parsing of the prefix len, but with parsing of the address itself (parseAllowedAddr function).
Note that parseAllowedAddr converts returned IPv4 addresses to mapped IPv6 and in the example provided it won't be expected ::10:0, so the "allow" logic will be broken.
I think the issue need some research on the affected systems:

  • if getaddrinfo returns AF_INET, then what is returned in ai_addr field? it must be valid IPv4 address (which can be used for connect());
  • does getaddrinfo return a single address? (parseAllowedAddr assumes so, but maybe that's wrong in the case)

@MBaesken
Copy link
Member Author

MBaesken commented Nov 9, 2023

does getaddrinfo return a single address? (parseAllowedAddr assumes so, but maybe that's wrong in the case)

From what I see on AIX, only one entry is returned in the results struct of the getaddrinfo call.

@MBaesken
Copy link
Member Author

A colleague contacted IBM about the different behavior of getaddrinfo on AIX (compared to Linux/macOS); maybe we have to adjust the result of the getaddrinfo call on AIX.

@bridgekeeper
Copy link

bridgekeeper bot commented Dec 11, 2023

@MBaesken This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@MBaesken
Copy link
Member Author

A colleague contacted IBM about the different behavior of getaddrinfo on AIX (compared to Linux/macOS); maybe we have to adjust the result of the getaddrinfo call on AIX.

Haven't heard from them so far, hopefully we get an update soon about the behavior of getaddrinfo on AIX .

@alexmenkov
Copy link

@MBaesken Just a thought: parseAllowedAddr() needs to parse only numeric addresses. getaddrinfo was used to handle both IPv4 and IPv6 by a single call, but maybe it would be better to reimplement parseAllowedAddr to do 2 inet_pton calls (for AF_INET and AF_INET6)

@MBaesken
Copy link
Member Author

@MBaesken Just a thought: parseAllowedAddr() needs to parse only numeric addresses. getaddrinfo was used to handle both IPv4 and IPv6 by a single call, but maybe it would be better to reimplement parseAllowedAddr to do 2 inet_pton calls (for AF_INET and AF_INET6)

Hi Alex, this seems to work (for AIX, and also for the other OpenJDK platforms) .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rfr Pull request is ready for review serviceability serviceability-dev@openjdk.org
3 participants