iproute2: separate tc into tiny and full variants

This change was investigated previously [1] but not deemed necessary. With
the recent addition [2] of modern BPF loader support, however, tc gained
dependencies on libelf and libbpf, with a larger installation footprint.

Similar to ip-tiny/ip-full, split tc into tc-full and tc-tiny variants,
where the latter excludes the eBPF loader, uses a smaller executable, and
avoids libelf and libbpf package dependencies. Both variants provide the
'tc' virtual package, with tc-tiny as the default.

The previous tc package included a loadable module for iptables actions.
Separate this out into a common package, tc-mod-iptables, which both
variants depend on. Some package sizes on mips_24kc:

Before:
  148343  tc_5.11.0-1_mips_24kc.ipk

After:
  144833  tc-full_5.11.0-2_mips_24kc.ipk
  138430  tc-tiny_5.11.0-2_mips_24kc.ipk  (and no libelf or libbpf)
    4115  tc-mod-iptables_5.11.0-2_mips_24kc.ipk

Also fix up some Makefile indentation.

[1] https://github.com/openwrt/openwrt/pull/1627#issuecomment-447619962
[2] b048a305a3 ("iproute2: update to 5.11.0")

Signed-off-by: Tony Ambardar <itugrok@yahoo.com>
This commit is contained in:
Tony Ambardar 2021-03-01 17:14:50 -08:00 committed by Hauke Mehrtens
parent 863ce4f15f
commit 72885e9608

View File

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=iproute2
PKG_VERSION:=5.11.0
PKG_RELEASE:=1
PKG_RELEASE:=2
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_SOURCE_URL:=@KERNEL/linux/utils/net/iproute2
@ -33,8 +33,8 @@ endef
define Package/ip-tiny
$(call Package/iproute2/Default)
TITLE:=Routing control utility (Minimal)
VARIANT:=tiny
TITLE:=Routing control utility (minimal)
VARIANT:=iptiny
DEFAULT_VARIANT:=1
PROVIDES:=ip
ALTERNATIVES:=200:/sbin/ip:/usr/libexec/ip-tiny
@ -43,19 +43,36 @@ endef
define Package/ip-full
$(call Package/iproute2/Default)
TITLE:=Routing control utility (Full)
VARIANT:=full
TITLE:=Routing control utility (full)
VARIANT:=ipfull
PROVIDES:=ip
ALTERNATIVES:=300:/sbin/ip:/usr/libexec/ip-full
DEPENDS:=+libnl-tiny +libbpf +(PACKAGE_devlink||PACKAGE_rdma):libmnl
endef
define Package/tc
define Package/tc-tiny
$(call Package/iproute2/Default)
TITLE:=Traffic control utility
VARIANT:=tc
TITLE:=Traffic control utility (minimal)
VARIANT:=tctiny
DEFAULT_VARIANT:=1
PROVIDES:=tc
DEPENDS:=+kmod-sched-core +libxtables +libbpf +(PACKAGE_devlink||PACKAGE_rdma):libmnl
ALTERNATIVES:=200:/sbin/tc:/usr/libexec/tc-tiny
DEPENDS:=+kmod-sched-core +libxtables +tc-mod-iptables +(PACKAGE_devlink||PACKAGE_rdma):libmnl
endef
define Package/tc-full
$(call Package/iproute2/Default)
TITLE:=Traffic control utility (full)
VARIANT:=tcfull
PROVIDES:=tc
ALTERNATIVES:=300:/sbin/tc:/usr/libexec/tc-full
DEPENDS:=+kmod-sched-core +libxtables +tc-mod-iptables +libbpf +(PACKAGE_devlink||PACKAGE_rdma):libmnl
endef
define Package/tc-mod-iptables
$(call Package/iproute2/Default)
TITLE:=Traffic control module - iptables action
DEPENDS:=+libxtables
endef
define Package/genl
@ -94,18 +111,22 @@ $(call Package/iproute2/Default)
DEPENDS:=+libmnl
endef
ifeq ($(BUILD_VARIANT),tiny)
ifeq ($(BUILD_VARIANT),iptiny)
IP_CONFIG_TINY:=y
LIBBPF_FORCE:=off
endif
ifeq ($(BUILD_VARIANT),full)
ifeq ($(BUILD_VARIANT),ipfull)
HAVE_ELF:=y
LIBBPF_FORCE:=on
HAVE_CAP:=n
endif
ifeq ($(BUILD_VARIANT),tc)
ifeq ($(BUILD_VARIANT),tctiny)
LIBBPF_FORCE:=off
SHARED_LIBS:=y
endif
ifeq ($(BUILD_VARIANT),tcfull)
HAVE_ELF:=y
LIBBPF_FORCE:=on
SHARED_LIBS:=y
@ -163,13 +184,19 @@ define Package/ip-full/install
$(INSTALL_BIN) $(PKG_BUILD_DIR)/ip/ip $(1)/usr/libexec/ip-full
endef
define Package/tc/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/tc/tc $(1)/usr/sbin/
ifeq ($(SHARED_LIBS),y)
define Package/tc-tiny/install
$(INSTALL_DIR) $(1)/usr/libexec
$(INSTALL_BIN) $(PKG_BUILD_DIR)/tc/tc $(1)/usr/libexec/tc-tiny
endef
define Package/tc-full/install
$(INSTALL_DIR) $(1)/usr/libexec
$(INSTALL_BIN) $(PKG_BUILD_DIR)/tc/tc $(1)/usr/libexec/tc-full
endef
define Package/tc-mod-iptables/install
$(INSTALL_DIR) $(1)/usr/lib/tc
$(CP) $(PKG_BUILD_DIR)/tc/*.so $(1)/usr/lib/tc
endif
$(CP) $(PKG_BUILD_DIR)/tc/m_xt.so $(1)/usr/lib/tc
endef
define Package/genl/install
@ -204,7 +231,9 @@ endef
$(eval $(call BuildPackage,ip-tiny))
$(eval $(call BuildPackage,ip-full))
$(eval $(call BuildPackage,tc))
$(eval $(call BuildPackage,tc-tiny))
$(eval $(call BuildPackage,tc-full))
$(eval $(call BuildPackage,tc-mod-iptables))
$(eval $(call BuildPackage,genl))
$(eval $(call BuildPackage,ip-bridge))
$(eval $(call BuildPackage,ss))