Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

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-toolsAssignee: Marcelo Ricardo Leitner <mleitner>
Status: CLOSED DUPLICATE QA Contact: Red Hat Kernel QE team <kernel-qe>
Severity: low Docs Contact:
Priority: low    
Version: 7.0CC: kzhang, mleitner, rkhan
Target Milestone: rcKeywords: 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    

Description Stuart Auchterlonie 2015-03-27 16:04:21 UTC
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

Comment 1 Marcelo Ricardo Leitner 2015-09-16 19:05:07 UTC
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.

Comment 2 Marcelo Ricardo Leitner 2015-09-16 19:06:43 UTC
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.

Comment 3 Marcelo Ricardo Leitner 2015-09-16 19:08:37 UTC
$ 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..

Comment 4 Marcelo Ricardo Leitner 2015-11-05 18:31:31 UTC
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.

Comment 5 Marcelo Ricardo Leitner 2015-11-11 12:20:54 UTC
Upstream fix: https://github.com/sctp/lksctp-tools/commit/d4f91efac21d91fce2cc49f292705a5a78a7f991

I'll wait for 7.3 to open to backport it..

Comment 6 Marcelo Ricardo Leitner 2015-11-18 18:42:58 UTC
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 ***