iproute2: add cake fwmark support

This commit is contained in:
coolsnowwolf 2019-03-20 14:30:49 +08:00
parent d118a76231
commit a52f85c70f
17 changed files with 416 additions and 493 deletions

View File

@ -8,12 +8,12 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=elfutils
PKG_VERSION:=0.174
PKG_RELEASE:=2
PKG_VERSION:=0.175
PKG_RELEASE:=4
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=https://sourceware.org/$(PKG_NAME)/ftp/$(PKG_VERSION)
PKG_HASH:=cdf27e70076e10a29539d89e367101d516bc4aa11b0d7777fe52139e3fcad08a
PKG_HASH:=f7ef925541ee32c6d15ae5cb27da5f119e01a5ccdbe9fe57bf836730d7b7a65b
PKG_MAINTAINER:=Luiz Angelo Daros de Luca <luizluca@gmail.com>
PKG_LICENSE:=GPL-3.0+
PKG_LICENSE_FILES:=COPYING COPYING-GPLV2 COPYING-LGPLV3
@ -33,24 +33,26 @@ define Package/elfutils/Default
CATEGORY:=Libraries
TITLE:=ELF manipulation libraries
URL:=https://fedorahosted.org/elfutils/
ABI_VERSION:=1
endef
define Package/libasm
$(call Package/elfutils/Default)
TITLE+= (libasm)
DEPENDS:=libelf1 +libdw
DEPENDS:=+libelf +libdw
endef
define Package/libdw
$(call Package/elfutils/Default)
DEPENDS:=libelf1 +libbz2
DEPENDS:=+libelf +libbz2
TITLE+= (libdw)
endef
define Package/libelf1
define Package/libelf
$(call Package/elfutils/Default)
DEPENDS:=$(INTL_DEPENDS) +zlib
TITLE+= (libelf)
PROVIDES:=libelf1
endef
ifeq ($(CONFIG_BUILD_NLS),y)
@ -79,19 +81,19 @@ endef
define Package/libasm/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libasm*.so* $(1)/usr/lib/
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libasm{-*.so,*.so.*} $(1)/usr/lib/
endef
define Package/libdw/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libdw*.so* $(1)/usr/lib/
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libdw{-*.so,*.so.*} $(1)/usr/lib/
endef
define Package/libelf1/install
define Package/libelf/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libelf*.so* $(1)/usr/lib/
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libelf{-*.so,*.so.*} $(1)/usr/lib/
endef
$(eval $(call BuildPackage,libasm))
$(eval $(call BuildPackage,libdw))
$(eval $(call BuildPackage,libelf1))
$(eval $(call BuildPackage,libelf))

View File

