OSPF performance/SPF calculations
Joakim Tjernlund
joakim.tjernlund at transmode.se
Fri Apr 23 17:29:09 CEST 2010
>
> On Fri, Apr 23, 2010 at 04:12:27PM +0200, Joakim Tjernlund wrote:
> > > As i looked on the Fletcher checksum, it seems that you cannot just swap
> > > the result instead of swapping the checked data.
> >
> > Then there is a bug else where. Fletcher as such does not
> > depend on host endian. It operates on bytes and those are
> > always the same endian.
>
> But it also takes in consideration the position of the bytes. If you put
> endianity-swapped data into it, you have a different byte sequence, and
> the algorithm returns a different result.
Yes, the sequence of bytes must be the same, but host endian
doesn't matter.
>
> > Did you try my patch?
>
> I looked at the Fletcher algorithm and found that it wouldn't work
> (because of the reason above). Perhaps i should try it to prove that.
>
> > > > Quagga does NOT do what BIRD does and it works as it should.
> > >
> > > Berhaps Quagga stores the LSAs in the network endianity (big endian) and
> > > BIRD stores the LSAs in the host endianity?
> >
> > Quagga does store its own LSAs in Big Endian, you have to make
> > them BE before transmitting them anyway so you might as well store
> > them directly in BE.
>
> But you also need LSAs in host endianity when doing SPF calculation.
> Although it would be probably possible to change SPF calculation to
> use directly BE values it would be huge work and it is questionable
> whether it wouldn't just move endianity swaps deeper in the code.
But how do you know when swap endian or not?
It seems to me that swapping endian back and forth for some LSAs and not
for others is more work.
Meanwhile, perhaps you could add something like this so only LE CPU suffer:
diff --git a/proto/ospf/lsalib.c b/proto/ospf/lsalib.c
index 35f02dc..2e40fb8 100644
--- a/proto/ospf/lsalib.c
+++ b/proto/ospf/lsalib.c
@@ -187,6 +187,11 @@ lsasum_calculate(struct ospf_lsa_header *h, void *body)
u16 length = h->length;
// log(L_WARN "Checksum %R %R %d start (len %d)", h->id, h->rt, h->type, length);
+
+ if (1 == htonl(1)) {
+ (void) lsasum_check(h, body);
+ return;
+ }
htonlsah(h, h);
htonlsab(body, body, length - sizeof(struct ospf_lsa_header));
More information about the Bird-users
mailing list