]> git.proxmox.com Git - mirror_frr.git/commit - tests/lib/test_checksum.c
[lib] Switch Fletcher checksum back to old ospfd version
authorPaul Jakma <paul.jakma@sun.com>
Sun, 16 Nov 2008 18:34:19 +0000 (18:34 +0000)
committerPaul Jakma <paul@quagga.net>
Sun, 16 Nov 2008 18:47:02 +0000 (18:47 +0000)
commit5d4b8cf2faba9f5386810a7c70837e5b7fae3572
treeec89383f7bfd4684a0cde15648e5f00e8d2d8f7b
parent41dc3488cf127a1e23333459a0c316ded67f7ff3
[lib] Switch Fletcher checksum back to old ospfd version

* lib/checksum.c: (fletcher_checksum) Switch the second phase of the checksum
  back to the old ospfd logic.

  The isisd-derived version:

  a) is very hard to follow
  b) had some kind of subtle bug that caused it be wrong when c0=0 and c1=254
     (potentially fixable by doing the mods before adjusting x and y)

  Additionally:

  - explicitely cast expressions using non-internal variables to int, to ensure
    the result is signed.
  - defensively change the length argument to 'size_t', to ensure the code
    works with that argument being unsigned..

  Thanks to Joakim Tjernlund for the investigative work into this bug.

* tests/test-checksum.c: new file to exercise the checksum code.
lib/checksum.c
lib/checksum.h
tests/Makefile.am
tests/test-checksum.c [new file with mode: 0644]