From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51849) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WMvgb-0008WS-3L for qemu-devel@nongnu.org; Mon, 10 Mar 2014 04:35:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WMvgU-0002EF-Kg for qemu-devel@nongnu.org; Mon, 10 Mar 2014 04:35:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44509) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WMvgU-0002E7-C6 for qemu-devel@nongnu.org; Mon, 10 Mar 2014 04:35:42 -0400 Date: Mon, 10 Mar 2014 09:35:31 +0100 From: Stefan Hajnoczi Message-ID: <20140310083531.GA24112@stefanha-thinkpad.redhat.com> References: <1394028740-710822-1-git-send-email-anton.ivanov@kot-begemot.co.uk> <20140306094428.GB23172@stefanha-thinkpad.redhat.com> <531C9F87.4000105@kot-begemot.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <531C9F87.4000105@kot-begemot.co.uk> Subject: Re: [Qemu-devel] [PATCH] New feature - RFC3931 L2TPv3 network transport using static Ethernet over L2TPv3 tunnels List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anton Ivanov Cc: Anton Ivanov , pbonzini@redhat.com, qemu-devel@nongnu.org, afaerber@suse.de On Sun, Mar 09, 2014 at 05:06:15PM +0000, Anton Ivanov wrote: > >>+ return -1; > >>+ } > >>+ > >>+ freeaddrinfo(result); > >>+ > >>+ memset(&hints, 0, sizeof(hints)); > >>+ > >>+ if (s->ipv6) { > >>+ hints.ai_family = AF_INET6; > >>+ } else { > >>+ hints.ai_family = AF_INET; > >>+ } > >>+ if (s->udp) { > >>+ hints.ai_socktype = SOCK_DGRAM; > >>+ hints.ai_protocol = 0; > >>+ } else { > >>+ hints.ai_socktype = SOCK_RAW; > >>+ hints.ai_protocol = IPPROTO_L2TP; > >Hang on, this is bogus. This is a *userspace* L2TP implementation! > > > >We don't want a kernel L2TP driver to handle this socket. Luckily this > >never happens anyway since net/l2tp/l2tp_ip.c only registers its socket > >type for and >IPPROTO_L2TP>. > > > >When we create this socket with what > >really happens is that the kernel falls back to the IPv4 raw socket > >driver due to a wildcard match. > > > >In other words, we shouldn't use IPPROTO_L2TP. Just use 0. > > > > This is not passed to socket directly - both setups share a call to > getaddinfo() after that and use whatever it returns. > > If you pass family, RAW, 0 to getaddrinfo it returns family, DGRAM, > 0. So when you use it later on the socket is setup incorrectly. > > If you pass RAW, PROTO_L2TPV3 it returns the correct values to setup > the socket. Bug for bug canceling each other out :( That doesn't match what I see. Can you double-check your test and figure out what is happening? Here is my test: $ grep -r SOCK_RAW /usr/include/ /usr/include/bits/socket_type.h: SOCK_RAW = 3, /* Raw protocol interface. */ $ ./a src ai_family 2 ai_socketype 3 ai_protocol 0 dst ai_family 2 ai_socketype 3 ai_protocol 0 $ cat a.c #include #include #include #include int main(int argc, char **argv) { int fd, gairet; struct addrinfo hints; struct addrinfo * result = NULL; memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_INET; hints.ai_socktype = SOCK_RAW; hints.ai_protocol = 0; gairet = getaddrinfo("localhost", NULL, &hints, &result); if ((gairet !=0) || (result == NULL)) { fprintf(stderr, "could not resolve src, errno = %s\n", gai_strerror(gairet)); return 1; } printf("src ai_family %d ai_socketype %d ai_protocol %d\n", result->ai_family, result->ai_socktype, result->ai_protocol); freeaddrinfo(result); memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_INET; hints.ai_socktype = SOCK_RAW; hints.ai_protocol = 0; gairet = getaddrinfo("8.8.8.8", NULL, &hints, &result); if ((gairet !=0) || (result == NULL)) { fprintf(stderr, "could not resolve dst, errno = %s\n", gai_strerror(gairet)); return 1; } printf("dst ai_family %d ai_socketype %d ai_protocol %d\n", result->ai_family, result->ai_socktype, result->ai_protocol); freeaddrinfo(result); return 0; }