Bug 7665 - getsockopt(IPV6_*CAST_HOPS) returns -1
Summary: getsockopt(IPV6_*CAST_HOPS) returns -1
Status: CLOSED PATCH_ALREADY_AVAILABLE
Alias: None
Product: Networking
Classification: Unclassified
Component: IPV6 (show other bugs)
Hardware: i386 Linux
: P2 normal
Assignee: Hideaki YOSHIFUJI
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-12-11 07:13 UTC by R
Modified: 2007-01-14 10:52 UTC (History)
0 users

See Also:
Kernel Version: 2.6.19
Subsystem:
Regression: ---
Bisected commit-id:


Attachments

Description R 2006-12-11 07:13:59 UTC
Most recent kernel where this bug did *NOT* occur: N/A
Distribution: Debian Sid
Hardware Environment: i386
Software Environment: glibc 2.3.6
Problem Description:

Where fd is a socket (datagram or raw) with IPv6 protocol family,
getsockopt(fd, IPPROTO_IPV6, IPV6_UNICAST_HOPS, ...) succeeds, but the returned 
hop limit is -1. connect()'ing the socket first does not solve the problem.

Same problem with IPV6_MULTICAST_HOPS.

Steps to reproduce:

Compile and run the following test case:

#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>

int main (void)
{
        int fd, val;
        socklen_t len = sizeof (val);
        struct sockaddr_in6 addr;

        memset (&addr, 0, sizeof (addr));
        fd = socket (AF_INET6, SOCK_RAW, IPPROTO_UDP);
        addr.sin6_family = AF_INET6;
        addr.sin6_addr.s6_addr[15] = 1;
        connect (fd, (struct sockaddr *)&addr, sizeof (addr));

        if (fd == -1) return 1;
        if (getsockopt (fd, IPPROTO_IPV6, IPV6_UNICAST_HOPS, &val, &len) == 0)
                printf ("Default unicast hops limit: %d\n", val);
        if (getsockopt (fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &val, &len) == 
0)
                printf ("Default multicast hops limit: %d\n", val);
        return 0;
}
Comment 1 Hideaki YOSHIFUJI 2006-12-13 00:49:10 UTC
-1 means, kernel has not determined the value
when you do getsockopt() and it will select
appropriate value when you actually send the packet.

Note that some other implementation(s) also returns -1.

Note You need to log in before you can comment on or make changes to this bug.