Subject: Re: strangeness while using SOCK_RAW
To: None <email@example.com>
From: Eric Auge <firstname.lastname@example.org>
Date: 02/09/2007 16:33:01
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
Content-Type: text/plain; charset=ISO-8859-1
Ignatios Souvatzis wrote:
> Hi Eric,
First of all, thanks answering :).
> On Thu, Feb 08, 2007 at 03:59:30PM +0100, Eric Auge wrote:
>> /usr/src/sys/netinet/raw_ip.c :
>> * XXX Compatibility: programs using raw IP expect ip_len
>> * XXX to have the header length subtracted, and in host order.
>> * XXX ip_off is also expected to be host order.
>> ip->ip_len =3D ntohs(ip->ip_len) - (ip->ip_hl << 2);
>> I don't understand this behavior and comment.
>> What "programs" using SOCK_RAW, IPPROTO_RAW (the behavior for undefine=
>> seems to be similar to the IPPROTO_RAW one) expect the RAW IP header
>> len(ip->ip_len) to be substracted from the size of the IP header witho=
>> off the header itself ...?
> I think I read a comment somewhere (Stevens Vol. 2 ?) that programs get=
> the same environment they would get in the kernel at a some calling poi=
I don't really understand what you mean here.
ok but why the ip_len field is modified then ? (i guess u speak about SOC=
if the program should get the same environement they would get in kernel,=
content should NOT be changed on-the-fly by the kernel on the way to user=
> Sounds reasonable - you can test basic stuff, before you start building=
> and booting kernels.
I don't understand.
I was speaking about porting openospfd from openbsd to netbsd (i did, i m=
quick "change" for the ip_len issue, it works, now I got problems pkgsrc'=
but that's another story), i see this strange behavior where in raw socke=
ip header len within the ip header is changed by the kernel on its way to=
userland, then userland application (openospfd) is driven to error becaus=
this, openospfd received 80 bytes of data and check if IP header has the =
value, but in NetBSD case it doesn't, recvfrom() says 80 bytes when IP he=
says 60 bytes, then I 'UTSL', I see those previous pasted kernel lines, a=
ask one simple question, why this behavior/choice ?, I just wish to under=
To me, it looks like a small issue, what have i missed ?
> For serious work, you'd socket(PF_INET, SOCK_DGRAM, PROTO_OSPF) (and
> write the code to support that in the kernel).
Is that really the path to follow? would it be useful to netbsd project?=
For such a small port I should do kernel changes ?
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (NetBSD)
-----END PGP SIGNATURE-----