From patchwork Sat Jul 10 11:41:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Joachim Wiberg X-Patchwork-Id: 1503467 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=busybox.net (client-ip=2605:bc80:3010::133; helo=smtp2.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=pG151hna; dkim-atps=neutral Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GMSnL1MLdz9sS8 for ; Sat, 10 Jul 2021 21:42:29 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 7A3B7400B5; Sat, 10 Jul 2021 11:42:24 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YwgsnElW7wyY; Sat, 10 Jul 2021 11:42:23 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp2.osuosl.org (Postfix) with ESMTP id 7DAE1402AB; Sat, 10 Jul 2021 11:42:22 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 9B1191BF584 for ; Sat, 10 Jul 2021 11:42:13 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 8A4FA83CF8 for ; Sat, 10 Jul 2021 11:42:13 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp1.osuosl.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 00pXaN3hBasL for ; Sat, 10 Jul 2021 11:42:12 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by smtp1.osuosl.org (Postfix) with ESMTPS id 24C2D83CF7 for ; Sat, 10 Jul 2021 11:42:12 +0000 (UTC) Received: by mail-lj1-x22a.google.com with SMTP id u14so2141657ljh.0 for ; Sat, 10 Jul 2021 04:42:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:organization:content-transfer-encoding; bh=vM/Q0ReUhydqIJq76LfdzRJqK3IpT++r6PKUYVqiPfQ=; b=pG151hna6FK/i9xC3C6EiddCj0e78LseygviuY77N8s/q6DwJkGPjavYeVDTI03tbc 0WvSFoH4t2P+TScH/L/yq7v4C3R864F0g6UfNdnt4OyRatfL39r/ujXif2yD0RrgaqO4 Z6ekV+pP2fzMU3PWB2aa72ErmphpGCQA2xoCwl6IqrotiQp9lEo5OMlQtDaD0Z0Q4A1t yNrAdMTGamMsM5kmlcLhu7RsGU+aDfphLJTuXfMJX7kvBS8HNmDXAQN7iQgMkD2XQX0m XXqsPjqg0o0l5/CbedesZgRf9VNzVyIKgzgPlu9XtUlgzJW2+TxJMwc0CY+c8pktC73/ XAqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:organization:content-transfer-encoding; bh=vM/Q0ReUhydqIJq76LfdzRJqK3IpT++r6PKUYVqiPfQ=; b=ZL/z8wgzCKSzCZ9qdaVQ1D03uSA354rN1yYitrLTmL485eFrOQFWDTkCuu0ZVnANth ZT8MrMmXdRU2oJU50biSCz8JsD4ErzuFBhn0+0ESKJY12DwYChu7qX071dIFfxx3pcz0 60BdWjBojqk0jQ9Mmx2U46glkiitY7Z4WFz9TAILEgLknk1qE7mXs0xcFVJ1alGBxSV8 uPnLPMirO21eOUkUfi7qxbxCoySAG61SpicPSoJAncYN4lBv/7kZnmLLEmpfe6d96H2w ysNu/x9cY6Pbg2G7mUNrxULE5txEq47ghoGx9RenWuggvuFxgsxzHKth52bSfppcAH1G jRTg== X-Gm-Message-State: AOAM533Zum6kDtIZrdZAJb3KZ1X8NDt/t8l4XzhYgxdqg7PBTSQDXiHp gSL86GoZhTbocXOFXg10HuRm+azW1NxipA== X-Google-Smtp-Source: ABdhPJyJB4MYFzPsDsRJpqzx9761AsZBc3GkzJn36mczG8WmGTQE4ff3ZKsRncLd4SuW1GpZRp2fqQ== X-Received: by 2002:a2e:3510:: with SMTP id z16mr17121209ljz.366.1625917329601; Sat, 10 Jul 2021 04:42:09 -0700 (PDT) Received: from wbg.labs.westermo.se (h-155-4-221-38.NA.cust.bahnhof.se. [155.4.221.38]) by smtp.gmail.com with ESMTPSA id k9sm53780ljn.24.2021.07.10.04.42.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Jul 2021 04:42:09 -0700 (PDT) From: Joachim Wiberg To: buildroot@buildroot.org Date: Sat, 10 Jul 2021 13:41:53 +0200 Message-Id: <20210710114153.369531-2-troglobit@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210710114153.369531-1-troglobit@gmail.com> References: <20210710114153.369531-1-troglobit@gmail.com> MIME-Version: 1.0 Organization: Westermo Network Technologies AB Subject: [Buildroot] [PATCH 1/1] package/libteam: new package X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joachim Wiberg , Thomas Petazzoni Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" This package is the userspace daemon, client tool, and library for the team device implementation in the Linux kernel. Team is an alternative to the traditional bonding driver and provides more "runners", or modes, of operation for aggregates. Team devices require the following kernel config, the most common modes have been included to be enabled when this package is selected: CONFIG_NET_TEAM=y CONFIG_NET_TEAM_MODE_ACTIVEBACKUP=y CONFIG_NET_TEAM_MODE_LOADBALANCE=y Other possible, but not enabled, modes are: CONFIG_NET_TEAM_MODE_BROADCAST=y CONFIG_NET_TEAM_MODE_ROUNDROBIN=y CONFIG_NET_TEAM_MODE_RANDOM=y Unfortunately the package relies on fork(), amongst other things, to run, hence BR2_USR_MMU. Backported the three most relevant patches to fix musl build, revert of a fix prior to 1.31 that can cause high CPU load, and a fix to prevent failing to stop the daemon due to too short timeout for kill command. Signed-off-by: Joachim Wiberg --- DEVELOPERS | 1 + package/Config.in | 1 + .../0001-revert-disregard-current-state.patch | 51 +++++++++++++++++++ .../0002-fix-build-on-openwrt-musl-libc.patch | 41 +++++++++++++++ ...3-increase-wait-time-for-daemon-kill.patch | 37 ++++++++++++++ package/libteam/Config.in | 20 ++++++++ package/libteam/libteam.hash | 3 ++ package/libteam/libteam.mk | 22 ++++++++ 8 files changed, 176 insertions(+) create mode 100644 package/libteam/0001-revert-disregard-current-state.patch create mode 100644 package/libteam/0002-fix-build-on-openwrt-musl-libc.patch create mode 100644 package/libteam/0003-increase-wait-time-for-daemon-kill.patch create mode 100644 package/libteam/Config.in create mode 100644 package/libteam/libteam.hash create mode 100644 package/libteam/libteam.mk diff --git a/DEVELOPERS b/DEVELOPERS index 2a69f88299..e46362b6ee 100644 --- a/DEVELOPERS +++ b/DEVELOPERS @@ -1316,6 +1316,7 @@ F: package/rtty/ N: Joachim Wiberg F: configs/globalscale_espressobin_defconfig F: board/globalscale/espressobin/ +F: package/libteam/ F: package/mg/ F: package/netcalc/ F: package/ssdp-responder/ diff --git a/package/Config.in b/package/Config.in index 22947edf2c..6335b04e9d 100644 --- a/package/Config.in +++ b/package/Config.in @@ -1808,6 +1808,7 @@ menu "Networking" source "package/libsoup/Config.in" source "package/libsrtp/Config.in" source "package/libstrophe/Config.in" + source "package/libteam/Config.in" source "package/libtelnet/Config.in" source "package/libtirpc/Config.in" source "package/libtorrent/Config.in" diff --git a/package/libteam/0001-revert-disregard-current-state.patch b/package/libteam/0001-revert-disregard-current-state.patch new file mode 100644 index 0000000000..339afbf416 --- /dev/null +++ b/package/libteam/0001-revert-disregard-current-state.patch @@ -0,0 +1,51 @@ +From 61efd6de2fbb8ee077863ee5a355ac3dfd9365b9 Mon Sep 17 00:00:00 2001 +From: Xin Long +Date: Tue, 1 Sep 2020 13:59:27 +0800 +Subject: [PATCH] Revert "teamd: Disregard current state when considering port + enablement" + +This reverts commit deadb5b715227429a1879b187f5906b39151eca9. + +As Patrick noticed, with that commit, teamd_port_check_enable() +would set the team port to the new state unconditionally, which +triggers another change message from kernel to userspace, then +teamd_port_check_enable() is called again to set the team port +to the new state. + +This would go around and around to update the team port state, +and even cause teamd to consume 100% cpu. + +As the issue caused by that commit is serious, it has to be +reverted. As for the issued fixed by that commit, I would +propose a new fix later. + +Signed-off-by: Jiri Pirko +--- + teamd/teamd_per_port.c | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +diff --git a/teamd/teamd_per_port.c b/teamd/teamd_per_port.c +index 166da57..d429753 100644 +--- a/teamd/teamd_per_port.c ++++ b/teamd/teamd_per_port.c +@@ -442,14 +442,18 @@ int teamd_port_check_enable(struct teamd_context *ctx, + bool should_enable, bool should_disable) + { + bool new_enabled_state; ++ bool curr_enabled_state; + int err; + + if (!teamd_port_present(ctx, tdport)) + return 0; ++ err = teamd_port_enabled(ctx, tdport, &curr_enabled_state); ++ if (err) ++ return err; + +- if (should_enable) ++ if (!curr_enabled_state && should_enable) + new_enabled_state = true; +- else if (should_disable) ++ else if (curr_enabled_state && should_disable) + new_enabled_state = false; + else + return 0; diff --git a/package/libteam/0002-fix-build-on-openwrt-musl-libc.patch b/package/libteam/0002-fix-build-on-openwrt-musl-libc.patch new file mode 100644 index 0000000000..f2b38a137d --- /dev/null +++ b/package/libteam/0002-fix-build-on-openwrt-musl-libc.patch @@ -0,0 +1,41 @@ +From 267f24839536234ca621d4fd0466d3b57cb6dccd Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Pavel=20=C5=A0imerda?= +Date: Tue, 12 Jan 2021 04:41:56 +0100 +Subject: [PATCH] fix build on OpenWRT/musl-libc +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: Pavel Šimerda +Signed-off-by: Jiri Pirko +--- + teamd/teamd_runner_lacp.c | 2 -- + utils/teamnl.c | 1 + + 2 files changed, 1 insertion(+), 2 deletions(-) + +diff --git a/teamd/teamd_runner_lacp.c b/teamd/teamd_runner_lacp.c +index 9437f05..f524be2 100644 +--- a/teamd/teamd_runner_lacp.c ++++ b/teamd/teamd_runner_lacp.c +@@ -23,9 +23,7 @@ + #include + #include + #include +-#include + #include +-#include + #include + #include + #include +diff --git a/utils/teamnl.c b/utils/teamnl.c +index c53345d..ec2b435 100644 +--- a/utils/teamnl.c ++++ b/utils/teamnl.c +@@ -24,6 +24,7 @@ + #include + #include + #include ++#include + #include + #include + #include diff --git a/package/libteam/0003-increase-wait-time-for-daemon-kill.patch b/package/libteam/0003-increase-wait-time-for-daemon-kill.patch new file mode 100644 index 0000000000..7827a654ef --- /dev/null +++ b/package/libteam/0003-increase-wait-time-for-daemon-kill.patch @@ -0,0 +1,37 @@ +From 6875e6c8efb0fe86766b3d4f1d0db390af6998b7 Mon Sep 17 00:00:00 2001 +From: Hangbin Liu +Date: Tue, 15 Dec 2020 19:33:17 +0800 +Subject: [PATCH] teamd: increase the waitting time for daemon killing + +In the current code, we wait for at most 5s when kill the daemon pid. +But in some environment, it may need more time. Then the teamd -k will +failed and return error "Failed to kill daemon: Timer expired". + +Let's increase the value to have enough time. Here is the reuslt with +this patch: + +$ time libteam/teamd/teamd -k -t team0 + +real 0m10.442s +user 0m0.017s +sys 0m0.016s + +Signed-off-by: Hangbin Liu +Signed-off-by: Jiri Pirko +--- + teamd/teamd.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/teamd/teamd.c b/teamd/teamd.c +index 9360cbf..b310140 100644 +--- a/teamd/teamd.c ++++ b/teamd/teamd.c +@@ -1858,7 +1858,7 @@ int main(int argc, char **argv) + break; + case DAEMON_CMD_KILL: + if (daemon_pid_file_is_running() > 0) { +- err = daemon_pid_file_kill_wait(SIGTERM, 5); ++ err = daemon_pid_file_kill_wait(SIGTERM, 30); + if (err) + teamd_log_warn("Failed to kill daemon: %s", + strerror(errno)); diff --git a/package/libteam/Config.in b/package/libteam/Config.in new file mode 100644 index 0000000000..743c0a4f7e --- /dev/null +++ b/package/libteam/Config.in @@ -0,0 +1,20 @@ +config BR2_PACKAGE_LIBTEAM + bool "libteam" + depends on BR2_USE_MMU # fork() + select BR2_PACKAGE_JANSSON + select BR2_PACKAGE_LIBDAEMON + select BR2_PACKAGE_LIBNL + select BR2_PACKAGE_LIBNL_TOOLS + help + The purpose of the Team driver is to provide a mechanism to + team multiple NICs (ports) into one logical one (teamdev) at + L2 layer. The process is called "channel bonding", "Ethernet + bonding", "channel teaming", "link aggregation", etc. + + Team tries to provide similar functionality as the bonding + driver, however architecturally it is quite different. Team is + modular, userspace driven, very lean and efficient, and it + does have some distinct advantages over bonding. The way Team + is configured differs dramatically from the way bonding is. + + https://github.com/jpirko/libteam diff --git a/package/libteam/libteam.hash b/package/libteam/libteam.hash new file mode 100644 index 0000000000..39d29425d3 --- /dev/null +++ b/package/libteam/libteam.hash @@ -0,0 +1,3 @@ +# Locally calculated +sha256 c69f7cf5a98203d66db10e67b396fe325b77a5a9491d1e07e8a07cba3ba841bb libteam-1.31.tar.gz +sha256 dc626520dcd53a22f727af3ee42c770e56c97a64fe3adb063799d8ab032fe551 COPYING diff --git a/package/libteam/libteam.mk b/package/libteam/libteam.mk new file mode 100644 index 0000000000..2a66345192 --- /dev/null +++ b/package/libteam/libteam.mk @@ -0,0 +1,22 @@ +################################################################################ +# +# libteam +# +################################################################################ + +LIBTEAM_VERSION = 1.31 +LIBTEAM_SITE = $(call github,jpirko,libteam,v$(LIBTEAM_VERSION)) +LIBTEAM_AUTORECONF = YES +LIBTEAM_LICENSE = LGPL-2.1+ +LIBTEAM_LICENSE_FILES = COPYING +LIBTEAM_INSTALL_STAGING = YES +LIBTEAM_DEPENDENCIES = host-pkgconf jansson libdaemon libnl + +# The most common team modes, use a custom kernel config to enable more. +define LIBTEAM_LINUX_CONFIG_FIXUPS + $(call KCONFIG_ENABLE_OPT,CONFIG_NET_TEAM) + $(call KCONFIG_ENABLE_OPT,CONFIG_NET_TEAM_MODE_ACTIVEBACKUP) + $(call KCONFIG_ENABLE_OPT,CONFIG_NET_TEAM_MODE_LOADBALANCE) +endef + +$(eval $(autotools-package))