From owner-freebsd-net@FreeBSD.ORG Mon Jul 11 16:01:45 2011 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3D780106564A for ; Mon, 11 Jul 2011 16:01:45 +0000 (UTC) (envelope-from Michael.Tuexen@lurchi.franken.de) Received: from mail-n.franken.de (drew.ipv6.franken.de [IPv6:2001:638:a02:a001:20e:cff:fe4a:feaa]) by mx1.freebsd.org (Postfix) with ESMTP id A20E48FC16 for ; Mon, 11 Jul 2011 16:01:44 +0000 (UTC) Received: from [192.168.1.195] (p508FB51C.dip.t-dialin.net [80.143.181.28]) (Authenticated sender: macmic) by mail-n.franken.de (Postfix) with ESMTP id 7757B1C0B4611; Mon, 11 Jul 2011 18:01:42 +0200 (CEST) Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: =?iso-8859-1?Q?Michael_T=FCxen?= In-Reply-To: Date: Mon, 11 Jul 2011 18:01:41 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: <8D48DCA3-E9C5-481D-9BB4-E798942B7D34@lurchi.franken.de> References: To: Matthew Cini Sarreo X-Mailer: Apple Mail (2.1084) Cc: freebsd-net@freebsd.org Subject: Re: ESP Raw Socket: Returned IP packet incorrect X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jul 2011 16:01:45 -0000 On Jul 11, 2011, at 5:26 PM, Matthew Cini Sarreo wrote: > Hello all; >=20 > I have recently encountered a problem when using raw sockets on = FreeBSD 8 > (8.0-RELEASE) when using ESP raw sockets. >=20 > I have created a raw esp socket using: > socket(AF_INET, SOCK_RAW, 50); > which works fine. However, when there is a packet on the socket, = recvfrom() > returns a packet where the length bytes in the IP header are = incorrect; they > are swapped (MSB is placed in the LSB and vice-versa) >=20 > tcpdump shows the following: >=20 > tcpdump: listening on le0, link-type EN10MB (Ethernet), capture size = 96 > bytes > 15:00:53.993810 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto = ESP > (50), length 120) > 10.0.251.228 > 10.0.252.231: ESP(spi=3D0xa0534f17,seq=3D0x3), = length 100 > 0x0000: 4500 0078 0000 4000 4032 2d88 0a00 fbe4 > 0x0010: 0a00 fce7 a053 4f17 0000 0003 6885 8abd > 0x0020: 2222 5ded 44dc 842f 3081 8fa3 bde4 2265 > 0x0030: 7438 2bf4 049c 664b 7dc4 44ef 1f6f 5e7d > 0x0040: b8c1 482f 8c3b f488 a19a 3d9a d5fe ed9d > 0x0050: b1c2 >=20 >=20 > However, recvfrom() returns the following buffer: > 4500 6400 0000 0040 4032 2D88 0A00 FBE4 > 0A00 FCE7 A053 4F17 0000 0003 6885 8ABD > 2222 5DED 44DC 842F 3081 8FA3 BDE4 2265 > 7438 2BF4 049C 664B 7DC4 44EF 1F6F 5E7D > B8C1 482F 8C3B F488 A19A 3D9A D5FE ED9D > B1C2 >=20 > As it is easy to see, the length is not correct (bytes 2 and 3 are = 0x6400 > instead of 0x0064) and it does not correspond to the value returned by > recvfrom(). >=20 > Is this a known issue? Am I missing some options for raw sockets that = are > required for FreeBSD? I have attempted this on a socket to a TUN = interface > (not with an ESP socket) and the buffer had the proper length; it = seems to > only happen with ESP. This code runs fine on multiple Linux = distributions > and on Windows; it was only noticed with FreeBSD. Could it be that = there is > some other ESP application running and interfering (I have not = installed > any; don't know if there are by default and I'm quite new to any of = the > BSDs)? I think Linux provides the tot_len field in network byte order whereas FreeBSD provides it in host byte order. At least they expect it that way when using a send call. So you must take care of this in the source code of the application by using an #ifdef... Best regards Michael >=20 > Any help would be much appreciated. > Matt > _______________________________________________ > freebsd-net@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-net > To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org" >=20