From 10b4905b401c00ce08900a00bf2b885342e67a9e79c3be39240d309fa1dfc521 Mon Sep 17 00:00:00 2001 From: Martin Hauke Date: Mon, 16 Nov 2020 15:39:18 +0000 Subject: [PATCH 1/2] Accepting request 848877 from home:m4r3k - Add patch to fix test on Big Endian architectures OBS-URL: https://build.opensuse.org/request/show/848877 OBS-URL: https://build.opensuse.org/package/show/network/bird?expand=0&rev=14 --- bird.changes | 5 +++ bird.spec | 2 + fix_test_for_bigendian_arch.patch | 74 +++++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 fix_test_for_bigendian_arch.patch diff --git a/bird.changes b/bird.changes index aaf4d66..9e4cdec 100644 --- a/bird.changes +++ b/bird.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Mon Nov 16 12:45:29 UTC 2020 - Mark Stopka + +- Add patch to fix test on Big Endian architectures + ------------------------------------------------------------------- Fri Sep 11 07:16:11 UTC 2020 - Dirk Mueller diff --git a/bird.spec b/bird.spec index d216aaa..56a3ea3 100644 --- a/bird.spec +++ b/bird.spec @@ -31,6 +31,7 @@ Source: ftp://bird.network.cz/pub/bird/bird-%{version}.tar.gz Source1: bird.service Source3: bird.tmpfiles.d Patch0: gcc10.patch +Patch1: fix_test_for_bigendian_arch.patch BuildRequires: bison BuildRequires: flex BuildRequires: ncurses-devel @@ -66,6 +67,7 @@ This package holds the HTML documentation. %prep %setup -q %patch0 -p1 +%patch1 -p1 %build export CFLAGS="${RPM_OPT_FLAGS} -fpic -DPIC -fno-strict-aliasing -Wno-parentheses -Wno-pointer-sign" diff --git a/fix_test_for_bigendian_arch.patch b/fix_test_for_bigendian_arch.patch new file mode 100644 index 0000000..c74f6e3 --- /dev/null +++ b/fix_test_for_bigendian_arch.patch @@ -0,0 +1,74 @@ +diff --git a/lib/fletcher16_test.c b/lib/fletcher16_test.c +index 1020e6ecc8cac116dd45710ff7993f2e8641d694..3cd4c302f19700d32b0d3e68d5137b4409bfe976 100644 +--- a/lib/fletcher16_test.c ++++ b/lib/fletcher16_test.c +@@ -24,24 +24,33 @@ straightforward_fletcher16_compute(const char *data) + sum2 = (sum2 + sum1) % 255; + } + +- return (sum2 << 8) | sum1; ++ sum2 = (sum2 + sum1) % 255; ++ sum2 = (sum2 + sum1) % 255; ++ ++ return (sum1 << 8) | sum2; + } + + static u16 + straightforward_fletcher16_checksum(const char *data) + { + u16 csum; +- u8 c0,c1,f0,f1; ++ u16 c0,c1,x,y; + + csum = straightforward_fletcher16_compute(data); +- f0 = csum & 0xff; +- f1 = (csum >> 8) & 0xff; +- c0 = 0xff - ((f0 + f1) % 0xff); +- c1 = 0xff - ((f0 + c0) % 0xff); ++ c0 = (csum >> 8) & 0xff; ++ c1 = csum & 0xff; ++ ++ x = (255 + c0 - c1) % 255; ++ y = (510 - 2*c0 + c1) % 255; + +- return (c1 << 8) | c0; ++ if (!x) x = 255; ++ if (!y) y = 255; ++ ++ return (x << 8) | y; + } + ++const u8 zero16[2] = {}; ++ + static int + test_fletcher16(void *out_, const void *in_, const void *expected_out_) + { +@@ -53,7 +62,8 @@ test_fletcher16(void *out_, const void *in_, const void *expected_out_) + + fletcher16_init(&ctxt); + fletcher16_update(&ctxt, in, strlen(in)); +- put_u16(out, fletcher16_compute(&ctxt)); ++ fletcher16_update(&ctxt, zero16, 2); ++ *out = fletcher16_compute(&ctxt); + + return *out == *expected_out; + } +@@ -70,7 +80,8 @@ test_fletcher16_checksum(void *out_, const void *in_, const void *expected_out_) + + fletcher16_init(&ctxt); + fletcher16_update(&ctxt, in, len); +- put_u16(out, fletcher16_final(&ctxt, len, len)); ++ fletcher16_update(&ctxt, zero16, 2); ++ *out = fletcher16_final(&ctxt, len+2, len); + + return *out == *expected_out; + } +@@ -81,7 +92,7 @@ t_fletcher16_compute(void) + struct bt_pair test_vectors[] = { + { + .in = "\001\002", +- .out = & (const u16) { 0x0403 }, ++ .out = & ((const u16) { straightforward_fletcher16_compute("\001\002") }), + }, + { + .in = "", From 95401b214cd0b34a1347f0a55985d8de3579e24e144e504c31a10e1c9d13fff3 Mon Sep 17 00:00:00 2001 From: Martin Hauke Date: Mon, 16 Nov 2020 19:14:37 +0000 Subject: [PATCH 2/2] Accepting request 848940 from home:mnhauke:network * fix_test_for_bigendian_arch.patch OBS-URL: https://build.opensuse.org/request/show/848940 OBS-URL: https://build.opensuse.org/package/show/network/bird?expand=0&rev=15 --- bird.changes | 1 + 1 file changed, 1 insertion(+) diff --git a/bird.changes b/bird.changes index 9e4cdec..c70bc1b 100644 --- a/bird.changes +++ b/bird.changes @@ -2,6 +2,7 @@ Mon Nov 16 12:45:29 UTC 2020 - Mark Stopka - Add patch to fix test on Big Endian architectures + * fix_test_for_bigendian_arch.patch ------------------------------------------------------------------- Fri Sep 11 07:16:11 UTC 2020 - Dirk Mueller