mirror of
https://github.com/coolsnowwolf/lede.git
synced 2025-04-16 04:13:31 +00:00
362 lines
13 KiB
Diff
362 lines
13 KiB
Diff
From 09980e54011e2d95a9db2d6134f635bc90e5a7f2 Mon Sep 17 00:00:00 2001
|
|
From: Ansuel Smith <ansuelsmth@gmail.com>
|
|
Date: Wed, 19 May 2021 02:38:53 +0200
|
|
Subject: [PATCH 01/12] treewide: componentize the module even more
|
|
|
|
Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
|
|
---
|
|
Makefile | 57 +++++++++++++++++++++++++-------
|
|
Makefile_61.mk | 1 -
|
|
ecm_db/ecm_db_connection.c | 8 +++++
|
|
ecm_db/ecm_db_node.c | 4 +++
|
|
ecm_interface.c | 8 +++++
|
|
frontends/ecm_front_end_common.c | 7 ++++
|
|
6 files changed, 72 insertions(+), 13 deletions(-)
|
|
|
|
--- a/Makefile
|
|
+++ b/Makefile
|
|
@@ -17,7 +17,7 @@
|
|
# ###################################################
|
|
# Makefile for the QCA NSS ECM
|
|
# ###################################################
|
|
-ifneq ($(findstring 6.1., $(KERNELVERSION)),)
|
|
+ifneq ($(findstring 6.2., $(KERNELVERSION)),)
|
|
include $(obj)/Makefile_61.mk
|
|
else
|
|
ifeq ($(ECM_FRONT_END_SFE_ENABLE), y)
|
|
@@ -134,9 +134,17 @@ ccflags-$(ECM_INTERFACE_BOND_ENABLE) += -DECM_INTERFACE_BOND_ENABLE
|
|
# Define ECM_INTERFACE_PPPOE_ENABLE=y in order
|
|
# to enable support for PPPoE acceleration.
|
|
# #############################################################################
|
|
-ECM_INTERFACE_PPPOE_ENABLE=y
|
|
+ifndef $(ECM_INTERFACE_PPPOE_ENABLE)
|
|
+ ECM_INTERFACE_PPPOE_ENABLE=y
|
|
+endif
|
|
ccflags-$(ECM_INTERFACE_PPPOE_ENABLE) += -DECM_INTERFACE_PPPOE_ENABLE
|
|
|
|
+# #############################################################################
|
|
+# Define ECM_INTERFACE_L2TPV2_PPTP_ENABLE=y in order
|
|
+# to enable support for l2tpv2 or PPTP detection.
|
|
+# #############################################################################
|
|
+ccflags-$(ECM_INTERFACE_L2TPV2_PPTP_ENABLE) += -DECM_INTERFACE_L2TPV2_PPTP_ENABLE
|
|
+
|
|
# #############################################################################
|
|
# Define ECM_INTERFACE_L2TPV2_ENABLE=y in order
|
|
# to enable support for l2tpv2 acceleration.
|
|
@@ -163,6 +171,12 @@ endif
|
|
endif
|
|
ccflags-$(ECM_INTERFACE_PPP_ENABLE) += -DECM_INTERFACE_PPP_ENABLE
|
|
|
|
+# #############################################################################
|
|
+# Define ECM_INTERFACE_GRE_ENABLE=y in order
|
|
+# to enable support for GRE detection.
|
|
+# #############################################################################
|
|
+ccflags-$(ECM_INTERFACE_GRE_ENABLE) += -DECM_INTERFACE_GRE_ENABLE
|
|
+
|
|
# #############################################################################
|
|
# Define ECM_INTERFACE_GRE_TAP_ENABLE=y in order
|
|
# to enable support for GRE TAP interface.
|
|
@@ -246,7 +260,9 @@ ccflags-$(ECM_INTERFACE_OVS_BRIDGE_ENABLE) += -DECM_INTERFACE_OVS_BRIDGE_ENABLE
|
|
# #############################################################################
|
|
# Define ECM_INTERFACE_VLAN_ENABLE=y in order to enable support for VLAN
|
|
# #############################################################################
|
|
-ECM_INTERFACE_VLAN_ENABLE=y
|
|
+ifndef $(ECM_INTERFACE_VLAN_ENABLE)
|
|
+ ECM_INTERFACE_VLAN_ENABLE=y
|
|
+endif
|
|
ccflags-$(ECM_INTERFACE_VLAN_ENABLE) += -DECM_INTERFACE_VLAN_ENABLE
|
|
|
|
# #############################################################################
|
|
@@ -288,7 +304,9 @@ ccflags-$(ECM_CLASSIFIER_OVS_ENABLE) += -DECM_CLASSIFIER_OVS_ENABLE
|
|
# #############################################################################
|
|
# Define ECM_CLASSIFIER_MARK_ENABLE=y in order to enable mark classifier.
|
|
# #############################################################################
|
|
-ECM_CLASSIFIER_MARK_ENABLE=y
|
|
+ifndef $(ECM_CLASSIFIER_MARK_ENABLE)
|
|
+ ECM_CLASSIFIER_MARK_ENABLE=y
|
|
+endif
|
|
ecm-$(ECM_CLASSIFIER_MARK_ENABLE) += ecm_classifier_mark.o
|
|
ccflags-$(ECM_CLASSIFIER_MARK_ENABLE) += -DECM_CLASSIFIER_MARK_ENABLE
|
|
|
|
@@ -312,7 +330,9 @@ ccflags-$(ECM_CLASSIFIER_NL_ENABLE) += -DECM_CLASSIFIER_NL_ENABLE
|
|
# #############################################################################
|
|
# Define ECM_CLASSIFIER_DSCP_ENABLE=y in order to enable DSCP classifier.
|
|
# #############################################################################
|
|
-ECM_CLASSIFIER_DSCP_ENABLE=y
|
|
+ifndef $(ECM_CLASSIFIER_DSCP_ENABLE)
|
|
+ ECM_CLASSIFIER_DSCP_ENABLE=y
|
|
+endif
|
|
ecm-$(ECM_CLASSIFIER_DSCP_ENABLE) += ecm_classifier_dscp.o
|
|
ccflags-$(ECM_CLASSIFIER_DSCP_ENABLE) += -DECM_CLASSIFIER_DSCP_ENABLE
|
|
ccflags-$(ECM_CLASSIFIER_DSCP_IGS) += -DECM_CLASSIFIER_DSCP_IGS
|
|
@@ -331,7 +351,9 @@ ccflags-$(ECM_CLASSIFIER_HYFI_ENABLE) += -DECM_CLASSIFIER_HYFI_ENABLE
|
|
# the Parental Controls subsystem classifier in ECM. Currently disabled until
|
|
# customers require it / if they need to integrate their Parental Controls with it.
|
|
# #############################################################################
|
|
-ECM_CLASSIFIER_PCC_ENABLE=y
|
|
+ifndef $(ECM_CLASSIFIER_PCC_ENABLE)
|
|
+ ECM_CLASSIFIER_PCC_ENABLE=y
|
|
+endif
|
|
ecm-$(ECM_CLASSIFIER_PCC_ENABLE) += ecm_classifier_pcc.o
|
|
ccflags-$(ECM_CLASSIFIER_PCC_ENABLE) += -DECM_CLASSIFIER_PCC_ENABLE
|
|
|
|
@@ -372,27 +394,36 @@ ccflags-$(ECM_NON_PORTED_SUPPORT_ENABLE) += -DECM_NON_PORTED_SUPPORT_ENABLE
|
|
# #############################################################################
|
|
# Define ECM_STATE_OUTPUT_ENABLE=y to support XML state output
|
|
# #############################################################################
|
|
-ECM_STATE_OUTPUT_ENABLE=y
|
|
+ifndef $(ECM_STATE_OUTPUT_ENABLE)
|
|
+ ECM_STATE_OUTPUT_ENABLE=y
|
|
+endif
|
|
ecm-$(ECM_STATE_OUTPUT_ENABLE) += ecm_state.o
|
|
ccflags-$(ECM_STATE_OUTPUT_ENABLE) += -DECM_STATE_OUTPUT_ENABLE
|
|
|
|
# #############################################################################
|
|
# Define ECM_DB_ADVANCED_STATS_ENABLE to support XML state output
|
|
# #############################################################################
|
|
-ECM_DB_ADVANCED_STATS_ENABLE=y
|
|
+ifndef $(ECM_DB_ADVANCED_STATS_ENABLE)
|
|
+ ECM_DB_ADVANCED_STATS_ENABLE=y
|
|
+endif
|
|
ccflags-$(ECM_DB_ADVANCED_STATS_ENABLE) += -DECM_DB_ADVANCED_STATS_ENABLE
|
|
|
|
# #############################################################################
|
|
# Define ECM_DB_CONNECTION_CROSS_REFERENCING_ENABLE=y in order to enable
|
|
# the database to track relationships between objects.
|
|
# #############################################################################
|
|
-ECM_DB_CONNECTION_CROSS_REFERENCING_ENABLE=y
|
|
+ifndef $(ECM_DB_CONNECTION_CROSS_REFERENCING_ENABLE)
|
|
+ ECM_DB_CONNECTION_CROSS_REFERENCING_ENABLE=y
|
|
+endif
|
|
ccflags-$(ECM_DB_CONNECTION_CROSS_REFERENCING_ENABLE) += -DECM_DB_XREF_ENABLE
|
|
|
|
# #############################################################################
|
|
# Define ECM_TRACKER_DPI_SUPPORT_ENABLE=y in order to enable support for
|
|
# deep packet inspection and tracking of data with the trackers.
|
|
# #############################################################################
|
|
+ifndef $(ECM_TRACKER_DPI_SUPPORT_ENABLE)
|
|
+ ECM_TRACKER_DPI_SUPPORT_ENABLE=y
|
|
+endif
|
|
ccflags-$(ECM_TRACKER_DPI_SUPPORT_ENABLE) += -DECM_TRACKER_DPI_SUPPORT_ENABLE
|
|
|
|
# #############################################################################
|
|
@@ -400,14 +431,18 @@ ccflags-$(ECM_TRACKER_DPI_SUPPORT_ENABLE) += -DECM_TRACKER_DPI_SUPPORT_ENABLE
|
|
# support for the database keeping lists of connections that are assigned
|
|
# on a per TYPE of classifier basis.
|
|
# #############################################################################
|
|
-ECM_DB_CLASSIFIER_TYPE_ASSIGNMENTS_TRACK_ENABLE=y
|
|
+ifndef $(ECM_DB_CLASSIFIER_TYPE_ASSIGNMENTS_TRACK_ENABLE)
|
|
+ ECM_DB_CLASSIFIER_TYPE_ASSIGNMENTS_TRACK_ENABLE=y
|
|
+endif
|
|
ccflags-$(ECM_DB_CLASSIFIER_TYPE_ASSIGNMENTS_TRACK_ENABLE) += -DECM_DB_CTA_TRACK_ENABLE
|
|
|
|
# #############################################################################
|
|
# Define ECM_BAND_STEERING_ENABLE=y in order to enable
|
|
# band steering feature.
|
|
# #############################################################################
|
|
-ECM_BAND_STEERING_ENABLE=y
|
|
+ifndef $(ECM_BAND_STEERING_ENABLE)
|
|
+ ECM_BAND_STEERING_ENABLE=y
|
|
+endif
|
|
ccflags-$(ECM_BAND_STEERING_ENABLE) += -DECM_BAND_STEERING_ENABLE
|
|
|
|
# #############################################################################
|
|
@@ -488,7 +523,6 @@ ccflags-y += -DECM_TRACKER_UDP_DEBUG_LEVEL=1
|
|
ccflags-y += -DECM_BOND_NOTIFIER_DEBUG_LEVEL=1
|
|
ccflags-y += -DECM_INTERFACE_DEBUG_LEVEL=1
|
|
ccflags-y += -DECM_STATE_DEBUG_LEVEL=1
|
|
-ccflags-y += -DECM_OPENWRT_SUPPORT=1
|
|
ccflags-y += -DECM_NOTIFIER_DEBUG_LEVEL=1
|
|
ccflags-y += -DECM_AE_CLASSIFIER_DEBUG_LEVEL=1
|
|
ccflags-y += -DECM_STATS_DEBUG_LEVEL=1
|
|
--- a/Makefile_61.mk
|
|
+++ b/Makefile_61.mk
|
|
@@ -465,7 +465,6 @@ ccflags-y += -DECM_TRACKER_UDP_DEBUG_LEVEL=1
|
|
ccflags-y += -DECM_BOND_NOTIFIER_DEBUG_LEVEL=1
|
|
ccflags-y += -DECM_INTERFACE_DEBUG_LEVEL=1
|
|
ccflags-y += -DECM_STATE_DEBUG_LEVEL=1
|
|
-ccflags-y += -DECM_OPENWRT_SUPPORT=1
|
|
ccflags-y += -DECM_NOTIFIER_DEBUG_LEVEL=1
|
|
ccflags-y += -DECM_AE_CLASSIFIER_DEBUG_LEVEL=1
|
|
ccflags-y += -DECM_STATS_DEBUG_LEVEL=1
|
|
--- a/ecm_db/ecm_db_connection.c
|
|
+++ b/ecm_db/ecm_db_connection.c
|
|
@@ -446,7 +446,9 @@ EXPORT_SYMBOL(ecm_db_connection_make_def
|
|
*/
|
|
void ecm_db_connection_data_totals_update(struct ecm_db_connection_instance *ci, bool is_from, uint64_t size, uint64_t packets)
|
|
{
|
|
+#ifdef ECM_DB_ADVANCED_STATS_ENABLE
|
|
int32_t i;
|
|
+#endif
|
|
|
|
DEBUG_CHECK_MAGIC(ci, ECM_DB_CONNECTION_INSTANCE_MAGIC, "%px: magic failed\n", ci);
|
|
|
|
@@ -545,7 +547,9 @@ EXPORT_SYMBOL(ecm_db_connection_data_tot
|
|
*/
|
|
void ecm_db_connection_data_totals_update_dropped(struct ecm_db_connection_instance *ci, bool is_from, uint64_t size, uint64_t packets)
|
|
{
|
|
+#ifdef ECM_DB_ADVANCED_STATS_ENABLE
|
|
int32_t i;
|
|
+#endif
|
|
|
|
DEBUG_CHECK_MAGIC(ci, ECM_DB_CONNECTION_INSTANCE_MAGIC, "%px: magic failed\n", ci);
|
|
|
|
@@ -1539,6 +1543,7 @@ void ecm_db_connection_defunct_all(void)
|
|
}
|
|
EXPORT_SYMBOL(ecm_db_connection_defunct_all);
|
|
|
|
+#ifdef ECM_INTERFACE_OVS_BRIDGE_ENABLE
|
|
/*
|
|
* ecm_db_connection_defunct_by_classifier()
|
|
* Make defunct based on masked fields
|
|
@@ -1705,6 +1710,7 @@ next_ci:
|
|
ECM_IP_ADDR_TO_OCTAL(dest_addr_mask), dest_port_mask, proto_mask, cnt);
|
|
}
|
|
}
|
|
+#endif
|
|
|
|
/*
|
|
* ecm_db_connection_defunct_by_port()
|
|
@@ -1994,6 +2000,7 @@ struct ecm_db_node_instance *ecm_db_conn
|
|
}
|
|
EXPORT_SYMBOL(ecm_db_connection_node_get_and_ref);
|
|
|
|
+#ifdef ECM_DB_XREF_ENABLE
|
|
/*
|
|
* ecm_db_connection_mapping_get_and_ref_next()
|
|
* Return reference to next connection in the mapping chain in the specified direction.
|
|
@@ -2035,6 +2042,7 @@ struct ecm_db_connection_instance *ecm_d
|
|
return nci;
|
|
}
|
|
EXPORT_SYMBOL(ecm_db_connection_iface_get_and_ref_next);
|
|
+#endif
|
|
|
|
/*
|
|
* ecm_db_connection_mapping_get_and_ref()
|
|
--- a/ecm_db/ecm_db_node.c
|
|
+++ b/ecm_db/ecm_db_node.c
|
|
@@ -227,9 +227,11 @@ EXPORT_SYMBOL(ecm_db_node_get_and_ref_ne
|
|
*/
|
|
int ecm_db_node_deref(struct ecm_db_node_instance *ni)
|
|
{
|
|
+#ifdef ECM_DB_XREF_ENABLE
|
|
#if (DEBUG_LEVEL >= 1)
|
|
int dir;
|
|
#endif
|
|
+#endif
|
|
DEBUG_CHECK_MAGIC(ni, ECM_DB_NODE_INSTANCE_MAGIC, "%px: magic failed\n", ni);
|
|
|
|
spin_lock_bh(&ecm_db_lock);
|
|
@@ -489,9 +491,11 @@ EXPORT_SYMBOL(ecm_db_node_iface_get_and_
|
|
void ecm_db_node_add(struct ecm_db_node_instance *ni, struct ecm_db_iface_instance *ii, uint8_t *address,
|
|
ecm_db_node_final_callback_t final, void *arg)
|
|
{
|
|
+#ifdef ECM_DB_XREF_ENABLE
|
|
#if (DEBUG_LEVEL >= 1)
|
|
int dir;
|
|
#endif
|
|
+#endif
|
|
ecm_db_node_hash_t hash_index;
|
|
struct ecm_db_listener_instance *li;
|
|
|
|
--- a/ecm_interface.c
|
|
+++ b/ecm_interface.c
|
|
@@ -1509,6 +1509,7 @@ struct neighbour *ecm_interface_ipv6_nei
|
|
*/
|
|
bool ecm_interface_is_pptp(struct sk_buff *skb, const struct net_device *out)
|
|
{
|
|
+#ifdef ECM_INTERFACE_PPTP_ENABLE
|
|
struct net_device *in;
|
|
|
|
/*
|
|
@@ -1533,6 +1534,7 @@ bool ecm_interface_is_pptp(struct sk_buf
|
|
}
|
|
|
|
dev_put(in);
|
|
+#endif
|
|
return false;
|
|
}
|
|
|
|
@@ -1545,6 +1547,7 @@ bool ecm_interface_is_pptp(struct sk_buf
|
|
*/
|
|
bool ecm_interface_is_l2tp_packet_by_version(struct sk_buff *skb, const struct net_device *out, int ver)
|
|
{
|
|
+#ifdef ECM_INTERFACE_L2TPV2_PPTP_ENABLE
|
|
uint32_t flag = 0;
|
|
struct net_device *in;
|
|
|
|
@@ -1577,6 +1580,7 @@ bool ecm_interface_is_l2tp_packet_by_ver
|
|
}
|
|
|
|
dev_put(in);
|
|
+#endif
|
|
return false;
|
|
}
|
|
|
|
@@ -1589,6 +1593,7 @@ bool ecm_interface_is_l2tp_packet_by_ver
|
|
*/
|
|
bool ecm_interface_is_l2tp_pptp(struct sk_buff *skb, const struct net_device *out)
|
|
{
|
|
+#ifdef ECM_INTERFACE_L2TPV2_PPTP_ENABLE
|
|
struct net_device *in;
|
|
|
|
/*
|
|
@@ -1611,6 +1616,7 @@ bool ecm_interface_is_l2tp_pptp(struct s
|
|
}
|
|
|
|
dev_put(in);
|
|
+#endif
|
|
return false;
|
|
}
|
|
|
|
@@ -7127,6 +7133,7 @@ static void ecm_interface_regenerate_con
|
|
return;
|
|
}
|
|
|
|
+#ifdef ECM_DB_XREF_ENABLE
|
|
for (dir = 0; dir < ECM_DB_OBJ_DIR_MAX; dir++) {
|
|
/*
|
|
* Re-generate all connections associated with this interface
|
|
@@ -7142,6 +7149,7 @@ static void ecm_interface_regenerate_con
|
|
ci[dir] = cin;
|
|
}
|
|
}
|
|
+#endif
|
|
|
|
#ifdef ECM_MULTICAST_ENABLE
|
|
/*
|
|
--- a/frontends/ecm_front_end_common.c
|
|
+++ b/frontends/ecm_front_end_common.c
|
|
@@ -517,6 +517,7 @@ bool ecm_front_end_gre_proto_is_accel_al
|
|
struct nf_conntrack_tuple *reply_tuple,
|
|
int ip_version, uint16_t offset)
|
|
{
|
|
+#ifdef ECM_INTERFACE_GRE_ENABLE
|
|
struct net_device *dev;
|
|
struct gre_base_hdr *greh;
|
|
|
|
@@ -528,10 +529,12 @@ bool ecm_front_end_gre_proto_is_accel_al
|
|
/*
|
|
* Case 1: PPTP locally terminated
|
|
*/
|
|
+#ifdef ECM_INTERFACE_PPTP_ENABLE
|
|
if (ecm_interface_is_pptp(skb, outdev)) {
|
|
DEBUG_TRACE("%px: PPTP GRE locally terminated - allow acceleration\n", skb);
|
|
return true;
|
|
}
|
|
+#endif
|
|
|
|
/*
|
|
* Case 2: PPTP pass through
|
|
@@ -657,6 +660,10 @@ bool ecm_front_end_gre_proto_is_accel_al
|
|
*/
|
|
DEBUG_TRACE("%px: GRE IPv%d pass through non NAT - allow acceleration\n", skb, ip_version);
|
|
return true;
|
|
+#else
|
|
+ DEBUG_TRACE("%px: GRE%d feature is disabled - do not allow acceleration\n", skb, ip_version);
|
|
+ return false;
|
|
+#endif
|
|
}
|
|
|
|
#ifdef ECM_CLASSIFIER_DSCP_ENABLE
|