diff options
author | sem <sem@FreeBSD.org> | 2008-12-16 01:46:36 +0800 |
---|---|---|
committer | sem <sem@FreeBSD.org> | 2008-12-16 01:46:36 +0800 |
commit | 85780fff1b48b7dc4300297e62ba0710d5c88cd9 (patch) | |
tree | 97286962038f31d12112fc1c5f99d40bd06d7112 /net/quagga | |
parent | e45d5ba8b2ce10c30b5113f671a7739999744711 (diff) | |
download | freebsd-ports-gnome-85780fff1b48b7dc4300297e62ba0710d5c88cd9.tar.gz freebsd-ports-gnome-85780fff1b48b7dc4300297e62ba0710d5c88cd9.tar.zst freebsd-ports-gnome-85780fff1b48b7dc4300297e62ba0710d5c88cd9.zip |
- Add a patch from quagga-qit. It fixes a fletcher checksum problem.
Diffstat (limited to 'net/quagga')
-rw-r--r-- | net/quagga/Makefile | 2 | ||||
-rw-r--r-- | net/quagga/files/patch-git-1-fletcher_checkusm | 95 |
2 files changed, 96 insertions, 1 deletions
diff --git a/net/quagga/Makefile b/net/quagga/Makefile index 44a7e4cb0d8d..a25546b7dc80 100644 --- a/net/quagga/Makefile +++ b/net/quagga/Makefile @@ -7,7 +7,7 @@ PORTNAME= quagga PORTVERSION= 0.99.11 -PORTREVISION= 0 +PORTREVISION= 1 CATEGORIES= net ipv6 MASTER_SITES= http://quagga.net/download/ \ http://www.ru.quagga.net/download/ \ diff --git a/net/quagga/files/patch-git-1-fletcher_checkusm b/net/quagga/files/patch-git-1-fletcher_checkusm new file mode 100644 index 000000000000..89e57992b383 --- /dev/null +++ b/net/quagga/files/patch-git-1-fletcher_checkusm @@ -0,0 +1,95 @@ +diff --git lib/checksum.c lib/checksum.c +index 88ec72a..f6d74d3 100644 +--- lib/checksum.c ++++ lib/checksum.c +@@ -52,34 +52,31 @@ in_cksum(void *parg, int nbytes) + /* To be consistent, offset is 0-based index, rather than the 1-based + index required in the specification ISO 8473, Annex C.1 */ + u_int16_t +-fletcher_checksum(u_char * buffer, int len, u_int16_t offset) ++fletcher_checksum(u_char * buffer, const size_t len, const uint16_t offset) + { + u_int8_t *p; +- int x; +- int y; +- u_int32_t mul; +- u_int32_t c0; +- u_int32_t c1; ++ int x, y, c0, c1; + u_int16_t checksum; + u_int16_t *csum; +- int i, init_len, partial_len; +- ++ size_t partial_len, i, left = len; ++ + checksum = 0; + ++ assert (offset < len); ++ + /* + * Zero the csum in the packet. + */ + csum = (u_int16_t *) (buffer + offset); +- *(csum) = checksum; ++ *(csum) = 0; + + p = buffer; + c0 = 0; + c1 = 0; +- init_len = len; + +- while (len != 0) ++ while (left != 0) + { +- partial_len = MIN(len, MODX); ++ partial_len = MIN(left, MODX); + + for (i = 0; i < partial_len; i++) + { +@@ -90,27 +87,18 @@ fletcher_checksum(u_char * buffer, int len, u_int16_t offset) + c0 = c0 % 255; + c1 = c1 % 255; + +- len -= partial_len; ++ left -= partial_len; + } +- +- mul = (init_len - offset)*(c0); +- +- x = mul - c0 - c1; +- y = c1 - mul - 1; +- +- if (y > 0) +- y++; +- if (x < 0) +- x--; +- +- x %= 255; +- y %= 255; +- +- if (x == 0) +- x = 255; +- if (y == 0) +- y = 1; +- ++ ++ /* 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; ++ + /* + * Now we write this to the packet. + * We could skip this step too, since the checksum returned would +diff --git a/lib/checksum.h b/lib/checksum.h +index d3ce930..da1d3cb 100644 +--- lib/checksum.h ++++ lib/checksum.h +@@ -1,2 +1,2 @@ + extern int in_cksum(void *, int); +-extern u_int16_t fletcher_checksum(u_char * buffer, int len, u_int16_t offset); ++extern u_int16_t fletcher_checksum(u_char *, const size_t len, const uint16_t offset); |