OSPF performance/SPF calculations

Joakim Tjernlund joakim.tjernlund at transmode.se
Fri Apr 23 15:09:20 CEST 2010


Ondrej Zajicek <santiago at crfreenet.org> wrote on 2010/04/23 14:22:18:
>
> On Fri, Apr 23, 2010 at 01:06:20PM +0200, Joakim Tjernlund wrote:
> > > I must be missing something then(not surprising as I just started looking
> > > at BIRD). Why do you need the separate allocation for the body of the LSA then?
> > > Why not just adding entries to the allocated LSA header?
> >
> > Ahh, I am starting to get a clue I think. It is the struct top_hash_entry
> > that has this separation of LSA header and body.
> > Would it be feasible to move struct ospf_lsa_header lsa into
> > void *lsa_body, that is, merge them into one so
> > there is just one struct ospf_lsa_header *lsa instead?
>
> Yes, LSA header and LSA body are separated and i am not sure what is a
> purpose of that separation, but it does not cause much problems, so it
> is probably pointless to change this. It probably makes slightly faster
> access to the header fields.

But it slows down the fletcher checksum as one need to test and extra
calculations because of this. Any gain by the separation is lost many times over
in the fletcher checksum which could be as simple as(from Quagga with my tweaks):

....
 while (left != 0)
    {
      partial_len = MIN(left, MODX);
      left -= partial_len;

      do
	{
	  c0 = c0 + *(++p);
	  c1 += c0;
	} while (--partial_len);

      c0 = c0 % 255;
      c1 = c1 % 255;
    }

  /* The cast is important, to ensure the mod is taken as a signed value. */
  x = ((int)(len - offset - 1) * c0 - c1) % 255;

  if (x <= 0)
    x += 255;
  y = 510 - c0 - x;
  if (y > 255)
    y -= 255;
....

    Jocke




More information about the Bird-users mailing list