mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
fix
This commit is contained in:
parent
406b678055
commit
4e406cd83b
3 changed files with 2340 additions and 39 deletions
|
@ -57,16 +57,7 @@ $(call Package/iproute2/Default)
|
||||||
DEFAULT_VARIANT:=1
|
DEFAULT_VARIANT:=1
|
||||||
PROVIDES:=tc
|
PROVIDES:=tc
|
||||||
ALTERNATIVES:=200:/sbin/tc:/usr/libexec/tc-tiny
|
ALTERNATIVES:=200:/sbin/tc:/usr/libexec/tc-tiny
|
||||||
DEPENDS:=+kmod-sched-core +(PACKAGE_devlink||PACKAGE_rdma):libmnl
|
DEPENDS:=+kmod-sched-core +libxtables +tc-mod-iptables +(PACKAGE_devlink||PACKAGE_rdma):libmnl
|
||||||
endef
|
|
||||||
|
|
||||||
define Package/tc-bpf
|
|
||||||
$(call Package/iproute2/Default)
|
|
||||||
TITLE:=Traffic control utility (bpf)
|
|
||||||
VARIANT:=tcbpf
|
|
||||||
PROVIDES:=tc
|
|
||||||
ALTERNATIVES:=300:/sbin/tc:/usr/libexec/tc-bpf
|
|
||||||
DEPENDS:=+kmod-sched-core +(PACKAGE_devlink||PACKAGE_rdma):libmnl +libbpf
|
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Package/tc-full
|
define Package/tc-full
|
||||||
|
@ -74,14 +65,13 @@ $(call Package/iproute2/Default)
|
||||||
TITLE:=Traffic control utility (full)
|
TITLE:=Traffic control utility (full)
|
||||||
VARIANT:=tcfull
|
VARIANT:=tcfull
|
||||||
PROVIDES:=tc
|
PROVIDES:=tc
|
||||||
ALTERNATIVES:=400:/sbin/tc:/usr/libexec/tc-full
|
ALTERNATIVES:=300:/sbin/tc:/usr/libexec/tc-full
|
||||||
DEPENDS:=+kmod-sched-core +(PACKAGE_devlink||PACKAGE_rdma):libmnl +libbpf +libxtables +tc-mod-iptables
|
DEPENDS:=+kmod-sched-core +libxtables +tc-mod-iptables +libbpf +(PACKAGE_devlink||PACKAGE_rdma):libmnl
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Package/tc-mod-iptables
|
define Package/tc-mod-iptables
|
||||||
$(call Package/iproute2/Default)
|
$(call Package/iproute2/Default)
|
||||||
TITLE:=Traffic control module - iptables action
|
TITLE:=Traffic control module - iptables action
|
||||||
VARIANT:=tcfull
|
|
||||||
DEPENDS:=+libxtables
|
DEPENDS:=+libxtables
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
@ -133,29 +123,13 @@ endif
|
||||||
|
|
||||||
ifeq ($(BUILD_VARIANT),tctiny)
|
ifeq ($(BUILD_VARIANT),tctiny)
|
||||||
LIBBPF_FORCE:=off
|
LIBBPF_FORCE:=off
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(BUILD_VARIANT),tcbpf)
|
|
||||||
HAVE_ELF:=y
|
|
||||||
LIBBPF_FORCE:=on
|
|
||||||
SHARED_LIBS:=y
|
SHARED_LIBS:=y
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(BUILD_VARIANT),tcfull)
|
ifeq ($(BUILD_VARIANT),tcfull)
|
||||||
#enable iptables/xtables requirement only if tciptables variant is selected
|
|
||||||
TC_CONFIG_XT:=y
|
|
||||||
TC_CONFIG_XT_OLD:=y
|
|
||||||
TC_CONFIG_XT_OLD_H:=y
|
|
||||||
TC_CONFIG_IPSET:=y
|
|
||||||
HAVE_ELF:=y
|
HAVE_ELF:=y
|
||||||
LIBBPF_FORCE:=on
|
LIBBPF_FORCE:=on
|
||||||
SHARED_LIBS:=y
|
SHARED_LIBS:=y
|
||||||
else
|
|
||||||
#disable iptables requirement by default
|
|
||||||
TC_CONFIG_XT:=n
|
|
||||||
TC_CONFIG_XT_OLD:=n
|
|
||||||
TC_CONFIG_XT_OLD_H:=n
|
|
||||||
TC_CONFIG_IPSET:=n
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifdef CONFIG_PACKAGE_devlink
|
ifdef CONFIG_PACKAGE_devlink
|
||||||
|
@ -186,10 +160,6 @@ MAKE_FLAGS += \
|
||||||
HAVE_CAP=$(HAVE_CAP) \
|
HAVE_CAP=$(HAVE_CAP) \
|
||||||
IPT_LIB_DIR=/usr/lib/iptables \
|
IPT_LIB_DIR=/usr/lib/iptables \
|
||||||
XT_LIB_DIR=/usr/lib/iptables \
|
XT_LIB_DIR=/usr/lib/iptables \
|
||||||
TC_CONFIG_XT=$(TC_CONFIG_XT) \
|
|
||||||
TC_CONFIG_XT_OLD=$(TC_CONFIG_XT_OLD) \
|
|
||||||
TC_CONFIG_XT_OLD_H=$(TC_CONFIG_XT_OLD_H) \
|
|
||||||
TC_CONFIG_IPSET=$(TC_CONFIG_IPSET) \
|
|
||||||
FPIC="$(FPIC)" \
|
FPIC="$(FPIC)" \
|
||||||
$(if $(findstring c,$(OPENWRT_VERBOSE)),V=1,V='')
|
$(if $(findstring c,$(OPENWRT_VERBOSE)),V=1,V='')
|
||||||
|
|
||||||
|
@ -220,11 +190,6 @@ define Package/tc-tiny/install
|
||||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/tc/tc $(1)/usr/libexec/tc-tiny
|
$(INSTALL_BIN) $(PKG_BUILD_DIR)/tc/tc $(1)/usr/libexec/tc-tiny
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Package/tc-bpf/install
|
|
||||||
$(INSTALL_DIR) $(1)/usr/libexec
|
|
||||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/tc/tc $(1)/usr/libexec/tc-bpf
|
|
||||||
endef
|
|
||||||
|
|
||||||
define Package/tc-full/install
|
define Package/tc-full/install
|
||||||
$(INSTALL_DIR) $(1)/usr/libexec
|
$(INSTALL_DIR) $(1)/usr/libexec
|
||||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/tc/tc $(1)/usr/libexec/tc-full
|
$(INSTALL_BIN) $(PKG_BUILD_DIR)/tc/tc $(1)/usr/libexec/tc-full
|
||||||
|
@ -271,7 +236,6 @@ $(eval $(call BuildPackage,ip-full))
|
||||||
# spurious rebuilds when building multiple variants.
|
# spurious rebuilds when building multiple variants.
|
||||||
$(eval $(call BuildPackage,tc-mod-iptables))
|
$(eval $(call BuildPackage,tc-mod-iptables))
|
||||||
$(eval $(call BuildPackage,tc-tiny))
|
$(eval $(call BuildPackage,tc-tiny))
|
||||||
$(eval $(call BuildPackage,tc-bpf))
|
|
||||||
$(eval $(call BuildPackage,tc-full))
|
$(eval $(call BuildPackage,tc-full))
|
||||||
$(eval $(call BuildPackage,genl))
|
$(eval $(call BuildPackage,genl))
|
||||||
$(eval $(call BuildPackage,ip-bridge))
|
$(eval $(call BuildPackage,ip-bridge))
|
||||||
|
|
2094
iproute2/patches/400-add-nss-qdisc.patch
Normal file
2094
iproute2/patches/400-add-nss-qdisc.patch
Normal file
File diff suppressed because it is too large
Load diff
243
iproute2/patches/500-add-nssmirred.patch
Normal file
243
iproute2/patches/500-add-nssmirred.patch
Normal file
|
@ -0,0 +1,243 @@
|
||||||
|
--- a/tc/Makefile 2019-04-08 12:48:15.425854828 +0530
|
||||||
|
+++ b/tc/Makefile 2019-04-08 13:03:17.204741000 +0530
|
||||||
|
@@ -54,6 +54,7 @@ TCMODULES += m_bpf.o
|
||||||
|
TCMODULES += m_sample.o
|
||||||
|
TCMODULES += m_ct.o
|
||||||
|
TCMODULES += m_gate.o
|
||||||
|
+TCMODULES += m_nssmirred.o
|
||||||
|
TCMODULES += p_ip.o
|
||||||
|
TCMODULES += p_ip6.o
|
||||||
|
TCMODULES += p_icmp.o
|
||||||
|
--- /dev/null 1970-01-01 05:30:00.000000000 +0530
|
||||||
|
+++ b/tc/m_nssmirred.c 2019-06-19 14:25:51.369793000 +0530
|
||||||
|
@@ -0,0 +1,183 @@
|
||||||
|
+/*
|
||||||
|
+ **************************************************************************
|
||||||
|
+ * Copyright (c) 2019 The Linux Foundation. All rights reserved.
|
||||||
|
+ * Permission to use, copy, modify, and/or distribute this software for
|
||||||
|
+ * any purpose with or without fee is hereby granted, provided that the
|
||||||
|
+ * above copyright notice and this permission notice appear in all copies.
|
||||||
|
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||||
|
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
+ **************************************************************************
|
||||||
|
+ */
|
||||||
|
+
|
||||||
|
+#include <stdio.h>
|
||||||
|
+#include <stdlib.h>
|
||||||
|
+#include <unistd.h>
|
||||||
|
+#include <syslog.h>
|
||||||
|
+#include <fcntl.h>
|
||||||
|
+#include <sys/socket.h>
|
||||||
|
+#include <netinet/in.h>
|
||||||
|
+#include <arpa/inet.h>
|
||||||
|
+#include <string.h>
|
||||||
|
+#include "utils.h"
|
||||||
|
+#include "tc_util.h"
|
||||||
|
+#include "tc_common.h"
|
||||||
|
+#include <linux/tc_act/tc_nssmirred.h>
|
||||||
|
+
|
||||||
|
+/*
|
||||||
|
+ * explain()
|
||||||
|
+ * API to print the explaination of nssmirred action statement's
|
||||||
|
+ * elements.
|
||||||
|
+ */
|
||||||
|
+static void explain(void)
|
||||||
|
+{
|
||||||
|
+ fprintf(stderr, "Usage: nssmirred redirect <dev TO_DEVICENAME fromdev FROM_DEVICENAME> \n");
|
||||||
|
+ fprintf(stderr, "where: \n");
|
||||||
|
+ fprintf(stderr, "\tTO_DEVICENAME is the devicename to redirect to\n");
|
||||||
|
+ fprintf(stderr, "\tFROM_DEVICENAME is the devicename to redirect from\n");
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+/*
|
||||||
|
+ * usage()
|
||||||
|
+ * API to show the usage of the nssmirred action.
|
||||||
|
+ */
|
||||||
|
+static void usage(void)
|
||||||
|
+{
|
||||||
|
+ explain();
|
||||||
|
+ exit(-1);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+/*
|
||||||
|
+ * parse_nss_mirred()
|
||||||
|
+ * Parse and validate the nssmirred action statement.
|
||||||
|
+ */
|
||||||
|
+static int parse_nss_mirred(struct action_util *a, int *argc_p, char ***argv_p,
|
||||||
|
+ int tca_id, struct nlmsghdr *n)
|
||||||
|
+{
|
||||||
|
+ int idx, argc = *argc_p;
|
||||||
|
+ char **argv = *argv_p;
|
||||||
|
+ struct tc_nss_mirred p;
|
||||||
|
+ struct rtattr *tail;
|
||||||
|
+
|
||||||
|
+ if (argc < 0) {
|
||||||
|
+ fprintf(stderr, "nssmirred bad argument count %d. Try option \"help\"\n", argc);
|
||||||
|
+ goto error;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (matches(*argv, "nssmirred")) {
|
||||||
|
+ fprintf(stderr, "nssmirred bad argument %s. Try option \"help\"\n", *argv);
|
||||||
|
+ goto error;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ NEXT_ARG();
|
||||||
|
+ if (!matches(*argv, "help")) {
|
||||||
|
+ usage();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (matches(*argv, "redirect")) {
|
||||||
|
+ fprintf(stderr, "nssmirred bad argument %s. Try option \"help\"\n", *argv);
|
||||||
|
+ goto error;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ NEXT_ARG();
|
||||||
|
+ if (matches(*argv, "dev")) {
|
||||||
|
+ fprintf(stderr, "nssmirred: bad value %s. Try option \"help\"\n", *argv);
|
||||||
|
+ goto error;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ NEXT_ARG();
|
||||||
|
+ memset(&p, 0, sizeof(struct tc_nss_mirred));
|
||||||
|
+ if ((idx = ll_name_to_index(*argv)) == 0) {
|
||||||
|
+ fprintf(stderr, "Cannot find to device \"%s\"\n", *argv);
|
||||||
|
+ goto error;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ p.to_ifindex = idx;
|
||||||
|
+ NEXT_ARG();
|
||||||
|
+ if (matches(*argv, "fromdev")) {
|
||||||
|
+ fprintf(stderr, "nssmirred: bad value %s. Try option \"help\"\n", *argv);
|
||||||
|
+ goto error;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ NEXT_ARG();
|
||||||
|
+ if ((idx = ll_name_to_index(*argv)) == 0) {
|
||||||
|
+ fprintf(stderr, "Cannot find from device \"%s\"\n", *argv);
|
||||||
|
+ goto error;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ p.from_ifindex = idx;
|
||||||
|
+ p.action = TC_ACT_STOLEN;
|
||||||
|
+ tail = NLMSG_TAIL(n);
|
||||||
|
+ addattr_l(n, MAX_MSG, tca_id, NULL, 0);
|
||||||
|
+ addattr_l(n, MAX_MSG, TCA_NSS_MIRRED_PARMS, &p, sizeof (p));
|
||||||
|
+ tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
|
||||||
|
+ argc--;
|
||||||
|
+ argv++;
|
||||||
|
+ *argc_p = argc;
|
||||||
|
+ *argv_p = argv;
|
||||||
|
+ return 0;
|
||||||
|
+
|
||||||
|
+error:
|
||||||
|
+ return -1;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+/*
|
||||||
|
+ * print_nss_mirred()
|
||||||
|
+ * Print information related to nssmirred action.
|
||||||
|
+ */
|
||||||
|
+static int print_nss_mirred(struct action_util *au, FILE * f, struct rtattr *arg)
|
||||||
|
+{
|
||||||
|
+ struct tc_nss_mirred *p;
|
||||||
|
+ struct rtattr *tb[TCA_NSS_MIRRED_MAX + 1];
|
||||||
|
+ const char *from_dev, *to_dev;
|
||||||
|
+
|
||||||
|
+ if (arg == NULL) {
|
||||||
|
+ return -1;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ parse_rtattr_nested(tb, TCA_NSS_MIRRED_MAX, arg);
|
||||||
|
+
|
||||||
|
+ if (tb[TCA_NSS_MIRRED_PARMS] == NULL) {
|
||||||
|
+ fprintf(f, "[NULL nssmirred parameters]");
|
||||||
|
+ goto error;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ p = RTA_DATA(tb[TCA_NSS_MIRRED_PARMS]);
|
||||||
|
+ if ((from_dev = ll_index_to_name(p->from_ifindex)) == 0) {
|
||||||
|
+ fprintf(stderr, "Invalid interface (index: %d)\n", p->from_ifindex);
|
||||||
|
+ goto error;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if ((to_dev = ll_index_to_name(p->to_ifindex)) == 0) {
|
||||||
|
+ fprintf(stderr, "Invalid interface (index: %d)\n", p->to_ifindex);
|
||||||
|
+ goto error;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ fprintf(f, "nssmirred (%s to device %s) stolen\n", from_dev, to_dev);
|
||||||
|
+ fprintf(f, "\tindex %d ref %d bind %d\n",p->index,p->refcnt,p->bindcnt);
|
||||||
|
+
|
||||||
|
+ if (show_stats) {
|
||||||
|
+ if (tb[TCA_NSS_MIRRED_TM]) {
|
||||||
|
+ struct tcf_t *tm = RTA_DATA(tb[TCA_NSS_MIRRED_TM]);
|
||||||
|
+ print_tm(f,tm);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ return 0;
|
||||||
|
+
|
||||||
|
+error:
|
||||||
|
+ return -1;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+/*
|
||||||
|
+ * nssmirred_action_util
|
||||||
|
+ * nssmirred action utility structure.
|
||||||
|
+ */
|
||||||
|
+struct action_util nssmirred_action_util = {
|
||||||
|
+ .id = "nssmirred",
|
||||||
|
+ .parse_aopt = parse_nss_mirred,
|
||||||
|
+ .print_aopt = print_nss_mirred,
|
||||||
|
+};
|
||||||
|
--- /dev/null 1970-01-01 05:30:00.000000000 +0530
|
||||||
|
+++ a/include/linux/tc_act/tc_nssmirred.h 2019-06-19 14:25:40.787768000 +0530
|
||||||
|
@@ -0,0 +1,44 @@
|
||||||
|
+/*
|
||||||
|
+ **************************************************************************
|
||||||
|
+ * Copyright (c) 2019 The Linux Foundation. All rights reserved.
|
||||||
|
+ * Permission to use, copy, modify, and/or distribute this software for
|
||||||
|
+ * any purpose with or without fee is hereby granted, provided that the
|
||||||
|
+ * above copyright notice and this permission notice appear in all copies.
|
||||||
|
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||||
|
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
+ **************************************************************************
|
||||||
|
+ */
|
||||||
|
+
|
||||||
|
+#ifndef __LINUX_TC_NSS_MIR_H
|
||||||
|
+#define __LINUX_TC_NSS_MIR_H
|
||||||
|
+
|
||||||
|
+#include <linux/types.h>
|
||||||
|
+#include <linux/pkt_cls.h>
|
||||||
|
+
|
||||||
|
+/*
|
||||||
|
+ * tc_nss_mirred
|
||||||
|
+ * Structure for nssmirred action.
|
||||||
|
+ */
|
||||||
|
+struct tc_nss_mirred {
|
||||||
|
+ tc_gen;
|
||||||
|
+ __u32 from_ifindex; /* ifindex of the port to be redirected from */
|
||||||
|
+ __u32 to_ifindex; /* ifindex of the port to be redirected to */
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+/*
|
||||||
|
+ * Types of nssmirred action parameters.
|
||||||
|
+ */
|
||||||
|
+enum {
|
||||||
|
+ TCA_NSS_MIRRED_UNSPEC,
|
||||||
|
+ TCA_NSS_MIRRED_TM,
|
||||||
|
+ TCA_NSS_MIRRED_PARMS,
|
||||||
|
+ __TCA_NSS_MIRRED_MAX
|
||||||
|
+};
|
||||||
|
+#define TCA_NSS_MIRRED_MAX (__TCA_NSS_MIRRED_MAX - 1)
|
||||||
|
+
|
||||||
|
+#endif /* __LINUX_TC_NSS_MIR_H */
|
Loading…
Add table
Add a link
Reference in a new issue