Subject: strangeness while using SOCK_RAW
To: None <tech-net@netbsd.org>
From: Eric Auge <eau@phear.org>
List: tech-net
Date: 02/07/2007 22:49:37
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--------------enigA3A0591EFFCC152A1BB891F6
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hello,

while porting openospfd to netbsd, I'm facing some voodoo
problem that might be obvious but i can't see it.

the application is using socket(PF_INET, SOCK_RAW, IPPROTO_OSPF)
with
[...]
#define IPPROTO_OSPF             89
[...]

the recvfrom() return 80, while the IP header length field return 60 (of
recvfrom()'ed packet).

dump from the application buffer after the recvfrom() :
0x45 0x00 0x3c 0x00 0x73 0x60 0x00 0x00  0x01 0x59 0x3a 0xe5 0x0a 0x09 0x=
21 0x02
0xe0 0x00 0x00 0x05 0x02 0x01 0x00 0x2c  0x0a 0x09 0x21 0x02 0x00 0x00 0x=
00 0x00
0x00 0x00 0x00 0x02 0x00 0x00 0x01 0x10  0x08 0x79 0x47 0xd5 0xff 0xff 0x=
ff 0x00
0x00 0x05 0x02 0x01 0x00 0x00 0x00 0x28  0x0a 0x09 0x21 0x02 0x00 0x00 0x=
00 0x00
0x9b 0x5c 0x59 0x99 0xf3 0xe7 0x85 0xc6  0xe7 0xb5 0xcd 0x3b 0x09 0x7f 0x=
da 0xb4

tcpdump from the same packet :
0x0000:  4500 0050 7360 0000 0159 3ae5 0a09 2102  E..Ps`...Y:...!.
0x0010:  e000 0005 0201 002c 0a09 2102 0000 0000  .......,..!.....
0x0020:  0000 0002 0000 0110 0879 47d5 ffff ff00  .........yG.....
0x0030:  0005 0201 0000 0028 0a09 2102 0000 0000  .......(..!.....
0x0040:  9b5c 5999 f3e7 85c6 e7b5 cd3b 097f dab4  .\Y........;....

0x50 (80 bytes) on the wire become suddenly 0x3c (60 bytes) when
send to userland, while tcpdump uses bpf so the packet arrives unmodified=
=2E

looks like the kernel is removing 20 from the length value (ip->ip_len) o=
f the
IP header which could be the size of the IP header.
It look strange to me that it changes the size from the IP header without=

removing the header itself...

I dont really know where to look in the kernel to check...

any ideas ? can someone enlighten me on this ?

Regards,
Eric.


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

iD8DBQFFykl0SdZNA80H8MYRAm0xAJ4zyBLQ+TbR7dyKZ0gtfpOExsQK3gCfd/8U
3FNIuew5C9sTeAF0kZR0Ggo=
=Q4BQ
-----END PGP SIGNATURE-----

--------------enigA3A0591EFFCC152A1BB891F6--