netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* linux kernel's IPV6_MULTICAST_HOPS default is 64; should be 1?
@ 2010-05-04  1:33 enh
  2010-05-04  2:16 ` Brian Haley
  0 siblings, 1 reply; 23+ messages in thread
From: enh @ 2010-05-04  1:33 UTC (permalink / raw)
  To: netdev

RFC 3493 (http://tools.ietf.org/rfc/rfc3493.txt) says:

      IPV6_MULTICAST_HOPS

         Set the hop limit to use for outgoing multicast packets.  (Note
         a separate option - IPV6_UNICAST_HOPS - is provided to set the
         hop limit to use for outgoing unicast packets.)

         The interpretation of the argument is the same as for the
         IPV6_UNICAST_HOPS option:

            x < -1:        return an error of EINVAL
            x == -1:       use kernel default
            0 <= x <= 255: use x
            x >= 256:      return an error of EINVAL

            If IPV6_MULTICAST_HOPS is not set, the default is 1
            (same as IPv4 today)

         Argument type: int

but if i create a socket and call getsockopt, i get 64, not 1. this
happens both on Android (2.6.32) and on Ubuntu 8.04 (2.6.24).

actually, i get whatever i've written to
/proc/sys/net/ipv6/conf/all/hop_limit. but afaics, nothing writes that
during init, so i think i'm getting the kernel's fallback default.

anyway, here's a test program you can use to see what i mean. i've
included the ipv4 equivalents, which give the values i'd expect.

/tmp$ cat sock.cpp
/* checkopts.c - based on Stevens */

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

struct sock_opts {
  const char	 *opt_str;
  int	 opt_level;
  int	 opt_name;
} sock_opts[] =
  {
    "IP_TTL",		IPPROTO_IP,	IP_TTL,
    "IP_MULTICAST_TTL",		IPPROTO_IP,	IP_MULTICAST_TTL,
    "IPV6_MULTICAST_HOPS",		IPPROTO_IPV6,	IPV6_MULTICAST_HOPS,
    "IPV6_UNICAST_HOPS",		IPPROTO_IPV6,	IPV6_UNICAST_HOPS,
    NULL,		0,		0,
  };

int main(int argc, char* argv[]) {
  int fd4 = socket(AF_INET, SOCK_DGRAM, 0);
  int fd6 = socket(AF_INET6, SOCK_DGRAM, 0);
  for (struct sock_opts* ptr = sock_opts; ptr->opt_str != NULL; ++ptr) {
    int val;
    socklen_t len = sizeof(int);
    int rc = getsockopt(ptr->opt_level == IPPROTO_IP ? fd4 : fd6,
ptr->opt_level, ptr->opt_name, &val, &len);
    printf("%s default = %d\n", ptr->opt_str, val);
  }
  return 0;
}

/tmp$ make sock && ./sock
make: `sock' is up to date.
IP_TTL default = 64
IP_MULTICAST_TTL default = 1
IPV6_MULTICAST_HOPS default = 64
IPV6_UNICAST_HOPS default = 64
/tmp$

is this a bug? is this the right place to report it? thanks!

-- 
Elliott Hughes - http://who/enh - http://jessies.org/~enh/

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2010-05-06  7:10 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-04  1:33 linux kernel's IPV6_MULTICAST_HOPS default is 64; should be 1? enh
2010-05-04  2:16 ` Brian Haley
2010-05-04  3:58   ` enh
2010-05-04  6:05   ` David Miller
2010-05-04  6:19     ` enh
2010-05-04  6:22       ` David Miller
2010-05-04  6:27         ` enh
2010-05-04  6:42           ` David Miller
2010-05-04  7:48           ` David Stevens
2010-05-04  7:57             ` David Miller
2010-05-04 14:40               ` Brian Haley
2010-05-04 16:12                 ` David Stevens
2010-05-04 16:43                   ` Brian Haley
2010-05-04 17:05                     ` David Stevens
2010-05-04 21:39                   ` David Miller
2010-05-04 21:38                 ` David Miller
2010-05-04 21:46                 ` David Miller
2010-05-04 22:26                   ` enh
2010-05-04 23:07                     ` David Miller
2010-05-05 15:36                   ` Brian Haley
2010-05-05 22:00                     ` David Miller
2010-05-06  1:50                       ` Brian Haley
2010-05-06  7:10                         ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).