Bug 207838

Summary: Perl getsockopt() on SCTP sockets doesn't work
Product: [Fedora] Fedora Reporter: Pawel Politowicz <pablo_p>
Component: perlAssignee: Neil Horman <nhorman>
Status: CLOSED NEXTRELEASE QA Contact: David Lawrence <dkl>
Severity: medium Docs Contact:
Priority: medium    
Version: 5CC: perl-devel
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2007-06-19 20:18:26 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Pawel Politowicz 2006-09-24 10:34:47 UTC
Description of problem:

Perl getsockopt() on SCTP socket does not work. Following perl code:
------------------------------------------
use strict;
use IO::Socket;

## create sctp socket
my $sock = new IO::Socket::INET(
        Proto => 132,
        Type  => SOCK_STREAM
) or die "Cannot create sctp socket";

## read rto data
my $i = getsockopt($sock, 132, 1);

#print rto data
print join("\n", unpack("I i*", $i));
------------------------------------------

Works on Solaris10, but not on (my) Linux. I checked C getsockopt, and code like
this:

ret  = getsockopt(sock , SOL_SCTP, SCTP_RTOINFO, &sctp_info, &len);

works OK only if len is initially set to sizeof(struct sctp_rtoinfo), which is
not what manual says:
-------------------------------------------
> man getsockopt
...
       The  parameters  optval and optlen are used to access option values for
       setsockopt().  For getsockopt() they identify a  buffer  in  which  the
       value  for  the  requested  option(s) are to be returned.  For getsock-
       opt(), optlen is a value-result  parameter,  initially  containing  the
       size  of  the  buffer  pointed  to by optval, and modified on return to
       indicate the actual size of the value returned.  If no option value  is
       to be supplied or returned, optval may be NULL.
...
-------------------------------------------

Above applies to all SCTP structures available via get/setsockopt.


Version-Release number of selected component (if applicable):
perl-5.8.8-5
glibc-2.4-11
kernel-2.6.17-1.2187_FC5

How reproducible:
every time

Steps to Reproduce:
1. run perl code from description
2. nothing is displayed
  
Actual results:
nothing is displayed

Expected results:
sctp socket rto into (4 parameters)

Additional info:
SELinux is disabled.

Comment 1 Neil Horman 2007-06-11 14:42:22 UTC
This seems like a kernel bug to me.  We're checking all our getsockopt values
for != sizeof(option) rather than for < sizeof(option), and we should be
returning ENOBUFS, rather than EINVAL (or silently truncating the result as
POSIX indicates).