lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 3 May 2010 18:33:46 -0700
From:	enh <enh@...gle.com>
To:	netdev@...r.kernel.org
Subject: linux kernel's IPV6_MULTICAST_HOPS default is 64; should be 1?

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/
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