@ -8,12 +8,12 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=iproute2
PKG_VERSION:=4.19.0
PKG_RELEASE:=8
PKG_VERSION:=4.20.0
PKG_RELEASE:=3
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_SOURCE_URL:=@KERNEL/linux/utils/net/iproute2
PKG_HASH:=d9ec5ca1f47d8a85416fa26e7dc1cbf5d067640eb60e90bdc1c7e5bdc6a29984
PKG_HASH:=c8adaa6a40f888476b23acb283cfa30c0dd55f07b5aa20663ed5ba2ef1f6fda8
PKG_BUILD_PARALLEL:=1
PKG_BUILD_DEPENDS:=iptables
PKG_LICENSE:=GPL-2.0
@ -37,6 +37,7 @@ 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
@ -48,55 +49,66 @@ $(call Package/iproute2/Default)
VARIANT:=full
PROVIDES:=ip
ALTERNATIVES:=300:/sbin/ip:/usr/libexec/ip-full
DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl
DEPENDS:=+libnl-tiny +libelf +(PACKAGE_devlink||PACKAGE_rdma):libmnl
endef
define Package/tc
$(call Package/iproute2/Default)
TITLE:=Traffic control utility
DEPENDS:=+kmod-sched-core +(PACKAGE_devlink||PACKAGE_rdma):libmnl +libelf1
VARIANT:=tc
PROVIDES:=tc
DEPENDS:=+kmod-sched-core +libxtables +libelf +(PACKAGE_devlink||PACKAGE_rdma):libmnl
endef
define Package/genl
$(call Package/iproute2/Default)
TITLE:=General netlink utility frontend
DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl
DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl +(PACKAGE_tc||PACKAGE_ip-full):libelf
endef
define Package/ip-bridge
$(call Package/iproute2/Default)
TITLE:=Bridge configuration utility from iproute2
DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl
DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl +(PACKAGE_tc||PACKAGE_ip-full):libelf
endef
define Package/ss
$(call Package/iproute2/Default)
TITLE:=Socket statistics utility
DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl
DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl +(PACKAGE_tc||PACKAGE_ip-full):libelf
endef
define Package/nstat
$(call Package/iproute2/Default)
TITLE:=Network statistics utility
DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl
DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl +(PACKAGE_tc||PACKAGE_ip-full):libelf
endef
define Package/devlink
$(call Package/iproute2/Default)
TITLE:=Network devlink utility
DEPENDS:=+libmnl
DEPENDS:=+libmnl +(PACKAGE_tc||PACKAGE_ip-full):libelf
endef
define Package/rdma
$(call Package/iproute2/Default)
TITLE:=Network rdma utility
DEPENDS:=+libmnl
DEPENDS:=+libmnl +(PACKAGE_tc||PACKAGE_ip-full):libelf
endef
ifeq ($(BUILD_VARIANT),tiny)
IP_CONFIG_TINY:=y
endif
ifeq ($(BUILD_VARIANT),full)
HAVE_ELF:=y
endif
ifeq ($(BUILD_VARIANT),tc)
HAVE_ELF:=y
SHARED_LIBS:=y
endif
ifdef CONFIG_PACKAGE_devlink
HAVE_MNL:=y
endif
@ -106,25 +118,22 @@ ifdef CONFIG_PACKAGE_rdma
endif
define Build/Configure
$(SED) "s,-I/usr/include/db3,," $(PKG_BUILD_DIR)/Makefile
$(SED) "s,^KERNEL_INCLUDE.*,KERNEL_INCLUDE=$(LINUX_DIR)/include," \
$(PKG_BUILD_DIR)/Makefile
$(SED) "s,^LIBC_INCLUDE.*,LIBC_INCLUDE=$(STAGING_DIR)/include," \
$(PKG_BUILD_DIR)/Makefile
echo "static const char SNAPSHOT[] = \"$(PKG_VERSION)-$(PKG_RELEASE)-openwrt\";" \
> $(PKG_BUILD_DIR)/include/SNAPSHOT.h
endef
TARGET_CFLAGS += -ffunction-sections -fdata-sections
TARGET_LDFLAGS += -Wl,--gc-sections
TARGET_CPPFLAGS += -I$(STAGING_DIR)/usr/include/libnl-tiny
MAKE_FLAGS += \
EXTRA_CCOPTS="-I$(STAGING_DIR)/usr/include/libnl-tiny" \
KERNEL_INCLUDE="$(LINUX_DIR)/include" \
SHARED_LIBS="" \
LDFLAGS="$(TARGET_LDFLAGS) -Wl,--gc-sections" \
KERNEL_INCLUDE="$(LINUX_DIR)/user_headers/include" \
SHARED_LIBS=$(SHARED_LIBS) \
IP_CONFIG_TINY=$(IP_CONFIG_TINY) \
HAVE_ELF=$(HAVE_ELF) \
HAVE_MNL=$(HAVE_MNL) \
IPT_LIB_DIR=/usr/lib/iptables \
XT_LIB_DIR=/usr/lib/iptables \
FPIC="$(FPIC)"
define Build/Compile
@ -153,6 +162,10 @@ define Package/tc/install
$(INSTALL_BIN) $(PKG_BUILD_DIR)/tc/tc $(1)/usr/sbin/
$(INSTALL_DIR) $(1)/etc/hotplug.d/iface
$(INSTALL_BIN) ./files/15-teql $(1)/etc/hotplug.d/iface/
ifeq ($(SHARED_LIBS),y)
$(INSTALL_DIR) $(1)/usr/lib/tc
$(CP) $(PKG_BUILD_DIR)/tc/*.so $(1)/usr/lib/tc
endif
endef
define Package/genl/install

View File

@ -1,343 +0,0 @@
From 90c5c969f0b9a2fbb0016b955fecc359aa884220 Mon Sep 17 00:00:00 2001
From: Stephen Hemminger <stephen@networkplumber.org>
Date: Mon, 10 Dec 2018 14:20:32 -0800
Subject: [PATCH] fix print_0xhex on 32 bit
The argument to print_0xhex is converted to unsigned long long
so the format string give for normal printout has to be some
variant of %llx. Otherwise, bogus values will be printed on
32 bit platforms.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
bridge/link.c | 2 +-
ip/ipaddress.c | 2 +-
ip/iplink_bridge.c | 2 +-
ip/iplink_bridge_slave.c | 6 +++---
ip/iplink_geneve.c | 5 ++---
ip/iplink_vxlan.c | 8 +++-----
ip/ipntable.c | 2 +-
ip/iproute.c | 8 ++++----
ip/iproute_lwtunnel.c | 2 +-
ip/iprule.c | 6 +++---
ip/iptuntap.c | 2 +-
ip/link_gre.c | 6 +++---
ip/link_gre6.c | 4 ++--
ip/link_ip6tnl.c | 2 +-
ip/link_iptnl.c | 4 ++--
ip/link_vti.c | 2 +-
ip/link_vti6.c | 2 +-
tc/m_ife.c | 2 +-
tc/q_htb.c | 2 +-
tc/q_taprio.c | 2 +-
20 files changed, 34 insertions(+), 37 deletions(-)
--- a/bridge/link.c
+++ b/bridge/link.c
@@ -90,7 +90,7 @@ static void print_hwmode(__u16 mode)
{
if (mode >= ARRAY_SIZE(hw_mode))
print_0xhex(PRINT_ANY, "hwmode",
- "hwmode %#hx ", mode);
+ "hwmode %#llx ", mode);
else
print_string(PRINT_ANY, "hwmode",
"hwmode %s ", hw_mode[mode]);
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -129,7 +129,7 @@ static void print_operstate(FILE *f, __u
if (is_json_context())
print_uint(PRINT_JSON, "operstate_index", NULL, state);
else
- print_0xhex(PRINT_FP, NULL, "state %#x", state);
+ print_0xhex(PRINT_FP, NULL, "state %#llx", state);
} else if (brief) {
print_color_string(PRINT_ANY,
oper_state_color(state),
--- a/ip/iplink_bridge.c
+++ b/ip/iplink_bridge.c
@@ -524,7 +524,7 @@ static void bridge_print_opt(struct link
if (tb[IFLA_BR_GROUP_FWD_MASK])
print_0xhex(PRINT_ANY,
"group_fwd_mask",
- "group_fwd_mask %#x ",
+ "group_fwd_mask %#llx ",
rta_getattr_u16(tb[IFLA_BR_GROUP_FWD_MASK]));
if (tb[IFLA_BR_GROUP_ADDR]) {
--- a/ip/iplink_bridge_slave.c
+++ b/ip/iplink_bridge_slave.c
@@ -167,11 +167,11 @@ static void bridge_slave_print_opt(struc
rta_getattr_u8(tb[IFLA_BRPORT_UNICAST_FLOOD]));
if (tb[IFLA_BRPORT_ID])
- print_0xhex(PRINT_ANY, "id", "port_id 0x%x ",
+ print_0xhex(PRINT_ANY, "id", "port_id %#llx ",
rta_getattr_u16(tb[IFLA_BRPORT_ID]));
if (tb[IFLA_BRPORT_NO])
- print_0xhex(PRINT_ANY, "no", "port_no 0x%x ",
+ print_0xhex(PRINT_ANY, "no", "port_no %#llx ",
rta_getattr_u16(tb[IFLA_BRPORT_NO]));
if (tb[IFLA_BRPORT_DESIGNATED_PORT])
@@ -266,7 +266,7 @@ static void bridge_slave_print_opt(struc
fwd_mask = rta_getattr_u16(tb[IFLA_BRPORT_GROUP_FWD_MASK]);
print_0xhex(PRINT_ANY, "group_fwd_mask",
- "group_fwd_mask 0x%x ", fwd_mask);
+ "group_fwd_mask %#llx ", fwd_mask);
_bitmask2str(fwd_mask, convbuf, sizeof(convbuf), fwd_mask_tbl);
print_string(PRINT_ANY, "group_fwd_mask_str",
"group_fwd_mask_str %s ", convbuf);
--- a/ip/iplink_geneve.c
+++ b/ip/iplink_geneve.c
@@ -276,7 +276,7 @@ static void geneve_print_opt(struct link
tos = rta_getattr_u8(tb[IFLA_GENEVE_TOS]);
if (tos) {
if (is_json_context() || tos != 1)
- print_0xhex(PRINT_ANY, "tos", "tos 0x%x ", tos);
+ print_0xhex(PRINT_ANY, "tos", "tos %#llx ", tos);
else
print_string(PRINT_FP, NULL, "tos %s ", "inherit");
}
@@ -286,8 +286,7 @@ static void geneve_print_opt(struct link
if (label)
print_0xhex(PRINT_ANY,
- "label",
- "flowlabel %#x ",
+ "label", "flowlabel %#llx ",
ntohl(label));
}
--- a/ip/iplink_vxlan.c
+++ b/ip/iplink_vxlan.c
@@ -522,7 +522,7 @@ static void vxlan_print_opt(struct link_
tos = rta_getattr_u8(tb[IFLA_VXLAN_TOS]);
if (tos) {
if (is_json_context() || tos != 1)
- print_0xhex(PRINT_ANY, "tos", "tos 0x%x ", tos);
+ print_0xhex(PRINT_ANY, "tos", "tos %#llx ", tos);
else
print_string(PRINT_FP, NULL, "tos %s ", "inherit");
}
@@ -542,10 +542,8 @@ static void vxlan_print_opt(struct link_
__u32 label = rta_getattr_u32(tb[IFLA_VXLAN_LABEL]);
if (label)
- print_0xhex(PRINT_ANY,
- "label",
- "flowlabel %#x ",
- ntohl(label));
+ print_0xhex(PRINT_ANY, "label",
+ "flowlabel %#llx ", ntohl(label));
}
if (tb[IFLA_VXLAN_AGEING]) {
--- a/ip/ipntable.c
+++ b/ip/ipntable.c
@@ -360,7 +360,7 @@ static void print_ndtconfig(const struct
print_uint(PRINT_ANY, "hash_rnd",
" hash_rnd %u ", ndtc->ndtc_hash_rnd);
print_0xhex(PRINT_ANY, "hash_mask",
- "hash_mask %08x ", ndtc->ndtc_hash_mask);
+ "hash_mask %08llx ", ndtc->ndtc_hash_mask);
print_uint(PRINT_ANY, "hash_chain_gc",
"hash_chain_gc %u ", ndtc->ndtc_hash_chain_gc);
--- a/ip/iproute.c
+++ b/ip/iproute.c
@@ -346,7 +346,7 @@ static void print_rtax_features(FILE *fp
if (features)
print_0xhex(PRINT_ANY,
- "features", "0x%x ", of);
+ "features", "%#llx ", of);
}
static void print_rt_flags(FILE *fp, unsigned int flags)
@@ -483,10 +483,10 @@ static void print_rta_cacheinfo(FILE *fp
}
if (ci->rta_id)
print_0xhex(PRINT_ANY, "ipid",
- "ipid 0x%04x ", ci->rta_id);
+ "ipid 0x%04llx ", ci->rta_id);
if (ci->rta_ts || ci->rta_tsage) {
print_0xhex(PRINT_ANY, "ts",
- "ts 0x%x", ci->rta_ts);
+ "ts 0x%llx", ci->rta_ts);
print_uint(PRINT_ANY, "tsage",
"tsage %usec ", ci->rta_tsage);
}
@@ -885,7 +885,7 @@ int print_route(const struct sockaddr_nl
print_uint(PRINT_JSON, "mark", NULL, mark);
else if (mark >= 16)
print_0xhex(PRINT_FP, NULL,
- "mark 0x%x ", mark);
+ "mark 0x%llx ", mark);
else
print_uint(PRINT_FP, NULL,
"mark %u ", mark);
--- a/ip/iproute_lwtunnel.c
+++ b/ip/iproute_lwtunnel.c
@@ -115,7 +115,7 @@ static void print_srh(FILE *fp, struct i
tlv = (struct sr6_tlv_hmac *)((char *)srh + offset);
print_0xhex(PRINT_ANY, "hmac",
- "hmac 0x%X ", ntohl(tlv->hmackeyid));
+ "hmac %llX ", ntohl(tlv->hmackeyid));
}
}
--- a/ip/iprule.c
+++ b/ip/iprule.c
@@ -263,10 +263,10 @@ int print_rule(const struct sockaddr_nl
if (tb[FRA_FWMASK] &&
(mask = rta_getattr_u32(tb[FRA_FWMASK])) != 0xFFFFFFFF) {
- print_0xhex(PRINT_ANY, "fwmark", "fwmark 0x%x", mark);
- print_0xhex(PRINT_ANY, "fwmask", "/0x%x ", mask);
+ print_0xhex(PRINT_ANY, "fwmark", "fwmark %#llx", mark);
+ print_0xhex(PRINT_ANY, "fwmask", "/%#llx ", mask);
} else {
- print_0xhex(PRINT_ANY, "fwmark", "fwmark 0x%x ", mark);
+ print_0xhex(PRINT_ANY, "fwmark", "fwmark %#llx ", mark);
}
}
--- a/ip/iptuntap.c
+++ b/ip/iptuntap.c
@@ -254,7 +254,7 @@ static void print_flags(long flags)
flags &= ~(IFF_TUN | IFF_TAP | IFF_NO_PI | IFF_ONE_QUEUE |
IFF_VNET_HDR | IFF_PERSIST | IFF_NOFILTER);
if (flags)
- print_0xhex(PRINT_ANY, NULL, "%#x", flags);
+ print_0xhex(PRINT_ANY, NULL, "%#llx", flags);
close_json_array(PRINT_JSON, NULL);
}
--- a/ip/link_gre.c
+++ b/ip/link_gre.c
@@ -463,7 +463,7 @@ static void gre_print_opt(struct link_ut
tos = rta_getattr_u8(tb[IFLA_GRE_TOS]);
if (tos) {
if (is_json_context() || tos != 1)
- print_0xhex(PRINT_ANY, "tos", "tos 0x%x ", tos);
+ print_0xhex(PRINT_ANY, "tos", "tos %#llx ", tos);
else
print_string(PRINT_FP, NULL, "tos %s ", "inherit");
}
@@ -508,7 +508,7 @@ static void gre_print_opt(struct link_ut
if (fwmark) {
print_0xhex(PRINT_ANY,
- "fwmark", "fwmark 0x%x ", fwmark);
+ "fwmark", "fwmark %#llx ", fwmark);
}
}
@@ -541,7 +541,7 @@ static void gre_print_opt(struct link_ut
__u16 erspan_hwid = rta_getattr_u16(tb[IFLA_GRE_ERSPAN_HWID]);
print_0xhex(PRINT_ANY,
- "erspan_hwid", "erspan_hwid 0x%x ", erspan_hwid);
+ "erspan_hwid", "erspan_hwid %#llx ", erspan_hwid);
}
tnl_print_encap(tb,
--- a/ip/link_gre6.c
+++ b/ip/link_gre6.c
@@ -576,7 +576,7 @@ static void gre_print_opt(struct link_ut
if (fwmark) {
print_0xhex(PRINT_ANY,
- "fwmark", "fwmark 0x%x ", fwmark);
+ "fwmark", "fwmark %#llx ", fwmark);
}
}
@@ -609,7 +609,7 @@ static void gre_print_opt(struct link_ut
__u16 erspan_hwid = rta_getattr_u16(tb[IFLA_GRE_ERSPAN_HWID]);
print_0xhex(PRINT_ANY,
- "erspan_hwid", "erspan_hwid 0x%x ", erspan_hwid);
+ "erspan_hwid", "erspan_hwid %#llx ", erspan_hwid);
}
tnl_print_encap(tb,
--- a/ip/link_ip6tnl.c
+++ b/ip/link_ip6tnl.c
@@ -457,7 +457,7 @@ static void ip6tunnel_print_opt(struct l
if (fwmark) {
print_0xhex(PRINT_ANY,
- "fwmark", "fwmark 0x%x ", fwmark);
+ "fwmark", "fwmark %#llx ", fwmark);
}
}
--- a/ip/link_iptnl.c
+++ b/ip/link_iptnl.c
@@ -418,7 +418,7 @@ static void iptunnel_print_opt(struct li
tos = rta_getattr_u8(tb[IFLA_IPTUN_TOS]);
if (tos) {
if (is_json_context() || tos != 1)
- print_0xhex(PRINT_ANY, "tos", "tos 0x%x ", tos);
+ print_0xhex(PRINT_ANY, "tos", "tos %#llx ", tos);
else
print_string(PRINT_FP, NULL, "tos %s ", "inherit");
}
@@ -476,7 +476,7 @@ static void iptunnel_print_opt(struct li
if (fwmark) {
print_0xhex(PRINT_ANY,
- "fwmark", "fwmark 0x%x ", fwmark);
+ "fwmark", "fwmark %#llx ", fwmark);
}
}
--- a/ip/link_vti.c
+++ b/ip/link_vti.c
@@ -208,7 +208,7 @@ static void vti_print_opt(struct link_ut
if (fwmark) {
print_0xhex(PRINT_ANY,
- "fwmark", "fwmark 0x%x ", fwmark);
+ "fwmark", "fwmark %#llx ", fwmark);
}
}
}
--- a/ip/link_vti6.c
+++ b/ip/link_vti6.c
@@ -210,7 +210,7 @@ static void vti6_print_opt(struct link_u
if (fwmark) {
print_0xhex(PRINT_ANY,
- "fwmark", "fwmark 0x%x ", fwmark);
+ "fwmark", "fwmark %#llx ", fwmark);
}
}
}
--- a/tc/m_ife.c
+++ b/tc/m_ife.c
@@ -247,7 +247,7 @@ static int print_ife(struct action_util
if (tb[TCA_IFE_TYPE]) {
ife_type = rta_getattr_u16(tb[TCA_IFE_TYPE]);
has_optional = 1;
- print_0xhex(PRINT_ANY, "type", "type 0x%X ", ife_type);
+ print_0xhex(PRINT_ANY, "type", "type %#llX ", ife_type);
}
if (has_optional)
--- a/tc/q_htb.c
+++ b/tc/q_htb.c
@@ -332,7 +332,7 @@ static int htb_print_opt(struct qdisc_ut
if (RTA_PAYLOAD(tb[TCA_HTB_INIT]) < sizeof(*gopt)) return -1;
print_int(PRINT_ANY, "r2q", "r2q %d", gopt->rate2quantum);
- print_0xhex(PRINT_ANY, "default", " default %x", gopt->defcls);
+ print_0xhex(PRINT_ANY, "default", " default %#llx", gopt->defcls);
print_uint(PRINT_ANY, "direct_packets_stat",
" direct_packets_stat %u", gopt->direct_pkts);
if (show_details) {

View File

@ -0,0 +1,10 @@
--- a/tc/f_flower.c
+++ b/tc/f_flower.c
@@ -17,6 +17,7 @@
#include <linux/if_arp.h>
#include <linux/if_ether.h>
#include <linux/ip.h>
+#include <linux/limits.h>
#include <linux/tc_act/tc_vlan.h>
#include <linux/mpls.h>

View File

@ -1,35 +0,0 @@
From 6ddb36c3a9686df1cca2f4d06518395f1eb9d5cc Mon Sep 17 00:00:00 2001
From: Syrone Wong <wong.syrone@gmail.com>
Date: Wed, 12 Dec 2018 19:35:08 +0800
Subject: [PATCH] tc: fix xtables incorrect usage of LDFLAGS
The incorrect setting of LDFLAGS causes error below:
> em_ipt.o: In function `em_ipt_print_epot':
> em_ipt.c:(.text.em_ipt_print_epot+0x2e): undefined reference to
> `xtables_init_all'
em_ipt.c gets involved when TC_CONFIG_XT=y, which requires xtables,
while tc/Makefile doesn't pass flags correctly. It adds '-lxtables'
to LDFLAGS instead of LDLIBS.
Fixes: dd296215 ("tc: add em_ipt ematch for calling xtables matches from tc matching context")
Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
Acked-by: Eyal Birger <eyal.birger@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
tc/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/tc/Makefile
+++ b/tc/Makefile
@@ -170,7 +170,7 @@ em_ipset.o: CFLAGS += $$($(PKG_CONFIG) x
em_ipt.o: CFLAGS += $$($(PKG_CONFIG) xtables --cflags)
ifeq ($(TC_CONFIG_XT),y)
- LDFLAGS += $$($(PKG_CONFIG) xtables --libs)
+ LDLIBS += $$($(PKG_CONFIG) xtables --libs)
endif
%.yacc.c: %.y

View File

@ -0,0 +1,155 @@
From 9572f793e6945dd90a3cd4db34814b9b1616cfe9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= <toke@toke.dk>
Date: Mon, 18 Mar 2019 01:30:19 +0100
Subject: [PATCH] pkt_sched.h: Add support for CAKE FWMARK
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
---
include/uapi/linux/pkt_sched.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/uapi/linux/pkt_sched.h b/include/uapi/linux/pkt_sched.h
index 01f96352..ef78de0c 100644
--- a/include/uapi/linux/pkt_sched.h
+++ b/include/uapi/linux/pkt_sched.h
@@ -954,6 +954,7 @@ enum {
TCA_CAKE_INGRESS,
TCA_CAKE_ACK_FILTER,
TCA_CAKE_SPLIT_GSO,
+ TCA_CAKE_FWMARK,
__TCA_CAKE_MAX
};
#define TCA_CAKE_MAX (__TCA_CAKE_MAX - 1)
From 5ebfe1f6fea2bb3bfccf4cf93829516caaa0233d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= <toke@toke.dk>
Date: Mon, 18 Mar 2019 01:30:45 +0100
Subject: [PATCH] q_cake: Add support for setting the fwmark option
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This adds support for the newly added fwmark option to CAKE, which allows
overriding the tin selection from the per-packet firewall marks. The fwmark
field is a bitmask that is applied to the fwmark to select the tin.
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
---
man/man8/tc-cake.8 | 16 ++++++++++++++++
tc/q_cake.c | 24 ++++++++++++++++++++++++
2 files changed, 40 insertions(+)
diff --git a/man/man8/tc-cake.8 b/man/man8/tc-cake.8
index eda436e1..8c57eadd 100644
--- a/man/man8/tc-cake.8
+++ b/man/man8/tc-cake.8
@@ -91,6 +91,10 @@ TIME |
LIMIT ]
.br
[
+.BR fwmark
+MASK ]
+.br
+[
.BR ptm
|
.BR atm
@@ -524,6 +528,18 @@ preset on the modern Internet is firmly discouraged.
.br
Voice (CS7, CS6, EF, VA, TOS4), 25% threshold, reduced Codel interval.
+.PP
+.B fwmark
+MASK
+.br
+ This options turns on fwmark-based overriding of CAKE's tin selection.
+If set, the option specifies a bitmask that will be applied to the fwmark
+associated with each packet. If the result of this masking is non-zero, the
+result will be right-shifted by the number of least-significant unset bits in
+the mask value, and the result will be used as a the tin number for that packet.
+This can be used to set policies in a firewall script that will override CAKE's
+built-in tin selection.
+
.SH OTHER PARAMETERS
.B memlimit
LIMIT
diff --git a/tc/q_cake.c b/tc/q_cake.c
index e827e3f1..307a12c0 100644
--- a/tc/q_cake.c
+++ b/tc/q_cake.c
@@ -82,6 +82,7 @@ static void explain(void)
" [ split-gso* | no-split-gso ]\n"
" [ ack-filter | ack-filter-aggressive | no-ack-filter* ]\n"
" [ memlimit LIMIT ]\n"
+" [ fwmark MASK ]\n"
" [ ptm | atm | noatm* ] [ overhead N | conservative | raw* ]\n"
" [ mpu N ] [ ingress | egress* ]\n"
" (* marks defaults)\n");
@@ -106,6 +107,7 @@ static int cake_parse_opt(struct qdisc_util *qu, int argc, char **argv,
int autorate = -1;
int ingress = -1;
int overhead = 0;
+ int fwmark = -1;
int wash = -1;
int nat = -1;
int atm = -1;
@@ -332,6 +334,16 @@ static int cake_parse_opt(struct qdisc_util *qu, int argc, char **argv,
"Illegal value for \"memlimit\": \"%s\"\n", *argv);
return -1;
}
+ } else if (strcmp(*argv, "fwmark") == 0) {
+ unsigned int fwm;
+
+ NEXT_ARG();
+ if (get_u32(&fwm, *argv, 0)) {
+ fprintf(stderr,
+ "Illegal value for \"fwmark\": \"%s\"\n", *argv);
+ return -1;
+ }
+ fwmark = fwm;
} else if (strcmp(*argv, "help") == 0) {
explain();
return -1;
@@ -376,6 +388,9 @@ static int cake_parse_opt(struct qdisc_util *qu, int argc, char **argv,
if (memlimit)
addattr_l(n, 1024, TCA_CAKE_MEMORY, &memlimit,
sizeof(memlimit));
+ if (fwmark != -1)
+ addattr_l(n, 1024, TCA_CAKE_FWMARK, &fwmark,
+ sizeof(fwmark));
if (nat != -1)
addattr_l(n, 1024, TCA_CAKE_NAT, &nat, sizeof(nat));
if (wash != -1)
@@ -409,6 +424,7 @@ static int cake_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
struct rtattr *tb[TCA_CAKE_MAX + 1];
unsigned int interval = 0;
unsigned int memlimit = 0;
+ unsigned int fwmark = 0;
__u64 bandwidth = 0;
int ack_filter = 0;
int split_gso = 0;
@@ -507,6 +523,10 @@ static int cake_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
RTA_PAYLOAD(tb[TCA_CAKE_RTT]) >= sizeof(__u32)) {
interval = rta_getattr_u32(tb[TCA_CAKE_RTT]);
}
+ if (tb[TCA_CAKE_FWMARK] &&
+ RTA_PAYLOAD(tb[TCA_CAKE_FWMARK]) >= sizeof(__u32)) {
+ fwmark = rta_getattr_u32(tb[TCA_CAKE_FWMARK]);
+ }
if (wash)
print_string(PRINT_FP, NULL, "wash ", NULL);
@@ -559,6 +579,10 @@ static int cake_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
sprint_size(memlimit, b1));
}
+ if (fwmark)
+ print_uint(PRINT_FP, NULL, "fwmark 0x%x ", fwmark);
+ print_0xhex(PRINT_JSON, "fwmark", NULL, fwmark);
+
return 0;
}

View File

@ -1,7 +0,0 @@
--- /dev/null
+++ b/Config
@@ -0,0 +1,4 @@
+# Fixed config to disable ATM support even if present on host system
+IP_CONFIG_SETNS:=y
+TC_CONFIG_ATM:=n
+TC_CONFIG_XT:=y

View File

@ -0,0 +1,12 @@
--- a/configure
+++ b/configure
@@ -32,7 +32,8 @@ int main(int argc, char **argv) {
}
EOF
- if $CC -I$INCLUDE -o $TMPDIR/atmtest $TMPDIR/atmtest.c -latm >/dev/null 2>&1; then
+# OpenWrt: disable ATM support even if present on host system
+ if [ 1 -eq 0 ]; then
echo "TC_CONFIG_ATM:=y" >>$CONFIG
echo yes
else

View File

@ -0,0 +1,12 @@
--- a/tc/Makefile
+++ b/tc/Makefile
@@ -120,6 +120,9 @@ CFLAGS += -DCONFIG_GACT -DCONFIG_GACT_PR
ifneq ($(IPT_LIB_DIR),)
CFLAGS += -DIPT_LIB_DIR=\"$(IPT_LIB_DIR)\"
endif
+ifneq ($(XT_LIB_DIR),)
+ CFLAGS += -DXT_LIB_DIR=\"$(XT_LIB_DIR)\"
+endif
YACC := bison
LEX := flex

View File

@ -0,0 +1,101 @@
Description: Sync header from iptables
The current versions in several suites have the same content:
- 1.6.1-2 (unstable)
Bug: https://bugs.debian.org/868059
Forwarded: not-needed
Author: Cyril Brulebois <cyril@debamax.com>
Last-Update: 2017-11-22
--- a/include/xtables.h
+++ b/include/xtables.h
@@ -205,9 +205,24 @@ enum xtables_ext_flags {
XTABLES_EXT_ALIAS = 1 << 0,
};
+struct xt_xlate;
+
+struct xt_xlate_mt_params {
+ const void *ip;
+ const struct xt_entry_match *match;
+ int numeric;
+ bool escape_quotes;
+};
+
+struct xt_xlate_tg_params {
+ const void *ip;
+ const struct xt_entry_target *target;
+ int numeric;
+ bool escape_quotes;
+};
+
/* Include file for additions: new matches and targets. */
-struct xtables_match
-{
+struct xtables_match {
/*
* ABI/API version this module requires. Must be first member,
* as the rest of this struct may be subject to ABI changes.
@@ -269,6 +284,10 @@ struct xtables_match
void (*x6_fcheck)(struct xt_fcheck_call *);
const struct xt_option_entry *x6_options;
+ /* Translate iptables to nft */
+ int (*xlate)(struct xt_xlate *xl,
+ const struct xt_xlate_mt_params *params);
+
/* Size of per-extension instance extra "global" scratch space */
size_t udata_size;
@@ -280,8 +299,7 @@ struct xtables_match
unsigned int loaded; /* simulate loading so options are merged properly */
};
-struct xtables_target
-{
+struct xtables_target {
/*
* ABI/API version this module requires. Must be first member,
* as the rest of this struct may be subject to ABI changes.
@@ -346,6 +364,10 @@ struct xtables_target
void (*x6_fcheck)(struct xt_fcheck_call *);
const struct xt_option_entry *x6_options;
+ /* Translate iptables to nft */
+ int (*xlate)(struct xt_xlate *xl,
+ const struct xt_xlate_tg_params *params);
+
size_t udata_size;
/* Ignore these men behind the curtain: */
@@ -406,6 +428,17 @@ struct xtables_globals
#define XT_GETOPT_TABLEEND {.name = NULL, .has_arg = false}
+/*
+ * enum op-
+ *
+ * For writing clean nftables translations code
+ */
+enum xt_op {
+ XT_OP_EQ,
+ XT_OP_NEQ,
+ XT_OP_MAX,
+};
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -548,6 +581,14 @@ extern void xtables_lmap_free(struct xta
extern int xtables_lmap_name2id(const struct xtables_lmap *, const char *);
extern const char *xtables_lmap_id2name(const struct xtables_lmap *, int);
+/* xlate infrastructure */
+struct xt_xlate *xt_xlate_alloc(int size);
+void xt_xlate_free(struct xt_xlate *xl);
+void xt_xlate_add(struct xt_xlate *xl, const char *fmt, ...);
+void xt_xlate_add_comment(struct xt_xlate *xl, const char *comment);
+const char *xt_xlate_get_comment(struct xt_xlate *xl);
+const char *xt_xlate_get(struct xt_xlate *xl);
+
#ifdef XTABLES_INTERNAL
/* Shipped modules rely on this... */

View File

@ -1,11 +1,11 @@
--- a/configure
+++ b/configure
@@ -281,7 +281,7 @@ check_selinux()
@@ -254,7 +254,7 @@ check_selinux()
check_mnl()
{
- if ${PKG_CONFIG} libmnl --exists
+ if [ "${HAVE_MNL}" = "y" ] && ${PKG_CONFIG} libmnl --exists
then
- if ${PKG_CONFIG} libmnl --exists; then
+ if [ "${HAVE_MNL}" = "y" ] && ${PKG_CONFIG} libmnl --exists; then
echo "HAVE_MNL:=y" >>$CONFIG
echo "yes"

View File

@ -0,0 +1,11 @@
--- a/configure
+++ b/configure
@@ -228,7 +228,7 @@ EOF
check_elf()
{
- if ${PKG_CONFIG} libelf --exists; then
+ if [ "${HAVE_ELF}" = "y" ] && ${PKG_CONFIG} libelf --exists; then
echo "HAVE_ELF:=y" >>$CONFIG
echo "yes"

View File

@ -1,11 +0,0 @@
--- a/Makefile
+++ b/Makefile
@@ -54,7 +54,7 @@ HOSTCC ?= $(CC)
DEFINES += -D_GNU_SOURCE
# Turn on transparent support for LFS
DEFINES += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
-CCOPTS = -O2
+CCOPTS = -O2 $(EXTRA_CCOPTS)
WFLAGS := -Wall -Wstrict-prototypes -Wmissing-prototypes
WFLAGS += -Wmissing-declarations -Wold-style-definition -Wformat=2

View File

@ -89,7 +89,7 @@
{ "help", do_help },
--- a/lib/utils.c
+++ b/lib/utils.c
@@ -1012,6 +1012,7 @@ const char *rt_addr_n2a_r(int af, int le
@@ -1000,6 +1000,7 @@ const char *rt_addr_n2a_r(int af, int le
return inet_ntop(af, addr, buf, buflen);
case AF_MPLS:
return mpls_ntop(af, addr, buf, buflen);
@ -97,7 +97,7 @@
case AF_IPX:
return ipx_ntop(af, addr, buf, buflen);
case AF_DECnet:
@@ -1021,6 +1022,7 @@ const char *rt_addr_n2a_r(int af, int le
@@ -1009,6 +1010,7 @@ const char *rt_addr_n2a_r(int af, int le
memcpy(dna.a_addr, addr, 2);
return dnet_ntop(af, &dna, buf, buflen);
}

View File

@ -0,0 +1,44 @@
--- a/tc/Makefile
+++ b/tc/Makefile
@@ -107,7 +107,7 @@ LDLIBS += -L. -lm
ifeq ($(SHARED_LIBS),y)
LDLIBS += -ldl
-LDFLAGS += -Wl,-export-dynamic
+LDFLAGS += -Wl,--dynamic-list=dynsyms.list
endif
TCLIB := tc_core.o
@@ -137,7 +137,7 @@ MODDESTDIR := $(DESTDIR)$(LIBDIR)/tc
all: tc $(TCSO)
tc: $(TCOBJ) $(LIBNETLINK) libtc.a
- $(QUIET_LINK)$(CC) $^ $(LDFLAGS) $(LDLIBS) -o $@
+ $(QUIET_LINK)$(CC) $(filter-out dynsyms.list, $^) $(LDFLAGS) $(LDLIBS) -o $@
libtc.a: $(TCLIB)
$(QUIET_AR)$(AR) rcs $@ $^
@@ -159,6 +159,7 @@ install: all
clean:
rm -f $(TCOBJ) $(TCLIB) libtc.a tc *.so emp_ematch.yacc.h; \
rm -f emp_ematch.yacc.*
+ rm -f dynsyms.list
q_atm.so: q_atm.c
$(QUIET_CC)$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -shared -fpic -o q_atm.so q_atm.c -latm
@@ -198,4 +199,15 @@ static-syms.h: $(wildcard *.c)
sed -n '/'$$s'[^ ]* =/{s:.* \([^ ]*'$$s'[^ ]*\) .*:extern char \1[] __attribute__((weak)); if (!strcmp(sym, "\1")) return \1;:;p}' $$files ; \
done > $@
+else
+
+tc: dynsyms.list
+dynsyms.list: $(wildcard *.c)
+ files="$(filter-out $(patsubst %.so,%.c,$(TCSO)), $^)" ; \
+ echo "{" > $@ ; \
+ for s in `grep -B 3 '\<dlsym' $$files | sed -n '/snprintf/{s:.*"\([^"]*\)".*:\1:;s:%s::;p}'` ; do \
+ sed -n '/'$$s'[^ ]* =/{s:.* \([^ ]*'$$s'[^ ]*\) .*:\1;:;p}' $$files ; \
+ done >> $@ ; \
+ echo "show_stats; print_tm; parse_rtattr; get_u32; matches; addattr_l; addattr_nest; addattr_nest_end; };" >> $@
+
endif

View File

@ -1,60 +0,0 @@
--- a/configure
+++ b/configure
@@ -257,8 +257,9 @@ check_elf()
echo "HAVE_ELF:=y" >>$CONFIG
echo "yes"
- echo 'CFLAGS += -DHAVE_ELF' `${PKG_CONFIG} libelf --cflags` >> $CONFIG
- echo 'LDLIBS += ' `${PKG_CONFIG} libelf --libs` >>$CONFIG
+ echo 'CFLAGS += -DHAVE_ELF' >> $CONFIG
+ echo 'ELF_CFLAGS += ' `${PKG_CONFIG} libelf --cflags` >> $CONFIG
+ echo 'ELF_LDLIBS += ' `${PKG_CONFIG} libelf --libs` >>$CONFIG
else
echo "no"
fi
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -11,9 +11,17 @@ UTILOBJ = utils.o rt_names.o ll_map.o ll
inet_proto.o namespace.o json_writer.o json_print.o \
names.o color.o bpf.o exec.o fs.o
+ELFOBJ=$(patsubst %.o,%.elf.o,$(UTILOBJ))
+
NLOBJ=libgenl.o libnetlink.o
-all: libnetlink.a libutil.a
+all: libnetlink.a libutil.a libutil-elf.a
+
+%.o: %.c
+ $(QUIET_CC)$(CC) $(CFLAGS) -UHAVE_ELF $(EXTRA_CFLAGS) -c -o $@ $<
+
+%.elf.o: %.c
+ $(QUIET_CC)$(CC) $(CFLAGS) $(ELF_CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
libnetlink.a: $(NLOBJ)
$(QUIET_AR)$(AR) rcs $@ $^
@@ -21,7 +29,10 @@ libnetlink.a: $(NLOBJ)
libutil.a: $(UTILOBJ) $(ADDLIB)
$(QUIET_AR)$(AR) rcs $@ $^
+libutil-elf.a: $(ELFOBJ) $(ADDLIB)
+ $(QUIET_AR)$(AR) rcs $@ $^
+
install:
clean:
- rm -f $(NLOBJ) $(UTILOBJ) $(ADDLIB) libnetlink.a libutil.a
+ rm -f $(NLOBJ) $(UTILOBJ) $(ELFOBJ) $(ADDLIB) libnetlink.a libutil.a libutil-elf.a
--- a/tc/Makefile
+++ b/tc/Makefile
@@ -132,8 +132,8 @@ MODDESTDIR := $(DESTDIR)$(LIBDIR)/tc
all: tc $(TCSO)
-tc: $(TCOBJ) $(LIBNETLINK) libtc.a
- $(QUIET_LINK)$(CC) $^ $(LDFLAGS) $(LDLIBS) -o $@
+tc: $(TCOBJ) $(subst libutil.a,libutil-elf.a,$(LIBNETLINK)) libtc.a
+ $(QUIET_LINK)$(CC) $^ $(LDFLAGS) $(LDLIBS) $(ELF_LDLIBS) -o $@
libtc.a: $(TCLIB)
$(QUIET_AR)$(AR) rcs $@ $^

View File

@ -0,0 +1,19 @@
--- a/configure
+++ b/configure
@@ -299,14 +299,8 @@ EOF
if $CC -I$INCLUDE -o $TMPDIR/strtest $TMPDIR/strtest.c >/dev/null 2>&1; then
echo "no"
else
- if ${PKG_CONFIG} libbsd --exists; then
- echo 'CFLAGS += -DHAVE_LIBBSD' `${PKG_CONFIG} libbsd --cflags` >>$CONFIG
- echo 'LDLIBS +=' `${PKG_CONFIG} libbsd --libs` >> $CONFIG
- echo "no"
- else
- echo 'CFLAGS += -DNEED_STRLCPY' >>$CONFIG
- echo "yes"
- fi
+ echo 'CFLAGS += -DNEED_STRLCPY' >>$CONFIG
+ echo "yes"
fi
rm -f $TMPDIR/strtest.c $TMPDIR/strtest
}