[BUG] Fixed PKTINFO case that was failing for IPv4+IPv6 bound sockets #2630
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The problem detected while fixing #2608 and handling of the dual-IP address binding cases.
The problem:
The CMSG should be provided only per requested information, however in case of dual-bound sockets (IPv4 + IPv6), which would be used in case when the listener has bound to "::" with IPV6_V6ONLY option 0 (which means binding to both IPv4 and IPv6 wildcards) will effectively have set both IPPROTO_IP/IP_PKTINFO and IPPROTO_IPV6/IPV6_RECVPKTINFO flags set and in consequence both IPv4 and IPv6 pktinfo message will be provided with
recvmsg
call. The problem was that the space reserved for filling in this message was set as the one for only IPv4 or IPv6. The fix reserved enough space to fill BOTH IPv4 and IPv6 pktinfo cmsg at once.Besides, there is added also an enhanced diagnostics where the problem has been detected: the flags set back on the returned data are parsed. This happens only for POSIX systems because Windows uses
WSARecvFrom
, which doesn't report these flags.