From ae02f13e848efc993a74463aed0bc1bbab319898 Mon Sep 17 00:00:00 2001 From: Karsten Sperling Date: Tue, 15 Oct 2024 13:24:19 +1300 Subject: [PATCH] Use mdnsresponder for openthread-br by default The new openthread-br-avahi variant of the package continues to use Avahi. Also tweak a few build options and default the UART baud rate to 460800; USB RCPs generally support this baud rate and it avoids the UART interface being the bottleneck for the border router. --- third_party/openthread-br/Makefile | 87 ++++++++++++++----- .../patches/010-init-script.patch | 4 +- 2 files changed, 68 insertions(+), 23 deletions(-) diff --git a/third_party/openthread-br/Makefile b/third_party/openthread-br/Makefile index 1fdea48..e607af1 100644 --- a/third_party/openthread-br/Makefile +++ b/third_party/openthread-br/Makefile @@ -29,7 +29,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=openthread-br -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_SOURCE_URL:=https://github.com/openthread/ot-br-posix.git PKG_SOURCE_PROTO:=git PKG_SOURCE_MIRROR:=0 # don't try OpenWrt mirror @@ -44,38 +44,75 @@ PKG_LICENSE_FILES:=LICENSE include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/cmake.mk +define Package/openthread-br/Default + SECTION:=net + CATEGORY:=Network + TITLE:=OpenThread Border Router + URL:=https://github.com/openthread/ot-br-posix + DEPENDS:=+libstdcpp +libjson-c +libubus +libblobmsg-json +kmod-usb-acm +kmod-tun +endef + +define Package/openthread-br/Default/description +The OpenThread Border Router daemon connects a Thread Network to the +Wi-Fi / Ethernet infrastructure network. Requires a Radio Co-Processor +(RCP) with appropriate firmware connected via UART / USB. +endef + + +define Package/openthread-br + $(call Package/openthread-br/Default) + VARIANT:=default + DEPENDS+= +libdnssd +endef + +define Package/openthread-br/description +$(call Package/openthread-br/Default/description) + +This default variant of the package uses mDNSResponder for mDNS / DNS-SD. +endef + + +define Package/openthread-br-avahi + $(call Package/openthread-br/Default) + VARIANT:=avahi + PROVIDES:=openthread-br + CONFLICTS:=openthread-br + DEPENDS+= +libavahi-client +endef + +define Package/openthread-br-avahi/description +$(call Package/openthread-br/Default/description) + +This variant of the package uses Avahi for mDNS / DNS-SD. +endef + + # Disable firewall integration due to https://github.com/openthread/ot-br-posix/issues/1675 CMAKE_OPTIONS+= \ - -DBUILD_TESTING=OFF \ + -DCMAKE_BUILD_TYPE=$(if $(CONFIG_DEBUG),Debug,Release) \ -DCMAKE_INSTALL_PREFIX=/usr \ + -DBUILD_TESTING=OFF \ + -DOTBR_OPENWRT=ON \ -DOTBR_BORDER_AGENT=ON \ -DOTBR_BORDER_ROUTING=ON \ -DOTBR_INFRA_IF_NAME=br-lan \ - -DOTBR_MDNS="avahi" \ - -DOTBR_OPENWRT=ON \ -DOTBR_SRP_ADVERTISING_PROXY=ON \ + -DOTBR_NAT64=OFF \ -DOT_FIREWALL=OFF \ -DOT_POSIX_SETTINGS_PATH=\"/etc/openthread\" \ - -DOT_READLINE=OFF \ - -DOTBR_NAT64=OFF \ - -DNAT64_SERVICE=\"openthread\" + -DOT_READLINE=OFF # OpenWrt uses /var/run instead of /run -TARGET_CFLAGS += -DOPENTHREAD_POSIX_CONFIG_DAEMON_SOCKET_BASENAME=\\\"/var/run/openthread-%s\\\" - -define Package/openthread-br - SECTION:=net - CATEGORY:=Network - TITLE:=OpenThread Border Router - URL:=https://github.com/openthread/ot-br-posix - DEPENDS:=+libstdcpp +libjson-c +libubus +libblobmsg-json +libavahi-client +avahi-daemon +kmod-usb-acm +kmod-tun -endef +TARGET_CFLAGS += \ + -DOPENTHREAD_POSIX_CONFIG_DAEMON_SOCKET_BASENAME=\\\"/var/run/openthread-%s\\\" \ + -DOPENTHREAD_CONFIG_LOG_PREPEND_UPTIME=0 \ + -DOPENTHREAD_CONFIG_LOG_PREPEND_LEVEL=0 -define Package/openthread-br/description - OpenThread Border Router - Connects a Thread Network to the Wi-Fi / Ethernet infrastructure network. - Requires a Radio Co-Processor (RCP) with appropriate firmware connected via UART / USB. -endef +ifeq ($(BUILD_VARIANT),avahi) +CMAKE_OPTIONS+= -DOTBR_MDNS="avahi" +else +CMAKE_OPTIONS+= -DOTBR_MDNS="mDNSResponder" +endif define Package/openthread-br/install $(INSTALL_DIR) $(1)/usr/sbin @@ -98,4 +135,12 @@ define Package/openthread-br/install $(CP) $(PKG_BUILD_DIR)/src/openwrt/handle_error.js $(1)/www/luci-static/resources endef +define Package/openthread-br/conffiles +/etc/openthread/ +endef + +Package/openthread-br-avahi/install=$(Package/openthread-br/install) +Package/openthread-br-avahi/conffiles=$(Package/openthread-br/conffiles) + $(eval $(call BuildPackage,openthread-br)) +$(eval $(call BuildPackage,openthread-br-avahi)) diff --git a/third_party/openthread-br/patches/010-init-script.patch b/third_party/openthread-br/patches/010-init-script.patch index 33bb4ab..4cf24f4 100644 --- a/third_party/openthread-br/patches/010-init-script.patch +++ b/third_party/openthread-br/patches/010-init-script.patch @@ -68,7 +68,7 @@ index 46505ff434..e942234fb9 100755 + 'thread_if_name:string' \ + 'infra_if_name:string' \ + 'uart_device:string' \ -+ 'uart_baudrate:uinteger:115200' \ ++ 'uart_baudrate:uinteger:460800' \ + 'uart_flow_control:bool:1' +} + @@ -117,5 +117,5 @@ index 855d708852..d80d91b5ff 100644 +config otbr-agent 'wpan0' + option infra_if_name '@OTBR_INFRA_IF_NAME@' + option uart_device '/dev/ttyACM0' -+ option uart_baudrate '115200' ++ option uart_baudrate '460800' + option uart_flow_control '1'