M7350v7_en_gpl
This commit is contained in:
1
shortcut-fe/fast-classifier/fast-classifier.c
Normal file → Executable file
1
shortcut-fe/fast-classifier/fast-classifier.c
Normal file → Executable file
@ -1353,6 +1353,7 @@ static const struct device_attribute fast_classifier_debug_info_attr =
|
||||
static const struct device_attribute fast_classifier_skip_bridge_ingress =
|
||||
__ATTR(skip_to_bridge_ingress, S_IWUGO | S_IRUGO, fast_classifier_get_skip_bridge_ingress, fast_classifier_set_skip_bridge_ingress);
|
||||
|
||||
|
||||
/*
|
||||
* fast_classifier_init()
|
||||
*/
|
||||
|
1
shortcut-fe/shortcut-fe/Makefile
Normal file → Executable file
1
shortcut-fe/shortcut-fe/Makefile
Normal file → Executable file
@ -35,6 +35,7 @@ shortcut-fe-cm-objs := \
|
||||
sfe_cm.o
|
||||
|
||||
ccflags-y += -D__CHECK_ENDIAN__
|
||||
ccflags-y += -DSFE_CONFIG_MARK
|
||||
|
||||
CDEFINES += -D__CHECK_ENDIAN__
|
||||
|
||||
|
0
shortcut-fe/shortcut-fe/sfe.h
Normal file → Executable file
0
shortcut-fe/shortcut-fe/sfe.h
Normal file → Executable file
98
shortcut-fe/shortcut-fe/sfe_cm.c
Normal file → Executable file
98
shortcut-fe/shortcut-fe/sfe_cm.c
Normal file → Executable file
@ -30,6 +30,12 @@
|
||||
#include <net/netfilter/nf_conntrack_core.h>
|
||||
#include <linux/if_bridge.h>
|
||||
|
||||
//[zhangguosong start]
|
||||
#ifdef TP_FEATURE_WLANTC
|
||||
#include <linux/netfilter_ipv4.h>
|
||||
#endif
|
||||
//[zhangguosong end]
|
||||
|
||||
#include "sfe.h"
|
||||
#include "sfe_cm.h"
|
||||
#include "sfe_backport.h"
|
||||
@ -551,6 +557,20 @@ static unsigned int sfe_cm_post_routing(struct sk_buff *skb, int is_v4)
|
||||
sic.dest_port = orig_tuple.dst.u.udp.port;
|
||||
sic.src_port_xlate = reply_tuple.dst.u.udp.port;
|
||||
sic.dest_port_xlate = reply_tuple.src.u.udp.port;
|
||||
|
||||
//[zhangguosong start] 2018-06-21
|
||||
/* Do not use package from reply to build sfe connection */
|
||||
if (likely(is_v4))
|
||||
{
|
||||
struct iphdr* iph = ip_hdr(skb);
|
||||
if (iph && ntohl(iph->saddr) != ntohl(sic.src_ip_xlate.ip)
|
||||
&& ntohl(iph->saddr) != ntohl(sic.src_ip.ip))
|
||||
{
|
||||
DEBUG_TRACE("%s: Ignore reply package\n", __FUNCTION__);
|
||||
return NF_ACCEPT;
|
||||
}
|
||||
}
|
||||
//[zhangguosong end]
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -665,9 +685,34 @@ static unsigned int sfe_cm_post_routing(struct sk_buff *skb, int is_v4)
|
||||
sic.src_dev = src_dev_use;
|
||||
sic.dest_dev = dest_dev_use;
|
||||
|
||||
//[zhangguosong start] 2018-07-30
|
||||
/* Fix#241362
|
||||
* <20><><EFBFBD><EFBFBD>: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٹ<EFBFBD><D9B9><EFBFBD><EFBFBD>Ŀͻ<C4BF><CDBB>˱<EFBFBD><CBB1><EFBFBD><EFBFBD><EFBFBD>ΪDMZ<4D><5A><EFBFBD><EFBFBD>ʱ,<2C>ⲿ<EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ,<2C>ÿͻ<C3BF><CDBB><EFBFBD><EFBFBD><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* ԭ<><D4AD>: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ⲿ<EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C>Ӷ<EFBFBD><D3B6><EFBFBD><EFBFBD><EFBFBD>conntrack<63><6B>origin_tuple<6C><65>src_ipΪ<70>ⲿ<EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD>,<2C><><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>ip<69><70>ַ
|
||||
* <20><><EFBFBD>ж<EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD>,<2C><EFBFBD>ȷ<D7BC>жϳ<D0B6><CFB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٵĿͻ<C4BF><CDBB><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C>Ӷ<EFBFBD><D3B6><EFBFBD><EFBFBD><EFBFBD>SFE<46><45>Ȼ
|
||||
* ʹ<><CAB9>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SFE<46><45><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Կͻ<D4BF><CDBB>˵<EFBFBD>Mark<72><6B><EFBFBD><EFBFBD>,<2C>Ӷ<EFBFBD><D3B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><DEB7><EFBFBD>Ч.
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ: 1. ɾ<><C9BE>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SpeedTest<73><74><EFBFBD><EFBFBD>;
|
||||
* 2. <20>ڴ<EFBFBD><DAB4><EFBFBD>SFEת<45><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮ǰ<D6AE><C7B0>skb<6B>е<EFBFBD>mark<72><6B><EFBFBD>ǽ<EFBFBD><C7BD><EFBFBD><EFBFBD>ж<EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>wan2lan<61><6E><EFBFBD><EFBFBD>(0x00008000),<2C><>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD>
|
||||
* Ϊ<><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><F2B2A2BD>䷵<EFBFBD>ظ<EFBFBD>Э<EFBFBD><D0AD>ջ;
|
||||
*/
|
||||
DEBUG_TRACE("%s: sic.src_dev->name = %s\n", __FUNCTION__, sic.src_dev->name);
|
||||
DEBUG_TRACE("%s: skb->mark = 0x%x\n", __FUNCTION__, skb->mark);
|
||||
if (skb->mark & MASK_FOR_WAN2LAN)
|
||||
{
|
||||
DEBUG_TRACE("%s: Download link package, ignore it.\n", __FUNCTION__);
|
||||
return NF_ACCEPT;
|
||||
}
|
||||
//[zhangguosong end]
|
||||
|
||||
sic.src_mtu = src_dev_use->mtu;
|
||||
sic.dest_mtu = dest_dev_use->mtu;
|
||||
|
||||
//[zhangguosong start] 2018-05-08 get mark
|
||||
sic.mark = ct->mark;
|
||||
sic.mark |= (skb->mark & 0x8FFF);
|
||||
//sic.mark |= skb->mark;
|
||||
//[zhangguosong end]
|
||||
|
||||
if (likely(is_v4)) {
|
||||
if (sfe_ipv4_create_rule(&sic) == 0) {
|
||||
ct->sfe_entry = (void *)(&sic);
|
||||
@ -1008,6 +1053,50 @@ static ssize_t sfe_cm_get_exceptions(struct device *dev,
|
||||
*/
|
||||
static const struct device_attribute sfe_cm_exceptions_attr =
|
||||
__ATTR(exceptions, S_IRUGO, sfe_cm_get_exceptions, NULL);
|
||||
#ifdef TP_FEATURE_CLOUD
|
||||
int do_sfe_cloud_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len)
|
||||
{
|
||||
int ret = 0;
|
||||
int status = 1;
|
||||
printk("%s: hande msg: %d\n", __FUNCTION__, cmd);
|
||||
|
||||
switch(cmd)
|
||||
{
|
||||
case SFE_ENABLE_CLOUD_BLCOK:
|
||||
if (NULL == user || len != 4)
|
||||
{
|
||||
printk("%s: invalid params.", __FUNCTION__);
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
copy_from_user(&status, user, len);
|
||||
printk("%s: sfe change cloud block status to %d.", __FUNCTION__, status);
|
||||
sfe_update_enable_block_status(status);
|
||||
break;
|
||||
default:
|
||||
DEBUG_ERROR("Receive an unknown set ctl command. cmd = %d\n", cmd);
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int do_sfe_cloud_get_ctl(struct sock* sk, int cmd, void __user *user, int *len)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct nf_sockopt_ops cloud_sockopts = {
|
||||
.pf = PF_INET,
|
||||
.set_optmin = SFE_CLOUD_BASE_CTL,
|
||||
.set_optmax = SFE_CLOUD_SET_MAX+1,
|
||||
.set = do_sfe_cloud_set_ctl,
|
||||
.get_optmin = SFE_CLOUD_BASE_CTL,
|
||||
.get_optmax = SFE_CLOUD_GET_MAX+1,
|
||||
.get = do_sfe_cloud_get_ctl,
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* sfe_cm_init()
|
||||
@ -1056,7 +1145,16 @@ static int __init sfe_cm_init(void)
|
||||
DEBUG_ERROR("can't register nf post routing hook: %d\n", result);
|
||||
goto exit3;
|
||||
}
|
||||
#ifdef TP_FEATURE_CLOUD
|
||||
result = nf_register_sockopt(&cloud_sockopts);
|
||||
if (result < 0)
|
||||
{
|
||||
DEBUG_ERROR("can't register nf sockopts for cloud: %d\n", result);
|
||||
goto exit3;
|
||||
}
|
||||
#endif
|
||||
|
||||
printk("%s: sfe register sockopt success.", __FUNCTION__);
|
||||
spin_lock_init(&sc->lock);
|
||||
|
||||
/*
|
||||
|
36
shortcut-fe/shortcut-fe/sfe_cm.h
Normal file → Executable file
36
shortcut-fe/shortcut-fe/sfe_cm.h
Normal file → Executable file
@ -15,6 +15,8 @@
|
||||
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <linux/spinlock.h>
|
||||
|
||||
/*
|
||||
* connection flags.
|
||||
*/
|
||||
@ -27,6 +29,13 @@
|
||||
#define SFE_SUPPORT_IPV6
|
||||
#endif
|
||||
|
||||
|
||||
//for test
|
||||
#ifndef TP_FEATURE_WLANTC
|
||||
#define TP_FEATURE_WLANTC
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* IPv6 address structure
|
||||
*/
|
||||
@ -165,6 +174,29 @@ struct sfe_connection_mark {
|
||||
uint32_t mark;
|
||||
};
|
||||
|
||||
|
||||
#ifdef TP_FEATURE_CLOUD
|
||||
#define SFE_CLOUD_BASE_CTL 512
|
||||
#define SFE_ENABLE_CLOUD_BLCOK (SFE_CLOUD_BASE_CTL)
|
||||
#define SFE_CLOUD_SET_MAX (SFE_ENABLE_CLOUD_BLCOK)
|
||||
#define SFE_CLOUD_GET_MAX (SFE_CLOUD_BASE_CTL)
|
||||
#endif
|
||||
|
||||
|
||||
//[zhangguosong start]
|
||||
#ifdef TP_FEATURE_WLANTC
|
||||
#define MAX_TC_RULES_NUM 20
|
||||
|
||||
/*
|
||||
* brief: this marco is used to mark the download packet(from WAN to LAN)
|
||||
*/
|
||||
#define MASK_FOR_WAN2LAN 0X00008000
|
||||
|
||||
static DEFINE_SPINLOCK(tc_lock);
|
||||
#endif
|
||||
//[zhangguosong end]
|
||||
|
||||
|
||||
/*
|
||||
* Type used for a sync rule callback.
|
||||
*/
|
||||
@ -181,6 +213,10 @@ extern void sfe_ipv4_register_sync_rule_callback(sfe_sync_rule_callback_t callba
|
||||
extern void sfe_ipv4_update_rule(struct sfe_connection_create *sic);
|
||||
extern void sfe_ipv4_mark_rule(struct sfe_connection_mark *mark);
|
||||
|
||||
#ifdef TP_FEATURE_CLOUD
|
||||
extern void sfe_update_enable_block_status(int status);
|
||||
#endif
|
||||
|
||||
#ifdef SFE_SUPPORT_IPV6
|
||||
/*
|
||||
* IPv6 APIs used by connection manager
|
||||
|
133
shortcut-fe/shortcut-fe/sfe_ipv4.c
Normal file → Executable file
133
shortcut-fe/shortcut-fe/sfe_ipv4.c
Normal file → Executable file
@ -35,7 +35,7 @@ int var_thresh = PKT_THRESHOLD;
|
||||
int skip_mtu_check = 1;
|
||||
int threshold_count;
|
||||
int timeout_count;
|
||||
|
||||
int enable_cloud_block = 0;
|
||||
#define XDBG_ADD_PROC_ENTRY(it, name, xdata) \
|
||||
{ \
|
||||
.procname = (name), \
|
||||
@ -543,6 +543,7 @@ typedef bool (*sfe_ipv4_debug_xml_write_method_t)(struct sfe_ipv4 *si, char *buf
|
||||
|
||||
struct sfe_ipv4 __si;
|
||||
|
||||
|
||||
/* When the timer expires this callback function is called*/
|
||||
void sfe_timer_callback(unsigned long data)
|
||||
{
|
||||
@ -1250,6 +1251,12 @@ static void sfe_ipv4_flush_sfe_ipv4_connection(struct sfe_ipv4 *si, struct sfe_i
|
||||
kfree(c);
|
||||
}
|
||||
|
||||
//[zhangguosong start] 2018-05-10 Export sfe_stat_cb function to ipt-stat to record stat
|
||||
int (*sfe_stat_cb)(struct sk_buff *skb) __rcu __read_mostly;
|
||||
EXPORT_SYMBOL_GPL(sfe_stat_cb);
|
||||
//[zhangguosong end]
|
||||
|
||||
|
||||
/*
|
||||
* sfe_ipv4_recv_udp()
|
||||
* Handle UDP packet receives and forwarding.
|
||||
@ -1265,11 +1272,21 @@ static int sfe_ipv4_recv_udp(struct sfe_ipv4 *si, struct sk_buff *skb, struct ne
|
||||
struct sfe_ipv4_connection_match *cm;
|
||||
uint8_t ttl;
|
||||
struct net_device *xmit_dev;
|
||||
|
||||
int (*stat_cb)(struct sk_buff *skb);
|
||||
|
||||
struct sk_buff *new_skb ;
|
||||
int k;
|
||||
const struct net_device_ops *ops;
|
||||
int queue_index = 0;
|
||||
struct sfe_ipv4_connection *c;
|
||||
|
||||
//[zhangguosong start]
|
||||
#ifdef TP_FEATURE_WLANTC
|
||||
struct sfe_ipv4_connection_match *counter_cm;
|
||||
int idx = 0;
|
||||
#endif
|
||||
//[zhangguosong end]
|
||||
/*
|
||||
* Is our packet too short to contain a valid UDP header?
|
||||
*/
|
||||
@ -1397,6 +1414,15 @@ static int sfe_ipv4_recv_udp(struct sfe_ipv4 *si, struct sk_buff *skb, struct ne
|
||||
if (unlikely(cm->flags & SFE_IPV4_CONNECTION_MATCH_FLAG_XLATE_SRC)) {
|
||||
uint16_t udp_csum;
|
||||
|
||||
//[zhangguosong start] 2018-05-10 update stats in ipt-stat
|
||||
stat_cb = rcu_dereference(sfe_stat_cb);
|
||||
if (stat_cb) {
|
||||
if (NF_DROP == stat_cb(skb)) { /* if ipt-stat return NF_DROP, it means reach limit data-usaged */
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
//[zhangguosong end]
|
||||
|
||||
iph->saddr = cm->xlate_src_ip;
|
||||
udph->source = cm->xlate_src_port;
|
||||
|
||||
@ -1445,8 +1471,35 @@ static int sfe_ipv4_recv_udp(struct sfe_ipv4 *si, struct sk_buff *skb, struct ne
|
||||
sum = (sum & 0xffff) + (sum >> 16);
|
||||
udph->check = (uint16_t)sum;
|
||||
}
|
||||
|
||||
//[zhangguosong start] 2018-05-10 update stats in ipt-stat
|
||||
stat_cb = rcu_dereference(sfe_stat_cb);
|
||||
if (stat_cb) {
|
||||
if (NF_DROP == stat_cb(skb)) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
//[zhangguosong end]
|
||||
}
|
||||
|
||||
//[zhangguosong start] 2018-05-10 Move from MR6400V3
|
||||
/**
|
||||
* add by wuchao, 18.03.21, fix bug#215239.
|
||||
* topology: lan pc - vpn server on dut - vpn client on wan pc
|
||||
* no need to do SNAT & DNAT
|
||||
*/
|
||||
if (unlikely(!(cm->flags & SFE_IPV4_CONNECTION_MATCH_FLAG_XLATE_SRC)) &&
|
||||
unlikely(!(cm->flags & SFE_IPV4_CONNECTION_MATCH_FLAG_XLATE_DEST)))
|
||||
{
|
||||
stat_cb = rcu_dereference(sfe_stat_cb);
|
||||
if (stat_cb) {
|
||||
if (NF_DROP == stat_cb(skb)) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
//[zhangguosong end]
|
||||
|
||||
/*
|
||||
* Replace the IP checksum.
|
||||
*/
|
||||
@ -1509,7 +1562,13 @@ static int sfe_ipv4_recv_udp(struct sfe_ipv4 *si, struct sk_buff *skb, struct ne
|
||||
/*
|
||||
* Mark outgoing packet.
|
||||
*/
|
||||
skb->mark = cm->connection->mark;
|
||||
DEBUG_TRACE("%s: cm->connection->mark = 0x%x\n", __FUNCTION__, cm->connection->mark);
|
||||
if (cm->connection->mark != 0) {
|
||||
skb->mark = skb->mark | cm->connection->mark /*| MASK_FOR_WAN2LAN*/;
|
||||
DEBUG_TRACE("%s: skb-mark = 0x%x", __FUNCTION__, skb->mark);
|
||||
}
|
||||
|
||||
//skb->mark = cm->connection->mark;
|
||||
if (skb->mark) {
|
||||
DEBUG_TRACE("SKB MARK is NON ZERO %x\n", skb->mark);
|
||||
}
|
||||
@ -1680,7 +1739,15 @@ static bool sfe_ipv4_process_tcp_option_sack(const struct sfe_ipv4_tcp_hdr *th,
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef TP_FEATURE_CLOUD
|
||||
void sfe_update_enable_block_status(int status)
|
||||
{
|
||||
struct sfe_ipv4 *si = &__si;
|
||||
spin_lock_bh(&si->lock);
|
||||
enable_cloud_block = status;
|
||||
spin_unlock_bh(&si->lock);
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
* sfe_ipv4_recv_tcp()
|
||||
* Handle TCP packet receives and forwarding.
|
||||
@ -1698,11 +1765,15 @@ static int sfe_ipv4_recv_tcp(struct sfe_ipv4 *si, struct sk_buff *skb, struct ne
|
||||
uint8_t ttl;
|
||||
uint32_t flags;
|
||||
struct net_device *xmit_dev;
|
||||
|
||||
int (*stat_cb)(struct sk_buff *skb);
|
||||
|
||||
struct sk_buff *new_skb ;
|
||||
int k;
|
||||
const struct net_device_ops *ops;
|
||||
int queue_index = 0;
|
||||
struct sfe_ipv4_connection *c;
|
||||
int idx = 0; //[zhangguosong add]
|
||||
|
||||
/*
|
||||
* Is our packet too short to contain a valid UDP header?
|
||||
@ -1732,6 +1803,21 @@ static int sfe_ipv4_recv_tcp(struct sfe_ipv4 *si, struct sk_buff *skb, struct ne
|
||||
|
||||
spin_lock_bh(&si->lock);
|
||||
|
||||
// [ lxw start]
|
||||
#ifdef TP_FEATURE_CLOUD
|
||||
if (enable_cloud_block == 1)
|
||||
{
|
||||
if (ntohs(src_port) == 80 || ntohs(dest_port) == 80)
|
||||
{
|
||||
si->exception_events[SFE_IPV4_EXCEPTION_EVENT_UNHANDLED_PROTOCOL]++;
|
||||
si->packets_not_forwarded++;
|
||||
spin_unlock_bh(&si->lock);
|
||||
DEBUG_TRACE("Enable to tip cloud upgrade, not forward http packet\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// [lxw end]
|
||||
/*
|
||||
* Look for a connection match.
|
||||
*/
|
||||
@ -2022,6 +2108,15 @@ static int sfe_ipv4_recv_tcp(struct sfe_ipv4 *si, struct sk_buff *skb, struct ne
|
||||
uint16_t tcp_csum;
|
||||
uint32_t sum;
|
||||
|
||||
//[zhangguosong start] 2018-05-10 Update stats in ipt-stat
|
||||
stat_cb = rcu_dereference(sfe_stat_cb);
|
||||
if (stat_cb) {
|
||||
if (NF_DROP == stat_cb(skb)) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
//[zhangguosong end]
|
||||
|
||||
iph->saddr = cm->xlate_src_ip;
|
||||
tcph->source = cm->xlate_src_port;
|
||||
|
||||
@ -2063,8 +2158,30 @@ static int sfe_ipv4_recv_tcp(struct sfe_ipv4 *si, struct sk_buff *skb, struct ne
|
||||
|
||||
sum = (sum & 0xffff) + (sum >> 16);
|
||||
tcph->check = (uint16_t)sum;
|
||||
|
||||
//[zhangguosong start] 2018-05-10 Update stats in ipt-stat
|
||||
stat_cb = rcu_dereference(sfe_stat_cb);
|
||||
if (stat_cb) {
|
||||
if (NF_DROP == stat_cb(skb)) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
//[zhangguosong end]
|
||||
}
|
||||
|
||||
//[zhangguosong start] 2018-05-10 Move from MR6400V3
|
||||
if (unlikely(!(cm->flags & SFE_IPV4_CONNECTION_MATCH_FLAG_XLATE_SRC)) &&
|
||||
unlikely(!(cm->flags & SFE_IPV4_CONNECTION_MATCH_FLAG_XLATE_DEST)))
|
||||
{
|
||||
stat_cb = rcu_dereference(sfe_stat_cb);
|
||||
if (stat_cb) {
|
||||
if (NF_DROP == stat_cb(skb)) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
//[zhangguosong end]
|
||||
|
||||
/*
|
||||
* Replace the IP checksum.
|
||||
*/
|
||||
@ -2127,7 +2244,12 @@ static int sfe_ipv4_recv_tcp(struct sfe_ipv4 *si, struct sk_buff *skb, struct ne
|
||||
/*
|
||||
* Mark outgoing packet
|
||||
*/
|
||||
skb->mark = cm->connection->mark;
|
||||
DEBUG_TRACE("%s: cm->connection->mark = 0x%x\n", __FUNCTION__, cm->connection->mark);
|
||||
if (cm->connection->mark != 0) {
|
||||
skb->mark = skb->mark | cm->connection->mark/* | MASK_FOR_WAN2LAN*/;
|
||||
DEBUG_TRACE("%s: skb->mark = 0x%x\n", __FUNCTION__, skb->mark);
|
||||
}
|
||||
// skb->mark = cm->connection->mark;
|
||||
if (skb->mark) {
|
||||
DEBUG_TRACE("SKB MARK is NON ZERO %x\n", skb->mark);
|
||||
}
|
||||
@ -3850,6 +3972,9 @@ EXPORT_SYMBOL(sfe_ipv4_update_rule);
|
||||
EXPORT_SYMBOL(sfe_register_flow_cookie_cb);
|
||||
EXPORT_SYMBOL(sfe_unregister_flow_cookie_cb);
|
||||
#endif
|
||||
#ifdef TP_FEATURE_CLOUD
|
||||
EXPORT_SYMBOL(sfe_update_enable_block_status);
|
||||
#endif
|
||||
|
||||
MODULE_AUTHOR("Qualcomm Atheros Inc.");
|
||||
MODULE_DESCRIPTION("Shortcut Forwarding Engine - IPv4 edition");
|
||||
|
113
shortcut-fe/shortcut-fe/sfe_ipv6.c
Normal file → Executable file
113
shortcut-fe/shortcut-fe/sfe_ipv6.c
Normal file → Executable file
@ -29,6 +29,8 @@
|
||||
#define PKT_THRESHOLD 10
|
||||
#define TIMEOUT 100
|
||||
|
||||
#define __OPEN_SUPPORT__IPV6__ 1
|
||||
|
||||
struct sfe_wlan_aggr_params aggr_params[MAX_WLAN_INDEX];
|
||||
|
||||
int var_timeout = TIMEOUT;
|
||||
@ -1315,6 +1317,9 @@ static void sfe_ipv6_flush_connection(struct sfe_ipv6 *si, struct sfe_ipv6_conne
|
||||
kfree(c);
|
||||
}
|
||||
|
||||
int (*sfe_ipv6_stat_cb)(struct sk_buff *skb) __rcu __read_mostly;
|
||||
EXPORT_SYMBOL_GPL(sfe_ipv6_stat_cb);
|
||||
|
||||
/*
|
||||
* sfe_ipv6_recv_udp()
|
||||
* Handle UDP packet receives and forwarding.
|
||||
@ -1334,6 +1339,8 @@ static int sfe_ipv6_recv_udp(struct sfe_ipv6 *si, struct sk_buff *skb, struct ne
|
||||
int queue_index = 0;
|
||||
struct sfe_ipv6_connection *c;
|
||||
|
||||
int (*stat_cb)(struct skb_buff *skb);
|
||||
|
||||
/*
|
||||
* Is our packet too short to contain a valid UDP header?
|
||||
*/
|
||||
@ -1456,6 +1463,19 @@ static int sfe_ipv6_recv_udp(struct sfe_ipv6 *si, struct sk_buff *skb, struct ne
|
||||
if (unlikely(cm->flags & SFE_IPV6_CONNECTION_MATCH_FLAG_XLATE_SRC)) {
|
||||
uint16_t udp_csum;
|
||||
|
||||
//[zhangguosong add] 2018-06-26
|
||||
#if __OPEN_SUPPORT__IPV6__
|
||||
stat_cb = rcu_dereference(sfe_ipv6_stat_cb);
|
||||
if (stat_cb)
|
||||
{
|
||||
if (NF_DROP == stat_cb(skb))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
//[zhangguosong end]
|
||||
|
||||
iph->saddr = cm->xlate_src_ip[0];
|
||||
udph->source = cm->xlate_src_port;
|
||||
|
||||
@ -1490,8 +1510,36 @@ static int sfe_ipv6_recv_udp(struct sfe_ipv6 *si, struct sk_buff *skb, struct ne
|
||||
sum = (sum & 0xffff) + (sum >> 16);
|
||||
udph->check = (uint16_t)sum;
|
||||
}
|
||||
|
||||
//[zhangguosong add] 2016-06-26
|
||||
#if __OPEN_SUPPORT__IPV6__
|
||||
stat_cb = rcu_dereference(sfe_ipv6_stat_cb);
|
||||
if (stat_cb)
|
||||
{
|
||||
if (NF_DROP == stat_cb(skb))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
//[zhangguosong end]
|
||||
}
|
||||
|
||||
#if __OPEN_SUPPORT_IPV6__
|
||||
if (unlikely(!(cm->flags & SFE_IPV6_CONNECTION_MATCH_FLAG_XLATE_SRC)) &&
|
||||
unlikely(!(cm->flags & SFE_IPV6_CONNECTION_MATCH_FLAG_XLATE_DEST)))
|
||||
{
|
||||
stat_cb = rcu_dereference(sfe_ipv6_stat_cb);
|
||||
if (stat_cb)
|
||||
{
|
||||
if (NF_DROP == stat_cb(skb))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Update traffic stats.
|
||||
*/
|
||||
@ -1548,9 +1596,15 @@ static int sfe_ipv6_recv_udp(struct sfe_ipv6 *si, struct sk_buff *skb, struct ne
|
||||
/*
|
||||
* Mark outgoing packet.
|
||||
*/
|
||||
skb->mark = cm->connection->mark;
|
||||
DEBUG_TRACE("%s: cm->connection->mark = 0x%x\n", __FUNCTION__, cm->connection->mark);
|
||||
if (0 != cm->connection->mark)
|
||||
{
|
||||
skb->mark = skb->mark | cm->connection->mark;
|
||||
DEBUG_TRACE("%s: skb->mark = 0x%x\n", __FUNCTION__, skb->mark);
|
||||
}
|
||||
|
||||
if (skb->mark) {
|
||||
DEBUG_TRACE("SKB MARK is NON ZERO %x\n", skb->mark);
|
||||
DEBUG_TRACE("%s: SKB MARK is NON ZERO %x\n", __FUNCTION__, skb->mark);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1741,6 +1795,8 @@ static int sfe_ipv6_recv_tcp(struct sfe_ipv6 *si, struct sk_buff *skb, struct ne
|
||||
int queue_index = 0;
|
||||
struct sfe_ipv6_connection *c;
|
||||
|
||||
int (*stat_cb)(struct skb_buff *skb);
|
||||
|
||||
/*
|
||||
* Is our packet too short to contain a valid UDP header?
|
||||
*/
|
||||
@ -2055,6 +2111,19 @@ static int sfe_ipv6_recv_tcp(struct sfe_ipv6 *si, struct sk_buff *skb, struct ne
|
||||
uint16_t tcp_csum;
|
||||
uint32_t sum;
|
||||
|
||||
//[zhangguosong start] 2018-06-26
|
||||
#if __OPEN_SUPPORT__IPV6__
|
||||
stat_cb = rcu_dereference(sfe_ipv6_stat_cb);
|
||||
if (stat_cb)
|
||||
{
|
||||
if (NF_DROP == stat_cb(skb))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
//[zhangguosong end]
|
||||
|
||||
iph->saddr = cm->xlate_src_ip[0];
|
||||
tcph->source = cm->xlate_src_port;
|
||||
|
||||
@ -2086,8 +2155,38 @@ static int sfe_ipv6_recv_tcp(struct sfe_ipv6 *si, struct sk_buff *skb, struct ne
|
||||
sum = tcp_csum + cm->xlate_dest_csum_adjustment;
|
||||
sum = (sum & 0xffff) + (sum >> 16);
|
||||
tcph->check = (uint16_t)sum;
|
||||
|
||||
//[zhangguosong start] 2018-06-27
|
||||
#if __OPEN_SUPPORT__IPV6__
|
||||
stat_cb = rcu_dereference(sfe_ipv6_stat_cb);
|
||||
if (stat_cb)
|
||||
{
|
||||
if (NF_DROP == stat_cb(skb))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
//[zhangguosong end]
|
||||
}
|
||||
|
||||
//[zhangguosong start] 2018-06-26
|
||||
#if __OPEN_SUPPORT__IPV6__
|
||||
if (unlikely(!(cm->flags & SFE_IPV6_CONNECTION_MATCH_FLAG_XLATE_SRC)) &&
|
||||
unlikely(!(cm->flags & SFE_IPV6_CONNECTION_MATCH_FLAG_XLATE_DEST)))
|
||||
{
|
||||
stat_cb = rcu_dereference(sfe_ipv6_stat_cb);
|
||||
if (stat_cb)
|
||||
{
|
||||
if (NF_DROP == stat_cb(skb))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
//[zhangguosong end]
|
||||
|
||||
/*
|
||||
* Update traffic stats.
|
||||
*/
|
||||
@ -2144,9 +2243,15 @@ static int sfe_ipv6_recv_tcp(struct sfe_ipv6 *si, struct sk_buff *skb, struct ne
|
||||
/*
|
||||
* Mark outgoing packet
|
||||
*/
|
||||
skb->mark = cm->connection->mark;
|
||||
DEBUG_TRACE("%s: cm->connection->mark = 0x%x\n", __FUNCTION__, cm->connection->mark);
|
||||
if (0 != cm->connection->mark)
|
||||
{
|
||||
skb->mark = skb->mark | cm->connection->mark;
|
||||
DEBUG_TRACE("%s: skb->mark = 0x%x\n", __FUNCTION__, skb->mark);
|
||||
}
|
||||
|
||||
if (skb->mark) {
|
||||
DEBUG_TRACE("SKB MARK is NON ZERO %x\n", skb->mark);
|
||||
DEBUG_TRACE("%s: SKB MARK is NON ZERO %x\n", __FUNCTION__, skb->mark);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user