diff options
author | Stefan Schmidt <stefan.schmidt@huawei.com> | 2022-04-07 21:14:35 +0200 |
---|---|---|
committer | Khem Raj <raj.khem@gmail.com> | 2022-04-07 17:40:45 -0400 |
commit | bb6a70a4638688ca971dc281d90627135f59ce0c (patch) | |
tree | c336ac82e9c8c1db1d5a19b2a3f10958424d9f94 | |
parent | b9e440ead8908280041e87a5a8abe03718c808ad (diff) | |
download | meta-openembedded-bb6a70a4638688ca971dc281d90627135f59ce0c.tar.gz |
ot-br-posix: add recipe for an OpenThread Border Router
The OpenThread project is an open source implementation of the Thread
low-power mesh network protocol. In a Thread network devices can have
different roles, and of of these roles is a Border Router that allows a
Thread network to be connected with other IP networks.
Ot-br-posix runs as a systemd service on a standard Linux system to
handle the connection to a Thread network.
In terms of patches we need a fix to allow building on musl + clang
(CMSG_NXTHDR macro triggers a -Wsign-compare warning) and a systemd
unit file change is OE specific and avoids having service dependencies
implemented as pre exec hooks.
Signed-off-by: Stefan Schmidt <stefan.schmidt@huawei.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
3 files changed, 225 insertions, 0 deletions
diff --git a/meta-networking/recipes-connectivity/openthread/ot-br-posix/0001-otbr-agent.service.in-remove-pre-exec-hook-for-mdns-.patch b/meta-networking/recipes-connectivity/openthread/ot-br-posix/0001-otbr-agent.service.in-remove-pre-exec-hook-for-mdns-.patch new file mode 100644 index 0000000000..250de4bdd8 --- /dev/null +++ b/meta-networking/recipes-connectivity/openthread/ot-br-posix/0001-otbr-agent.service.in-remove-pre-exec-hook-for-mdns-.patch | |||
@@ -0,0 +1,35 @@ | |||
1 | From ed60d4605b81c43b9ba9504a37835109c247c6f8 Mon Sep 17 00:00:00 2001 | ||
2 | From: Stefan Schmidt <stefan.schmidt@huawei.com> | ||
3 | Date: Fri, 1 Apr 2022 21:46:03 +0200 | ||
4 | Subject: [PATCH] otbr-agent.service.in: remove pre exec hook for mdns service | ||
5 | |||
6 | It uses the service command which is not available in all cases under | ||
7 | Yocto/OE. The upstream project uses this mainly with Ubuntu and Raspian | ||
8 | as testbeds. | ||
9 | |||
10 | In our case we simply ensure that avahi-daemon is installed on the | ||
11 | system inside the recipe. | ||
12 | |||
13 | Upstream-Status: Inappropriate [OE specific] | ||
14 | |||
15 | Signed-off-by: Stefan Schmidt <stefan.schmidt@huawei.com> | ||
16 | --- | ||
17 | src/agent/otbr-agent.service.in | 2 +- | ||
18 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
19 | |||
20 | diff --git a/src/agent/otbr-agent.service.in b/src/agent/otbr-agent.service.in | ||
21 | index 8314121347..4c97869def 100644 | ||
22 | --- a/src/agent/otbr-agent.service.in | ||
23 | +++ b/src/agent/otbr-agent.service.in | ||
24 | @@ -6,7 +6,7 @@ After=dbus.socket | ||
25 | |||
26 | [Service] | ||
27 | EnvironmentFile=-@CMAKE_INSTALL_FULL_SYSCONFDIR@/default/otbr-agent | ||
28 | -@EXEC_START_PRE@ExecStart=@CMAKE_INSTALL_FULL_SBINDIR@/otbr-agent $OTBR_AGENT_OPTS | ||
29 | +ExecStart=@CMAKE_INSTALL_FULL_SBINDIR@/otbr-agent $OTBR_AGENT_OPTS | ||
30 | KillMode=mixed | ||
31 | Restart=on-failure | ||
32 | RestartSec=5 | ||
33 | -- | ||
34 | 2.35.1 | ||
35 | |||
diff --git a/meta-networking/recipes-connectivity/openthread/ot-br-posix/Turn-off-sign-compare-for-musl-libc.patch b/meta-networking/recipes-connectivity/openthread/ot-br-posix/Turn-off-sign-compare-for-musl-libc.patch new file mode 100644 index 0000000000..df84550be0 --- /dev/null +++ b/meta-networking/recipes-connectivity/openthread/ot-br-posix/Turn-off-sign-compare-for-musl-libc.patch | |||
@@ -0,0 +1,131 @@ | |||
1 | From: Stefan Schmidt <stefan.schmidt@huawei.com> | ||
2 | Subject: Turn off sign compare for musl libc | ||
3 | |||
4 | When building with musl and clang the usage of CMSG_NXTHDR results in | ||
5 | sign-compare error. Disable the check only in this specific part of the | ||
6 | code with a #pragma. | ||
7 | |||
8 | | /home/stefan/huawei/yocto-upstream/yoe/workspace/sources/ot-br-posix/third_party/openthread/repo/src/posix/platform/udp.cpp:147:28: fatal error: comparison of integers of different signs: 'unsigned long' and 'long' [-Wsign-compare] | ||
9 | | cmsg = CMSG_NXTHDR(&msg, cmsg); | ||
10 | | ^~~~~~~~~~~~~~~~~~~~~~~ | ||
11 | | /home/stefan/huawei/yocto-upstream/yoe/build/tmp/work/cortexa57-yoe-linux-musl/ot-br-posix/0.3.0+git999-r0/recipe-sysroot/usr/include/sys/socket.h:358:44: note: expanded from macro 'CMSG_NXTHDR' | ||
12 | | __CMSG_LEN(cmsg) + sizeof(struct cmsghdr) >= __MHDR_END(mhdr) - (unsigned char *)(cmsg) \ | ||
13 | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
14 | | 1 error generated. | ||
15 | |||
16 | Idea and fix taken from | ||
17 | recipes-devtools/breakpad/breakpad/0001-Turn-off-sign-compare-for-musl-libc.patch | ||
18 | by Khem Raj. | ||
19 | |||
20 | Upstream-Status: Inappropriate [OE specific] | ||
21 | |||
22 | Signed-off-by: Stefan Schmidt <stefan.schmidt@huawei.com> | ||
23 | |||
24 | diff --git a/src/backbone_router/nd_proxy.cpp b/src/backbone_router/nd_proxy.cpp | ||
25 | index 7136878c3d..8a223c95c7 100644 | ||
26 | --- a/src/backbone_router/nd_proxy.cpp | ||
27 | +++ b/src/backbone_router/nd_proxy.cpp | ||
28 | @@ -185,9 +185,18 @@ void NdProxyManager::ProcessMulticastNeighborSolicition() | ||
29 | VerifyOrExit(icmp6header->icmp6_type == ND_NEIGHBOR_SOLICIT, error = OTBR_ERROR_PARSE); | ||
30 | |||
31 | otbrLogDebug("NdProxyManager: Received ND-NS from %s", src.ToString().c_str()); | ||
32 | - | ||
33 | +#ifndef __GLIBC__ | ||
34 | + // In musl-libc, CMSG_NXTHDR typecasts char* to cmsghdr* which causes | ||
35 | + // clang to throw sign-compare warning. This is to suppress the warning | ||
36 | + // inline. | ||
37 | + #pragma clang diagnostic push | ||
38 | + #pragma clang diagnostic ignored "-Wsign-compare" | ||
39 | +#endif | ||
40 | for (cmsghdr = CMSG_FIRSTHDR(&msghdr); cmsghdr; cmsghdr = CMSG_NXTHDR(&msghdr, cmsghdr)) | ||
41 | - { | ||
42 | +#ifndef __GLIBC__ | ||
43 | + #pragma clang diagnostic pop | ||
44 | +#endif | ||
45 | + { | ||
46 | if (cmsghdr->cmsg_level != IPPROTO_IPV6) | ||
47 | { | ||
48 | continue; | ||
49 | Submodule third_party/openthread/repo contains modified content | ||
50 | diff --git a/third_party/openthread/repo/src/posix/platform/infra_if.cpp b/third_party/openthread/repo/src/posix/platform/infra_if.cpp | ||
51 | index 9f93d2b1c..1ed40fe50 100644 | ||
52 | --- a/third_party/openthread/repo/src/posix/platform/infra_if.cpp | ||
53 | +++ b/third_party/openthread/repo/src/posix/platform/infra_if.cpp | ||
54 | @@ -228,7 +228,17 @@ otError InfraNetif::SendIcmp6Nd(uint32_t aInfraIfIndex, | ||
55 | packetInfo->ipi6_ifindex = mInfraIfIndex; | ||
56 | |||
57 | // Per section 6.1.2 of RFC 4861, we need to send the ICMPv6 message with IP Hop Limit 255. | ||
58 | +#ifndef __GLIBC__ | ||
59 | + // In musl-libc, CMSG_NXTHDR typecasts char* to cmsghdr* which causes | ||
60 | + // clang to throw sign-compare warning. This is to suppress the warning | ||
61 | + // inline. | ||
62 | + #pragma clang diagnostic push | ||
63 | + #pragma clang diagnostic ignored "-Wsign-compare" | ||
64 | +#endif | ||
65 | cmsgPointer = CMSG_NXTHDR(&msgHeader, cmsgPointer); | ||
66 | +#ifndef __GLIBC__ | ||
67 | + #pragma clang diagnostic pop | ||
68 | +#endif | ||
69 | cmsgPointer->cmsg_level = IPPROTO_IPV6; | ||
70 | cmsgPointer->cmsg_type = IPV6_HOPLIMIT; | ||
71 | cmsgPointer->cmsg_len = CMSG_LEN(sizeof(hopLimit)); | ||
72 | @@ -481,7 +491,17 @@ void InfraNetif::ReceiveIcmp6Message(void) | ||
73 | |||
74 | bufferLength = static_cast<uint16_t>(rval); | ||
75 | |||
76 | +#ifndef __GLIBC__ | ||
77 | + // In musl-libc, CMSG_NXTHDR typecasts char* to cmsghdr* which causes | ||
78 | + // clang to throw sign-compare warning. This is to suppress the warning | ||
79 | + // inline. | ||
80 | + #pragma clang diagnostic push | ||
81 | + #pragma clang diagnostic ignored "-Wsign-compare" | ||
82 | +#endif | ||
83 | for (cmh = CMSG_FIRSTHDR(&msg); cmh; cmh = CMSG_NXTHDR(&msg, cmh)) | ||
84 | +#ifndef __GLIBC__ | ||
85 | + #pragma clang diagnostic pop | ||
86 | +#endif | ||
87 | { | ||
88 | if (cmh->cmsg_level == IPPROTO_IPV6 && cmh->cmsg_type == IPV6_PKTINFO && | ||
89 | cmh->cmsg_len == CMSG_LEN(sizeof(struct in6_pktinfo))) | ||
90 | diff --git a/third_party/openthread/repo/src/posix/platform/udp.cpp b/third_party/openthread/repo/src/posix/platform/udp.cpp | ||
91 | index b7aacc5fa..a814fea70 100644 | ||
92 | --- a/third_party/openthread/repo/src/posix/platform/udp.cpp | ||
93 | +++ b/third_party/openthread/repo/src/posix/platform/udp.cpp | ||
94 | @@ -144,8 +144,18 @@ otError transmitPacket(int aFd, uint8_t *aPayload, uint16_t aLength, const otMes | ||
95 | { | ||
96 | struct in6_pktinfo pktinfo; | ||
97 | |||
98 | +#ifndef __GLIBC__ | ||
99 | + // In musl-libc, CMSG_NXTHDR typecasts char* to cmsghdr* which causes | ||
100 | + // clang to throw sign-compare warning. This is to suppress the warning | ||
101 | + // inline. | ||
102 | + #pragma clang diagnostic push | ||
103 | + #pragma clang diagnostic ignored "-Wsign-compare" | ||
104 | +#endif | ||
105 | cmsg = CMSG_NXTHDR(&msg, cmsg); | ||
106 | - cmsg->cmsg_level = IPPROTO_IPV6; | ||
107 | +#ifndef __GLIBC__ | ||
108 | + #pragma clang diagnostic pop | ||
109 | +#endif | ||
110 | + cmsg->cmsg_level = IPPROTO_IPV6; | ||
111 | cmsg->cmsg_type = IPV6_PKTINFO; | ||
112 | cmsg->cmsg_len = CMSG_LEN(sizeof(pktinfo)); | ||
113 | |||
114 | @@ -200,7 +210,17 @@ otError receivePacket(int aFd, uint8_t *aPayload, uint16_t &aLength, otMessageIn | ||
115 | VerifyOrExit(rval > 0, perror("recvmsg")); | ||
116 | aLength = static_cast<uint16_t>(rval); | ||
117 | |||
118 | +#ifndef __GLIBC__ | ||
119 | + // In musl-libc, CMSG_NXTHDR typecasts char* to cmsghdr* which causes | ||
120 | + // clang to throw sign-compare warning. This is to suppress the warning | ||
121 | + // inline. | ||
122 | + #pragma clang diagnostic push | ||
123 | + #pragma clang diagnostic ignored "-Wsign-compare" | ||
124 | +#endif | ||
125 | for (struct cmsghdr *cmsg = CMSG_FIRSTHDR(&msg); cmsg != nullptr; cmsg = CMSG_NXTHDR(&msg, cmsg)) | ||
126 | +#ifndef __GLIBC__ | ||
127 | + #pragma clang diagnostic pop | ||
128 | +#endif | ||
129 | { | ||
130 | if (cmsg->cmsg_level == IPPROTO_IPV6) | ||
131 | { | ||
diff --git a/meta-networking/recipes-connectivity/openthread/ot-br-posix_git.bb b/meta-networking/recipes-connectivity/openthread/ot-br-posix_git.bb new file mode 100644 index 0000000000..d9f558d792 --- /dev/null +++ b/meta-networking/recipes-connectivity/openthread/ot-br-posix_git.bb | |||
@@ -0,0 +1,59 @@ | |||
1 | # SPDX-FileCopyrightText: Huawei Inc. | ||
2 | # | ||
3 | # SPDX-License-Identifier: Apache-2.0 | ||
4 | SUMMARY = "OpenThread Border Router" | ||
5 | SECTION = "net" | ||
6 | LICENSE = "BSD-3-Clause & MIT" | ||
7 | LIC_FILES_CHKSUM = "file://LICENSE;md5=87109e44b2fda96a8991f27684a7349c \ | ||
8 | file://third_party/Simple-web-server/repo/LICENSE;md5=852b3f7f320b19f6431487b8b2fb1d74 \ | ||
9 | file://third_party/cJSON/repo/LICENSE;md5=218947f77e8cb8e2fa02918dc41c50d0 \ | ||
10 | file://third_party/http-parser/repo/LICENSE-MIT;md5=9bfa835d048c194ab30487af8d7b3778 \ | ||
11 | file://third_party/openthread/repo/LICENSE;md5=543b6fe90ec5901a683320a36390c65f \ | ||
12 | " | ||
13 | DEPENDS = "autoconf-archive dbus readline avahi jsoncpp boost libnetfilter-queue" | ||
14 | SRCREV = "ad6822257ffddbac295db97186e4ab449a2ed32a" | ||
15 | PV = "0.3.0+git${SRCPV}" | ||
16 | |||
17 | SRC_URI = "gitsm://github.com/openthread/ot-br-posix.git;protocol=https;branch=main \ | ||
18 | file://0001-otbr-agent.service.in-remove-pre-exec-hook-for-mdns-.patch \ | ||
19 | file://Turn-off-sign-compare-for-musl-libc.patch \ | ||
20 | " | ||
21 | |||
22 | S = "${WORKDIR}/git" | ||
23 | SYSTEMD_SERVICE:${PN} = "otbr-agent.service" | ||
24 | |||
25 | inherit pkgconfig cmake systemd | ||
26 | |||
27 | EXTRA_OECMAKE = "-DBUILD_TESTING=OFF \ | ||
28 | -DOTBR_DBUS=ON \ | ||
29 | -DOTBR_REST=ON \ | ||
30 | -DOTBR_WEB=OFF \ | ||
31 | -DCMAKE_LIBRARY_PATH=${libdir} \ | ||
32 | -DOTBR_MDNS=avahi \ | ||
33 | -DOTBR_BACKBONE_ROUTER=ON \ | ||
34 | -DOTBR_BORDER_ROUTING=ON \ | ||
35 | -DOTBR_SRP_ADVERTISING_PROXY=ON \ | ||
36 | -DOTBR_BORDER_AGENT=ON \ | ||
37 | -DOT_SPINEL_RESET_CONNECTION=ON \ | ||
38 | -DOT_TREL=ON \ | ||
39 | -DOT_MLR=ON \ | ||
40 | -DOT_SRP_SERVER=ON \ | ||
41 | -DOT_ECDSA=ON \ | ||
42 | -DOT_SERVICE=ON \ | ||
43 | -DOTBR_DUA_ROUTING=ON \ | ||
44 | -DOT_DUA=ON \ | ||
45 | -DOT_BORDER_ROUTING_NAT64=ON \ | ||
46 | -DOTBR_DNSSD_DISCOVERY_PROXY=ON \ | ||
47 | -DOTBR_INFRA_IF_NAME=eth0 \ | ||
48 | -DOTBR_NO_AUTO_ATTACH=1 \ | ||
49 | -DOT_REFERENCE_DEVICE=ON \ | ||
50 | -DOT_DHCP6_CLIENT=ON \ | ||
51 | -DOT_DHCP6_SERVER=ON \ | ||
52 | " | ||
53 | |||
54 | RDEPENDS:${PN} = "iproute2 avahi-daemon" | ||
55 | |||
56 | RCONFLICTS:${PN} = "ot-daemon" | ||
57 | |||
58 | FILES:${PN} += "${systemd_unitdir}/*" | ||
59 | FILES:${PN} += "${datadir}/*" | ||