diff --git a/radvd-endianess.patch b/radvd-endianess.patch new file mode 100644 index 0000000..9893eea --- /dev/null +++ b/radvd-endianess.patch @@ -0,0 +1,82 @@ +From 05f06df832f1a9da671d431c19191c47ec48e722 Mon Sep 17 00:00:00 2001 +From: Sergei Trofimovich +Date: Fri, 17 Nov 2017 23:40:20 +0000 +Subject: [PATCH] nd_opt_6co: use uint8_t as a bitfield to be + endianness-agnostic + +Bug: https://github.com/reubenhwk/radvd/issues/77 +Signed-off-by: Sergei Trofimovich +--- + radvd.h | 4 +--- + send.c | 4 ++-- + test/send.c | 3 +-- + 3 files changed, 4 insertions(+), 7 deletions(-) + +diff --git a/radvd.h b/radvd.h +index 89a5b9e..f520f24 100644 +--- a/radvd.h ++++ b/radvd.h +@@ -259,9 +259,7 @@ struct nd_opt_6co { + uint8_t nd_opt_6co_type; + uint8_t nd_opt_6co_len; + uint8_t nd_opt_6co_context_len; +- uint8_t nd_opt_6co_res : 3; +- uint8_t nd_opt_6co_c : 1; +- uint8_t nd_opt_6co_cid : 4; ++ uint8_t nd_opt_6co_res_c_cid; /* [ res=3-bits | c=1-bit | cid=4-bits ] */ + uint16_t nd_opt_6co_reserved; + uint16_t nd_opt_6co_valid_lifetime; + struct in6_addr nd_opt_6co_con_prefix; +diff --git a/send.c b/send.c +index 8bc16a8..d44f85c 100644 +--- a/send.c ++++ b/send.c +@@ -619,8 +619,8 @@ static void add_ra_option_lowpanco(struct safe_buffer *sb, struct AdvLowpanCo co + co.nd_opt_6co_type = ND_OPT_6CO; + co.nd_opt_6co_len = 3; + co.nd_opt_6co_context_len = lowpanco->ContextLength; +- co.nd_opt_6co_c = lowpanco->ContextCompressionFlag; +- co.nd_opt_6co_cid = lowpanco->AdvContextID; ++ co.nd_opt_6co_res_c_cid = ((lowpanco->ContextCompressionFlag ? 1 : 0) << 4) ++ | (lowpanco->AdvContextID & 0x0F); + co.nd_opt_6co_valid_lifetime = lowpanco->AdvLifeTime; + co.nd_opt_6co_con_prefix = lowpanco->AdvContextPrefix; + +diff --git a/test/send.c b/test/send.c +index 92fe45b..4124986 100644 +--- a/test/send.c ++++ b/test/send.c +@@ -309,10 +309,9 @@ START_TEST(test_add_ra_option_lowpanco) + ck_assert_msg(0, "\n%s", &buf); + #else + unsigned char expected[] = { +- 0x22, 0x03, 0x32, 0x48, 0x00, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, ++ 0x22, 0x03, 0x32, 0x14, 0x00, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; +- + ck_assert_int_eq(sb.used, sizeof(expected)); + ck_assert_int_eq(0, memcmp(expected, sb.buffer, sizeof(expected))); + #endif +diff --git a/test/send.c b/test/send.c +index 4124986..b194449 100644 +--- a/test/send.c ++++ b/test/send.c +@@ -309,7 +309,7 @@ START_TEST(test_add_ra_option_lowpanco) + ck_assert_msg(0, "\n%s", &buf); + #else + unsigned char expected[] = { +- 0x22, 0x03, 0x32, 0x14, 0x00, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, ++ 0x22, 0x03, 0x32, 0x14, 0x00, 0x00, 0x03, 0xe8, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + ck_assert_int_eq(sb.used, sizeof(expected)); +@@ -333,7 +333,7 @@ START_TEST(test_add_ra_option_abro) + ck_assert_msg(0, "\n%s", &buf); + #else + unsigned char expected[] = { +- 0x23, 0x03, 0x0a, 0x00, 0x02, 0x00, 0x02, 0x00, 0xfe, 0x80, 0x00, 0x00, ++ 0x23, 0x03, 0x00, 0x0a, 0x00, 0x02, 0x00, 0x02, 0xfe, 0x80, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xa2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + }; + diff --git a/radvd.spec b/radvd.spec index 32aaca3..ef2ceb6 100644 --- a/radvd.spec +++ b/radvd.spec @@ -11,6 +11,7 @@ Source1: radvd-tmpfs.conf Source2: radvd.service ## https://github.com/reubenhwk/radvd/commit/6e45acbf3d64b9bd945adcb3de622fd7d059ceb9.patch Patch0: radvd-werror.patch +Patch1: radvd-endianess.patch BuildRequires: gcc BuildRequires: bison @@ -36,6 +37,7 @@ services. %prep %setup -q %patch0 -p1 -b .werror +%patch1 -p1 -b .endianess for F in CHANGES; do iconv -f iso-8859-1 -t utf-8 < "$F" > "${F}.new" @@ -44,9 +46,10 @@ for F in CHANGES; do done %build -export CFLAGS="$RPM_OPT_FLAGS -fPIE -Werror=all" +export CFLAGS="$RPM_OPT_FLAGS -fPIE " export LDFLAGS='-pie -Wl,-z,relro,-z,now,-z,noexecstack,-z,nodlopen' %configure \ + --with-check \ --disable-silent-rules \ --with-pidfile=/run/radvd/radvd.pid make %{?_smp_mflags} @@ -67,7 +70,7 @@ install -m 644 %{SOURCE2} %{buildroot}%{_unitdir} %check # The tests don't work, see https://github.com/reubenhwk/radvd/issues/30 -#make check +make check %postun %systemd_postun_with_restart radvd.service