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

Problem: can't unbind with bound addr with IPv6 #1902

Merged
merged 3 commits into from
Apr 18, 2016

Conversation

bluca
Copy link
Member

@bluca bluca commented Apr 18, 2016

Solution: un-break un-binding a socket with the same endpoint string that was used to bind it when IPv6 is enabled. The breakage was caused by using the actual last_endpoint as a key instead of the string passed by the user, which is necessary in the wildcard case. But it broke the normal case with IPv6, since even if the address is an IPv4 one it will be saved in IPv6 format, so it doesn't match anymore. This is the culprit: 09e7416

My solution is a liiitle bit of a hack - basically I try to use the used-provided endpoint string and resolve it, just like it's used in connect/bind case, and see if that succeeds before giving up. At least it should be future-proof, and if more changes are done to the connect/bind they should be picked up in the unbind/disconnect. And the existing API for wildcard sockets is maintained, nothing is broken.

Also added a bunch of tests for various combinations of TCP sockets endpoints. Note that Travis on Precise (legacy) or Trusty does not support IPv6, so I added a test run on the container-based environment which is the only one that has a loopback interface with ::1 bound on it, so IPv6 test cases can run there. Note that I can't test this on Windows - I think it should work as I've used the same options as in existing part of the library.

Fixes zeromq/zeromq4-1#114

@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 74.767% when pulling 89592cf on bluca:zmq_unbind_api_breakage into 8d49650 on zeromq:master.

Solution: add helper function is_ipv6_available to testutil.hpp to
test if IPv6 is available on the building platform.
This function will try to open and bind a socket to ::1:*, as it's
the ultimate way of knowing if, at least on the loopback, IPv6 is
enabled.
Solution: add one test run in a docket container environment, which
is currently the only environment where it's possibile to bind a
socket to ::1.
Solution: try to resolve the TCP endpoint passed by the user in the
zmq_unbind call before giving up, if it doesn't match.
This fixes a breakage in the API, where after a call to
zmq_bind(s, "tcp://127.0.0.1:9999") with IPv6 enabled on s would
result in the call to zmq_unbind(s, "tcp://127.0.0.1:9999") failing.
Add more test cases to increase coverage on all combinations of TCP
endpoints.
@coveralls
Copy link

Coverage Status

Coverage increased (+0.02%) to 74.76% when pulling c8211bf on bluca:zmq_unbind_api_breakage into 8d49650 on zeromq:master.

@bluca
Copy link
Member Author

bluca commented Apr 18, 2016

Backported to 4.1: zeromq/zeromq4-1#118

@bluca bluca deleted the zmq_unbind_api_breakage branch April 18, 2016 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Problem: API compatibility broken between 4.1.0 and 4.1.1+
3 participants