Bug 1206650
| Summary: | lksctp-tools: sctp_test fails to connect via ipv6 socket | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 7 | Reporter: | Stuart Auchterlonie <sauchter> |
| Component: | lksctp-tools | Assignee: | Marcelo Ricardo Leitner <mleitner> |
| Status: | CLOSED DUPLICATE | QA Contact: | Red Hat Kernel QE team <kernel-qe> |
| Severity: | low | Docs Contact: | |
| Priority: | low | ||
| Version: | 7.0 | CC: | kzhang, mleitner, rkhan |
| Target Milestone: | rc | Keywords: | Patch |
| Target Release: | --- | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | Bug Fix | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2015-11-18 18:42:58 UTC | Type: | Bug |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
| Bug Depends On: | |||
| Bug Blocks: | 1203710 | ||
It's because 'localhost' is resolving to :: instead of ::1 :
$ sctp_test -H :: -P 2223 -h :: -p 2222 -s
remote:addr=::, port=EtherNet/IP-1, family=10
local:addr=::, port=rockwell-csp2, family=10
seed = 1442430120
Starting tests...
socket(SOCK_SEQPACKET, IPPROTO_SCTP) -> sk=3
bind(sk=3, [a:::,p:rockwell-csp2]) -- attempt 1/10
Client: Sending packets.(1/10)
sendmsg(sk=3, assoc=0) 1 bytes.
SNDRCV(stream=0 flags=0x1 ppid=713825665
*** sendmsg: Invalid argument ***
$ sctp_test -H :: -P 2223 -h ::1 -p 2222 -s | head
remote:addr=::1, port=EtherNet/IP-1, family=10
local:addr=::, port=rockwell-csp2, family=10
seed = 1442430153
Starting tests...
socket(SOCK_SEQPACKET, IPPROTO_SCTP) -> sk=3
bind(sk=3, [a:::,p:rockwell-csp2]) -- attempt 1/10
Client: Sending packets.(1/10)
sendmsg(sk=3, assoc=0) 1 bytes.
SNDRCV(stream=0 flags=0x1 ppid=1404335244
and in your strace:
19970 15:43:02 sendmsg(3, {msg_name(128)={sa_family=AF_INET6,
sin6_port=htons(2222), inet_pton(AF_INET6, "::", &sin6_addr), sin6_flowinfo=0,
^^^^
Sounds like an issue with sctp_test or glibc, because my /etc/hosts has:
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
sctp is thus rejecting it at sctp_v6_addr_valid(), at the check:
/* Is this a non-unicast address */
if (!(ret & IPV6_ADDR_UNICAST))
return 0;
as this is not a unicast address and cannot be used for destination.
Erf, the head truncated too much. This sould cover it better:
$ sctp_test -H :: -P 2223 -h ::1 -p 2222 -s | head -n15
remote:addr=::1, port=EtherNet/IP-1, family=10
local:addr=::, port=rockwell-csp2, family=10
seed = 1442430365
Starting tests...
socket(SOCK_SEQPACKET, IPPROTO_SCTP) -> sk=3
bind(sk=3, [a:::,p:rockwell-csp2]) -- attempt 1/10
Client: Sending packets.(1/10)
sendmsg(sk=3, assoc=0) 1 bytes.
SNDRCV(stream=0 flags=0x1 ppid=294682043
sendmsg(sk=3, assoc=0) 1 bytes.
SNDRCV(stream=0 flags=0x1 ppid=1698865507
sendmsg(sk=3, assoc=0) 1 bytes.
SNDRCV(stream=0 flags=0x1 ppid=1654707877
sendmsg(sk=3, assoc=0) 1 bytes.
$ sudo strace -e sendto ping6 localhost
PING localhost(localhost) 56 data bytes
sendto(3, "\200\0\0\0\10l\0\1\3\276\371U\0\0\0\0q\347\7\0\0\0\0\0\20\21\22\23\24\25\26\27".
.., 64, 0, {sa_family=AF_INET6, sin6_port=htons(58), inet_pton(AF_INET6, "::1",
^^^^^
&sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, 28) = 64
glibc should be fine..
It's an issue in the test application:
error = getaddrinfo(remote_host, 0, NULL, &res);
if (error) {
printf("%s.\n", gai_strerror(error));
usage(argv[0]);
exit(1);
}
switch (res->ai_family) {
...
case AF_INET6:
t_addr6 = (struct sockaddr_in6 *)&s_rem;
if (interface)
t_addr6->sin6_scope_id =
if_nametoindex(interface);
t_addr6->sin6_family = AF_INET6;
t_addr6->sin6_port = htons(remote_port);
inet_pton(AF_INET6, remote_host,
&t_addr6->sin6_addr);
r_len = sizeof (struct sockaddr_in6);
#ifdef __FreeBSD__
t_addr6->sin6_len = r_len;
#endif
break;
}
Note how it just ignores the value from getaddrinfo and tries to use inet_pton() to convert the parameter to the binary format, while it should be just copying it from res.ai_addr.
Same happens for ipv4, but glibc handles it nicely in there.
As it is, you just can't use hostnames if you want to use ipv6 addresses.
Upstream fix: https://github.com/sctp/lksctp-tools/commit/d4f91efac21d91fce2cc49f292705a5a78a7f991 I'll wait for 7.3 to open to backport it.. I'm closing this bug as a dup of bz1283339 as this last will do an update to the package. If you need a z-stream of this fix, please request it against this one. Then only this fix will get backported. *** This bug has been marked as a duplicate of bug 1283339 *** |
Description of problem: When trying to run sctp_test and connect to an endpoint with an ipv6 address it fails Version-Release number of selected component (if applicable): lksctp-tools-1.0.13-3.el7.x86_64 How reproducible: 100% Steps to Reproduce: 1. Start server `/usr/bin/sctp_status -H localhost -P 2222 -l` 2. Start client `/usr/bin/sctp_test -H localhost -P 2223 -h localhost -p 2222 -s` 3. Actual results: remote:addr=::, port=EtherNet/IP-1, family=10 local:addr=::, port=rockwell-csp2, family=10 seed = 1427472111 Starting tests... socket(SOCK_SEQPACKET, IPPROTO_SCTP) -> sk=3 bind(sk=3, [a:::,p:rockwell-csp2]) -- attempt 1/10 Client: Sending packets.(1/10) sendmsg(sk=3, assoc=0) 1 bytes. SNDRCV(stream=0 flags=0x1 ppid=1903553113 *** sendmsg: Invalid argument *** Expected results: Test completes. Additional info: The above test will work if the command line is modified to /usr/bin/sctp_test -H localhost -P 2223 -h 127.0.0.1 -p 2222 -s to force sctp_test to connect via ipv4. Performing an strace on the client sctp_test shows the following 19970 15:43:02 sendmsg(3, {msg_name(128)={sa_family=AF_INET6, sin6_port=htons(2222), inet_pton(AF_INET6, "::", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, msg_iov(1)=[{"\0", 1}], msg_controllen=48, {cmsg_len=48, cmsg_level=0x84 /* SOL_??? */, cmsg_type=, ...}, msg_flags=0}, MSG_WAITALL) = -1 EINVAL (Invalid argument) <0.000013> I've also pulled the latest sources from git://github.com/borkmann/lksctp-tools.git and the issue exists here too