Skip to contentSkip to conversation

Add support for teamd/libteam

PATCH Superseded Joachim Wiberg 2 participants 4 messages Jul 15, 2021 – Jul 19, 2021

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover Add support for teamd/libteam

Hi!

This patch adds support for teamd/libteam to Buildroot. A few musl libc related patches have been backported from project's master branch at

https://github.com/jpirko/libteam/

Basic tests pass:

    $ ./utils/check-package package/libteam/*
    187 lines processed
    0 warnings generated
    $ ./utils/test-pkg -c libteam.config -p libteam
                        bootlin-armv5-uclibc [1/6]: OK
                         bootlin-armv7-glibc [2/6]: OK
                       bootlin-armv7m-uclibc [3/6]: SKIPPED
                         bootlin-x86-64-musl [4/6]: OK
                          br-arm-full-static [5/6]: OK
                                sourcery-arm [6/6]: OK
    6 builds, 1 skipped, 0 build failed, 0 legal-info failed

Best regards
/Joachim

---
v2: added missing libnl deps in libteam/Config.in (Yegor)

Joachim Wiberg (1):
package/libteam: new package

 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                     | 26 ++++++++++
 package/libteam/libteam.hash                  |  3 ++
 package/libteam/libteam.mk                    | 22 ++++++++
 8 files changed, 182 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
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 1/1 package/libteam: new package

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

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.

---
 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                     | 26 ++++++++++
 package/libteam/libteam.hash                  |  3 ++
 package/libteam/libteam.mk                    | 22 ++++++++
 8 files changed, 182 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
DEVELOPERS +1 -0
index 2a69f88299..e46362b6ee 100644
@@ -1316,6 +1316,7 @@ F:	package/rtty/
 N:	Joachim Wiberg <[email protected]>
 F:	configs/globalscale_espressobin_defconfig
 F:	board/globalscale/espressobin/
+F:	package/libteam/
 F:	package/mg/
 F:	package/netcalc/
 F:	package/ssdp-responder/
package/Config.in +1 -0
index e883cf3780..f55d9f4cc2 100644
@@ -1809,6 +1809,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"
package/libteam/0001-revert-disregard-current-state.patch new file +51 -0

51 lines not on this page · raw message

package/libteam/0002-fix-build-on-openwrt-musl-libc.patch new file +41 -0

41 lines not on this page · raw message

package/libteam/0003-increase-wait-time-for-daemon-kill.patch new file +37 -0
new file mode 100644
index 0000000000..7827a654ef
@@ -0,0 +1,37 @@
+From 6875e6c8efb0fe86766b3d4f1d0db390af6998b7 Mon Sep 17 00:00:00 2001
+From: Hangbin Liu <[email protected]>
+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 <[email protected]>
+Signed-off-by: Jiri Pirko <[email protected]>
+---
+ 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));
package/libteam/Config.in new file +26 -0
new file mode 100644
index 0000000000..e44bdeeba8
@@ -0,0 +1,26 @@
+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
+
+comment "libnl tools needs a toolchain w/ dynamic library"
+	depends on BR2_STATIC_LIBS
+
+comment "libnl needs a toolchain w/ threads"
+	depends on !BR2_TOOLCHAIN_HAS_THREADS
package/libteam/libteam.hash new file +3 -0
new file mode 100644
index 0000000000..39d29425d3
@@ -0,0 +1,3 @@
+# Locally calculated
+sha256  c69f7cf5a98203d66db10e67b396fe325b77a5a9491d1e07e8a07cba3ba841bb  libteam-1.31.tar.gz
+sha256  dc626520dcd53a22f727af3ee42c770e56c97a64fe3adb063799d8ab032fe551  COPYING
package/libteam/libteam.mk new file +22 -0
new file mode 100644
index 0000000000..2a66345192
@@ -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))
Signature · 1 line
2.25.1
#2 lore raw

PATCH v2 1/1 package/libteam: new package

Joachim, All,

On 2021-07-15 10:34 +0200, Joachim Wiberg spake thusly:

Quoted 9 lines

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

This also needs NETDEVICES and NET_CORE. Arguably, those two will most probably be selected, but still...

Quoted 2 lines

CONFIG_NET_TEAM_MODE_ACTIVEBACKUP=y
CONFIG_NET_TEAM_MODE_LOADBALANCE=y

Is it really necessary to select those last two?

Load-balancing requires BPF, too, to load the BPF function that will do the port selection.

But I would really just leave it up to the user to enable whatever mode they need/want; just enforce CONFIG_NET_TEAM=y (and NETDEVICES and NET_CORE, of course).

Quoted 5 lines

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

Those do look like they are not really usefull in production, and are rather for testing pruposes, indeed.

Quoted 7 lines

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.

---

[--SNIP--]

package/libteam/Config.in line 7

Quoted 13 lines
package/libteam/Config.in new file +7 -0
new file mode 100644
index 0000000000..e44bdeeba8
@@ -0,0 +1,26 @@
+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

As noted by Yegor previopusly, you need to propagate the dependencies of the packags you select;

depends on BR2_TOOLCHAIN_HAS_THREADS # libnl
depends on !BR2_STATIC_LIBS # libnl-tools
select BR2_PACKAGE_LIBNL
select BR2_PACKAGE_LIBNL_TOOLS

Quoted 5 lines
package/libteam/Config.in new file +5 -0
+	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.

package/libteam/Config.in line 22

Quoted 10 lines
package/libteam/Config.in new file +10 -0
+
+	  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
+
+comment "libnl tools needs a toolchain w/ dynamic library"

This is not libnl, but libteam (the comment is about this package).

package/libteam/Config.in line 23

Quoted 1 line
package/libteam/Config.in new file +1 -0
+	depends on BR2_STATIC_LIBS

The comment should also depend on MMU, so that it is not visible when MMU is not enabled.

package/libteam/Config.in line 26

Quoted 3 lines
package/libteam/Config.in new file +3 -0
+
+comment "libnl needs a toolchain w/ threads"
+	depends on !BR2_TOOLCHAIN_HAS_THREADS

Ditto, this is libteam, and it should also depend on MMU.

Quoted 18 lines
package/libteam/libteam.hash new file +3 -0
new file mode 100644
index 0000000000..39d29425d3
@@ -0,0 +1,3 @@
+# Locally calculated
+sha256  c69f7cf5a98203d66db10e67b396fe325b77a5a9491d1e07e8a07cba3ba841bb  libteam-1.31.tar.gz
+sha256  dc626520dcd53a22f727af3ee42c770e56c97a64fe3adb063799d8ab032fe551  COPYING
package/libteam/libteam.mk new file +3 -0
new file mode 100644
index 0000000000..2a66345192
@@ -0,0 +1,22 @@
+################################################################################
+#
+# libteam

package/libteam/libteam.mk line 13

Quoted 10 lines
package/libteam/libteam.mk new file +10 -0
+#
+################################################################################
+
+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

Pet-peeve of mine, about the ordering:

    _VERSION = ...
    _SITE = ...

    _CPE_ID_xxx = ... (if any)
    _LICENSE = ...
    _LICENSE_FILES = ...

    _DEPENDENCIES = ...
    _AUTORECONF = YES
    _INSTALL_STAGING = YES

This is enforced nowhere, is decribed nowhere, but it follows quite a logical ordering and grouping:

- where to find it
- what it is (cpe) and the conditions to use it (license)
- what it needs
- how to pre-configure it
- where to instal it (staging., target...)

Regards,
Yann E. MORIN.

Quoted 15 lines
package/libteam/libteam.mk new file +8 -0
+# 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))
Signature · 6 lines
2.25.1

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#3 lore raw

PATCH v2 1/1 package/libteam: new package

Hi Yann!

Quoted 7 lines · Yann E. MORIN

On 2021-07-15 10:34 +0200, Joachim Wiberg spake thusly:

Quoted 4 lines

[snip]
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

This also needs NETDEVICES and NET_CORE. Arguably, those two will most probably be selected, but still...

Ah, thanks or course!

Quoted 3 lines
Quoted 2 lines

CONFIG_NET_TEAM_MODE_ACTIVEBACKUP=y
CONFIG_NET_TEAM_MODE_LOADBALANCE=y

Is it really necessary to select those last two?

I think least one mode should be enabled, but then I'm just focusing too much on my particular use-case (active-backup).

Quoted 2 lines

Load-balancing requires BPF, too, to load the BPF function that will do the port selection.

True, so that one goes without saying.

Quoted 3 lines

But I would really just leave it up to the user to enable whatever mode they need/want; just enforce CONFIG_NET_TEAM=y (and NETDEVICES and NET_CORE, of course).

Hmm, OK you're right. We shouldn't guess what the user needs and this being an advanced component make that pretty clear. Thank you!

Quoted 8 lines
Quoted 8 lines

[snop]
+++ b/package/libteam/Config.in

package/libteam/Config.in new file +5 -0
@@ -0,0 +1,26 @@
+config BR2_PACKAGE_LIBTEAM
+	bool "libteam"
+	depends on BR2_USE_MMU # fork()
+	select BR2_PACKAGE_JANSSON
+	select BR2_PACKAGE_LIBDAEMON
Quoted 8 lines

package/libteam/Config.in line 7

Quoted 2 lines
package/libteam/Config.in new file +2 -0
+	select BR2_PACKAGE_LIBNL
+	select BR2_PACKAGE_LIBNL_TOOLS

As noted by Yegor previopusly, you need to propagate the dependencies of the packags you select;
depends on BR2_TOOLCHAIN_HAS_THREADS # libnl
depends on !BR2_STATIC_LIBS # libnl-tools
select BR2_PACKAGE_LIBNL
select BR2_PACKAGE_LIBNL_TOOLS

Ahaa, now I'm finally starting to understand! :)

Quoted 2 lines

package/libteam/Config.in line 22

Quoted 1 line
package/libteam/Config.in new file +1 -0
+comment "libnl tools needs a toolchain w/ dynamic library"

This is not libnl, but libteam (the comment is about this package).

Got it, that makes much more sense. I really didn't get it the first time around. Sorry for the mess.

Quoted 3 lines

package/libteam/Config.in line 23

Quoted 1 line
package/libteam/Config.in new file +1 -0
+	depends on BR2_STATIC_LIBS

The comment should also depend on MMU, so that it is not visible when MMU is not enabled.

OK, fixing.

Quoted 3 lines

package/libteam/Config.in line 26

Quoted 2 lines
package/libteam/Config.in new file +2 -0
+comment "libnl needs a toolchain w/ threads"
+	depends on !BR2_TOOLCHAIN_HAS_THREADS

Ditto, this is libteam, and it should also depend on MMU.

Just read through a ton of other Config.in's, and I think I've got it now how depe?dencies and the user-friendly comment helper work.

Quoted 11 lines

package/libteam/libteam.mk line 13

Quoted 8 lines

[snip]

package/libteam/libteam.mk new file +7 -0
+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

Pet-peeve of mine, about the ordering:
This is enforced nowhere, is decribed nowhere, but it follows quite a logical ordering and grouping:

Thank you for taking the time to explain, it does indeed make sense, I will fix that too in v3.

Cheers
/Joachim