Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 128 additions & 0 deletions net/libteam/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=libteam
PKG_VERSION:=1.32
PKG_RELEASE:=1

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/jpirko/libteam/tar.gz/refs/tags/v$(PKG_VERSION)?
PKG_HASH:=7ad90555db8aecdcaf002f543d330408501600edf7065e0ca398fce9b1e64820

PKG_FIXUP:=autoreconf
PKG_INSTALL:=1
PKG_BUILD_PARALLEL:=1
PKG_BUILD_FLAGS:=lto

PKG_MAINTAINER:=Qingfang Deng <[email protected]>
PKG_LICENSE:=LGPL-2.1-only
PKG_LICENSE_FILES:=COPYING

include $(INCLUDE_DIR)/package.mk

CONFIGURE_ARGS+=--disable-static

define Package/libteam/default
SECTION:=libs
CATEGORY:=Libraries
URL:=https://github.com/jpirko/libteam
endef

define Package/libteam
$(Package/libteam/default)
TITLE:=Team common library
DEPENDS:=+kmod-team +libnl-cli
ABI_VERSION:=5
endef

define Package/libteam/description
Libteam lib is a userspace wrapper of Team Netlink communication.
endef

define Package/libteamdctl
$(Package/libteam/default)
TITLE:=Team daemon control library
ABI_VERSION:=0
endef

define Package/libteamdctl/description
Common library for teamdctl.
endef

define Package/teamd/default
SECTION:=net
CATEGORY:=Network
URL:=https://github.com/jpirko/libteam
endef

define Package/teamd
$(Package/teamd/default)
TITLE:=Team daemon
DEPENDS:=+libteam +libdaemon +jansson
endef

define Package/teamd/description
teamd is a daemon to control a given team network device, during runtime,
as a puppeteer controls a puppet. It uses libteam to communicate with the
kernel team device instance via Netlink sockets. The behaviour depends on
the selected runner and its configuration.
endef

define Package/teamdctl
$(Package/teamd/default)
TITLE:=Team daemon control tool
DEPENDS:=+teamd +libteamdctl
endef

define Package/teamdctl/description
teamdctl is a tool that allows a user to interact with a running teamd instance.
endef

define Package/teamnl
$(Package/teamd/default)
TITLE:=Team Netlink interface tool
DEPENDS:=+libteam
endef

define Package/teamnl/description
teamnl is a tool enabling interaction with a team device via the team driver
Netlink interface. This tools serves mainly for debugging purposes. Note that
it makes no sense to use this tool to change options on team device controlled
by a teamd instance.
endef

define Build/InstallDev
$(INSTALL_DIR) $(1)/usr
$(CP) $(PKG_INSTALL_DIR)/usr/include $(1)/usr
$(CP) $(PKG_INSTALL_DIR)/usr/lib $(1)/usr
endef

define Package/libteam/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libteam.so.$(ABI_VERSION)* $(1)/usr/lib/
endef

define Package/libteamdctl/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libteamdctl.so.$(ABI_VERSION)* $(1)/usr/lib/
endef

define Package/teamd/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/teamd $(1)/usr/bin/
endef

define Package/teamdctl/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/teamdctl $(1)/usr/bin/
endef

define Package/teamnl/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/teamnl $(1)/usr/bin/
endef

$(eval $(call BuildPackage,libteam))
$(eval $(call BuildPackage,libteamdctl))
$(eval $(call BuildPackage,teamd))
$(eval $(call BuildPackage,teamdctl))
$(eval $(call BuildPackage,teamnl))
Comment on lines +124 to +128
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You added 5 packages, but in the commit description and in the commit itself, you mentioned only one. Please try to describe a little bit more in your commit why do we need to have 5 packages, what is the size, etc. I think (maybe...) you splitted it into so many packages and it is not necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From Project Wiki and HOWTO

  • libteam.so is a wrapper library to interface the Team Netlink API.
  • teamd is a service/daemon to control a team netdev using the libteam library.
  • teamdctl is a utility to alter teamd configuration at runtime.
  • libteamdctl.so is a library used by teamdctl
  • teamnl is an alternative to teamd.

apk size on cortex-a53:

18703 libteam5-1.32-r1.apk
 6250 libteamdctl0-1.32-r1.apk
48211 teamd-1.32-r1.apk
 8970 teamdctl-1.32-r1.apk
 6010 teamnl-1.32-r1.apk

Then I noticed all uncompressed ELF sizes (not just libteam, but other packages also) are multiple of 64KiB. Is that normal?

> ll /usr/bin/team*
-rwxr-xr-x    1 root     root        131449 Dec 16 17:29 /usr/bin/teamd*
-rwxr-xr-x    1 root     root         65499 Dec 16 17:29 /usr/bin/teamdctl*
-rwxr-xr-x    1 root     root         65499 Dec 16 17:29 /usr/bin/teamnl*

> ll /usr/lib/libteam*
lrwxrwxrwx    1 root     root            16 Dec 16 17:29 /usr/lib/libteam.so.5 -> libteam.so.5.6.2*
-rwxr-xr-x    1 root     root         65539 Dec 16 17:29 /usr/lib/libteam.so.5.6.2*
lrwxrwxrwx    1 root     root            20 Dec 16 17:29 /usr/lib/libteamdctl.so.0 -> libteamdctl.so.0.1.6*
-rwxr-xr-x    1 root     root         65539 Dec 16 17:29 /usr/lib/libteamdctl.so.0.1.6*

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there has been a misunderstanding here. I was asking why we actually need 5 different packages, because when I look at https://repology.org/, I only see the libteam package there, not the others.

For example, in Debian, some of these tools are packaged as libteam-utils, while elsewhere they appear as libteam-tools. I would prefer not to reinvent the wheel here; I think we should follow what is done in other GNU/Linux distributions so we don't fragment it further or create something non-standard. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debian is a desktop distro, while OpenWrt is not. We have size constraints.

teamd and teamnl are mutually exclusive, so I think it's better to split them. ALT Linux does that too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If these two are mutually exclusive, they should be marked as such either through PROVIDES or CONFLICTS.

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
From 4eb54a811bef43da2be9cc84009567e5d6ca9741 Mon Sep 17 00:00:00 2001
From: Khem Raj <[email protected]>
Date: Sat, 11 May 2024 23:15:59 -0700
Subject: [PATCH] teamd: Pass correct parameter type to accept API

accept() expects sockaddr as second parameter

int accept (int, struct sockaddr *__restrict, socklen_t *__restrict);

Fixes build with gcc-16 on musl systems
| ../../git/teamd/teamd_usock.c: In function 'callback_usock':
| ../../git/teamd/teamd_usock.c:280:40: error: passing argument 2 of 'accept' from incompatible pointer type [-Wincompatible-pointer-types]
| 280 | sock = accept(ctx->usock.sock, &addr, &alen);
| | ^~~~~
| | |
| | struct sockaddr_un *

Signed-off-by: Khem Raj <[email protected]>
Signed-off-by: Jiri Pirko <[email protected]>
---
teamd/teamd_usock.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

--- a/teamd/teamd_usock.c
+++ b/teamd/teamd_usock.c
@@ -277,7 +277,7 @@ static int callback_usock(struct teamd_c
int err;

alen = sizeof(addr);
- sock = accept(ctx->usock.sock, &addr, &alen);
+ sock = accept(ctx->usock.sock, (struct sockaddr *)&addr, &alen);
if (sock == -1) {
teamd_log_err("usock: Failed to accept connection.");
return -errno;