netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* IPV6 raw socket denies bind(2)
@ 2010-10-27 22:01 Jan Engelhardt
  2010-10-27 23:54 ` Brian Haley
  2010-10-28  8:25 ` Rémi Denis-Courmont
  0 siblings, 2 replies; 3+ messages in thread
From: Jan Engelhardt @ 2010-10-27 22:01 UTC (permalink / raw)
  To: netdev; +Cc: David S. Miller, Eric Dumazet

[Doublepost: linux-netdev does not exist. Sigh. "netdev" is totally 
nonstandard to all the other linux-* list names. :-?]

Hi,


I was trying out raw sockets and stumbled into a case whereby I cannot 
call bind(2) on a AF_INET6, SOCK_RAW socket. Apparently, I am triggering 
this particular code path that means absolutely nothing to me:

# ./rawtest

kernel pseudo callgraph:
static int rawv6_bind(struct sock *sk, struct sockaddr *uaddr, int 
addr_len)
addr >= SIN6_LEN_RFC2133
addr_type != IPV6_ADDR_MAPPED
sk->sk_state == TCP_CLOSED
addr_type != IPV6_ADDR_ANY
!(addr_type & IPV6_ADDR_LINKLOCAL)
!(addr_type & IPV6_ADDR_MULTICAST)
dev == NULL
ipv6_chk_addr does not have any addresses to loop through (wtf? checked 
with printk.)
=> going -EADDRNOTAVAIL

At this point I have no idea why ipv6_chk_addr does not run through 
its loop. No devices in the hash bucket or something. Happens in 
2.6.36. I hope somebody can shed some light here.

---Userspace testcase---
#include <sys/socket.h>
#include <stdio.h>
#include <string.h>
#include <netinet/udp.h>
#include <netinet/in.h>
#include <netinet/ip6.h>
#include <arpa/inet.h>
#include <stdlib.h>

int main(void)
{
	struct sockaddr_in6 src = {};
	int sk;

	sk = socket(AF_INET6, SOCK_RAW, IPPROTO_UDP);
	memset(&src, 0, sizeof(src));
	inet_pton(AF_INET6, "::1", &src);
	src.sin6_family = AF_INET6;

	if (bind(sk, (void *)&src, sizeof(src)) < 0) {
		perror("bind");
		abort();
	}
	return 0;
}

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

end of thread, other threads:[~2010-10-28  8:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-27 22:01 IPV6 raw socket denies bind(2) Jan Engelhardt
2010-10-27 23:54 ` Brian Haley
2010-10-28  8:25 ` Rémi Denis-Courmont

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).