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
5169ec4f31
commit
6a2332b51a
38 changed files with 8 additions and 12918 deletions
|
@ -11,7 +11,7 @@ include $(INCLUDE_DIR)/kernel.mk
|
|||
|
||||
PKG_NAME:=ndpi-netfilter2
|
||||
PKG_RELEASE:=4
|
||||
PKG_REV:=3deea541af037b663b1b83a055b80d9a06a0afd2
|
||||
PKG_REV:=fbb2104d125a13db3b8c7fdc34ea0e3fcfe92d12
|
||||
PKG_VERSION:=4-$(PKG_REV)
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
|
@ -21,7 +21,6 @@ PKG_SOURCE_URL:=https://github.com/vel21ripn/nDPI.git
|
|||
PKG_SOURCE_VERSION:=$(PKG_REV)
|
||||
|
||||
PKG_BUILD_PARALLEL:=0
|
||||
PKG_FORTIFY_SOURCE:=0
|
||||
|
||||
PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
|
@ -35,8 +34,7 @@ define Package/iptables-mod-ndpi
|
|||
URL:=http://www.ntop.org/products/ndpi/
|
||||
# DEPENDS:=+iptables +iptables-mod-conntrack-extra +kmod-ipt-ndpi +libpcap
|
||||
# DEPENDS:=+iptables +kmod-ipt-ndpi +libpcap @(LINUX_5_4||LINUX_5_15||TARGET_x86_64)
|
||||
# DEPENDS:=+iptables +kmod-ipt-ndpi +libpcap @(LINUX_5_4||LINUX_5_15) @!TARGET_ramips
|
||||
DEPENDS:=+iptables +kmod-ipt-ndpi +libpcap @!TARGET_ramips
|
||||
DEPENDS:=+iptables +kmod-ipt-ndpi +libpcap @(LINUX_5_4||LINUX_5_15)
|
||||
MAINTAINER:=Ycarus (Yannick Chabanois) <ycarus@zugaina.org>
|
||||
endef
|
||||
|
||||
|
@ -52,7 +50,7 @@ MAKE_PATH:=ndpi-netfilter
|
|||
MAKE_FLAGS += \
|
||||
KERNEL_DIR="$(LINUX_DIR)" \
|
||||
MODULES_DIR="$(TARGET_MODULES_DIR)" \
|
||||
NDPI_PATH=$(PKG_BUILD_DIR)/ndpi-netfilter
|
||||
NDPI_PATH=$(PKG_BUILD_DIR)/ndpi-netfilter \
|
||||
|
||||
ifeq ($ARCH),aarch64)
|
||||
MAKE_FLAGS += ARCH="arm64"
|
||||
|
@ -76,15 +74,14 @@ define KernelPackage/ipt-ndpi
|
|||
SUBMENU:=Netfilter Extensions
|
||||
TITLE:= nDPI net netfilter module
|
||||
# DEPENDS:=+kmod-nf-conntrack +kmod-nf-conntrack-netlink +kmod-ipt-compat-xtables +libpcap @(LINUX_5_4||LINUX_5_15||TARGET_x86_64)
|
||||
# DEPENDS:=+kmod-nf-conntrack +kmod-nf-conntrack-netlink +kmod-ipt-compat-xtables +libpcap @(LINUX_5_4||LINUX_5_15) @!TARGET_ramips
|
||||
DEPENDS:=+kmod-nf-conntrack +kmod-nf-conntrack-netlink +kmod-ipt-compat-xtables +libpcap @!TARGET_ramips
|
||||
DEPENDS:=+kmod-nf-conntrack +kmod-nf-conntrack-netlink +kmod-ipt-compat-xtables +libpcap @(LINUX_5_4||LINUX_5_15)
|
||||
KCONFIG:=CONFIG_NF_CONNTRACK_LABELS=y \
|
||||
CONFIG_NETFILTER_XT_MATCH_CONNLABEL=y
|
||||
FILES:= $(PKG_BUILD_DIR)/ndpi-netfilter/src/xt_ndpi.ko
|
||||
AUTOLOAD:=$(call AutoProbe,xt_ndpi)
|
||||
# MODPARAMS.xt_ndpi:=ndpi_enable_flow=1
|
||||
KCONFIG:=\
|
||||
CONFIG_NDPI_HOOK=y \
|
||||
CONFIG_LIVEPATCH=y \
|
||||
CONFIG_NF_CONNTRACK=y \
|
||||
CONFIG_NF_CONNTRACK_LABELS=y \
|
||||
CONFIG_NETFILTER_XT_MATCH_CONNLABEL=y \
|
||||
|
|
|
@ -1,190 +0,0 @@
|
|||
From 9e2bc31b8c330dc6ad0e6e478103652cd72dc3c8 Mon Sep 17 00:00:00 2001
|
||||
From: Sebastian Gottschall <s.gottschall@dd-wrt.com>
|
||||
Date: Sun, 9 Jul 2023 12:22:02 +0600
|
||||
Subject: [PATCH] add ndpi support for arm/arm64 etc. in 6.1
|
||||
|
||||
ndpi is not supported in more recent kernels without livepatch support
|
||||
however. livepatch is only supported for x86_64 architectures.
|
||||
so ndpi cannot be used on any other platform anymore.
|
||||
we solve this by adding a simple hook to nf_ct_destroy
|
||||
|
||||
Signed-off-by: Sebastian Gottschall <s.gottschall@dd-wrt.com>
|
||||
---
|
||||
ndpi-netfilter/kernel-patch/v6.1.38.diff | 81 ++++++++++++++++++++++++
|
||||
ndpi-netfilter/src/main.c | 23 +++++--
|
||||
2 files changed, 98 insertions(+), 6 deletions(-)
|
||||
create mode 100644 ndpi-netfilter/kernel-patch/v6.1.38.diff
|
||||
|
||||
diff --git a/ndpi-netfilter/kernel-patch/v6.1.38.diff b/ndpi-netfilter/kernel-patch/v6.1.38.diff
|
||||
new file mode 100644
|
||||
index 0000000000..6846dc84fc
|
||||
--- /dev/null
|
||||
+++ b/ndpi-netfilter/kernel-patch/v6.1.38.diff
|
||||
@@ -0,0 +1,81 @@
|
||||
+diff -urpN linux-6.1.38.old/include/net/netfilter/nf_conntrack.h linux-6.1.38/include/net/netfilter/nf_conntrack.h
|
||||
+--- linux-6.1.38.old/include/net/netfilter/nf_conntrack.h 2023-07-05 23:27:38.000000000 +0600
|
||||
++++ linux-6.1.38/include/net/netfilter/nf_conntrack.h 2023-07-14 12:34:56.663750711 +0600
|
||||
+@@ -362,6 +362,11 @@ static inline struct nf_conntrack_net *n
|
||||
+ return net_generic(net, nf_conntrack_net_id);
|
||||
+ }
|
||||
+
|
||||
++#ifdef CONFIG_NDPI_HOOK
|
||||
++void register_ndpi_hook(void (*hook)(struct nf_conn *));
|
||||
++void unregister_ndpi_hook(void);
|
||||
++#endif
|
||||
++
|
||||
+ #define NF_CT_STAT_INC(net, count) __this_cpu_inc((net)->ct.stat->count)
|
||||
+ #define NF_CT_STAT_INC_ATOMIC(net, count) this_cpu_inc((net)->ct.stat->count)
|
||||
+ #define NF_CT_STAT_ADD_ATOMIC(net, count, v) this_cpu_add((net)->ct.stat->count, (v))
|
||||
+diff -urpN linux-6.1.38.old/net/netfilter/Kconfig linux-6.1.38/net/netfilter/Kconfig
|
||||
+--- linux-6.1.38.old/net/netfilter/Kconfig 2023-07-05 23:27:38.000000000 +0600
|
||||
++++ linux-6.1.38/net/netfilter/Kconfig 2023-07-14 12:34:11.966879899 +0600
|
||||
+@@ -76,11 +76,15 @@ config NETFILTER_NETLINK_OSF
|
||||
+ If this option is enabled, the kernel will include support
|
||||
+ for passive OS fingerprint via NFNETLINK.
|
||||
+
|
||||
++config NDPI_HOOK
|
||||
++ bool
|
||||
++
|
||||
+ config NF_CONNTRACK
|
||||
+ tristate "Netfilter connection tracking support"
|
||||
+ default m if NETFILTER_ADVANCED=n
|
||||
+ select NF_DEFRAG_IPV4
|
||||
+ select NF_DEFRAG_IPV6 if IPV6 != n
|
||||
++ select NDPI_HOOK
|
||||
+ help
|
||||
+ Connection tracking keeps a record of what packets have passed
|
||||
+ through your machine, in order to figure out how they are related
|
||||
+diff -urpN linux-6.1.38.old/net/netfilter/nf_conntrack_core.c linux-6.1.38/net/netfilter/nf_conntrack_core.c
|
||||
+--- linux-6.1.38.old/net/netfilter/nf_conntrack_core.c 2023-07-05 23:27:38.000000000 +0600
|
||||
++++ linux-6.1.38/net/netfilter/nf_conntrack_core.c 2023-07-14 12:33:45.580092713 +0600
|
||||
+@@ -582,9 +582,30 @@ static void destroy_gre_conntrack(struct
|
||||
+ #endif
|
||||
+ }
|
||||
+
|
||||
++#ifdef CONFIG_NDPI_HOOK
|
||||
++
|
||||
++static void (*ndpi_hook)(struct nf_conn *) __rcu __read_mostly = NULL;
|
||||
++
|
||||
++void register_ndpi_hook(void (*hook)(struct nf_conn *))
|
||||
++{
|
||||
++ rcu_assign_pointer(ndpi_hook, hook);
|
||||
++}
|
||||
++EXPORT_SYMBOL(register_ndpi_hook);
|
||||
++
|
||||
++void unregister_ndpi_hook(void)
|
||||
++{
|
||||
++ rcu_assign_pointer(ndpi_hook, NULL);
|
||||
++}
|
||||
++
|
||||
++EXPORT_SYMBOL(unregister_ndpi_hook);
|
||||
++#endif
|
||||
++
|
||||
+ void nf_ct_destroy(struct nf_conntrack *nfct)
|
||||
+ {
|
||||
+ struct nf_conn *ct = (struct nf_conn *)nfct;
|
||||
++#ifdef CONFIG_NDPI_HOOK
|
||||
++ void (*hook)(struct nf_conn *);
|
||||
++#endif
|
||||
+
|
||||
+ pr_debug("%s(%p)\n", __func__, ct);
|
||||
+ WARN_ON(refcount_read(&nfct->use) != 0);
|
||||
+@@ -594,6 +615,12 @@ void nf_ct_destroy(struct nf_conntrack *
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
++#ifdef CONFIG_NDPI_HOOK
|
||||
++ hook = rcu_dereference(ndpi_hook);
|
||||
++ if (hook)
|
||||
++ hook(ct);
|
||||
++#endif
|
||||
++
|
||||
+ if (unlikely(nf_ct_protonum(ct) == IPPROTO_GRE))
|
||||
+ destroy_gre_conntrack(ct);
|
||||
+
|
||||
diff --git a/ndpi-netfilter/src/main.c b/ndpi-netfilter/src/main.c
|
||||
index 024ca4bb79..e8ae3912d7 100644
|
||||
--- a/ndpi-netfilter/src/main.c
|
||||
+++ b/ndpi-netfilter/src/main.c
|
||||
@@ -102,7 +102,9 @@ static char proto_name[]="proto";
|
||||
static char debug_name[]="debug";
|
||||
static char risk_name[]="risks";
|
||||
|
||||
-#if LINUX_VERSION_CODE > KERNEL_VERSION(5,19,0)
|
||||
+#ifdef CONFIG_NDPI_HOOK
|
||||
+#define USE_NDPI_HOOK
|
||||
+#elif LINUX_VERSION_CODE > KERNEL_VERSION(5,19,0)
|
||||
#ifndef USE_LIVEPATCH
|
||||
#define USE_LIVEPATCH
|
||||
#endif
|
||||
@@ -162,15 +164,17 @@ static inline const struct net_device *xt_out(const struct xt_action_param *par)
|
||||
// for testing only!
|
||||
// #define USE_CONNLABELS
|
||||
|
||||
-#if !defined(USE_CONNLABELS) && defined(CONFIG_NF_CONNTRACK_CUSTOM) && CONFIG_NF_CONNTRACK_CUSTOM > 0
|
||||
+#if !defined(USE_CONNLABELS) && !defined(USE_NDPI_HOOK) && defined(CONFIG_NF_CONNTRACK_CUSTOM) && CONFIG_NF_CONNTRACK_CUSTOM > 0
|
||||
#define NF_CT_CUSTOM
|
||||
#else
|
||||
+#ifndef USE_NDPI_HOOK
|
||||
#undef NF_CT_CUSTOM
|
||||
#include <net/netfilter/nf_conntrack_labels.h>
|
||||
#ifndef CONFIG_NF_CONNTRACK_LABELS
|
||||
#error NF_CONNTRACK_LABELS not defined
|
||||
#endif
|
||||
#endif
|
||||
+#endif
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,19,0)
|
||||
#define nf_ct_l3proto_try_module_get(a) 0
|
||||
@@ -3187,7 +3191,7 @@ static int __net_init ndpi_net_init(struct net *net)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
-#ifndef USE_LIVEPATCH
|
||||
+#if !defined(USE_LIVEPATCH) && !defined(USE_NDPI_HOOK)
|
||||
static struct nf_ct_ext_type ndpi_extend = {
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4,8,0)
|
||||
.seq_print = seq_print_ndpi,
|
||||
@@ -3197,7 +3201,7 @@ static struct nf_ct_ext_type ndpi_extend = {
|
||||
.align = __alignof__(uint32_t),
|
||||
.id = 0,
|
||||
};
|
||||
-#else
|
||||
+#elif !defined(USE_NDPI_HOOK)
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,17,0)
|
||||
#error "not implemented"
|
||||
@@ -3266,6 +3270,8 @@ static int __init ndpi_mt_init(void)
|
||||
return -EBUSY;
|
||||
}
|
||||
nf_ct_ext_id_ndpi = ndpi_extend.id;
|
||||
+#elif defined(USE_NDPI_HOOK)
|
||||
+ register_ndpi_hook(&nf_ndpi_free_flow);
|
||||
#else
|
||||
#ifdef USE_LIVEPATCH
|
||||
nf_ct_ext_id_ndpi = NF_CT_EXT_LABELS;
|
||||
@@ -3389,8 +3395,11 @@ static int __init ndpi_mt_init(void)
|
||||
unreg_pernet:
|
||||
unregister_pernet_subsys(&ndpi_net_ops);
|
||||
unreg_ext:
|
||||
-#ifndef USE_LIVEPATCH
|
||||
+#if !defined(USE_LIVEPATCH) && !defined(USE_NDPI_HOOK)
|
||||
nf_ct_extend_unregister(&ndpi_extend);
|
||||
+#endif
|
||||
+#if defined(USE_NDPI_HOOK)
|
||||
+ unregister_ndpi_hook();
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
@@ -3401,8 +3410,10 @@ static void __exit ndpi_mt_exit(void)
|
||||
xt_unregister_target(&ndpi_tg_reg);
|
||||
xt_unregister_match(&ndpi_mt_reg);
|
||||
unregister_pernet_subsys(&ndpi_net_ops);
|
||||
-#ifndef USE_LIVEPATCH
|
||||
+#if !defined(USE_LIVEPATCH) && !defined(USE_NDPI_HOOK)
|
||||
nf_ct_extend_unregister(&ndpi_extend);
|
||||
+#elif defined(USE_NDPI_HOOK)
|
||||
+ unregister_ndpi_hook();
|
||||
#else
|
||||
rcu_assign_pointer(nf_conntrack_destroy_cb,NULL);
|
||||
#endif
|
|
@ -1,237 +0,0 @@
|
|||
--- a/src/lib/protocols/bittorrent.c.old 2023-07-15 11:45:44.566446059 +0200
|
||||
+++ b/src/lib/protocols/bittorrent.c 2023-07-15 11:49:25.498828807 +0200
|
||||
@@ -263,19 +263,6 @@
|
||||
return key % (size-1);
|
||||
}
|
||||
|
||||
-#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
||||
-static inline u_int32_t hash_calc6(ndpi_ip_addr_t *ip,u_int16_t port,u_int32_t size) {
|
||||
- u_int32_t M,I;
|
||||
- u_int8_t *ipp = (u_int8_t *)&I;
|
||||
- u_int32_t key;
|
||||
- M=103;
|
||||
- I = ip->ipv6.u6_addr.u6_addr32[0] + ip->ipv6.u6_addr.u6_addr32[1] + ip->ipv6.u6_addr.u6_addr32[2] + ip->ipv6.u6_addr.u6_addr32[3];
|
||||
- key = (((ipp[0] * M) + ipp[1] * M) + ipp[2]) * M +ipp[3];
|
||||
- ipp = (u_int8_t *)&port;
|
||||
- key = ((key * M) + ipp[0] * M) + ipp[1];
|
||||
- return key % (size-1);
|
||||
-}
|
||||
-#endif
|
||||
|
||||
// ndpi_ip_addr_t
|
||||
static struct hash_ip4p_node *hash_ip4p_add(struct hash_ip4p_table *ht,
|
||||
@@ -283,9 +270,6 @@
|
||||
struct hash_ip4p_node *n,*t;
|
||||
|
||||
u_int32_t key =
|
||||
-#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
||||
- ht->ipv6 ? hash_calc6(ip,port,ht->size) :
|
||||
-#endif
|
||||
hash_calc(ip,port,ht->size);
|
||||
|
||||
n = NULL;
|
||||
@@ -293,22 +277,6 @@
|
||||
spin_lock(&ht->tbl[key].lock);
|
||||
|
||||
n = ht->tbl[key].top;
|
||||
-#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
||||
- if(ht->ipv6) {
|
||||
- while(n) {
|
||||
- if(!memcmp(&n->ip,ip->ipv6.u6_addr.u6_addr8,16) && n->port == port) {
|
||||
- n->lchg = lchg;
|
||||
- n->flag |= flag;
|
||||
- move_up(&ht->tbl[key],n);
|
||||
- goto unlock;
|
||||
- }
|
||||
- n = n->next;
|
||||
- }
|
||||
- n = BT_N_MALLOC(sizeof(struct hash_ip4p_node)+12);
|
||||
- if(!n) goto unlock;
|
||||
- memcpy(&n->ip,ip->ipv6.u6_addr.u6_addr8,16);
|
||||
- } else {
|
||||
-#endif
|
||||
while(n) {
|
||||
if(n->ip == ip->ipv4 && n->port == port) {
|
||||
n->lchg = lchg;
|
||||
@@ -321,9 +289,6 @@
|
||||
n = BT_N_MALLOC(sizeof(struct hash_ip4p_node));
|
||||
if(!n) goto unlock;
|
||||
n->ip = ip->ipv4;
|
||||
-#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
||||
- }
|
||||
-#endif
|
||||
t = ht->tbl[key].top;
|
||||
n->next = t;
|
||||
n->prev = NULL;
|
||||
@@ -347,31 +312,16 @@
|
||||
struct hash_ip4p_node *n;
|
||||
|
||||
u_int16_t key =
|
||||
-#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
||||
- ht->ipv6 ? hash_calc6(ip,port,ht->size) :
|
||||
-#endif
|
||||
hash_calc(ip,port,ht->size);
|
||||
|
||||
n = NULL;
|
||||
spin_lock(&ht->tbl[key].lock);
|
||||
|
||||
n = ht->tbl[key].top;
|
||||
-#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
||||
- if(ht->ipv6) {
|
||||
- while(n) {
|
||||
- if(!memcmp(&n->ip,ip->ipv6.u6_addr.u6_addr8,16) && n->port == port)
|
||||
- break;
|
||||
- n = n->next;
|
||||
- }
|
||||
- } else {
|
||||
-#endif
|
||||
while(n) {
|
||||
if(n->ip == ip->ipv4 && n->port == port) break;
|
||||
n = n->next;
|
||||
}
|
||||
-#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
||||
- }
|
||||
-#endif
|
||||
if(n) {
|
||||
#ifdef __KERNEL__
|
||||
diagram(ndpi_btp_tm,sizeof(ndpi_btp_tm)/sizeof(ndpi_btp_tm[0]),lchg - n->lchg);
|
||||
@@ -805,13 +755,6 @@
|
||||
u_int16_t s_port = packet->udp ? packet->udp->source :
|
||||
packet->tcp ? packet->tcp->source : 0;
|
||||
|
||||
-#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
||||
- if(packet->iphv6)
|
||||
- bt_add_announce(ndpi_struct,
|
||||
- ndpi_struct->bt_ann, ndpi_struct->bt_ann_len,
|
||||
- 1, (ndpi_ip_addr_t *)&packet->iphv6->ip6_src,
|
||||
- s_port, &x.p,p_now);
|
||||
-#endif
|
||||
if(packet->iph)
|
||||
bt_add_announce(ndpi_struct,
|
||||
ndpi_struct->bt_ann, ndpi_struct->bt_ann_len,
|
||||
@@ -819,39 +762,6 @@
|
||||
s_port, &x.p,p_now);
|
||||
}
|
||||
#endif
|
||||
-#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
||||
-if(packet->iphv6 && ndpi_struct->bt6_ht) {
|
||||
-NDPI_LOG_DBG2(ndpi_struct,
|
||||
- "BT: detected valid DHT6 %d %d\n",
|
||||
- x.p.r.nn6,x.p.r.nv6);
|
||||
-#ifndef __KERNEL__
|
||||
-if(bt_parse_debug) dump_bt_proto_struct(&x.p);
|
||||
-#endif
|
||||
- if(x.p.r.nodes6 && x.p.r.nn6) {
|
||||
- struct bt_nodes6_data *n = x.p.r.nodes6;
|
||||
- for(i=0; i < x.p.r.nn6; i++,n++) {
|
||||
- hash_ip4p_add(ndpi_struct->bt6_ht,(ndpi_ip_addr_t *)&n->ip,n->port,p_now,0x2);
|
||||
-
|
||||
- NDPI_LOG_DBG2(ndpi_struct,
|
||||
- "BT: nodes6 add DHT peer %s:%d\n",
|
||||
- inet_ntop(AF_INET6,(void *)&n->ip, ip6buf,sizeof(ip6buf)),
|
||||
- htons(n->port));
|
||||
- }
|
||||
- }
|
||||
- if(x.p.r.values6 && x.p.r.nv6) {
|
||||
- struct bt_ipv6p2 *n = (struct bt_ipv6p2 *)x.p.r.values6;
|
||||
- for(i=0; i < x.p.r.nv6; i++,n++) {
|
||||
- hash_ip4p_add(ndpi_struct->bt6_ht,(ndpi_ip_addr_t *)&n->d.ip,n->d.port,p_now,0x4);
|
||||
-
|
||||
- NDPI_LOG_DBG2(ndpi_struct,
|
||||
- "BT: values6 add DHT peer %s:%d\n",
|
||||
- inet_ntop(AF_INET6,(void *)&n->d.ip, ip6buf,sizeof(ip6buf)),
|
||||
- htons(n->d.port));
|
||||
- }
|
||||
- }
|
||||
- return r >= 0;
|
||||
-}
|
||||
-#endif
|
||||
|
||||
if(!ndpi_struct->bt_ht) return r >= 0;
|
||||
|
||||
@@ -899,16 +809,6 @@
|
||||
static void ndpi_bt_add_peer_cache(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_packet_struct *packet, uint16_t p_src, uint16_t p_dst) {
|
||||
|
||||
-#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
||||
- if(ndpi_struct->bt6_ht && packet->iphv6) {
|
||||
- if(packet->packet_direction)
|
||||
- hash_ip4p_add(ndpi_struct->bt6_ht,(ndpi_ip_addr_t *)&packet->iphv6->ip6_src,
|
||||
- p_src, packet->current_time,1);
|
||||
- else
|
||||
- hash_ip4p_add(ndpi_struct->bt6_ht,(ndpi_ip_addr_t *)&packet->iphv6->ip6_dst,
|
||||
- p_dst, packet->current_time,1);
|
||||
- } else
|
||||
-#endif
|
||||
if(ndpi_struct->bt_ht && packet->iph) {
|
||||
if(packet->packet_direction)
|
||||
hash_ip4p_add(ndpi_struct->bt_ht,(ndpi_ip_addr_t *)&packet->iph->saddr,
|
||||
@@ -1073,19 +973,6 @@
|
||||
if(!packet->tcp) return 0;
|
||||
source = packet->tcp->source;
|
||||
dest = packet->tcp->dest;
|
||||
-#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
||||
- if(ndpi_struct->bt6_ht && packet->iphv6) {
|
||||
- f1 = hash_ip4p_find(ndpi_struct->bt6_ht,(ndpi_ip_addr_t *)&packet->iphv6->ip6_src,source,
|
||||
- packet->current_time);
|
||||
- f2 = hash_ip4p_find(ndpi_struct->bt6_ht,(ndpi_ip_addr_t *)&packet->iphv6->ip6_dst,dest,
|
||||
- packet->current_time);
|
||||
-#ifdef __KERNEL__
|
||||
- if(f1) ndpi_ptss++;
|
||||
- if(f2) ndpi_ptdd++;
|
||||
-#endif
|
||||
- return f1 != NULL || f2 != NULL;
|
||||
- }
|
||||
-#endif
|
||||
if(ndpi_struct->bt_ht && packet->iph) {
|
||||
f1 = hash_ip4p_find(ndpi_struct->bt_ht,(ndpi_ip_addr_t *)&packet->iph->saddr,source,
|
||||
packet->current_time);
|
||||
@@ -1110,23 +997,6 @@
|
||||
if(!packet->udp) return 0;
|
||||
source = packet->udp->source;
|
||||
dest = packet->udp->dest;
|
||||
-#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
||||
- if(ndpi_struct->bt6_ht && packet->iphv6) {
|
||||
- f1 = hash_ip4p_find(ndpi_struct->bt6_ht,(ndpi_ip_addr_t *)&packet->iphv6->ip6_src,source,
|
||||
- packet->current_time);
|
||||
- f2 = hash_ip4p_find(ndpi_struct->bt6_ht,(ndpi_ip_addr_t *)&packet->iphv6->ip6_dst,dest,
|
||||
- packet->current_time);
|
||||
-#ifdef __KERNEL__
|
||||
- if(f1) {
|
||||
- DIRC(ndpi_pusr,ndpi_pusf);
|
||||
- }
|
||||
- if(f2) {
|
||||
- DIRC(ndpi_pudr,ndpi_pudf);
|
||||
- }
|
||||
-#endif
|
||||
- return f1 != NULL || f2 != NULL;
|
||||
- }
|
||||
-#endif
|
||||
if(ndpi_struct->bt_ht && packet->iph) {
|
||||
f1 = hash_ip4p_find(ndpi_struct->bt_ht,(ndpi_ip_addr_t *)&packet->iph->saddr,source,
|
||||
packet->current_time);
|
||||
@@ -1653,11 +1523,6 @@
|
||||
u_int32_t size,u_int32_t size6,u_int32_t tmo,int logsize) {
|
||||
|
||||
ndpi_struct->bt_ht = hash_ip4p_init(size);
|
||||
-#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
||||
- ndpi_struct->bt6_ht = hash_ip4p_init(size6);
|
||||
- if(ndpi_struct->bt6_ht)
|
||||
- ndpi_struct->bt6_ht->ipv6=1;
|
||||
-#endif
|
||||
ndpi_bt_node_expire = tmo;
|
||||
#ifdef BT_ANNOUNCE
|
||||
if(logsize > 0) {
|
||||
@@ -1679,12 +1544,6 @@
|
||||
hash_ip4p_del(ndpi_struct->bt_ht);
|
||||
ndpi_struct->bt_ht = NULL;
|
||||
}
|
||||
-#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
||||
-if(ndpi_struct->bt6_ht) {
|
||||
- hash_ip4p_del(ndpi_struct->bt6_ht);
|
||||
- ndpi_struct->bt6_ht = NULL;
|
||||
-}
|
||||
-#endif
|
||||
}
|
||||
|
||||
void init_bittorrent_dissector(struct ndpi_detection_module_struct *ndpi_struct,
|
|
@ -7,7 +7,7 @@
|
|||
+cc-option = $(shell if $(CC) -Werror $(1) -S -o /dev/null -xc /dev/null \
|
||||
+ > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
|
||||
+mno_outline_atomics := $(call cc-option, -mno-outline-atomics, "")
|
||||
+ccflags-y += $(mno_outline_atomics) -Wframe-larger-than=2600
|
||||
+ccflags-y += $(mno_outline_atomics)
|
||||
#ccflags-y += -Wshadow-local
|
||||
# Needed for pahole
|
||||
#ccflags-y += -femit-struct-debug-detailed=any
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
KERNEL_DIR := /lib/modules/$(shell uname -r)/build
|
||||
endif
|
||||
|
||||
-ifeq ($(shell test -f $(KERNEL_DIR)/source/include/linux/skbuff.h && grep -c userid $(KERNEL_DIR)/source/include/linux/skbuff.h),1)
|
||||
+ifeq ($(shell test -f $(KERNEL_DIR)/include/linux/skbuff.h && shell grep -c userid $(KERNEL_DIR)/include/linux/skbuff.h),1)
|
||||
-ifeq ($(shell test -f $(KERNEL_DIR)/source/include/linux/skbuff.h && grep -qc userid $(KERNEL_DIR)/source/include/linux/skbuff.h),1)
|
||||
+ifeq ($(shell test -f $(KERNEL_DIR)/include/linux/skbuff.h && shell grep -qc userid $(KERNEL_DIR)/include/linux/skbuff.h),1)
|
||||
ccflags-y += -DUSE_HACK_USERID=1
|
||||
endif
|
||||
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
# Attribution: https://gist.github.com/lenew/9b41ba901c3393047ede0766760f9d55
|
||||
|
||||
#Put this source to 'package/lean/r8125' folder of OpenWRT/LEDE SDK
|
||||
#Build(make menuconfig, make defconfig, make)
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=r8125
|
||||
PKG_VERSION:=9.010.01-1
|
||||
PKG_RELEASE:=$(AUTORELEASE)
|
||||
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=https://codeload.github.com/awesometic/realtek-r8125-dkms/tar.gz/$(PKG_VERSION)?
|
||||
PKG_HASH:=81fb9a100e6cefb421557639b476fd03af61a99c55bc8fb03c6e396532bd0944
|
||||
PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/realtek-$(PKG_NAME)-dkms-$(PKG_VERSION)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define KernelPackage/r8125
|
||||
TITLE:=Driver for Realtek r8125 chipsets
|
||||
SUBMENU:=Network Devices
|
||||
VERSION:=$(LINUX_VERSION)+$(PKG_VERSION)-$(BOARD)-$(PKG_RELEASE)
|
||||
FILES:= $(PKG_BUILD_DIR)/src/r8125.ko
|
||||
AUTOLOAD:=$(call AutoProbe,r8125)
|
||||
endef
|
||||
|
||||
define Package/r8125/description
|
||||
This package contains a driver for Realtek r8125 chipsets.
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
+$(KERNEL_MAKE) M=$(PKG_BUILD_DIR)/src modules
|
||||
endef
|
||||
|
||||
$(eval $(call KernelPackage,r8125))
|
|
@ -1,22 +0,0 @@
|
|||
--- a/src/Makefile
|
||||
+++ b/src/Makefile
|
||||
@@ -35,16 +35,16 @@ ENABLE_REALWOW_SUPPORT = n
|
||||
ENABLE_DASH_SUPPORT = n
|
||||
ENABLE_DASH_PRINTER_SUPPORT = n
|
||||
CONFIG_DOWN_SPEED_100 = n
|
||||
-CONFIG_ASPM = y
|
||||
+CONFIG_ASPM = n
|
||||
ENABLE_S5WOL = y
|
||||
ENABLE_S5_KEEP_CURR_MAC = n
|
||||
ENABLE_EEE = y
|
||||
ENABLE_S0_MAGIC_PACKET = n
|
||||
ENABLE_TX_NO_CLOSE = y
|
||||
-ENABLE_MULTIPLE_TX_QUEUE = n
|
||||
+ENABLE_MULTIPLE_TX_QUEUE = y
|
||||
ENABLE_PTP_SUPPORT = n
|
||||
ENABLE_PTP_MASTER_MODE = n
|
||||
-ENABLE_RSS_SUPPORT = n
|
||||
+ENABLE_RSS_SUPPORT = y
|
||||
ENABLE_LIB_SUPPORT = n
|
||||
ENABLE_USE_FIRMWARE_FILE = n
|
||||
DISABLE_PM_SUPPORT = n
|
|
@ -1,18 +0,0 @@
|
|||
--- a/src/r8125_n.c
|
||||
+++ b/src/r8125_n.c
|
||||
@@ -116,6 +116,15 @@
|
||||
#define FIRMWARE_8168FP_3 "rtl_nic/rtl8168fp-3.fw"
|
||||
#define FIRMWARE_8168FP_4 "rtl_nic/rtl8168fp-4.fw"
|
||||
|
||||
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 0)
|
||||
+static inline void netif_set_gso_max_size(struct net_device *dev,
|
||||
+ unsigned int size)
|
||||
+{
|
||||
+ /* dev->gso_max_size is read locklessly from sk_setup_caps() */
|
||||
+ WRITE_ONCE(dev->gso_max_size, size);
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
/* Maximum number of multicast addresses to filter (vs. Rx-all-multicast).
|
||||
The RTL chips use a 64 element hash table based on the Ethernet CRC. */
|
||||
static const int multicast_filter_limit = 32;
|
|
@ -1,14 +0,0 @@
|
|||
--- a/src/r8125.h
|
||||
+++ b/src/r8125.h
|
||||
@@ -633,7 +633,11 @@
|
||||
typedef struct napi_struct *napi_ptr;
|
||||
typedef int napi_budget;
|
||||
|
||||
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
|
||||
+#define RTL_NAPI_CONFIG(ndev, priv, function, weight) netif_napi_add_weight(ndev, &priv->napi, function, weight)
|
||||
+#else
|
||||
#define RTL_NAPI_CONFIG(ndev, priv, function, weight) netif_napi_add(ndev, &priv->napi, function, weight)
|
||||
+#endif
|
||||
#define RTL_NAPI_QUOTA(budget, ndev) min(budget, budget)
|
||||
#define RTL_GET_PRIV(stuct_ptr, priv_struct) container_of(stuct_ptr, priv_struct, stuct_ptr)
|
||||
#define RTL_GET_NETDEV(priv_ptr) struct net_device *dev = priv_ptr->dev;
|
|
@ -1,43 +0,0 @@
|
|||
--- a/src/r8125_n.c
|
||||
+++ b/src/r8125_n.c
|
||||
@@ -43,6 +43,7 @@
|
||||
#include <linux/etherdevice.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/mii.h>
|
||||
+#include <linux/of.h>
|
||||
#include <linux/if_vlan.h>
|
||||
#include <linux/crc32.h>
|
||||
#include <linux/interrupt.h>
|
||||
@@ -10407,6 +10408,23 @@ rtl8125_setup_mqs_reg(struct rtl8125_private *tp)
|
||||
}
|
||||
}
|
||||
|
||||
+static int
|
||||
+rtl8125_led_configuration(struct rtl8125_private *tp)
|
||||
+{
|
||||
+ u32 led_data;
|
||||
+ int ret;
|
||||
+
|
||||
+ ret = of_property_read_u32(tp->pci_dev->dev.of_node,
|
||||
+ "realtek,led-data", &led_data);
|
||||
+
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ RTL_W16(tp, CustomLED, led_data);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
static void
|
||||
rtl8125_init_software_variable(struct net_device *dev)
|
||||
{
|
||||
@@ -10838,6 +10856,8 @@ rtl8125_init_software_variable(struct net_device *dev)
|
||||
if (tp->InitRxDescType == RX_DESC_RING_TYPE_3)
|
||||
tp->rtl8125_rx_config |= EnableRxDescV3;
|
||||
|
||||
+ rtl8125_led_configuration(tp);
|
||||
+
|
||||
tp->NicCustLedValue = RTL_R16(tp, CustomLED);
|
||||
|
||||
tp->wol_opts = rtl8125_get_hw_wol(tp);
|
|
@ -1,55 +0,0 @@
|
|||
#
|
||||
# Download realtek r8152 linux driver from official site:
|
||||
# [https://www.realtek.com/en/component/zoo/category/network-interface-controllers-10-100-1000m-gigabit-ethernet-usb-3-0-software]
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=r8152
|
||||
PKG_VERSION:=2.16.3.20220914
|
||||
PKG_RELEASE:=3
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=https://codeload.github.com/wget/realtek-r8152-linux/tar.gz/v$(PKG_VERSION)?
|
||||
PKG_HASH:=61ed7af34c8882c6028ddd1a27bb78fb5bfba41211f84dd7a06e4dc84dbe9a9a
|
||||
|
||||
PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/realtek-$(PKG_NAME)-linux-$(PKG_VERSION)
|
||||
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
|
||||
PKG_MAINTAINER:=Tianling Shen <cnsztl@immortalwrt.org>
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define KernelPackage/usb-net-rtl8152-vendor
|
||||
VERSION:=$(LINUX_VERSION)+$(PKG_VERSION)-$(BOARD)-$(PKG_RELEASE)
|
||||
TITLE:=Kernel module for USB-to-Ethernet Realtek convertors
|
||||
SUBMENU:=USB Support
|
||||
DEPENDS:=+kmod-usb-net
|
||||
FILES:=$(PKG_BUILD_DIR)/r8152.ko
|
||||
AUTOLOAD:=$(call AutoProbe,r8152)
|
||||
CONFLICTS:=kmod-usb-net-rtl8152
|
||||
endef
|
||||
|
||||
define KernelPackage/usb-net-rtl8152-vendor/description
|
||||
Kernel module for Realtek RTL8152/RTL8153 Based USB Ethernet Adapters
|
||||
endef
|
||||
|
||||
R8152_MAKEOPTS= -C $(PKG_BUILD_DIR) \
|
||||
PATH="$(TARGET_PATH)" \
|
||||
ARCH="$(LINUX_KARCH)" \
|
||||
CROSS_COMPILE="$(TARGET_CROSS)" \
|
||||
TARGET="$(HAL_TARGET)" \
|
||||
TOOLPREFIX="$(KERNEL_CROSS)" \
|
||||
TOOLPATH="$(KERNEL_CROSS)" \
|
||||
KERNELPATH="$(LINUX_DIR)" \
|
||||
KERNELDIR="$(LINUX_DIR)" \
|
||||
LDOPTS=" " \
|
||||
DOMULTI=1
|
||||
|
||||
define Build/Compile
|
||||
+$(MAKE) $(PKG_JOBS) $(R8152_MAKEOPTS) modules
|
||||
endef
|
||||
|
||||
$(eval $(call KernelPackage,usb-net-rtl8152-vendor))
|
|
@ -1,19 +0,0 @@
|
|||
--- a/r8152.c
|
||||
+++ b/r8152.c
|
||||
@@ -1026,6 +1026,16 @@
|
||||
#define RTL_ADVERTISED_1000_FULL BIT(5)
|
||||
#define RTL_ADVERTISED_2500_FULL BIT(6)
|
||||
|
||||
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 0)
|
||||
+static inline void netif_set_gso_max_size(struct net_device *dev,
|
||||
+ unsigned int size)
|
||||
+{
|
||||
+ /* dev->gso_max_size is read locklessly from sk_setup_caps() */
|
||||
+ WRITE_ONCE(dev->gso_max_size, size);
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
+
|
||||
/* Maximum number of multicast addresses to filter (vs. Rx-all-multicast).
|
||||
* The RTL chips use a 64 element hash table based on the Ethernet CRC.
|
||||
*/
|
|
@ -1,38 +0,0 @@
|
|||
--- a/compatibility.h
|
||||
+++ b/compatibility.h
|
||||
@@ -237,9 +237,15 @@
|
||||
#define napi_disable(napi_ptr) netif_poll_disable(container_of(napi_ptr, struct r8152, napi)->netdev)
|
||||
#define napi_schedule(napi_ptr) netif_rx_schedule(container_of(napi_ptr, struct r8152, napi)->netdev)
|
||||
#define napi_complete(napi_ptr) netif_rx_complete(container_of(napi_ptr, struct r8152, napi)->netdev)
|
||||
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
|
||||
+ #define netif_napi_add_weight(ndev, napi_ptr, function, weight_t) \
|
||||
+ ndev->poll = function; \
|
||||
+ ndev->weight = weight_t;
|
||||
+#else
|
||||
#define netif_napi_add(ndev, napi_ptr, function, weight_t) \
|
||||
ndev->poll = function; \
|
||||
ndev->weight = weight_t;
|
||||
+#endif
|
||||
typedef unsigned long uintptr_t;
|
||||
#define DMA_BIT_MASK(value) \
|
||||
(value < 64 ? ((1ULL << value) - 1) : 0xFFFFFFFFFFFFFFFFULL)
|
||||
--- a/r8152.c
|
||||
+++ b/r8152.c
|
||||
@@ -20718,10 +20718,17 @@
|
||||
|
||||
usb_set_intfdata(intf, tp);
|
||||
|
||||
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
|
||||
+ if (tp->support_2500full)
|
||||
+ netif_napi_add_weight(netdev, &tp->napi, r8152_poll, 256);
|
||||
+ else
|
||||
+ netif_napi_add_weight(netdev, &tp->napi, r8152_poll, 64);
|
||||
+#else
|
||||
if (tp->support_2500full)
|
||||
netif_napi_add(netdev, &tp->napi, r8152_poll, 256);
|
||||
else
|
||||
netif_napi_add(netdev, &tp->napi, r8152_poll, 64);
|
||||
+#endif
|
||||
|
||||
ret = register_netdev(netdev);
|
||||
if (ret != 0) {
|
|
@ -1,74 +0,0 @@
|
|||
From 82985725e071f2a5735052f18e109a32aeac3a0b Mon Sep 17 00:00:00 2001
|
||||
From: David Bauer <mail@david-bauer.net>
|
||||
Date: Sun, 26 Jul 2020 02:38:31 +0200
|
||||
Subject: [PATCH] add LED configuration from OF
|
||||
|
||||
This adds the ability to configure the LED configuration register using
|
||||
OF. This way, the correct value for board specific LED configuration can
|
||||
be determined.
|
||||
|
||||
Signed-off-by: David Bauer <mail@david-bauer.net>
|
||||
---
|
||||
r8152.c | 23 +++++++++++++++++++++++
|
||||
1 file changed, 23 insertions(+)
|
||||
|
||||
--- a/r8152.c
|
||||
+++ b/r8152.c
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <linux/mii.h>
|
||||
#include <linux/ethtool.h>
|
||||
#include <linux/usb.h>
|
||||
+#include <linux/of.h>
|
||||
#include <linux/crc32.h>
|
||||
#include <linux/if_vlan.h>
|
||||
#include <linux/uaccess.h>
|
||||
@@ -9804,6 +9805,22 @@ static void rtl_tally_reset(struct r8152
|
||||
ocp_write_word(tp, MCU_TYPE_PLA, PLA_RSTTALLY, ocp_data);
|
||||
}
|
||||
|
||||
+static int r8152_led_configuration(struct r8152 *tp)
|
||||
+{
|
||||
+ u32 led_data;
|
||||
+ int ret;
|
||||
+
|
||||
+ ret = of_property_read_u32(tp->udev->dev.of_node, "realtek,led-data",
|
||||
+ &led_data);
|
||||
+
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_LEDSEL, led_data);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
static void r8152b_init(struct r8152 *tp)
|
||||
{
|
||||
u32 ocp_data;
|
||||
@@ -9865,6 +9882,8 @@ static void r8152b_init(struct r8152 *tp
|
||||
ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_USB_CTRL);
|
||||
ocp_data &= ~(RX_AGG_DISABLE | RX_ZERO_EN);
|
||||
ocp_write_word(tp, MCU_TYPE_USB, USB_USB_CTRL, ocp_data);
|
||||
+
|
||||
+ r8152_led_configuration(tp);
|
||||
}
|
||||
|
||||
static void r8153_init(struct r8152 *tp)
|
||||
@@ -10008,6 +10027,8 @@ static void r8153_init(struct r8152 *tp)
|
||||
tp->coalesce = COALESCE_SLOW;
|
||||
break;
|
||||
}
|
||||
+
|
||||
+ r8152_led_configuration(tp);
|
||||
}
|
||||
|
||||
static void r8153b_init(struct r8152 *tp)
|
||||
@@ -10098,6 +10119,8 @@ static void r8153b_init(struct r8152 *tp
|
||||
rtl_tally_reset(tp);
|
||||
|
||||
tp->coalesce = 15000; /* 15 us */
|
||||
+
|
||||
+ r8152_led_configuration(tp);
|
||||
}
|
||||
|
||||
static void r8153c_init(struct r8152 *tp)
|
|
@ -1,39 +0,0 @@
|
|||
#
|
||||
# Download realtek r8168 linux driver from official site:
|
||||
# [https://www.realtek.com/component/zoo/category/network-interface-controllers-10-100-1000m-gigabit-ethernet-pci-express-software]
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=r8168
|
||||
PKG_VERSION:=8.051.02
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://github.com/BROBIRD/openwrt-r8168.git
|
||||
PKG_SOURCE_VERSION:=4f6cfe1ca12fb772deed57f1d2d1062af041ad07
|
||||
PKG_MIRROR_HASH:=6b149f5eb3b9e1dc50867a694984d253aa58d97dd5fbab30eb405d2d7b2be587
|
||||
|
||||
PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define KernelPackage/r8168
|
||||
TITLE:=Driver for Realtek r8168 chipsets
|
||||
SUBMENU:=Network Devices
|
||||
VERSION:=$(LINUX_VERSION)+$(PKG_VERSION)-$(BOARD)-$(PKG_RELEASE)
|
||||
FILES:= $(PKG_BUILD_DIR)/src/r8168.ko
|
||||
AUTOLOAD:=$(call AutoProbe,r8168)
|
||||
CONFLICTS:=kmod-r8169
|
||||
endef
|
||||
|
||||
define Package/r8168/description
|
||||
This package contains a driver for Realtek r8168 chipsets.
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
+$(KERNEL_MAKE) M=$(PKG_BUILD_DIR)/src modules
|
||||
endef
|
||||
|
||||
$(eval $(call KernelPackage,r8168))
|
|
@ -1,42 +0,0 @@
|
|||
--- a/src/r8168_n.c
|
||||
+++ b/src/r8168_n.c
|
||||
@@ -47,6 +47,7 @@
|
||||
#include <linux/etherdevice.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/mii.h>
|
||||
+#include <linux/of.h>
|
||||
#include <linux/if_vlan.h>
|
||||
#include <linux/crc32.h>
|
||||
#include <linux/interrupt.h>
|
||||
@@ -24643,6 +24644,22 @@ rtl8168_set_bios_setting(struct net_devi
|
||||
}
|
||||
}
|
||||
|
||||
+static int rtl8168_led_configuration(struct rtl8168_private *tp)
|
||||
+{
|
||||
+ u32 led_data;
|
||||
+ int ret;
|
||||
+
|
||||
+ ret = of_property_read_u32(tp->pci_dev->dev.of_node,
|
||||
+ "realtek,led-data", &led_data);
|
||||
+
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ RTL_W16(tp, CustomLED, led_data);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
static void
|
||||
rtl8168_init_software_variable(struct net_device *dev)
|
||||
{
|
||||
@@ -25206,6 +25223,8 @@ rtl8168_init_software_variable(struct ne
|
||||
tp->NotWrMcuPatchCode = TRUE;
|
||||
}
|
||||
|
||||
+ rtl8168_led_configuration(tp);
|
||||
+
|
||||
tp->NicCustLedValue = RTL_R16(tp, CustomLED);
|
||||
|
||||
rtl8168_get_hw_wol(dev);
|
|
@ -1,47 +0,0 @@
|
|||
--- a/src/r8168_n.c
|
||||
+++ b/src/r8168_n.c
|
||||
@@ -3715,7 +3715,11 @@
|
||||
txd->opts2 = 0;
|
||||
while (1) {
|
||||
memset(tmpAddr, pattern++, len - 14);
|
||||
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,18,0)
|
||||
pci_dma_sync_single_for_device(tp->pci_dev,
|
||||
+#else
|
||||
+ dma_sync_single_for_device(tp_to_dev(tp),
|
||||
+#endif
|
||||
le64_to_cpu(mapping),
|
||||
len, DMA_TO_DEVICE);
|
||||
txd->opts1 = cpu_to_le32(DescOwn | FirstFrag | LastFrag | len);
|
||||
@@ -3743,7 +3747,11 @@
|
||||
if (rx_len == len) {
|
||||
dma_sync_single_for_cpu(tp_to_dev(tp), le64_to_cpu(rxd->addr), tp->rx_buf_sz, DMA_FROM_DEVICE);
|
||||
i = memcmp(skb->data, rx_skb->data, rx_len);
|
||||
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,18,0)
|
||||
pci_dma_sync_single_for_device(tp->pci_dev, le64_to_cpu(rxd->addr), tp->rx_buf_sz, DMA_FROM_DEVICE);
|
||||
+#else
|
||||
+ dma_sync_single_for_device(tp_to_dev(tp), le64_to_cpu(rxd->addr), tp->rx_buf_sz, DMA_FROM_DEVICE);
|
||||
+#endif
|
||||
if (i == 0) {
|
||||
// dev_printk(KERN_INFO, tp_to_dev(tp), "loopback test finished\n",rx_len,len);
|
||||
break;
|
||||
@@ -26464,11 +26472,20 @@
|
||||
|
||||
if ((sizeof(dma_addr_t) > 4) &&
|
||||
use_dac &&
|
||||
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,18,0)
|
||||
!pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) &&
|
||||
!pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64))) {
|
||||
+#else
|
||||
+ !dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)) &&
|
||||
+ !dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64))) {
|
||||
+#endif
|
||||
dev->features |= NETIF_F_HIGHDMA;
|
||||
} else {
|
||||
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,18,0)
|
||||
rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
|
||||
+#else
|
||||
+ rc = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
|
||||
+#endif
|
||||
if (rc < 0) {
|
||||
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0)
|
||||
if (netif_msg_probe(tp))
|
|
@ -1,18 +0,0 @@
|
|||
--- a/src/r8168_n.c
|
||||
+++ b/src/r8168_n.c
|
||||
@@ -116,6 +116,15 @@
|
||||
#define FIRMWARE_8168FP_3 "rtl_nic/rtl8168fp-3.fw"
|
||||
#define FIRMWARE_8168FP_4 "rtl_nic/rtl8168fp-4.fw"
|
||||
|
||||
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 0)
|
||||
+static inline void netif_set_gso_max_size(struct net_device *dev,
|
||||
+ unsigned int size)
|
||||
+{
|
||||
+ /* dev->gso_max_size is read locklessly from sk_setup_caps() */
|
||||
+ WRITE_ONCE(dev->gso_max_size, size);
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
/* Maximum number of multicast addresses to filter (vs. Rx-all-multicast).
|
||||
The RTL chips use a 64 element hash table based on the Ethernet CRC. */
|
||||
static const int multicast_filter_limit = 32;
|
|
@ -1,14 +0,0 @@
|
|||
--- a/src/r8168.h
|
||||
--- b/src/r8168.h
|
||||
@@ -566,7 +566,11 @@
|
||||
typedef struct napi_struct *napi_ptr;
|
||||
typedef int napi_budget;
|
||||
|
||||
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
|
||||
+#define RTL_NAPI_CONFIG(ndev, priv, function, weight) netif_napi_add_weight(ndev, &priv->napi, function, weight)
|
||||
+#else
|
||||
#define RTL_NAPI_CONFIG(ndev, priv, function, weight) netif_napi_add(ndev, &priv->napi, function, weight)
|
||||
+#endif
|
||||
#define RTL_NAPI_QUOTA(budget, ndev) min(budget, budget)
|
||||
#define RTL_GET_PRIV(stuct_ptr, priv_struct) container_of(stuct_ptr, priv_struct, stuct_ptr)
|
||||
#define RTL_GET_NETDEV(priv_ptr) struct net_device *dev = priv_ptr->dev;
|
|
@ -1,109 +0,0 @@
|
|||
#
|
||||
# Copyright (c) 2013-2018 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 $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=fast-classifier
|
||||
PKG_RELEASE:=6
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define KernelPackage/fast-classifier/Default
|
||||
SECTION:=kernel
|
||||
CATEGORY:=Kernel modules
|
||||
SUBMENU:=Network Support
|
||||
DEPENDS:=+kmod-ipt-conntrack +kmod-shortcut-fe
|
||||
TITLE:=Kernel driver for FAST Classifier
|
||||
FILES:=$(PKG_BUILD_DIR)/fast-classifier.ko
|
||||
KCONFIG:= \
|
||||
CONFIG_NF_CONNTRACK_EVENTS=y \
|
||||
CONFIG_NF_CONNTRACK_CHAIN_EVENTS=y \
|
||||
CONFIG_NF_CONNTRACK_MARK=y \
|
||||
CONFIG_XFRM=y
|
||||
CONFLICTS:=kmod-shortcut-fe-drv kmod-shortcut-fe-cm
|
||||
endef
|
||||
|
||||
define KernelPackage/fast-classifier
|
||||
$(call KernelPackage/fast-classifier/Default)
|
||||
endef
|
||||
|
||||
define KernelPackage/fast-classifier-noload
|
||||
$(call KernelPackage/fast-classifier/Default)
|
||||
endef
|
||||
|
||||
define KernelPackage/fast-classifier/Default/description
|
||||
FAST Classifier talks to SFE to make decisions about offloading connections
|
||||
endef
|
||||
|
||||
define KernelPackage/fast-classifier/description
|
||||
$(call KernelPackage/fast-classifier/Default/description)
|
||||
endef
|
||||
|
||||
define KernelPackage/fast-classifier-noload/description
|
||||
$(call KernelPackage/fast-classifier/Default/description)
|
||||
|
||||
This package does not load fast-classifier at boot by default
|
||||
endef
|
||||
|
||||
define Package/fast-classifier-example
|
||||
TITLE:=Example user space program for fast-classifier
|
||||
DEPENDS:=+libnl +kmod-fast-classifier
|
||||
endef
|
||||
|
||||
define Package/fast-classifier-example/description
|
||||
Example user space program that communicates with fast
|
||||
classifier kernel module
|
||||
endef
|
||||
|
||||
HAVE_ECM:=$(CONFIG_PACKAGE_kmod-qca-nss-ecm-premium)$(CONFIG_PACKAGE_kmod-qca-nss-ecm-noload)$(CONFIG_PACKAGE_kmod-qca-nss-ecm-premium-noload)$(CONFIG_PACKAGE_kmod-qca-nss-ecm-standard)
|
||||
|
||||
define Build/Compile/kmod
|
||||
+$(MAKE) $(PKG_JOBS) -C "$(LINUX_DIR)" \
|
||||
$(KERNEL_MAKE_FLAGS) \
|
||||
$(PKG_MAKE_FLAGS) \
|
||||
M="$(PKG_BUILD_DIR)" \
|
||||
CONFIG_FAST_CLASSIFIER=m \
|
||||
EXTRA_CFLAGS+="-DSFE_SUPPORT_IPV6" \
|
||||
$(if $(HAVE_ECM),EXTRA_CFLAGS+="-DCONFIG_SFE_ECM" CONFIG_SFE_ECM=y,) \
|
||||
modules
|
||||
endef
|
||||
|
||||
define Build/Compile/example
|
||||
$(TARGET_CC) -o $(PKG_BUILD_DIR)/userspace_fast_classifier \
|
||||
-I $(PKG_BUILD_DIR) \
|
||||
-I$(STAGING_DIR)/usr/include/libnl \
|
||||
-I$(STAGING_DIR)/usr/include/libnl3 \
|
||||
-lnl-genl-3 -lnl-3 \
|
||||
$(PKG_BUILD_DIR)/nl_classifier_test.c
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
$(Build/Compile/kmod)
|
||||
$(if $(CONFIG_PACKAGE_fast-classifier-example),$(Build/Compile/example))
|
||||
endef
|
||||
|
||||
define Build/InstallDev
|
||||
$(INSTALL_DIR) $(1)/usr/include
|
||||
$(CP) $(PKG_BUILD_DIR)/fast-classifier.h $(1)/usr/include/
|
||||
endef
|
||||
|
||||
define Package/fast-classifier-example/install
|
||||
$(INSTALL_DIR) $(1)/sbin
|
||||
$(CP) $(PKG_BUILD_DIR)/userspace_fast_classifier $(1)/sbin/
|
||||
endef
|
||||
|
||||
$(eval $(call KernelPackage,fast-classifier))
|
||||
#$(eval $(call KernelPackage,fast-classifier-noload))
|
||||
#$(eval $(call BuildPackage,fast-classifier-example))
|
|
@ -1,10 +0,0 @@
|
|||
obj-$(CONFIG_FAST_CLASSIFIER) += fast-classifier.o
|
||||
|
||||
ifeq ($(SFE_SUPPORT_IPV6),)
|
||||
SFE_SUPPORT_IPV6=y
|
||||
endif
|
||||
ccflags-$(SFE_SUPPORT_IPV6) += -DSFE_SUPPORT_IPV6
|
||||
|
||||
ccflags-y += -I$(obj)/../shortcut-fe
|
||||
|
||||
obj ?= .
|
File diff suppressed because it is too large
Load diff
|
@ -1,57 +0,0 @@
|
|||
/*
|
||||
* User space header to send message to the fast classifier
|
||||
*
|
||||
* Copyright (c) 2013,2016 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 <linux/if_ether.h>
|
||||
|
||||
#define FAST_CLASSIFIER_GENL_VERSION (1)
|
||||
#define FAST_CLASSIFIER_GENL_NAME "FC"
|
||||
#define FAST_CLASSIFIER_GENL_MCGRP "FC_MCGRP"
|
||||
#define FAST_CLASSIFIER_GENL_HDRSIZE (0)
|
||||
|
||||
enum {
|
||||
FAST_CLASSIFIER_A_UNSPEC,
|
||||
FAST_CLASSIFIER_A_TUPLE,
|
||||
__FAST_CLASSIFIER_A_MAX,
|
||||
};
|
||||
|
||||
#define FAST_CLASSIFIER_A_MAX (__FAST_CLASSIFIER_A_MAX - 1)
|
||||
|
||||
enum {
|
||||
FAST_CLASSIFIER_C_UNSPEC,
|
||||
FAST_CLASSIFIER_C_OFFLOAD,
|
||||
FAST_CLASSIFIER_C_OFFLOADED,
|
||||
FAST_CLASSIFIER_C_DONE,
|
||||
__FAST_CLASSIFIER_C_MAX,
|
||||
};
|
||||
|
||||
#define FAST_CLASSIFIER_C_MAX (__FAST_CLASSIFIER_C_MAX - 1)
|
||||
|
||||
struct fast_classifier_tuple {
|
||||
unsigned short ethertype;
|
||||
unsigned char proto;
|
||||
union {
|
||||
struct in_addr in;
|
||||
struct in6_addr in6;
|
||||
} src_saddr;
|
||||
union {
|
||||
struct in_addr in;
|
||||
struct in6_addr in6;
|
||||
} dst_saddr;
|
||||
unsigned short sport;
|
||||
unsigned short dport;
|
||||
unsigned char smac[ETH_ALEN];
|
||||
unsigned char dmac[ETH_ALEN];
|
||||
};
|
|
@ -1,281 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016 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 <netlink/genl/genl.h>
|
||||
#include <netlink/genl/ctrl.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#define NL_CLASSIFIER_GENL_VERSION 1
|
||||
#define NL_CLASSIFIER_GENL_FAMILY "FC"
|
||||
#define NL_CLASSIFIER_GENL_GROUP "FC_MCGRP"
|
||||
#define NL_CLASSIFIER_GENL_HDRSIZE 0
|
||||
|
||||
enum NL_CLASSIFIER_CMD {
|
||||
NL_CLASSIFIER_CMD_UNSPEC,
|
||||
NL_CLASSIFIER_CMD_ACCEL,
|
||||
NL_CLASSIFIER_CMD_ACCEL_OK,
|
||||
NL_CLASSIFIER_CMD_CONNECTION_CLOSED,
|
||||
NL_CLASSIFIER_CMD_MAX,
|
||||
};
|
||||
|
||||
enum NL_CLASSIFIER_ATTR {
|
||||
NL_CLASSIFIER_ATTR_UNSPEC,
|
||||
NL_CLASSIFIER_ATTR_TUPLE,
|
||||
NL_CLASSIFIER_ATTR_MAX,
|
||||
};
|
||||
|
||||
union nl_classifier_tuple_ip {
|
||||
struct in_addr in;
|
||||
struct in6_addr in6;
|
||||
};
|
||||
|
||||
struct nl_classifier_tuple {
|
||||
unsigned short af;
|
||||
unsigned char proto;
|
||||
union nl_classifier_tuple_ip src_ip;
|
||||
union nl_classifier_tuple_ip dst_ip;
|
||||
unsigned short sport;
|
||||
unsigned short dport;
|
||||
unsigned char smac[6];
|
||||
unsigned char dmac[6];
|
||||
};
|
||||
|
||||
struct nl_classifier_instance {
|
||||
struct nl_sock *sock;
|
||||
int family_id;
|
||||
int group_id;
|
||||
int stop;
|
||||
};
|
||||
|
||||
struct nl_classifier_instance nl_cls_inst;
|
||||
|
||||
static struct nla_policy nl_classifier_genl_policy[(NL_CLASSIFIER_ATTR_MAX+1)] = {
|
||||
[NL_CLASSIFIER_ATTR_TUPLE] = { .type = NLA_UNSPEC },
|
||||
};
|
||||
|
||||
void nl_classifier_dump_nl_tuple(struct nl_classifier_tuple *tuple)
|
||||
{
|
||||
char ip_str[64];
|
||||
|
||||
printf("protocol = %s\n", (tuple->proto == IPPROTO_UDP) ? "udp" : ((tuple->proto == IPPROTO_TCP) ? "tcp" : "unknown"));
|
||||
printf("source ip = %s\n", inet_ntop(tuple->af, &tuple->src_ip, ip_str, sizeof(ip_str)));
|
||||
printf("destination ip = %s\n", inet_ntop(tuple->af, &tuple->dst_ip, ip_str, sizeof(ip_str)));
|
||||
printf("source port = %d\n", ntohs(tuple->sport));
|
||||
printf("destination port = %d\n", ntohs(tuple->dport));
|
||||
}
|
||||
|
||||
int nl_classifier_msg_recv(struct nl_msg *msg, void *arg)
|
||||
{
|
||||
struct nlmsghdr *nlh = nlmsg_hdr(msg);
|
||||
struct genlmsghdr *gnlh = nlmsg_data(nlh);
|
||||
struct nlattr *attrs[(NL_CLASSIFIER_ATTR_MAX+1)];
|
||||
|
||||
genlmsg_parse(nlh, NL_CLASSIFIER_GENL_HDRSIZE, attrs, NL_CLASSIFIER_ATTR_MAX, nl_classifier_genl_policy);
|
||||
|
||||
switch (gnlh->cmd) {
|
||||
case NL_CLASSIFIER_CMD_ACCEL_OK:
|
||||
printf("Acceleration successful:\n");
|
||||
nl_classifier_dump_nl_tuple(nla_data(attrs[NL_CLASSIFIER_ATTR_TUPLE]));
|
||||
return NL_OK;
|
||||
case NL_CLASSIFIER_CMD_CONNECTION_CLOSED:
|
||||
printf("Connection is closed:\n");
|
||||
nl_classifier_dump_nl_tuple(nla_data(attrs[NL_CLASSIFIER_ATTR_TUPLE]));
|
||||
return NL_OK;
|
||||
default:
|
||||
printf("nl classifier received unknow message %d\n", gnlh->cmd);
|
||||
}
|
||||
|
||||
return NL_SKIP;
|
||||
}
|
||||
|
||||
void nl_classifier_offload(struct nl_classifier_instance *inst,
|
||||
unsigned char proto, unsigned long *src_saddr,
|
||||
unsigned long *dst_saddr, unsigned short sport,
|
||||
unsigned short dport, int af)
|
||||
{
|
||||
struct nl_msg *msg;
|
||||
int ret;
|
||||
struct nl_classifier_tuple classifier_msg;
|
||||
|
||||
memset(&classifier_msg, 0, sizeof(classifier_msg));
|
||||
classifier_msg.af = af;
|
||||
classifier_msg.proto = proto;
|
||||
memcpy(&classifier_msg.src_ip, src_saddr, (af == AF_INET ? 4 : 16));
|
||||
memcpy(&classifier_msg.dst_ip, dst_saddr, (af == AF_INET ? 4 : 16));
|
||||
classifier_msg.sport = sport;
|
||||
classifier_msg.dport = dport;
|
||||
|
||||
msg = nlmsg_alloc();
|
||||
if (!msg) {
|
||||
printf("Unable to allocate message\n");
|
||||
return;
|
||||
}
|
||||
|
||||
genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, inst->family_id,
|
||||
NL_CLASSIFIER_GENL_HDRSIZE, NLM_F_REQUEST,
|
||||
NL_CLASSIFIER_CMD_ACCEL, NL_CLASSIFIER_GENL_VERSION);
|
||||
nla_put(msg, NL_CLASSIFIER_ATTR_TUPLE, sizeof(classifier_msg), &classifier_msg);
|
||||
|
||||
ret = nl_send_auto(inst->sock, msg);
|
||||
if (ret < 0) {
|
||||
printf("send netlink message failed.\n");
|
||||
nlmsg_free(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
nlmsg_free(msg);
|
||||
printf("nl classifier offload connection successful\n");
|
||||
}
|
||||
|
||||
int nl_classifier_init(struct nl_classifier_instance *inst)
|
||||
{
|
||||
int ret;
|
||||
|
||||
inst->sock = nl_socket_alloc();
|
||||
if (!inst->sock) {
|
||||
printf("Unable to allocation socket.\n");
|
||||
return -1;
|
||||
}
|
||||
genl_connect(inst->sock);
|
||||
|
||||
inst->family_id = genl_ctrl_resolve(inst->sock, NL_CLASSIFIER_GENL_FAMILY);
|
||||
if (inst->family_id < 0) {
|
||||
printf("Unable to resolve family %s\n", NL_CLASSIFIER_GENL_FAMILY);
|
||||
goto init_failed;
|
||||
}
|
||||
|
||||
inst->group_id = genl_ctrl_resolve_grp(inst->sock, NL_CLASSIFIER_GENL_FAMILY, NL_CLASSIFIER_GENL_GROUP);
|
||||
if (inst->group_id < 0) {
|
||||
printf("Unable to resolve mcast group %s\n", NL_CLASSIFIER_GENL_GROUP);
|
||||
goto init_failed;
|
||||
}
|
||||
|
||||
ret = nl_socket_add_membership(inst->sock, inst->group_id);
|
||||
if (ret < 0) {
|
||||
printf("Unable to add membership\n");
|
||||
goto init_failed;
|
||||
}
|
||||
|
||||
nl_socket_disable_seq_check(inst->sock);
|
||||
nl_socket_modify_cb(inst->sock, NL_CB_VALID, NL_CB_CUSTOM, nl_classifier_msg_recv, NULL);
|
||||
|
||||
printf("nl classifier init successful\n");
|
||||
return 0;
|
||||
|
||||
init_failed:
|
||||
if (inst->sock) {
|
||||
nl_close(inst->sock);
|
||||
nl_socket_free(inst->sock);
|
||||
inst->sock = NULL;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void nl_classifier_exit(struct nl_classifier_instance *inst)
|
||||
{
|
||||
if (inst->sock) {
|
||||
nl_close(inst->sock);
|
||||
nl_socket_free(inst->sock);
|
||||
inst->sock = NULL;
|
||||
}
|
||||
printf("nl classifier exit successful\n");
|
||||
}
|
||||
|
||||
int nl_classifier_parse_arg(int argc, char *argv[], unsigned char *proto, unsigned long *src_saddr,
|
||||
unsigned long *dst_saddr, unsigned short *sport, unsigned short *dport, int *af)
|
||||
{
|
||||
int ret;
|
||||
unsigned short port;
|
||||
|
||||
if (argc < 7) {
|
||||
printf("help: nl_classifier <v4|v6> <udp|tcp> <source ip> <destination ip> <source port> <destination port>\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (0 == strncmp(argv[1], "v4", 2)) {
|
||||
*af = AF_INET;
|
||||
} else if (0 == strncmp(argv[1], "v6", 2)) {
|
||||
*af = AF_INET6;
|
||||
} else {
|
||||
printf("Address family is not supported");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (0 == strncmp(argv[2], "udp", 3)) {
|
||||
*proto = IPPROTO_UDP;
|
||||
} else if (0 == strncmp(argv[2], "tcp", 3)) {
|
||||
*proto = IPPROTO_TCP;
|
||||
} else {
|
||||
printf("Protocol is not supported");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = inet_pton(*af, argv[3], src_saddr);
|
||||
if (ret <= 0) {
|
||||
printf("source ip has wrong format\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = inet_pton(*af, argv[4], dst_saddr);
|
||||
if (ret <= 0) {
|
||||
printf("destination ip has wrong format\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
port = strtol(argv[5], NULL, 0);
|
||||
*sport = htons(port);
|
||||
port = strtol(argv[6], NULL, 0);
|
||||
*dport = htons(port);
|
||||
|
||||
printf("nl classifier parse arguments successful\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
struct nl_classifier_instance *inst = &nl_cls_inst;
|
||||
unsigned char proto;
|
||||
unsigned long src_addr[4];
|
||||
unsigned long dst_addr[4];
|
||||
unsigned short sport;
|
||||
unsigned short dport;
|
||||
int af;
|
||||
int ret;
|
||||
|
||||
ret = nl_classifier_parse_arg(argc, argv, &proto, src_addr, dst_addr, &sport, &dport, &af);
|
||||
if (ret < 0) {
|
||||
printf("Failed to parse arguments\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = nl_classifier_init(inst);
|
||||
if (ret < 0) {
|
||||
printf("Unable to init generic netlink\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
nl_classifier_offload(inst, proto, src_addr, dst_addr, sport, dport, af);
|
||||
|
||||
/* main loop to listen on message */
|
||||
while (!inst->stop) {
|
||||
nl_recvmsgs_default(inst->sock);
|
||||
}
|
||||
|
||||
nl_classifier_exit(inst);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,232 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2013,2016 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 <netlink/genl/genl.h>
|
||||
#include <netlink/genl/ctrl.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <fast-classifier.h>
|
||||
|
||||
static struct nl_sock *sock;
|
||||
static struct nl_sock *sock_event;
|
||||
static int family;
|
||||
static int grp_id;
|
||||
|
||||
static struct nla_policy fast_classifier_genl_policy[FAST_CLASSIFIER_A_MAX + 1] = {
|
||||
[FAST_CLASSIFIER_A_TUPLE] = { .type = NLA_UNSPEC },
|
||||
};
|
||||
|
||||
void dump_fc_tuple(struct fast_classifier_tuple *fc_msg)
|
||||
{
|
||||
char src_str[INET_ADDRSTRLEN];
|
||||
char dst_str[INET_ADDRSTRLEN];
|
||||
|
||||
printf("TUPLE: %d, %s, %s, %d, %d"
|
||||
" SMAC=%02x:%02x:%02x:%02x:%02x:%02x",
|
||||
" DMAC=%02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
fc_msg->proto,
|
||||
inet_ntop(AF_INET,
|
||||
&fc_msg->src_saddr.in.s_addr,
|
||||
src_str,
|
||||
INET_ADDRSTRLEN),
|
||||
inet_ntop(AF_INET,
|
||||
&fc_msg->dst_saddr.in.s_addr,
|
||||
dst_str,
|
||||
INET_ADDRSTRLEN),
|
||||
fc_msg->sport, fc_msg->dport,
|
||||
fc_msg->smac[0], fc_msg->smac[1], fc_msg->smac[2],
|
||||
fc_msg->smac[3], fc_msg->smac[4], fc_msg->smac[5],
|
||||
fc_msg->dmac[0], fc_msg->dmac[1], fc_msg->dmac[2],
|
||||
fc_msg->dmac[3], fc_msg->dmac[4], fc_msg->dmac[5]);
|
||||
}
|
||||
|
||||
static int parse_cb(struct nl_msg *msg, void *arg)
|
||||
{
|
||||
struct nlmsghdr *nlh = nlmsg_hdr(msg);
|
||||
struct genlmsghdr *gnlh = nlmsg_data(nlh);
|
||||
struct nlattr *attrs[FAST_CLASSIFIER_A_MAX];
|
||||
|
||||
genlmsg_parse(nlh, 0, attrs, FAST_CLASSIFIER_A_MAX, fast_classifier_genl_policy);
|
||||
|
||||
switch (gnlh->cmd) {
|
||||
case FAST_CLASSIFIER_C_OFFLOADED:
|
||||
printf("Got a offloaded message\n");
|
||||
dump_fc_tuple(nla_data(attrs[FAST_CLASSIFIER_A_TUPLE]));
|
||||
return NL_OK;
|
||||
case FAST_CLASSIFIER_C_DONE:
|
||||
printf("Got a done message\n");
|
||||
dump_fc_tuple(nla_data(attrs[FAST_CLASSIFIER_A_TUPLE]));
|
||||
return NL_OK;
|
||||
}
|
||||
|
||||
return NL_SKIP;
|
||||
}
|
||||
|
||||
int fast_classifier_init(void)
|
||||
{
|
||||
int err;
|
||||
|
||||
sock = nl_socket_alloc();
|
||||
if (!sock) {
|
||||
printf("Unable to allocation socket.\n");
|
||||
return -1;
|
||||
}
|
||||
genl_connect(sock);
|
||||
|
||||
sock_event = nl_socket_alloc();
|
||||
if (!sock_event) {
|
||||
nl_close(sock);
|
||||
nl_socket_free(sock);
|
||||
printf("Unable to allocation socket.\n");
|
||||
return -1;
|
||||
}
|
||||
genl_connect(sock_event);
|
||||
|
||||
family = genl_ctrl_resolve(sock, FAST_CLASSIFIER_GENL_NAME);
|
||||
if (family < 0) {
|
||||
nl_close(sock_event);
|
||||
nl_close(sock);
|
||||
nl_socket_free(sock);
|
||||
nl_socket_free(sock_event);
|
||||
printf("Unable to resolve family\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
grp_id = genl_ctrl_resolve_grp(sock, FAST_CLASSIFIER_GENL_NAME,
|
||||
FAST_CLASSIFIER_GENL_MCGRP);
|
||||
if (grp_id < 0) {
|
||||
printf("Unable to resolve mcast group\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
err = nl_socket_add_membership(sock_event, grp_id);
|
||||
if (err < 0) {
|
||||
printf("Unable to add membership\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
nl_socket_disable_seq_check(sock_event);
|
||||
nl_socket_modify_cb(sock_event, NL_CB_VALID, NL_CB_CUSTOM, parse_cb, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void fast_classifier_close(void)
|
||||
{
|
||||
nl_close(sock_event);
|
||||
nl_close(sock);
|
||||
nl_socket_free(sock_event);
|
||||
nl_socket_free(sock);
|
||||
}
|
||||
|
||||
void fast_classifier_ipv4_offload(unsigned char proto, unsigned long src_saddr,
|
||||
unsigned long dst_saddr, unsigned short sport,
|
||||
unsigned short dport)
|
||||
{
|
||||
struct nl_msg *msg;
|
||||
int ret;
|
||||
#ifdef DEBUG
|
||||
char src_str[INET_ADDRSTRLEN];
|
||||
char dst_str[INET_ADDRSTRLEN];
|
||||
#endif
|
||||
struct fast_classifier_tuple fc_msg;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("DEBUG: would offload: %d, %s, %s, %d, %d\n", proto,
|
||||
inet_ntop(AF_INET, &src_saddr, src_str, INET_ADDRSTRLEN),
|
||||
inet_ntop(AF_INET, &dst_saddr, dst_str, INET_ADDRSTRLEN),
|
||||
sport, dport);
|
||||
#endif
|
||||
|
||||
fc_msg.proto = proto;
|
||||
fc_msg.src_saddr.in.s_addr = src_saddr;
|
||||
fc_msg.dst_saddr.in.s_addr = dst_saddr;
|
||||
fc_msg.sport = sport;
|
||||
fc_msg.dport = dport;
|
||||
fc_msg.smac[0] = 'a';
|
||||
fc_msg.smac[1] = 'b';
|
||||
fc_msg.smac[2] = 'c';
|
||||
fc_msg.smac[3] = 'd';
|
||||
fc_msg.smac[4] = 'e';
|
||||
fc_msg.smac[5] = 'f';
|
||||
fc_msg.dmac[0] = 'f';
|
||||
fc_msg.dmac[1] = 'e';
|
||||
fc_msg.dmac[2] = 'd';
|
||||
fc_msg.dmac[3] = 'c';
|
||||
fc_msg.dmac[4] = 'b';
|
||||
fc_msg.dmac[5] = 'a';
|
||||
|
||||
if (fast_classifier_init() < 0) {
|
||||
printf("Unable to init generic netlink\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
msg = nlmsg_alloc();
|
||||
if (!msg) {
|
||||
nl_socket_free(sock);
|
||||
printf("Unable to allocate message\n");
|
||||
return;
|
||||
}
|
||||
|
||||
genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, family,
|
||||
FAST_CLASSIFIER_GENL_HDRSIZE, NLM_F_REQUEST,
|
||||
FAST_CLASSIFIER_C_OFFLOAD, FAST_CLASSIFIER_GENL_VERSION);
|
||||
nla_put(msg, 1, sizeof(fc_msg), &fc_msg);
|
||||
|
||||
ret = nl_send_auto_complete(sock, msg);
|
||||
|
||||
nlmsg_free(msg);
|
||||
if (ret < 0) {
|
||||
printf("nlmsg_free failed");
|
||||
nl_close(sock);
|
||||
nl_socket_free(sock);
|
||||
return;
|
||||
}
|
||||
|
||||
ret = nl_wait_for_ack(sock);
|
||||
if (ret < 0) {
|
||||
printf("wait for ack failed");
|
||||
nl_close(sock);
|
||||
nl_socket_free(sock);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void fast_classifier_listen_for_messages(void)
|
||||
{
|
||||
printf("waiting for netlink events\n");
|
||||
|
||||
while (1) {
|
||||
nl_recvmsgs_default(sock_event);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (fast_classifier_init() < 0) {
|
||||
printf("Unable to init generic netlink\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fast_classifier_ipv4_offload('a', 0, 0, 0, 0);
|
||||
|
||||
/* this never returns */
|
||||
fast_classifier_listen_for_messages();
|
||||
|
||||
fast_classifier_close();
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,92 +0,0 @@
|
|||
#
|
||||
# Copyright (c) 2013-2018, 2020 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 $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=shortcut-fe
|
||||
PKG_RELEASE:=8
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define KernelPackage/shortcut-fe
|
||||
SECTION:=kernel
|
||||
CATEGORY:=Kernel modules
|
||||
SUBMENU:=Network Support
|
||||
DEPENDS:=@IPV6 +kmod-nf-conntrack
|
||||
TITLE:=Kernel driver for SFE
|
||||
FILES:= \
|
||||
$(PKG_BUILD_DIR)/shortcut-fe.ko \
|
||||
$(PKG_BUILD_DIR)/shortcut-fe-ipv6.ko
|
||||
KCONFIG:= \
|
||||
CONFIG_NF_CONNTRACK_EVENTS=y \
|
||||
CONFIG_NF_CONNTRACK_TIMEOUT=y \
|
||||
CONFIG_SHORTCUT_FE=y \
|
||||
CONFIG_XFRM=y
|
||||
PROVIDES:=$(PKG_NAME)
|
||||
AUTOLOAD:=$(call AutoLoad,09,shortcut-fe shortcut-fe-ipv6)
|
||||
endef
|
||||
|
||||
define KernelPackage/shortcut-fe/Description
|
||||
Shortcut is an in-Linux-kernel IP packet forwarding engine.
|
||||
endef
|
||||
|
||||
define KernelPackage/shortcut-fe/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) ./files/usr/bin/sfe_dump $(1)/usr/bin
|
||||
endef
|
||||
|
||||
HAVE_ECM:=$(CONFIG_PACKAGE_kmod-qca-nss-ecm-premium)$(CONFIG_PACKAGE_kmod-qca-nss-ecm-noload)$(CONFIG_PACKAGE_kmod-qca-nss-ecm-premium-noload)$(CONFIG_PACKAGE_kmod-qca-nss-ecm-standard)
|
||||
|
||||
define KernelPackage/shortcut-fe-cm
|
||||
SECTION:=kernel
|
||||
CATEGORY:=Kernel modules
|
||||
SUBMENU:=Network Support
|
||||
DEPENDS:=+kmod-ipt-conntrack +kmod-shortcut-fe
|
||||
TITLE:=Kernel driver for SFE
|
||||
FILES:=$(PKG_BUILD_DIR)/shortcut-fe-cm.ko
|
||||
KCONFIG:= \
|
||||
CONFIG_NF_CONNTRACK_CHAIN_EVENTS=y \
|
||||
CONFIG_NF_CONNTRACK_EVENTS=y \
|
||||
CONFIG_XFRM=y
|
||||
CONFLICTS:=kmod-shortcut-fe-drv
|
||||
endef
|
||||
|
||||
define KernelPackage/shortcut-fe-cm/Description
|
||||
Simple connection manager for the Shortcut forwarding engine.
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
$(MAKE) $(PKG_JOBS) -C "$(LINUX_DIR)" \
|
||||
$(KERNEL_MAKE_FLAGS) \
|
||||
$(PKG_MAKE_FLAGS) \
|
||||
M="$(PKG_BUILD_DIR)" \
|
||||
EXTRA_CFLAGS+="-DSFE_SUPPORT_IPV6" SFE_SUPPORT_IPV6=y \
|
||||
$(if $(HAVE_ECM),EXTRA_CFLAGS+="-DCONFIG_SFE_ECM" CONFIG_SFE_ECM=y,) \
|
||||
modules
|
||||
endef
|
||||
|
||||
ifneq ($(CONFIG_PACKAGE_kmod-shortcut-fe)$(CONFIG_PACKAGE_kmod-shortcut-fe-cm),)
|
||||
define Build/InstallDev
|
||||
$(INSTALL_DIR) $(1)/usr/include
|
||||
$(INSTALL_DIR) $(1)/usr/include/shortcut-fe
|
||||
$(CP) -rf $(PKG_BUILD_DIR)/sfe.h $(1)/usr/include/shortcut-fe
|
||||
$(CP) -rf $(PKG_BUILD_DIR)/sfe.h $(1)/usr/include
|
||||
$(CP) -rf $(PKG_BUILD_DIR)/sfe_cm.h $(1)/usr/include
|
||||
$(CP) -rf $(PKG_BUILD_DIR)/sfe_backport.h $(1)/usr/include
|
||||
endef
|
||||
endif
|
||||
|
||||
$(eval $(call KernelPackage,shortcut-fe))
|
||||
$(eval $(call KernelPackage,shortcut-fe-cm))
|
|
@ -1,51 +0,0 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
#
|
||||
# Copyright (c) 2014-2015 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.
|
||||
#
|
||||
|
||||
#SFE connection manager has a lower priority, it should be started after other connection manager
|
||||
#to detect the existence of connection manager with higher priority
|
||||
START=70
|
||||
|
||||
have_cm() {
|
||||
[ -d "/sys/kernel/debug/ecm" ] && echo 1 && return
|
||||
|
||||
echo 0
|
||||
}
|
||||
|
||||
#load shortcut-fe and connection manager
|
||||
load_sfe() {
|
||||
local kernel_version=$(uname -r)
|
||||
|
||||
[ -d "/sys/module/shortcut_fe" ] || insmod /lib/modules/$kernel_version/shortcut-fe.ko
|
||||
[ -d "/sys/module/shortcut_fe_ipv6" ] || insmod /lib/modules/$kernel_version/shortcut-fe-ipv6.ko
|
||||
|
||||
[ -e "/lib/modules/$kernel_version/shortcut-fe-cm.ko" ] && {
|
||||
[ -d /sys/module/shortcut_fe_cm ] || insmod /lib/modules/$kernel_version/shortcut-fe-cm.ko
|
||||
}
|
||||
[ -e "/lib/modules/$kernel_version/fast-classifier.ko" ] && {
|
||||
[ -d /sys/module/fast_classifier ] || insmod /lib/modules/$kernel_version/fast-classifier.ko
|
||||
}
|
||||
}
|
||||
|
||||
start() {
|
||||
[ "$(have_cm)" = "0" ] && load_sfe
|
||||
}
|
||||
|
||||
stop() {
|
||||
[ -d "/sys/module/shortcut_fe_cm" ] && rmmod shortcut_fe_cm
|
||||
[ -d "/sys/module/shortcut_fe_ipv6" ] && rmmod shortcut_fe_ipv6
|
||||
[ -d "/sys/module/shortcut_fe" ] && rmmod shortcut_fe
|
||||
[ -d "/sys/module/shortcut_fe_drv" ] && rmmod shortcut_fe_drv
|
||||
[ -d "/sys/module/fast_classifier" ] && rmmod fast_classifier
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) 2015 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.
|
||||
#
|
||||
|
||||
#@sfe_dump
|
||||
#@example : sfe_dump (ipv4|ipv6)
|
||||
sfe_dump(){
|
||||
[ -e "/dev/sfe_ipv4" ] || {
|
||||
dev_num=$(cat /sys/sfe_ipv4/debug_dev)
|
||||
mknod /dev/sfe_ipv4 c $dev_num 0
|
||||
}
|
||||
[ -e "/dev/sfe_ipv6" ] || {
|
||||
dev_num=$(cat /sys/sfe_ipv6/debug_dev)
|
||||
mknod /dev/sfe_ipv6 c $dev_num 0
|
||||
}
|
||||
cat /dev/sfe_$1
|
||||
}
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
sfe_dump ipv4
|
||||
sfe_dump ipv6
|
||||
else
|
||||
sfe_dump $1
|
||||
fi
|
|
@ -1,14 +0,0 @@
|
|||
#
|
||||
# Shortcut forwarding engine
|
||||
#
|
||||
|
||||
config SHORTCUT_FE
|
||||
tristate "Shortcut Forwarding Engine"
|
||||
depends on NF_CONNTRACK
|
||||
---help---
|
||||
Shortcut is a fast in-kernel packet forwarding engine.
|
||||
|
||||
To compile this code as a module, choose M here: the module will be
|
||||
called shortcut-fe.
|
||||
|
||||
If unsure, say N.
|
|
@ -1,24 +0,0 @@
|
|||
#
|
||||
# Makefile for Shortcut FE.
|
||||
#
|
||||
|
||||
obj-m += shortcut-fe.o
|
||||
|
||||
ifdef SFE_SUPPORT_IPV6
|
||||
obj-m += shortcut-fe-ipv6.o
|
||||
endif
|
||||
|
||||
obj-m += shortcut-fe-cm.o
|
||||
|
||||
shortcut-fe-objs := \
|
||||
sfe_ipv4.o
|
||||
|
||||
ifdef SFE_SUPPORT_IPV6
|
||||
shortcut-fe-ipv6-objs := \
|
||||
sfe_ipv6.o
|
||||
endif
|
||||
|
||||
shortcut-fe-cm-objs := \
|
||||
sfe_cm.o
|
||||
|
||||
ccflags-y += -Werror -Wall
|
|
@ -1,114 +0,0 @@
|
|||
/*
|
||||
* sfe.h
|
||||
* Shortcut forwarding engine.
|
||||
*
|
||||
* Copyright (c) 2013-2017 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.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* The following are debug macros used throughout the SFE.
|
||||
*
|
||||
* The DEBUG_LEVEL enables the followings based on its value,
|
||||
* when dynamic debug option is disabled.
|
||||
*
|
||||
* 0 = OFF
|
||||
* 1 = ASSERTS / ERRORS
|
||||
* 2 = 1 + WARN
|
||||
* 3 = 2 + INFO
|
||||
* 4 = 3 + TRACE
|
||||
*/
|
||||
#define DEBUG_LEVEL 2
|
||||
|
||||
#if (DEBUG_LEVEL < 1)
|
||||
#define DEBUG_ASSERT(s, ...)
|
||||
#define DEBUG_ERROR(s, ...)
|
||||
#else
|
||||
#define DEBUG_ASSERT(c, s, ...) if (!(c)) { pr_emerg("ASSERT: %s:%d:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__); BUG(); }
|
||||
#define DEBUG_ERROR(s, ...) pr_err("%s:%d:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_DYNAMIC_DEBUG)
|
||||
/*
|
||||
* Compile messages for dynamic enable/disable
|
||||
*/
|
||||
#define DEBUG_WARN(s, ...) pr_debug("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__)
|
||||
#define DEBUG_INFO(s, ...) pr_debug("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__)
|
||||
#define DEBUG_TRACE(s, ...) pr_debug("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__)
|
||||
#else
|
||||
|
||||
/*
|
||||
* Statically compile messages at different levels
|
||||
*/
|
||||
#if (DEBUG_LEVEL < 2)
|
||||
#define DEBUG_WARN(s, ...)
|
||||
#else
|
||||
#define DEBUG_WARN(s, ...) pr_warn("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#if (DEBUG_LEVEL < 3)
|
||||
#define DEBUG_INFO(s, ...)
|
||||
#else
|
||||
#define DEBUG_INFO(s, ...) pr_notice("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#if (DEBUG_LEVEL < 4)
|
||||
#define DEBUG_TRACE(s, ...)
|
||||
#else
|
||||
#define DEBUG_TRACE(s, ...) pr_info("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NF_FLOW_COOKIE
|
||||
typedef int (*flow_cookie_set_func_t)(u32 protocol, __be32 src_ip, __be16 src_port,
|
||||
__be32 dst_ip, __be16 dst_port, u16 flow_cookie);
|
||||
/*
|
||||
* sfe_register_flow_cookie_cb
|
||||
* register a function in SFE to let SFE use this function to configure flow cookie for a flow
|
||||
*
|
||||
* Hardware driver which support flow cookie should register a callback function in SFE. Then SFE
|
||||
* can use this function to configure flow cookie for a flow.
|
||||
* return: 0, success; !=0, fail
|
||||
*/
|
||||
int sfe_register_flow_cookie_cb(flow_cookie_set_func_t cb);
|
||||
|
||||
/*
|
||||
* sfe_unregister_flow_cookie_cb
|
||||
* unregister function which is used to configure flow cookie for a flow
|
||||
*
|
||||
* return: 0, success; !=0, fail
|
||||
*/
|
||||
int sfe_unregister_flow_cookie_cb(flow_cookie_set_func_t cb);
|
||||
|
||||
typedef int (*sfe_ipv6_flow_cookie_set_func_t)(u32 protocol, __be32 src_ip[4], __be16 src_port,
|
||||
__be32 dst_ip[4], __be16 dst_port, u16 flow_cookie);
|
||||
|
||||
/*
|
||||
* sfe_ipv6_register_flow_cookie_cb
|
||||
* register a function in SFE to let SFE use this function to configure flow cookie for a flow
|
||||
*
|
||||
* Hardware driver which support flow cookie should register a callback function in SFE. Then SFE
|
||||
* can use this function to configure flow cookie for a flow.
|
||||
* return: 0, success; !=0, fail
|
||||
*/
|
||||
int sfe_ipv6_register_flow_cookie_cb(sfe_ipv6_flow_cookie_set_func_t cb);
|
||||
|
||||
/*
|
||||
* sfe_ipv6_unregister_flow_cookie_cb
|
||||
* unregister function which is used to configure flow cookie for a flow
|
||||
*
|
||||
* return: 0, success; !=0, fail
|
||||
*/
|
||||
int sfe_ipv6_unregister_flow_cookie_cb(sfe_ipv6_flow_cookie_set_func_t cb);
|
||||
|
||||
#endif /*CONFIG_NF_FLOW_COOKIE*/
|
|
@ -1,195 +0,0 @@
|
|||
/*
|
||||
* sfe_backport.h
|
||||
* Shortcut forwarding engine compatible header file.
|
||||
*
|
||||
* Copyright (c) 2014-2016 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 <linux/version.h>
|
||||
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4, 0))
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0))
|
||||
#include <net/netfilter/nf_conntrack_timeout.h>
|
||||
#else
|
||||
enum udp_conntrack {
|
||||
UDP_CT_UNREPLIED,
|
||||
UDP_CT_REPLIED,
|
||||
UDP_CT_MAX
|
||||
};
|
||||
|
||||
static inline unsigned int *
|
||||
nf_ct_timeout_lookup(struct net *net, struct nf_conn *ct,
|
||||
struct nf_conntrack_l4proto *l4proto)
|
||||
{
|
||||
#ifdef CONFIG_NF_CONNTRACK_TIMEOUT
|
||||
struct nf_conn_timeout *timeout_ext;
|
||||
unsigned int *timeouts;
|
||||
|
||||
timeout_ext = nf_ct_timeout_find(ct);
|
||||
if (timeout_ext)
|
||||
timeouts = NF_CT_TIMEOUT_EXT_DATA(timeout_ext);
|
||||
else
|
||||
timeouts = l4proto->get_timeouts(net);
|
||||
|
||||
return timeouts;
|
||||
#else
|
||||
return l4proto->get_timeouts(net);
|
||||
#endif /*CONFIG_NF_CONNTRACK_TIMEOUT*/
|
||||
}
|
||||
#endif /*KERNEL_VERSION(3, 7, 0)*/
|
||||
#endif /*KERNEL_VERSION(3, 4, 0)*/
|
||||
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0))
|
||||
#define sfe_define_post_routing_hook(FN_NAME, HOOKNUM, OPS, SKB, UNUSED, OUT, OKFN) \
|
||||
static unsigned int FN_NAME(void *priv, \
|
||||
struct sk_buff *SKB, \
|
||||
const struct nf_hook_state *state)
|
||||
#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0))
|
||||
#define sfe_define_post_routing_hook(FN_NAME, HOOKNUM, OPS, SKB, UNUSED, OUT, OKFN) \
|
||||
static unsigned int FN_NAME(const struct nf_hook_ops *OPS, \
|
||||
struct sk_buff *SKB, \
|
||||
const struct net_device *UNUSED, \
|
||||
const struct net_device *OUT, \
|
||||
int (*OKFN)(struct sk_buff *))
|
||||
#else
|
||||
#define sfe_define_post_routing_hook(FN_NAME, HOOKNUM, OPS, SKB, UNUSED, OUT, OKFN) \
|
||||
static unsigned int FN_NAME(unsigned int HOOKNUM, \
|
||||
struct sk_buff *SKB, \
|
||||
const struct net_device *UNUSED, \
|
||||
const struct net_device *OUT, \
|
||||
int (*OKFN)(struct sk_buff *))
|
||||
#endif
|
||||
|
||||
#define sfe_cm_ipv4_post_routing_hook(HOOKNUM, OPS, SKB, UNUSED, OUT, OKFN) \
|
||||
sfe_define_post_routing_hook(__sfe_cm_ipv4_post_routing_hook, HOOKNUM, OPS, SKB, UNUSED, OUT, OKFN)
|
||||
#define sfe_cm_ipv6_post_routing_hook(HOOKNUM, OPS, SKB, UNUSED, OUT, OKFN) \
|
||||
sfe_define_post_routing_hook(__sfe_cm_ipv6_post_routing_hook, HOOKNUM, OPS, SKB, UNUSED, OUT, OKFN)
|
||||
#define fast_classifier_ipv4_post_routing_hook(HOOKNUM, OPS, SKB, UNUSED, OUT, OKFN) \
|
||||
sfe_define_post_routing_hook(__fast_classifier_ipv4_post_routing_hook, HOOKNUM, OPS, SKB, UNUSED, OUT, OKFN)
|
||||
#define fast_classifier_ipv6_post_routing_hook(HOOKNUM, OPS, SKB, UNUSED, OUT, OKFN) \
|
||||
sfe_define_post_routing_hook(__fast_classifier_ipv6_post_routing_hook, HOOKNUM, OPS, SKB, UNUSED, OUT, OKFN)
|
||||
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0))
|
||||
#define SFE_IPV4_NF_POST_ROUTING_HOOK(fn) \
|
||||
{ \
|
||||
.hook = fn, \
|
||||
.pf = NFPROTO_IPV4, \
|
||||
.hooknum = NF_INET_POST_ROUTING, \
|
||||
.priority = NF_IP_PRI_NAT_SRC + 1, \
|
||||
}
|
||||
#else
|
||||
#define SFE_IPV4_NF_POST_ROUTING_HOOK(fn) \
|
||||
{ \
|
||||
.hook = fn, \
|
||||
.owner = THIS_MODULE, \
|
||||
.pf = NFPROTO_IPV4, \
|
||||
.hooknum = NF_INET_POST_ROUTING, \
|
||||
.priority = NF_IP_PRI_NAT_SRC + 1, \
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0))
|
||||
#define SFE_IPV6_NF_POST_ROUTING_HOOK(fn) \
|
||||
{ \
|
||||
.hook = fn, \
|
||||
.pf = NFPROTO_IPV6, \
|
||||
.hooknum = NF_INET_POST_ROUTING, \
|
||||
.priority = NF_IP_PRI_NAT_SRC + 1, \
|
||||
}
|
||||
#else
|
||||
#define SFE_IPV6_NF_POST_ROUTING_HOOK(fn) \
|
||||
{ \
|
||||
.hook = fn, \
|
||||
.owner = THIS_MODULE, \
|
||||
.pf = NFPROTO_IPV6, \
|
||||
.hooknum = NF_INET_POST_ROUTING, \
|
||||
.priority = NF_IP6_PRI_NAT_SRC + 1, \
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0))
|
||||
#define SFE_NF_CT_DEFAULT_ZONE (&nf_ct_zone_dflt)
|
||||
#else
|
||||
#define SFE_NF_CT_DEFAULT_ZONE NF_CT_DEFAULT_ZONE
|
||||
#endif
|
||||
|
||||
/*
|
||||
* sfe_dev_get_master
|
||||
* get master of bridge port, and hold it
|
||||
*/
|
||||
static inline struct net_device *sfe_dev_get_master(struct net_device *dev)
|
||||
{
|
||||
struct net_device *master;
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0))
|
||||
rcu_read_lock();
|
||||
master = netdev_master_upper_dev_get_rcu(dev);
|
||||
if (master)
|
||||
dev_hold(master);
|
||||
|
||||
rcu_read_unlock();
|
||||
#else
|
||||
master = dev->master;
|
||||
if (master)
|
||||
dev_hold(master);
|
||||
#endif
|
||||
return master;
|
||||
}
|
||||
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
|
||||
#define SFE_DEV_EVENT_PTR(PTR) netdev_notifier_info_to_dev(PTR)
|
||||
#else
|
||||
#define SFE_DEV_EVENT_PTR(PTR) (struct net_device *)(PTR)
|
||||
#endif
|
||||
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0))
|
||||
#define SFE_NF_CONN_ACCT(NM) struct nf_conn_acct *NM
|
||||
#else
|
||||
#define SFE_NF_CONN_ACCT(NM) struct nf_conn_counter *NM
|
||||
#endif
|
||||
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0))
|
||||
#define SFE_ACCT_COUNTER(NM) ((NM)->counter)
|
||||
#else
|
||||
#define SFE_ACCT_COUNTER(NM) (NM)
|
||||
#endif
|
||||
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0))
|
||||
#define sfe_hash_for_each_possible(name, obj, node, member, key) \
|
||||
hash_for_each_possible(name, obj, member, key)
|
||||
#else
|
||||
#define sfe_hash_for_each_possible(name, obj, node, member, key) \
|
||||
hash_for_each_possible(name, obj, node, member, key)
|
||||
#endif
|
||||
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0))
|
||||
#define sfe_hash_for_each(name, bkt, node, obj, member) \
|
||||
hash_for_each(name, bkt, obj, member)
|
||||
#else
|
||||
#define sfe_hash_for_each(name, bkt, node, obj, member) \
|
||||
hash_for_each(name, bkt, node, obj, member)
|
||||
#endif
|
||||
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4, 0))
|
||||
#define sfe_dst_get_neighbour(dst, daddr) dst_neigh_lookup(dst, addr)
|
||||
#else
|
||||
static inline struct neighbour *
|
||||
sfe_dst_get_neighbour(struct dst_entry *dst, void *daddr)
|
||||
{
|
||||
struct neighbour *neigh = dst_get_neighbour_noref(dst);
|
||||
|
||||
if (neigh)
|
||||
neigh_hold(neigh);
|
||||
|
||||
return neigh;
|
||||
}
|
||||
#endif
|
File diff suppressed because it is too large
Load diff
|
@ -1,260 +0,0 @@
|
|||
/*
|
||||
* sfe_cm.h
|
||||
* Shortcut forwarding engine.
|
||||
*
|
||||
* Copyright (c) 2013-2016 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* connection flags.
|
||||
*/
|
||||
#define SFE_CREATE_FLAG_NO_SEQ_CHECK BIT(0)
|
||||
/* Indicates that we should not check sequence numbers */
|
||||
#define SFE_CREATE_FLAG_REMARK_PRIORITY BIT(1)
|
||||
/* Indicates that we should remark priority of skb */
|
||||
#define SFE_CREATE_FLAG_REMARK_DSCP BIT(2)
|
||||
/* Indicates that we should remark DSCP of packet */
|
||||
|
||||
/*
|
||||
* IPv6 address structure
|
||||
*/
|
||||
struct sfe_ipv6_addr {
|
||||
__be32 addr[4];
|
||||
};
|
||||
|
||||
typedef union {
|
||||
__be32 ip;
|
||||
struct sfe_ipv6_addr ip6[1];
|
||||
} sfe_ip_addr_t;
|
||||
|
||||
/*
|
||||
* connection creation structure.
|
||||
*/
|
||||
struct sfe_connection_create {
|
||||
int protocol;
|
||||
struct net_device *src_dev;
|
||||
struct net_device *dest_dev;
|
||||
u32 flags;
|
||||
u32 src_mtu;
|
||||
u32 dest_mtu;
|
||||
sfe_ip_addr_t src_ip;
|
||||
sfe_ip_addr_t src_ip_xlate;
|
||||
sfe_ip_addr_t dest_ip;
|
||||
sfe_ip_addr_t dest_ip_xlate;
|
||||
__be16 src_port;
|
||||
__be16 src_port_xlate;
|
||||
__be16 dest_port;
|
||||
__be16 dest_port_xlate;
|
||||
u8 src_mac[ETH_ALEN];
|
||||
u8 src_mac_xlate[ETH_ALEN];
|
||||
u8 dest_mac[ETH_ALEN];
|
||||
u8 dest_mac_xlate[ETH_ALEN];
|
||||
u8 src_td_window_scale;
|
||||
u32 src_td_max_window;
|
||||
u32 src_td_end;
|
||||
u32 src_td_max_end;
|
||||
u8 dest_td_window_scale;
|
||||
u32 dest_td_max_window;
|
||||
u32 dest_td_end;
|
||||
u32 dest_td_max_end;
|
||||
u32 mark;
|
||||
#ifdef CONFIG_XFRM
|
||||
u32 original_accel;
|
||||
u32 reply_accel;
|
||||
#endif
|
||||
u32 src_priority;
|
||||
u32 dest_priority;
|
||||
u32 src_dscp;
|
||||
u32 dest_dscp;
|
||||
};
|
||||
|
||||
/*
|
||||
* connection destruction structure.
|
||||
*/
|
||||
struct sfe_connection_destroy {
|
||||
int protocol;
|
||||
sfe_ip_addr_t src_ip;
|
||||
sfe_ip_addr_t dest_ip;
|
||||
__be16 src_port;
|
||||
__be16 dest_port;
|
||||
};
|
||||
|
||||
typedef enum sfe_sync_reason {
|
||||
SFE_SYNC_REASON_STATS, /* Sync is to synchronize stats */
|
||||
SFE_SYNC_REASON_FLUSH, /* Sync is to flush a entry */
|
||||
SFE_SYNC_REASON_DESTROY /* Sync is to destroy a entry(requested by connection manager) */
|
||||
} sfe_sync_reason_t;
|
||||
|
||||
/*
|
||||
* Structure used to sync connection stats/state back within the system.
|
||||
*
|
||||
* NOTE: The addresses here are NON-NAT addresses, i.e. the true endpoint addressing.
|
||||
* 'src' is the creator of the connection.
|
||||
*/
|
||||
struct sfe_connection_sync {
|
||||
struct net_device *src_dev;
|
||||
struct net_device *dest_dev;
|
||||
int is_v6; /* Is it for ipv6? */
|
||||
int protocol; /* IP protocol number (IPPROTO_...) */
|
||||
sfe_ip_addr_t src_ip; /* Non-NAT source address, i.e. the creator of the connection */
|
||||
sfe_ip_addr_t src_ip_xlate; /* NATed source address */
|
||||
__be16 src_port; /* Non-NAT source port */
|
||||
__be16 src_port_xlate; /* NATed source port */
|
||||
sfe_ip_addr_t dest_ip; /* Non-NAT destination address, i.e. to whom the connection was created */
|
||||
sfe_ip_addr_t dest_ip_xlate; /* NATed destination address */
|
||||
__be16 dest_port; /* Non-NAT destination port */
|
||||
__be16 dest_port_xlate; /* NATed destination port */
|
||||
u32 src_td_max_window;
|
||||
u32 src_td_end;
|
||||
u32 src_td_max_end;
|
||||
u64 src_packet_count;
|
||||
u64 src_byte_count;
|
||||
u32 src_new_packet_count;
|
||||
u32 src_new_byte_count;
|
||||
u32 dest_td_max_window;
|
||||
u32 dest_td_end;
|
||||
u32 dest_td_max_end;
|
||||
u64 dest_packet_count;
|
||||
u64 dest_byte_count;
|
||||
u32 dest_new_packet_count;
|
||||
u32 dest_new_byte_count;
|
||||
u32 reason; /* reason for stats sync message, i.e. destroy, flush, period sync */
|
||||
u64 delta_jiffies; /* Time to be added to the current timeout to keep the connection alive */
|
||||
};
|
||||
|
||||
/*
|
||||
* connection mark structure
|
||||
*/
|
||||
struct sfe_connection_mark {
|
||||
int protocol;
|
||||
sfe_ip_addr_t src_ip;
|
||||
sfe_ip_addr_t dest_ip;
|
||||
__be16 src_port;
|
||||
__be16 dest_port;
|
||||
u32 mark;
|
||||
};
|
||||
|
||||
/*
|
||||
* Expose the hook for the receive processing.
|
||||
*/
|
||||
extern int (*athrs_fast_nat_recv)(struct sk_buff *skb);
|
||||
|
||||
/*
|
||||
* Expose what should be a static flag in the TCP connection tracker.
|
||||
*/
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0)
|
||||
extern int nf_ct_tcp_no_window_check;
|
||||
#endif
|
||||
/*
|
||||
* This callback will be called in a timer
|
||||
* at 100 times per second to sync stats back to
|
||||
* Linux connection track.
|
||||
*
|
||||
* A RCU lock is taken to prevent this callback
|
||||
* from unregistering.
|
||||
*/
|
||||
typedef void (*sfe_sync_rule_callback_t)(struct sfe_connection_sync *);
|
||||
|
||||
/*
|
||||
* IPv4 APIs used by connection manager
|
||||
*/
|
||||
int sfe_ipv4_recv(struct net_device *dev, struct sk_buff *skb);
|
||||
int sfe_ipv4_create_rule(struct sfe_connection_create *sic);
|
||||
void sfe_ipv4_destroy_rule(struct sfe_connection_destroy *sid);
|
||||
void sfe_ipv4_destroy_all_rules_for_dev(struct net_device *dev);
|
||||
void sfe_ipv4_register_sync_rule_callback(sfe_sync_rule_callback_t callback);
|
||||
void sfe_ipv4_update_rule(struct sfe_connection_create *sic);
|
||||
void sfe_ipv4_mark_rule(struct sfe_connection_mark *mark);
|
||||
|
||||
#ifdef SFE_SUPPORT_IPV6
|
||||
/*
|
||||
* IPv6 APIs used by connection manager
|
||||
*/
|
||||
int sfe_ipv6_recv(struct net_device *dev, struct sk_buff *skb);
|
||||
int sfe_ipv6_create_rule(struct sfe_connection_create *sic);
|
||||
void sfe_ipv6_destroy_rule(struct sfe_connection_destroy *sid);
|
||||
void sfe_ipv6_destroy_all_rules_for_dev(struct net_device *dev);
|
||||
void sfe_ipv6_register_sync_rule_callback(sfe_sync_rule_callback_t callback);
|
||||
void sfe_ipv6_update_rule(struct sfe_connection_create *sic);
|
||||
void sfe_ipv6_mark_rule(struct sfe_connection_mark *mark);
|
||||
#else
|
||||
static inline int sfe_ipv6_recv(struct net_device *dev, struct sk_buff *skb)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int sfe_ipv6_create_rule(struct sfe_connection_create *sic)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void sfe_ipv6_destroy_rule(struct sfe_connection_destroy *sid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static inline void sfe_ipv6_destroy_all_rules_for_dev(struct net_device *dev)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static inline void sfe_ipv6_register_sync_rule_callback(sfe_sync_rule_callback_t callback)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static inline void sfe_ipv6_update_rule(struct sfe_connection_create *sic)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static inline void sfe_ipv6_mark_rule(struct sfe_connection_mark *mark)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* sfe_ipv6_addr_equal()
|
||||
* compare ipv6 address
|
||||
*
|
||||
* return: 1, equal; 0, no equal
|
||||
*/
|
||||
static inline int sfe_ipv6_addr_equal(struct sfe_ipv6_addr *a,
|
||||
struct sfe_ipv6_addr *b)
|
||||
{
|
||||
return a->addr[0] == b->addr[0] &&
|
||||
a->addr[1] == b->addr[1] &&
|
||||
a->addr[2] == b->addr[2] &&
|
||||
a->addr[3] == b->addr[3];
|
||||
}
|
||||
|
||||
/*
|
||||
* sfe_ipv4_addr_equal()
|
||||
* compare ipv4 address
|
||||
*
|
||||
* return: 1, equal; 0, no equal
|
||||
*/
|
||||
#define sfe_ipv4_addr_equal(a, b) ((u32)(a) == (u32)(b))
|
||||
|
||||
/*
|
||||
* sfe_addr_equal()
|
||||
* compare ipv4 or ipv6 address
|
||||
*
|
||||
* return: 1, equal; 0, no equal
|
||||
*/
|
||||
static inline int sfe_addr_equal(sfe_ip_addr_t *a,
|
||||
sfe_ip_addr_t *b, int is_v4)
|
||||
{
|
||||
return is_v4 ? sfe_ipv4_addr_equal(a->ip, b->ip) : sfe_ipv6_addr_equal(a->ip6, b->ip6);
|
||||
}
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,60 +0,0 @@
|
|||
#
|
||||
# Copyright (c) 2015,2016 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 $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=shortcut-fe-simulated-driver
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE_URL:=https://git.codelinaro.org/clo/qsdk/oss/lklm/shortcut-fe.git
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_DATE:=2021-03-17
|
||||
PKG_SOURCE_VERSION:=697977d8d0ccf0ab596e5692d08608a75dd7f33d
|
||||
PKG_MIRROR_HASH:=659fa82a431e15af797a6c7069faeee02810453ad8b576c51c29f95a1761a045
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define KernelPackage/shortcut-fe-drv
|
||||
SECTION:=kernel
|
||||
CATEGORY:=Kernel modules
|
||||
SUBMENU:=Network Support
|
||||
DEPENDS:=@TARGET_ipq806x||TARGET_ipq807x +kmod-shortcut-fe
|
||||
KCONFIG:= \
|
||||
CONFIG_NET_CLS_ACT=y \
|
||||
CONFIG_XFRM=y
|
||||
TITLE:=Simulated sfe driver for ECM
|
||||
FILES:=$(PKG_BUILD_DIR)/simulated-driver/shortcut-fe-drv.ko
|
||||
endef
|
||||
|
||||
define KernelPackage/shortcut-fe-drv/Description
|
||||
Simulated sfe driver which act as an adapter to convert message
|
||||
between a connection manager and the SFE core engine.
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
$(MAKE) $(PKG_JOBS) -C "$(LINUX_DIR)" \
|
||||
$(KERNEL_MAKE_FLAGS) \
|
||||
$(PKG_MAKE_FLAGS) \
|
||||
M="$(PKG_BUILD_DIR)/simulated-driver" \
|
||||
EXTRA_CFLAGS="-DSFE_SUPPORT_IPV6" \
|
||||
modules
|
||||
endef
|
||||
|
||||
define Build/InstallDev
|
||||
$(INSTALL_DIR) $(1)/usr/include/shortcut-fe
|
||||
$(CP) -rf $(PKG_BUILD_DIR)/simulated-driver/sfe_drv.h $(1)/usr/include/shortcut-fe
|
||||
endef
|
||||
|
||||
$(eval $(call KernelPackage,shortcut-fe-drv))
|
|
@ -1,11 +0,0 @@
|
|||
--- ./simulated-driver/sfe_drv.c.orig 2020-06-16 12:49:47.680153371 +0800
|
||||
+++ ./simulated-driver/sfe_drv.c 2020-06-16 12:50:18.540153371 +0800
|
||||
@@ -1167,7 +1167,7 @@ int sfe_drv_recv(struct sk_buff *skb)
|
||||
* If ingress Qdisc configured, and packet not processed by ingress Qdisc yet
|
||||
* We can not accelerate this packet.
|
||||
*/
|
||||
- if (dev->ingress_queue && !(skb->tc_verd & TC_NCLS)) {
|
||||
+ if (dev->ingress_queue && !(skb->tc_verd_qca_nss & TC_NCLS)) {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue