Warning to all gated users.

A.N.Kuznetsov (kuznet@ms2.inr.ac.ru)
Wed, 10 Jul 1996 16:34:30 +0400 (MSD)


Hello!

My story.
I run gated almost for year and never had serious problems.
Well, sometimes I saw in logs funny message "OSPF: packet size > ip length",
but it occured very rarely and did not broke anything,
so that I believed that it is a harmless Cisco bug.

Yesterday, my gated stopped to talk to Cisco and logs
were overfill with this message. Unfortunately, at this time
I debugged my "next generation" routing code and decided
that I broke something. I backtraced changes, no guess.
Rebooted old, good kernel - it does not work! Disaster!

Gated turned out to believe that raw packets contain
in ip length field not tot_len in net order, but length of
datagram payload(!) in HOST order(!!).

What is it? Bug in gated? Idiotic BSD feature?
Can someone explain it?

Well, raw.c contains:

skb->daddr = saddr;

#if 0
/*
* For no adequately explained reasons BSD likes to mess up the header of
* the received frame.
*/

if(sk->bsdism)
skb->ip_hdr->tot_len=ntohs(skb->ip_hdr->tot_len-4*skb->ip_hdr->ihl);
#endif

if (sk->users) {

(BTW, it was incorrect, when it was not commented.

First, it should look as:

skb->ip_hdr->tot_len=ntohs(skb->ip_hdr->tot_len)-4*skb->ip_hdr->ihl;

Second, if this packet will be backlogged, we garble it up to death
at redo.
And third, if this skb is clone of another, it will garble it too,
so that this fix should be done in raw_recvmsg in user buffer)

Alexey Kuznetsov.