From 72885e9608d9c0fa06abce6bdb6dd054c2116eb7 Mon Sep 17 00:00:00 2001 From: Tony Ambardar Date: Mon, 1 Mar 2021 17:14:50 -0800 Subject: [PATCH] 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] b048a305a3d3 ("iproute2: update to 5.11.0") Signed-off-by: Tony Ambardar --- package/network/utils/iproute2/Makefile | 83 +++++++++++++++++-------- 1 file changed, 56 insertions(+), 27 deletions(-) diff --git a/package/network/utils/iproute2/Makefile b/package/network/utils/iproute2/Makefile index a20e81c75a..b1a137c18f 100644 --- a/package/network/utils/iproute2/Makefile +++ b/package/network/utils/iproute2/Makefile @@ -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,29 +33,46 @@ endef define Package/ip-tiny $(call Package/iproute2/Default) - TITLE:=Routing control utility (Minimal) - VARIANT:=tiny - DEFAULT_VARIANT:=1 - PROVIDES:=ip - ALTERNATIVES:=200:/sbin/ip:/usr/libexec/ip-tiny - DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl + TITLE:=Routing control utility (minimal) + VARIANT:=iptiny + DEFAULT_VARIANT:=1 + PROVIDES:=ip + ALTERNATIVES:=200:/sbin/ip:/usr/libexec/ip-tiny + DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl endef define Package/ip-full $(call Package/iproute2/Default) - TITLE:=Routing control utility (Full) - VARIANT:=full - PROVIDES:=ip - ALTERNATIVES:=300:/sbin/ip:/usr/libexec/ip-full - DEPENDS:=+libnl-tiny +libbpf +(PACKAGE_devlink||PACKAGE_rdma):libmnl + 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-tiny +$(call Package/iproute2/Default) + TITLE:=Traffic control utility (minimal) + VARIANT:=tctiny + DEFAULT_VARIANT:=1 + PROVIDES:=tc + 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 +define Package/tc-full $(call Package/iproute2/Default) - TITLE:=Traffic control utility - VARIANT:=tc + TITLE:=Traffic control utility (full) + VARIANT:=tcfull PROVIDES:=tc - DEPENDS:=+kmod-sched-core +libxtables +libbpf +(PACKAGE_devlink||PACKAGE_rdma):libmnl + 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)) -- 2.30.2