summaryrefslogtreecommitdiffstats
path: root/target/linux/realtek/files/net/rtl/features
diff options
context:
space:
mode:
authorRoman Yeryomin <roman@advem.lv>2013-02-06 02:59:31 +0200
committerRoman Yeryomin <roman@advem.lv>2013-02-06 02:59:31 +0200
commit691cc9529efe8ea7abaab170c452ae4470bf3ac2 (patch)
tree8d18d131720975fc63c8c2abc7bd933efe503e5f /target/linux/realtek/files/net/rtl/features
parent62da0fe6152d0025e570ca41a6f9ae68df7da89b (diff)
Rebase files to rsdk 3.2 and refresh patches. Compilable (not by humans).
Signed-off-by: Roman Yeryomin <roman@advem.lv>
Diffstat (limited to 'target/linux/realtek/files/net/rtl/features')
-rw-r--r--target/linux/realtek/files/net/rtl/features/96C/rtl_features.c2202
-rw-r--r--target/linux/realtek/files/net/rtl/features/96C/rtl_ps_hooks.c819
-rw-r--r--target/linux/realtek/files/net/rtl/features/96E/rtl_nf_connGC.S (renamed from target/linux/realtek/files/net/rtl/features/96C/rtl_nf_connGC.S)1610
-rw-r--r--target/linux/realtek/files/net/rtl/features/98/rtl_features.c2202
-rw-r--r--target/linux/realtek/files/net/rtl/features/98/rtl_ps_hooks.c819
-rw-r--r--target/linux/realtek/files/net/rtl/features/9xD/rtl_nf_connGC.S2169
-rw-r--r--target/linux/realtek/files/net/rtl/features/lan_restrict.c442
-rw-r--r--target/linux/realtek/files/net/rtl/features/lan_restrict.h10
8 files changed, 3441 insertions, 6832 deletions
diff --git a/target/linux/realtek/files/net/rtl/features/96C/rtl_features.c b/target/linux/realtek/files/net/rtl/features/96C/rtl_features.c
deleted file mode 100644
index 1a5983521..000000000
--- a/target/linux/realtek/files/net/rtl/features/96C/rtl_features.c
+++ /dev/null
@@ -1,2202 +0,0 @@
-#include <linux/types.h>
-#include <linux/netfilter.h>
-#include <linux/module.h>
-#include <linux/skbuff.h>
-#include <linux/moduleparam.h>
-#include <linux/notifier.h>
-#include <linux/kernel.h>
-#include <linux/inetdevice.h>
-#include <linux/netdevice.h>
-#include <linux/ip.h>
-#include <linux/tcp.h>
-
-#if defined(CONFIG_PROC_FS)
-#include <linux/proc_fs.h>
-#endif
-
-#if defined(CONFIG_RTL_HARDWARE_NAT )&&defined(CONFIG_RTL_MULTIPLE_WAN)
-#include <net/arp.h>
-#endif
-#include <net/netfilter/nf_conntrack.h>
-#include <net/netfilter/nf_conntrack_core.h>
-#include <net/netfilter/nf_conntrack_helper.h>
-#if defined(CONFIG_RTL_HARDWARE_NAT)
-#include <net/ip_fib.h>
-#include <net/ip_vs.h>
-#include <net/netfilter/nf_nat.h>
-#include <net/netfilter/nf_nat_core.h>
-#endif
-#include <net/rtl/rtl_types.h>
-#include <net/rtl/rtl_nic.h>
-#if defined(CONFIG_RTL_HARDWARE_NAT)
-#include <net/rtl/rtl865x_nat.h>
-#endif
-
-#ifdef CONFIG_RTL_LAYERED_DRIVER_L3
-#include <net/rtl/rtl865x_ppp.h>
-#include <net/rtl/rtl865x_route_api.h>
-#include <net/rtl/rtl865x_arp_api.h>
-#endif
-
-#include <net/rtl/features/rtl_features.h>
-
-#if defined(CONFIG_RTL_IPTABLES_FAST_PATH) || defined(CONFIG_RTL_HARDWARE_NAT)
-#include <linux/netfilter/nf_conntrack_tcp.h>
-#endif
-
-#if defined(CONFIG_RTL_IPTABLES_FAST_PATH)
-#include <net/rtl/fastpath/fastpath_core.h>
-#endif
-
-#if defined(CONFIG_RTL_LOCAL_PUBLIC) || defined(CONFIG_RTL_MULTIPLE_WAN) || (defined(CONFIG_NET_SCHED)&&defined(CONFIG_RTL_IPTABLES_FAST_PATH)) || defined(CONFIG_RTL_HW_QOS_SUPPORT)
-#include <net/rtl/rtl865x_netif.h>
-#endif
-
-#if defined(CONFIG_RTL_HW_QOS_SUPPORT)
-#include <net/rtl/rtl865x_outputQueue.h>
-#endif
-
-#if defined (CONFIG_RTL_LOCAL_PUBLIC)
-#include <net/rtl/rtl865x_localPublic.h>
-extern int rtl865x_curOpMode;
-#endif
-
-#if defined(CONFIG_RTL_FAST_BRIDGE)
-#include <net/rtl/fastpath/fast_br.h>
-#endif
-
-#if defined(CONFIG_NET_SCHED)
-__DRAM_GEN int gQosEnabled;
-#endif
-
-#ifdef CONFIG_RTL_HARDWARE_NAT
-/*2007-12-19*/
-#ifdef CONFIG_RTL_LAYERED_DRIVER_L3
-#include <net/rtl/rtl865x_ip_api.h>
-#endif
-#endif
-
-#include <linux/netfilter_ipv4.h>
-#include <linux/netfilter_ipv4/ip_tables.h>
-
-#if defined(CONFIG_FAST_PATH_MODULE) && defined(CONFIG_RTL_IPTABLES_FAST_PATH)
-#include <fast_l2tp_core.h>
-enum LR_RESULT (*FastPath_hook4)( rtl_fp_napt_entry *fpNaptEntry)=NULL;
-enum LR_RESULT (*FastPath_hook6)( rtl_fp_napt_entry *fpNaptEntry,
-#if defined(IMPROVE_QOS)
- struct sk_buff *pskb, struct nf_conn *ct,
-#endif
- enum NP_FLAGS flags)=NULL;
-enum LR_RESULT (*FastPath_hook11)(rtl_fp_napt_entry *fpNaptEntry, uint32 interval)=NULL;
-int (*fast_path_hook)(struct sk_buff **pskb) = NULL;
-EXPORT_SYMBOL(FastPath_hook4);
-EXPORT_SYMBOL(FastPath_hook6);
-EXPORT_SYMBOL(FastPath_hook11);
-EXPORT_SYMBOL(fast_path_hook);
-#endif
-
-#ifdef FAST_PPTP
- void (*sync_tx_pptp_gre_seqno_hook)(struct sk_buff *skb) = NULL;
-#ifdef CONFIG_FAST_PATH_MODULE
-EXPORT_SYMBOL(sync_tx_pptp_gre_seqno_hook);
-#endif
-#endif
-
-#if defined(CONFIG_RTL_HARDWARE_NAT)
-__DRAM_GEN int gHwNatEnabled;
-
-int rtl865x_handle_nat(struct nf_conn *ct, int act, struct sk_buff *skb)
-{
- struct nf_conn_nat *nat;
- u_int32_t sip, dip, gip;
- u_int16_t sp, dp, gp, proto=0;
- u_int32_t timeval;
- int rc=0;
-
-#if defined(CONFIG_RTL_HW_QOS_SUPPORT)
- uint32 ret;
- struct net_device *lanDev, *wanDev;
-#endif
-
-#if defined(CONFIG_RTL_LAYERED_DRIVER_L4)
- rtl865x_napt_entry rtl865xNaptEntry;
- rtl865x_priority rtl865xPrio;
- rtl865x_qos_mark rtl865xQosMark;
-#endif
-
- if (gHwNatEnabled!=1)
- return -1;
-
- proto = (ct->tuplehash[0].tuple.dst.protonum==IPPROTO_TCP)? 1: 0;
-
- if (ct->status & IPS_SRC_NAT)
- { /* outbound flow */
- sip = ct->tuplehash[0].tuple.src.u3.ip;
- dip = ct->tuplehash[0].tuple.dst.u3.ip;
- gip = ct->tuplehash[1].tuple.dst.u3.ip;
- sp = (proto)? ct->tuplehash[0].tuple.src.u.tcp.port: ct->tuplehash[0].tuple.src.u.udp.port;
- dp = (proto)? ct->tuplehash[0].tuple.dst.u.tcp.port: ct->tuplehash[0].tuple.dst.u.udp.port;
- gp = (proto)? ct->tuplehash[1].tuple.dst.u.tcp.port: ct->tuplehash[1].tuple.dst.u.udp.port;
- }
- else if (ct->status & IPS_DST_NAT)
- { /* inbound flow */
- sip = ct->tuplehash[1].tuple.src.u3.ip;
- dip = ct->tuplehash[1].tuple.dst.u3.ip;
- gip = ct->tuplehash[0].tuple.dst.u3.ip;
- sp = (proto)? ct->tuplehash[1].tuple.src.u.tcp.port: ct->tuplehash[1].tuple.src.u.udp.port;
- dp = (proto)? ct->tuplehash[1].tuple.dst.u.tcp.port: ct->tuplehash[1].tuple.dst.u.udp.port;
- gp = (proto)? ct->tuplehash[0].tuple.dst.u.tcp.port: ct->tuplehash[0].tuple.dst.u.udp.port;
- }
- else
- return -1;
-
- /* do not add hardware NAPT table if protocol is UDP and source IP address is equal to gateway IP address */
- if ((act == 1) && (proto == 0) && (sip == gip))
- return -1;
-
- /* for TZO DDNS */
- if ((act == 1) && (proto == 1) && (dp == 21347)) {
- return -1;
- }
-
- if (act == 2) {
- /* query for idle */
- timeval = 0;
-#ifdef CONFIG_RTL_LAYERED_DRIVER_L4
- rtl865xNaptEntry.protocol=proto;
- rtl865xNaptEntry.intIp=sip;
- rtl865xNaptEntry.intPort=sp;
- rtl865xNaptEntry.extIp=gip;
- rtl865xNaptEntry.extPort=gp;
- rtl865xNaptEntry.remIp=dip;
- rtl865xNaptEntry.remPort=dp;
-
- timeval = rtl865x_naptSync(&rtl865xNaptEntry, 0);
-#endif
- if (timeval > 0)
- return 0;
- else
- return -1;
- }
- else if (act == 0) {
- /* delete */
- rc = 0;
-#ifdef CONFIG_RTL_LAYERED_DRIVER_L4
- rtl865xNaptEntry.protocol=proto;
- rtl865xNaptEntry.intIp=sip;
- rtl865xNaptEntry.intPort=sp;
- rtl865xNaptEntry.extIp=gip;
- rtl865xNaptEntry.extPort=gp;
- rtl865xNaptEntry.remIp=dip;
- rtl865xNaptEntry.remPort=dp;
-
- rc = rtl865x_delNaptConnection(&rtl865xNaptEntry);
-#endif
- }
- else {
- #if defined(CONFIG_RTL_HW_QOS_SUPPORT)
- if (NULL!=skb)
- {
- rtl865xNaptEntry.protocol=proto;
- rtl865xNaptEntry.intIp=sip;
- rtl865xNaptEntry.intPort=sp;
- rtl865xNaptEntry.extIp=gip;
- rtl865xNaptEntry.extPort=gp;
- rtl865xNaptEntry.remIp=dip;
- rtl865xNaptEntry.remPort=dp;
-
- rtl865xQosMark.downlinkMark=0; //Initial
- rtl865xQosMark.uplinkMark=0; //Initial
- ret=rtl_qosGetSkbMarkByNaptEntry(&rtl865xNaptEntry, &rtl865xQosMark, skb);
-
- lanDev=rtl865x_getLanDev();
- wanDev=rtl865x_getWanDev();
- rtl865xPrio.downlinkPrio=rtl_qosGetPriorityByMark(lanDev->name, rtl865xQosMark.downlinkMark);
- rtl865xPrio.uplinkPrio=rtl_qosGetPriorityByMark(wanDev->name, rtl865xQosMark.uplinkMark);
-
- if(lanDev)
- dev_put(lanDev);
-
- if(wanDev)
- dev_put(wanDev);
- } else
- #endif
- {
- rtl865xPrio.downlinkPrio=0;
- rtl865xPrio.uplinkPrio=0;
- }
-
-#if defined(CONFIG_RTL_LAYERED_DRIVER_L4)
- rtl865xNaptEntry.protocol=proto;
- rtl865xNaptEntry.intIp=sip;
- rtl865xNaptEntry.intPort=sp;
- rtl865xNaptEntry.extIp=gip;
- rtl865xNaptEntry.extPort=gp;
- rtl865xNaptEntry.remIp=dip;
- rtl865xNaptEntry.remPort=dp;
-#endif
-
- /* add */
-#if defined(CONFIG_PROC_FS) && defined(CONFIG_NET_SCHED) && !defined(CONFIG_RTL_HW_QOS_SUPPORT)
- if (gQosEnabled == 0)
- {
-#ifdef CONFIG_RTL_LAYERED_DRIVER_L4
- rc = rtl865x_addNaptConnection(&rtl865xNaptEntry, &rtl865xPrio);
-#endif
- }
- else
- {
- act = 0;
- }
-#else
-#ifdef CONFIG_RTL_LAYERED_DRIVER_L4
- rc = rtl865x_addNaptConnection(&rtl865xNaptEntry, &rtl865xPrio);
-#endif
-
-#endif
- }
-
- nat = nfct_nat(ct);
- if (!rc && nat && act == 1) /* mark it as an asic entry */
- nat->hw_acc = 1;
- if (!rc && nat && act == 0) /* unmark it */
- nat->hw_acc = 0;
-
- #ifdef CONFIG_HARDWARE_NAT_DEBUG
- /*2007-12-19*/
- DEBUGP("%s:%d:(%s): errno=%d\n %s (%u.%u.%u.%u:%u -> %u.%u.%u.%u:%u) g:(%u.%u.%u.%u:%u)\n",
- __FUNCTION__,__LINE__,((is_add)?"add_nat": "del_nat"), rc, ((proto)? "tcp": "udp"),
- NIPQUAD(sip), sp, NIPQUAD(dip), dp, NIPQUAD(gip), gp);
- #endif
-
- return 0;
-}
-
-/* return value:
- FAILED: ct should be delete
- SUCCESS: ct should NOT be delete.
-*/
-int rtl_hwnat_timer_update(struct nf_conn *ct)
-{
- unsigned long expires, now;
- struct nf_conn_nat *nat;
-
- if (gHwNatEnabled!=1)
- return FAILED;
-
- nat = nfct_nat(ct);
- if (nat==NULL || nat->hw_acc!=1)
- return FAILED;
-
- now = jiffies;
- //read_lock_bh(&nf_conntrack_lock);
- if (ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum == IPPROTO_UDP) {
- if(ct->status & IPS_SEEN_REPLY)
- expires = nf_ct_udp_timeout_stream;
- else
- expires = nf_ct_udp_timeout;
- } else if (ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum == IPPROTO_TCP &&
- ct->proto.tcp.state < TCP_CONNTRACK_LAST_ACK) {
- expires = tcp_get_timeouts_by_state(ct->proto.tcp.state);
- } else {
- //read_unlock_bh(&nf_conntrack_lock);
- return FAILED;
- }
- //read_unlock_bh(&nf_conntrack_lock);
-
- if (!rtl865x_handle_nat(ct, 2, NULL)) {
- /* update ct expires time */
- ct->timeout.expires = now+expires;
- rtl_check_for_acc(ct, (now+expires));
- return SUCCESS;
- } else
- return FAILED;
-
-}
-#endif
-
-
-#if defined(CONFIG_RTL_IPTABLES_FAST_PATH) || defined(CONFIG_RTL_HARDWARE_NAT)
-int smart_count=0;
-unsigned long smart_count_start_timer;
-unsigned int _br0_ip;
-unsigned int _br0_mask;
-static void get_br0_ip_mask(void)
-{
- struct in_device *in_dev;
- struct net_device *landev;
- struct in_ifaddr *ifap = NULL;
-
- if ((landev = __dev_get_by_name(&init_net, RTL_PS_BR0_DEV_NAME)) != NULL){
- in_dev=(struct in_device *)(landev->ip_ptr);
- if (in_dev != NULL) {
- for (ifap=in_dev->ifa_list; ifap != NULL; ifap=ifap->ifa_next) {
- if (strcmp(RTL_PS_BR0_DEV_NAME, ifap->ifa_label) == 0){
- _br0_ip = ifap->ifa_address;
- _br0_mask = ifap->ifa_mask;
- return;
- }
- }
-
- }
- }
-}
-
-/* return value:
- FAILED: ct should be delete
- SUCCESS: ct should NOT be delete.
-*/
-void rtl_delConnCache(struct nf_conn *ct)
-{
- #if defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- enum NP_PROTOCOL protocol;
- rtl_fp_napt_entry rtlFpNaptEntry;
- #endif
- #ifdef CONFIG_RTL_HARDWARE_NAT
- struct nf_conn_nat *nat;
- #endif
-
- if (ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum == IPPROTO_TCP) {
- #if defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- protocol = NP_TCP;
- #endif
- } else if (ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum == IPPROTO_UDP) {
- #if defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- protocol = NP_UDP;
- #endif
- } else {
- return;
- }
-
- spin_lock_bh(&nf_conntrack_lock);
- #if defined(CONFIG_RTL_HARDWARE_NAT)
- nat = nfct_nat(ct);
- if ((nat!=NULL) && (nat->hw_acc==1)) {
- rtl865x_handle_nat(ct, 0, NULL);
- }
- #endif
-
- #if defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- if(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip
- == ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip) {
- /*case WAN->LAN(BC->AB) use C|A-B*/
-
- rtlFpNaptEntry.protocol=protocol;
- rtlFpNaptEntry.intIp=ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3.ip;
- rtlFpNaptEntry.intPort=ntohs(ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u.all);
- rtlFpNaptEntry.extIp=ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.u3.ip;
- rtlFpNaptEntry.extPort=ntohs(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.u.all);
- rtlFpNaptEntry.remIp=ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip;
- rtlFpNaptEntry.remPort=ntohs(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u.all);
-
- #ifdef CONFIG_FAST_PATH_MODULE
- if(FastPath_hook4!=NULL)
- {
- FastPath_hook4(&rtlFpNaptEntry) ;
- }
- #else
- rtk_delNaptConnection(&rtlFpNaptEntry) ;
- #endif
- } else if (ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.u3.ip
- == ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3.ip) {
- /*case LAN->WAN(AB->BC) use A|C-B*/
-
- rtlFpNaptEntry.protocol=protocol;
- rtlFpNaptEntry.intIp=ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip;
- rtlFpNaptEntry.intPort=ntohs(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u.all);
- rtlFpNaptEntry.extIp=ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip;
- rtlFpNaptEntry.extPort=ntohs(ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u.all);
- rtlFpNaptEntry.remIp=ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3.ip;
- rtlFpNaptEntry.remPort=ntohs(ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u.all);
-
- #ifdef CONFIG_FAST_PATH_MODULE
- if(FastPath_hook4!=NULL)
- {
- FastPath_hook4(&rtlFpNaptEntry);
- }
- #else
- rtk_delNaptConnection(&rtlFpNaptEntry);
- #endif
- }
- #endif
- spin_unlock_bh(&nf_conntrack_lock);
-}
-
-void rtl_check_for_acc(struct nf_conn *ct, unsigned long expires)
-{
- #if defined(CONFIG_RTL_NF_CONNTRACK_GARBAGE_NEW)
- int newstate;
- struct list_head* state_hash;
-
- write_lock_bh(&nf_conntrack_lock);
- if (ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum == IPPROTO_TCP) {
- newstate = ct->proto.tcp.state;
- state_hash = Tcp_State_Hash_Head[newstate].state_hash;
- } else if (ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum == IPPROTO_UDP) {
- if(ct->status & IPS_SEEN_REPLY)
- newstate = 1;
- else
- newstate = 0;
- state_hash = Udp_State_Hash_Head[newstate].state_hash;
- } else {
- write_unlock_bh(&nf_conntrack_lock);
- return;
- }
-
- list_move_tail(&ct->state_tuple, state_hash);
- write_unlock_bh(&nf_conntrack_lock);
- #endif
-}
-
-int32 rtl_connCache_timer_update(struct nf_conn *ct)
-{
- spin_lock_bh(&nf_conntrack_lock);
- if (time_after_eq(jiffies, ct->timeout.expires)) {
- #if defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- if (SUCCESS==rtl_fpTimer_update(ct)) {
- add_timer(&ct->timeout);
- spin_unlock_bh(&nf_conntrack_lock);
- return SUCCESS;
- }
- #endif
-
- #if defined(CONFIG_RTL_HARDWARE_NAT)
- if (SUCCESS==rtl_hwnat_timer_update(ct)) {
- add_timer(&ct->timeout);
- spin_unlock_bh(&nf_conntrack_lock);
- return SUCCESS;
- }
- #endif
- }
- spin_unlock_bh(&nf_conntrack_lock);
- return FAILED;
-}
-
-#if defined(IMPROVE_QOS)
-/*
- * ### for iperf application test ###
- * the behavior of iperf UDP test is LAN PC (client) will burst UDP from LAN to WAN (by one way),
- * WAN PC (server) will only send one UDP packet (statistics) at the end of test.
- * so the fastpath or hardware NAT will create link at the end of test.
- *
- * the purpose for adding the following code is to create fastpath or hardware NAT link
- * when we only get one packet from LAN to WAN in UDP case.
- */
-static inline int32 rtl_addConnCheck(struct nf_conn *ct, struct iphdr *iph, struct sk_buff *skb)
-{
- extern unsigned int _br0_ip;
- extern unsigned int _br0_mask;
- extern int smart_count;
- extern unsigned long smart_count_start_timer;
- struct tcphdr *tcph;
- uint32 sip, dip;
- int32 create_conn;
-
- sip = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip;
- dip = ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3.ip;
- create_conn = FALSE;
-
- if (((ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.u3.ip
- == ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3.ip) ||
- (ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip
- == ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip))
- #if defined(UNNUMBER_IP)
- && (is_unnumber_ip(dip)==FALSE)
- #endif
- ) {
- /* UDP and "LAN to WAN" */
- /* ignore some cases:
- * 1. sip = br0's ip -----> (ex. sip 192.168.1.254 ==> dip 239.255.255.250)
- * 2. (sip & br0's mask) != (br0's ip & br0's mask) -----> sip is not in br0's subnet
- * 3. (dip & br0's mask) = (br0's ip & br0's mask) -----> dip is in br0's subnet
- * 4. dip != multicast IP address
- * 5. sip != gip
- */
- if (iph->protocol == IPPROTO_UDP) {
- if ((ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.u3.ip
- == ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3.ip)&&
- (sip != _br0_ip) &&
- ((sip & _br0_mask) == (_br0_ip & _br0_mask)) &&
- ((dip & _br0_mask) != (_br0_ip & _br0_mask)) &&
- ((dip & 0xf0000000) != 0xe0000000) &&
- (sip != (ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip))) {
- create_conn = TRUE;
- } else if ((ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip
- == ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip)&&
- ((sip & _br0_mask) != (_br0_ip & _br0_mask))&&
- ((dip & _br0_mask) == (_br0_ip & _br0_mask))&&
- (iph->daddr ==dip)) {
- create_conn = TRUE;
- }
- } else if (iph->protocol == IPPROTO_TCP) {
- tcph=(void *) iph + iph->ihl*4;
- if (!tcph->fin && !tcph->syn && !tcph->rst && tcph->psh==1 &&
- tcph->ack ==1 &&
- (((ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.u3.ip==ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3.ip) &&
- (iph->daddr !=_br0_ip) && ((sip & _br0_mask) == (_br0_ip & _br0_mask)) &&
- ((dip & _br0_mask) != (_br0_ip & _br0_mask)) && (sip != (ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip)))||
- ((ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip==ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip) &&
- ((sip & _br0_mask) != (_br0_ip & _br0_mask)) &&
- ((dip & _br0_mask) == (_br0_ip & _br0_mask))&& (sip == iph->saddr)))) {
-
- if (smart_count==0) {
- smart_count_start_timer = jiffies+HZ;
- }
-
- if (time_after(jiffies, smart_count_start_timer)) {
- smart_count_start_timer = jiffies+HZ;
- smart_count=0;
- }
-
- smart_count++;
- if(smart_count >810){
- //panic_printk("the case hit for mart flow:tcp state=%d, assured=%d\n",ct->proto.tcp.state,test_bit(IPS_ASSURED_BIT, &ct->status));
- create_conn=TRUE;
- }
- }
- } else {
- return create_conn;
- }
-
-#if defined(UNNUMBER_IP)
- if ((!create_conn)
- && (is_unnumber_ip(sip)==TRUE))
- ){
- create_conn = TRUE;
- }
-#endif
- }
-
- return create_conn;
-}
-
-void rtl_addConnCache(struct nf_conn *ct, struct sk_buff *skb)
-{
- int assured;
- int create_conn;
- struct iphdr *iph;
- #if defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- enum NP_PROTOCOL protocol;
- rtl_fp_napt_entry rtlFpNaptEntry;
- #endif
-
- if (nfct_help(ct))
- return;
-
- iph=ip_hdr(skb);
- if (iph->protocol== IPPROTO_TCP) {
- assured = ((ct->proto.tcp.state==TCP_CONNTRACK_ESTABLISHED)&&
- (test_bit(IPS_DST_NAT_DONE_BIT, &ct->status) ||
- test_bit(IPS_SRC_NAT_DONE_BIT, &ct->status)));
-
- #if defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- protocol = NP_TCP;
- #endif
- } else if (iph->protocol== IPPROTO_UDP) {
- assured = (test_bit(IPS_DST_NAT_DONE_BIT, &ct->status) ||
- test_bit(IPS_SRC_NAT_DONE_BIT, &ct->status));
-
- #if defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- protocol = NP_UDP;
- #endif
- } else {
- return;
- }
-
-
- if (!assured) {
- create_conn = rtl_addConnCheck(ct, iph, skb);
- } else
- create_conn = 0;
-
- #if defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- /*1.add "!(ct->helper)" to fix ftp-cmd type packet
- 2.add identify case LAN->WAN(AB->BC) or WAN->LAN(BC->AB)
- 3.add !(ct->nat.info.helper) for best ALG avoid
- */
- if (assured || create_conn) {
- if(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip
- == ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip) {
- /*case BC->AB*/
- /* wan->lan */
-
- rtlFpNaptEntry.protocol=protocol;
- rtlFpNaptEntry.intIp=ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3.ip;
- rtlFpNaptEntry.intPort=ntohs(ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u.all);
- rtlFpNaptEntry.extIp=ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.u3.ip;
- rtlFpNaptEntry.extPort=ntohs(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.u.all);
- rtlFpNaptEntry.remIp=ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip;
- rtlFpNaptEntry.remPort=ntohs(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u.all);
-
- #ifdef CONFIG_FAST_PATH_MODULE
- if(FastPath_hook6!=NULL)
- {
- FastPath_hook6(&rtlFpNaptEntry,
- skb, ct,
- NP_NONE);
- }
- #else
- rtk_addNaptConnection(&rtlFpNaptEntry,
- skb, ct,
- NP_NONE);
- #endif
- } else if (ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.u3.ip
- == ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3.ip) {
- /*case AB->BC*/
- /* lan->wan */
-
- rtlFpNaptEntry.protocol=protocol;
- rtlFpNaptEntry.intIp=ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip;
- rtlFpNaptEntry.intPort=ntohs(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u.all);
- rtlFpNaptEntry.extIp=ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip;
- rtlFpNaptEntry.extPort=ntohs(ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u.all);
- rtlFpNaptEntry.remIp=ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3.ip;
- rtlFpNaptEntry.remPort=ntohs(ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u.all);
-
- #ifdef CONFIG_FAST_PATH_MODULE
- if(FastPath_hook6!=NULL)
- {
- FastPath_hook6(&rtlFpNaptEntry,
- skb, ct,
- NP_NONE);
- }
- #else
- rtk_addNaptConnection(&rtlFpNaptEntry,
- skb, ct,
- NP_NONE);
- #endif
- }
- }
- #endif
-
- #if defined(CONFIG_RTL_HARDWARE_NAT)
- /*2007-12-19*/
- #if !defined(CONFIG_RTL865x_TCPFLOW_NONE_STATUS_CHECK)
- if (assured || create_conn)
- #endif
- {
- rtl865x_handle_nat(ct, 1, skb);
- }
- #endif
-}
-#else /* !defined(IMPROVE_QOS) */
-/*
- * ### for iperf application test ###
- * the behavior of iperf UDP test is LAN PC (client) will burst UDP from LAN to WAN (by one way),
- * WAN PC (server) will only send one UDP packet (statistics) at the end of test.
- * so the fastpath or hardware NAT will create link at the end of test.
- *
- * the purpose for adding the following code is to create fastpath or hardware NAT link
- * when we only get one packet from LAN to WAN in UDP case.
- */
-static int32 rtl_fpAddConnCheck(struct nf_conn *ct, struct iphdr *iph, struct sk_buff *skb)
-{
- extern unsigned int _br0_ip;
- extern unsigned int _br0_mask;
- struct tcphdr *tcph;
- uint32 sip, dip;
- int32 create_conn;
-
- sip = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip;
- dip = ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3.ip;
- create_conn = FALSE;
-
- if ((ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.u3.ip
- == ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3.ip)
- #if defined(UNNUMBER_IP)
- && (is_unnumber_ip(dip)==FALSE)
- #endif
- ) {
- /* lan -> wan */
- if (iph->protocol == IPPROTO_UDP &&
- (sip != _br0_ip) &&
- ((sip & _br0_mask) == (_br0_ip & _br0_mask)) &&
- ((dip & _br0_mask) != (_br0_ip & _br0_mask)) &&
- (!IS_CLASSD_ADDR(dip)) &&
- (sip != (ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip))
- ) {
- create_conn = TRUE;
- /* copied from last 2 line of this function **/
- set_bit(IPS_SEEN_REPLY_BIT, &ct->status);
- /* next 3 lines are copied from udp_packet() in ip_conntrack_proto_udp.c */
- nf_ct_refresh(ct,skb, nf_ct_udp_timeout_stream);
- /* Also, more likely to be important, and not a probe */
- set_bit(IPS_ASSURED_BIT, &ct->status);
- } else if (iph->protocol == IPPROTO_TCP) {
- tcph=(void *) iph + iph->ihl*4;
- if (!tcph->fin && !tcph->syn && !tcph->rst && tcph->psh==1 &&
- tcph->ack ==TRUE && (iph->daddr !=_br0_ip) && ((sip & _br0_mask) == (_br0_ip & _br0_mask)) &&
- ((dip & _br0_mask) != (_br0_ip & _br0_mask)) && (sip != (ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip))) {
-
- if (smart_count==0) {
- smart_count_start_timer = jiffies+HZ;
- }
-
- if (time_after(jiffies, smart_count_start_timer)) {
- smart_count_start_timer = jiffies+HZ;
- smart_count=0;
- }
-
- smart_count++;
- if(smart_count >810){
- //panic_printk("the case hit for mart flow:tcp state=%d, assured=%d\n",ct->proto.tcp.state,test_bit(IPS_ASSURED_BIT, &ct->status));
- create_conn=TRUE;
- }
- }
- } else {
- return FALSE;
- }
-
-#if defined(UNNUMBER_IP)
- if ((!create_conn)
- && (is_unnumber_ip(sip)==TRUE))
- ){
- create_conn = TRUE;
- }
-#endif
- }
-
- return create_conn;
-}
-
-void rtl_fpAddConnCache(struct nf_conn *ct, struct sk_buff *skb)
-{
- int assured;
- int create_conn;
- struct iphdr *iph;
- enum NP_PROTOCOL protocol;
- rtl_fp_napt_entry rtlFpNaptEntry;
-
- if (nfct_help(ct))
- return;
-
- iph=ip_hdr(skb);
- create_conn = rtl_fpAddConnCheck(ct, iph, skb);
- assured = test_bit(IPS_ASSURED_BIT, &ct->status);
-
- /*1.add "!(ct->helper)" to fix ftp-cmd type packet
- 2.add identify case LAN->WAN(AB->BC) or WAN->LAN(BC->AB)
- 3.add !(ct->nat.info.helper) for best ALG avoid
- */
-
- if ((assured) || (TRUE==create_conn))
- {
- if (ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum == IPPROTO_TCP) {
- protocol = NP_TCP;
- } else if (ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum == IPPROTO_UDP) {
- protocol = NP_UDP;
- }
-
- if(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip
- == ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip) {
- /*case BC->AB*/
- /* wan->lan */
-
- rtlFpNaptEntry.protocol=protocol;
- rtlFpNaptEntry.intIp=ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3.ip;
- rtlFpNaptEntry.intPort=ntohs(ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u.all);
- rtlFpNaptEntry.extIp=ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.u3.ip;
- rtlFpNaptEntry.extPort=ntohs(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.u.all);
- rtlFpNaptEntry.remIp=ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip;
- rtlFpNaptEntry.remPort=ntohs(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u.all);
-
- #ifdef CONFIG_FAST_PATH_MODULE
- if(FastPath_hook6!=NULL)
- {
- FastPath_hook6(&rtlFpNaptEntry,
- NP_NONE);
- }
- #else
- rtk_addNaptConnection(&rtlFpNaptEntry,
- NP_NONE);
- #endif
- } else if (ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.u3.ip
- == ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3.ip) {
- /*case AB->BC*/
- /* lan->wan */
-
- rtlFpNaptEntry.protocol=protocol;
- rtlFpNaptEntry.intIp=ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip;
- rtlFpNaptEntry.intPort=ntohs(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u.all);
- rtlFpNaptEntry.extIp=ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip;
- rtlFpNaptEntry.extPort=ntohs(ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u.all);
- rtlFpNaptEntry.remIp=ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3.ip;
- rtlFpNaptEntry.remPort=ntohs(ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u.all);
-
- #ifdef CONFIG_FAST_PATH_MODULE
- if(FastPath_hook6!=NULL)
- {
- FastPath_hook6(&rtlFpNaptEntry,
- NP_NONE);
- }
- #else
- rtk_addNaptConnection(&rtlFpNaptEntry,
- NP_NONE);
- #endif
- }
- }
-
-}
-#endif /* defined(IMPROVE_QOS) */
-
-#endif
-
-#if defined(CONFIG_PROC_FS) && defined(CONFIG_RTL_HARDWARE_NAT )
-static struct proc_dir_entry *proc_hw_nat=NULL;
-static char gHwNatSetting[16];
-//extern unsigned int ldst, lmask, wdst, wmask;
-
-static int hw_nat_read_proc(char *page, char **start, off_t off,
- int count, int *eof, void *data)
-{
- int len;
-
- len = sprintf(page, "%s\n", gHwNatSetting);
-
- if (len <= off+count) *eof = 1;
- *start = page + off;
- len -= off;
- if (len>count) len = count;
- if (len<0) len = 0;
- return len;
-}
-
-static int hw_nat_write_proc(struct file *file, const char *buffer,
- unsigned long count, void *data)
-{
- if (count < 2)
- return -EFAULT;
-
- if (buffer && !copy_from_user(&gHwNatSetting, buffer, 8)) {
- if (gHwNatSetting[0] == '0') { /* hardware NAT disabled, operation mode = gateway */
- gHwNatEnabled = 0;
- rtl865x_nat_reinit();
- rtl865x_changeOpMode(GATEWAY_MODE);
- //rtl8651_setAsicOperationLayer(4);
- }
- else if (gHwNatSetting[0] == '1') { /* hardware NAT enabled, operation mode = gateway */
-
- rtl865x_changeOpMode(GATEWAY_MODE);
- //rtl8651_setAsicOperationLayer(4);
- gHwNatEnabled = 1;
- }
- else if (gHwNatSetting[0] == '2') { /* hardware NAT enabled, operation mode = bridge mode*/
- //rtl865x_delRoute(wdst, wmask);
- //rtl865x_delRoute(ldst, lmask);
- rtl865x_changeOpMode(BRIDGE_MODE);
- //rtl8651_setAsicOperationLayer(3);
- gHwNatEnabled = 2;
- }
- else if(gHwNatSetting[0] == '3'){ /* hardware NAT enabled, operation mode = wisp mode */
- rtl865x_changeOpMode(WISP_MODE);
- //rtl8651_setAsicOperationLayer(3);
- gHwNatEnabled = 3;
- }
- else if ((gHwNatSetting[0] == '8')&&
- ((gHwNatSetting[1] == '5') /* L2TP */
- ||(gHwNatSetting[1] == '4') /* PPTP */))
- {
- gHwNatEnabled = 0;
- }
- #if defined(CONFIG_RTL_HARDWARE_NAT) || defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- else if (gHwNatSetting[0] == '9') {
- get_br0_ip_mask();
- }
- #endif
- return count;
- }
- return -EFAULT;
-}
-#endif
-
-#if defined(CONFIG_RTL_819X) && (defined(CONFIG_PROC_FS) && !defined(CONFIG_RTL_HARDWARE_NAT))
-static struct proc_dir_entry *proc_sw_nat=NULL;
-static char gSwNatSetting[16];
-
-static int sw_nat_read_proc(char *page, char **start, off_t off,
- int count, int *eof, void *data)
-{
- int len;
-
- len = sprintf(page, "%s\n", gSwNatSetting);
-
- if (len <= off+count) *eof = 1;
- *start = page + off;
- len -= off;
- if (len>count) len = count;
- if (len<0) len = 0;
- return len;
-}
-
-static int sw_nat_write_proc(struct file *file, const char *buffer,
- unsigned long count, void *data)
-{
- if (count < 2)
- return -EFAULT;
-
- if (buffer && !copy_from_user(&gSwNatSetting, buffer, 8)) {
- if (gSwNatSetting[0] == '0'){ /* operation mode = GATEWAY */
- //SoftNAT_OP_Mode(2);
- rtl865x_changeOpMode(GATEWAY_MODE);
- //rtl8651_setAsicOperationLayer(2);
- }
- else if (gSwNatSetting[0] == '1'){ /* operation mode = BRIDGE*/
- //SoftNAT_OP_Mode(1);
- rtl865x_changeOpMode(BRIDGE_MODE);
- //rtl8651_setAsicOperationLayer(2);
- }
- else if(gSwNatSetting[0] == '2'){ /* operation mode = WISP */
- rtl865x_changeOpMode(WISP_MODE);
- //rtl8651_setAsicOperationLayer(2);
- }
-#if defined(CONFIG_RTL_HARDWARE_NAT) || defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- else if(gSwNatSetting[0] == '9'){
- get_br0_ip_mask();
- }
-#endif
- return count;
- }
- return -EFAULT;
-}
-#endif /* defined(CONFIG_RTL_819X) && (defined(CONFIG_PROC_FS) && !defined(CONFIG_RTL_HARDWARE_NAT)) */
-
-#if defined(CONFIG_RTL_819X)
-int32 rtl_nat_init(void)
-{
- #if defined(CONFIG_PROC_FS) && defined(CONFIG_RTL_HARDWARE_NAT)
- proc_hw_nat = create_proc_entry("hw_nat", 0, NULL);
- if (proc_hw_nat) {
- proc_hw_nat->read_proc = hw_nat_read_proc;
- proc_hw_nat->write_proc = hw_nat_write_proc;
- }
- #endif
-
- #if defined(CONFIG_PROC_FS) && !defined(CONFIG_RTL_HARDWARE_NAT)
- proc_sw_nat = create_proc_entry("sw_nat", 0, NULL);
- if (proc_sw_nat) {
- proc_sw_nat->read_proc = sw_nat_read_proc;
- proc_sw_nat->write_proc = sw_nat_write_proc;
- }
- #endif
-
- #if defined(CONFIG_RTL_HARDWARE_NAT)
- gHwNatEnabled=1;
- #endif
-
- return SUCCESS;
-}
-#endif
-
-#if defined(CONFIG_RTL_LOCAL_PUBLIC) || defined(CONFIG_RTL_MULTIPLE_WAN) || (defined(CONFIG_NET_SCHED)&&defined(CONFIG_RTL_IPTABLES_FAST_PATH))
-extern int rtl865x_curOpMode;
-struct net_device *rtl865x_getWanDev(void )
-{
- struct net_device * wanDev=NULL;
-
- if(rtl865x_curOpMode==GATEWAY_MODE)
- {
-#if defined(CONFIG_RTL_PUBLIC_SSID)
- wanDev=dev_get_by_name(&init_net,RTL_GW_WAN_DEVICE_NAME);
-#else
- //Try ppp0 first
- wanDev=dev_get_by_name(&init_net,RTL_PS_PPP0_DEV_NAME);
- if(wanDev==NULL)
- {
- //Try eth1 then
- wanDev=dev_get_by_name(&init_net,RTL_PS_WAN0_DEV_NAME);
- }
-#endif
- }
- else if(rtl865x_curOpMode==WISP_MODE)
- {
-#if defined(CONFIG_RTL_PUBLIC_SSID)
- wanDev=dev_get_by_name(&init_net,RTL_WISP_WAN_DEVICE_NAME);
-#else
- wanDev=dev_get_by_name(&init_net,RTL_PS_WLAN0_DEV_NAME);
-#endif
- }
- else if(rtl865x_curOpMode==BRIDGE_MODE)
- {
-#if defined(CONFIG_RTL_PUBLIC_SSID)
- wanDev=dev_get_by_name(&init_net,RTL_BR_WAN_DEVICE_NAME);
-#else
- wanDev=dev_get_by_name(&init_net,RTL_PS_BR0_DEV_NAME);
-#endif
- }
-
- return wanDev;
-}
-
-struct net_device *rtl865x_getLanDev(void )
-{
- struct net_device * lanDev=NULL;
- lanDev=dev_get_by_name(&init_net,RTL_PS_BR0_DEV_NAME);
- return lanDev;
-}
-#endif
-
-#if defined (CONFIG_RTL_LOCAL_PUBLIC) || defined(CONFIG_RTL_HW_QOS_SUPPORT)
-int rtl865x_attainDevType(unsigned char *devName, unsigned int *isLanDev, unsigned int *isWanDev)
-{
- *isLanDev=0;
- *isWanDev=0;
- if(rtl865x_curOpMode==GATEWAY_MODE)
- {
-#if defined(CONFIG_RTL_PUBLIC_SSID)
- if(strncmp(devName, RTL_PS_WAN0_DEV_NAME, 4) ==0 || strncmp(devName, RTL_GW_WAN_DEVICE_NAME, 3) ==0 ||
- rtl865x_from_public_ssid_device(devName)
- )
-#else
- if(strncmp(devName, RTL_PS_WAN0_DEV_NAME, 4) ==0)
-#endif
- {
- *isWanDev=1;
- }
- else if( (strncmp(devName, RTL_PS_BR0_DEV_NAME, 3) ==0)||
- (strncmp(devName, RTL_PS_ETH_NAME, 3) ==0) ||
- (strncmp(devName, RTL_PS_WLAN_NAME, 4) ==0))
- {
- *isLanDev=1;
- }
- else
- {
- return -1;
- }
-
- }
- else if(rtl865x_curOpMode==WISP_MODE)
- {
- if(strncmp(devName, RTL_PS_WAN0_DEV_NAME, 4)==0)
- {
- *isWanDev=1;
- }
- else if( (strncmp(devName, RTL_PS_BR0_DEV_NAME, 3) ==0) ||
- (strncmp(devName, RTL_PS_ETH_NAME, 3) ==0))
- {
- *isLanDev=1;
- }
- else
- {
- return -1;
- }
- }
- else if(rtl865x_curOpMode==BRIDGE_MODE)
- {
- if( (strncmp(devName, RTL_PS_BR0_DEV_NAME, 3) ==0) ||
- (strncmp(devName, RTL_PS_ETH_NAME, 3) ==0) ||
- (strncmp(devName, RTL_PS_WLAN_NAME, 4) ==0))
- {
- *isLanDev=0;
- }
- else
- {
- return -1;
- }
- }
- else
- {
- return -1;
- }
-
- return 0;
-}
-#endif
-
-#if defined (CONFIG_RTL_LOCAL_PUBLIC)
-int rtl865x_localPublicRx(struct sk_buff *skb)
-{
- struct rtl865x_pktInfo pktInfo;
- unsigned int rxFromLan, rxFromWan;
-
- if(rtl865x_localPublicEnabled() ==0)
- {
- goto end_of_local_public_rx;
- }
-
- if(rtl865x_attainDevType(skb->dev->name, &rxFromLan, &rxFromWan))
- {
- return NET_RX_SUCCESS;
- }
-
- if(skb->localPublicFlags == 0x1)
- {
- //local public has done
- return NET_RX_SUCCESS;
- }
- #if 0
- printk("%s:%d,skb->dev->name is %s,rxFromLan is %d,rxFromWan is %d\n",__FUNCTION__,__LINE__,skb->dev->name,rxFromLan,rxFromWan);
- printk("EtherType: 0x%x\n", *((uint16*)&skb->mac.raw[12]));
- printk("%x:%x:%x:%x:%x:%x ==> %x:%x:%x:%x:%x:%x \n\n",
- skb->mac.raw[6], skb->mac.raw[7], skb->mac.raw[8],
- skb->mac.raw[9], skb->mac.raw[10], skb->mac.raw[11],
- skb->mac.raw[0], skb->mac.raw[1], skb->mac.raw[2],
- skb->mac.raw[3], skb->mac.raw[4], skb->mac.raw[5]);
- #endif
- if(rxFromWan)
- {
- /*rx from ethernet wan*/
- /*direction WAN--->LAN*/
- //pktInfo.data=skb->mac.raw;
- pktInfo.data=skb_mac_header(skb);
- pktInfo.action=RX_WAN_PACKET;
- rtl865x_checkLocalPublic(&pktInfo);
-
- if(pktInfo.fromLocalPublic==1)
- {
- kfree_skb(skb);
- return NET_RX_DROP;
- }
- else if(pktInfo.toLocalPublic==1)
- {
-
- skb->pkt_type=PACKET_HOST;
- //printk("%s:%d,pktInfo.fromLocalPublic is %d,pktInfo.toLocalPublic is %d\n",__FUNCTION__,__LINE__,pktInfo.fromLocalPublic,pktInfo.toLocalPublic );
- memcpy(eth_hdr(skb)->h_dest, skb->dev->dev_addr, 6);
- }
-
- }
- else if (rxFromLan)
- {
- /*rx from ethernet lan*/
- pktInfo.data=skb_mac_header(skb);
- pktInfo.port=skb->srcPort;
- pktInfo.action=RX_LAN_PACKET;
- strcpy(pktInfo.dev, skb->dev->name);
- rtl865x_checkLocalPublic(&pktInfo);
- //printk("%s:%d,pktInfo.fromLocalPublic is %d,pktInfo.toLocalPublic is %d\n",__FUNCTION__,__LINE__,pktInfo.fromLocalPublic,pktInfo.toLocalPublic );
- if(pktInfo.fromLocalPublic==1)
- {
- skb->fromLocalPublic=1;
- skb->srcLocalPublicIp=pktInfo.srcIp;
- //if(pktInfo.toLocalPublic==1)
- {
- skb->pkt_type=PACKET_HOST;
- memcpy(eth_hdr(skb)->h_dest, skb->dev->dev_addr, 6);
- #if 0
- dest = eth_hdr(skb)->h_dest;
- src = eth_hdr(skb)->h_source;
- printk("=========%s(%d),dst(%x:%x:%x:%x:%x:%x),src(%x:%x:%x:%x:%x:%x)\n",__FUNCTION__,__LINE__,
- dest[0],dest[1],dest[2],dest[3],dest[4],dest[5],
- src[0],src[1],src[2],src[3],src[4],src[5]);
- #endif
-
- }
- }
-
- }
- skb->localPublicFlags = 0x1;
-
-end_of_local_public_rx:
- return NET_RX_SUCCESS;
-}
-
-int rtl865x_localPublicTx(struct sk_buff *skb, struct net_device *dev)
-{
- unsigned int txToLan, txToWan;
- if(rtl865x_attainDevType(skb->dev->name, &txToLan, &txToWan))
- {
- return NET_RX_SUCCESS;
- }
-
- if(txToWan)
- {
- if((skb->fromLocalPublic==1) && (skb->srcLocalPublicIp!=0))
- {
- rtl865x_getLocalPublicMac(skb->srcLocalPublicIp, eth_hdr(skb)->h_source);
- }
-
- }
- else if (txToLan)
- {
- /*needn't do anything*/
-
- }
- return NET_RX_SUCCESS;
-}
-
-#endif
-
-int rtl865x_getDevIpAndNetmask(struct net_device * dev, unsigned int *ipAddr, unsigned int *netMask )
-{
- struct in_device *in_dev;
- struct in_ifaddr *ifap = NULL;
-
- if((dev==NULL) || (ipAddr==NULL) || (netMask==NULL))
- {
- return FAILED;
- }
-
- *ipAddr=0;
- *netMask=0;
-
- in_dev=(struct net_device *)(dev->ip_ptr);
- if (in_dev != NULL) {
- for (ifap=in_dev->ifa_list; ifap != NULL; ifap=ifap->ifa_next) {
- if (strcmp(dev->name, ifap->ifa_label) == 0){
- *ipAddr = ifap->ifa_address;
- *netMask = ifap->ifa_mask;
- return SUCCESS;
- }
- }
-
- }
-
- return FAILED;
-
-}
-
-
-#if defined(CONFIG_PROC_FS) && defined(CONFIG_NET_SCHED)
-#define QOS_CLASSIFY_INFO_LEN 16
-typedef struct {
- /* classify */
- unsigned int protocol;
- struct in_addr local_ip;
- struct in_addr remote_ip;
- unsigned short lo_port;
- unsigned short re_port;
-
- /* tc */
- uint32 mark;
- unsigned char prio;
-} rtl865x_qos_cache_t;
-
-static struct proc_dir_entry *proc_qos=NULL;
-
-static char *gQosSetting = NULL;
-#ifdef CONFIG_FAST_PATH_MODULE
-EXPORT_SYMBOL(gQosEnabled);
-#endif
-
-static int qos_read_proc(char *page, char **start, off_t off,
- int count, int *eof, void *data)
-{
- int len;
-
- len = sprintf(page, "%s\n", gQosSetting);
-
- if (len <= off+count) *eof = 1;
- *start = page + off;
- len -= off;
- if (len>count) len = count;
- if (len<0) len = 0;
- return len;
-}
-
-static int qos_write_proc(struct file *file, const char *buffer,
- unsigned long count, void *data)
-{
- if ( gQosSetting==NULL || count < 2)
- return -EFAULT;
-
- if (buffer && !copy_from_user(gQosSetting, buffer, count)) {
- gQosSetting[count-1] = 0; /* remove 0x0a */
- if (gQosSetting[0] == '0')
- gQosEnabled = 0;
- else
- gQosEnabled = 1;
-
-#if defined (CONFIG_RTL_HW_QOS_SUPPORT) && defined(CONFIG_RTL_QOS_PATCH)
- if(gQosEnabled == 1){
- rtl865x_reinitOutputQueuePatchForQoS(TRUE);
- }
- else{
- rtl865x_reinitOutputQueuePatchForQoS(FALSE);
- }
-#endif
-
- return count;
- }
- return -EFAULT;
-}
-#endif
-
-#if defined(CONFIG_NET_SCHED)
-#define RTL_QOS_PROC_MAX_LEN 1024
-int32 rtl_qos_init(void)
-{
- #if defined(CONFIG_PROC_FS)
- proc_qos = create_proc_entry("qos", 0, NULL);
- if (proc_qos) {
- proc_qos->read_proc = qos_read_proc;
- proc_qos->write_proc = qos_write_proc;
- }
- #endif
- gQosSetting = kmalloc(RTL_QOS_PROC_MAX_LEN, GFP_KERNEL);
- memset(gQosSetting, 0, RTL_QOS_PROC_MAX_LEN);
- gQosEnabled = 0;
-
- return SUCCESS;
-}
-
-int32 rtl_qos_cleanup(void)
-{
- kfree(gQosSetting);
-
- return SUCCESS;
-}
-#endif
-
-
-#if defined(CONFIG_RTL_FAST_BRIDGE)
-int32 rtl_fb_add_br_entry(skb)
-{
- struct net_bridge_fdb_entry *dst;
- const unsigned char *dest = eth_hdr(skb)->h_dest;
- if (!is_multicast_ether_addr(dest))
- {
- dst = __br_fdb_get(skb->dev->br_port->br, dest);
- if(dst != NULL && dst->dst->dev == skb->dev)
- {
- fast_br_cache_entry entry;
- memset(&entry,0,sizeof(fast_br_cache_entry));
- memcpy(&entry.mac_addr,dest,6);
- entry.ageing_timer = jiffies;
- entry.to_dev = skb->dev;
- entry.valid = 1;
-
- rtl_add_fast_br_entry(&entry);
- }
- }
-}
-#endif
-
-#if defined(FAST_PATH_SPI_ENABLED)
-enum tcp_bit_set {
- TCP_SYN_SET,
- TCP_SYNACK_SET,
- TCP_FIN_SET,
- TCP_ACK_SET,
- TCP_RST_SET,
- TCP_NONE_SET,
-};
-
-static unsigned int rtl_spi_get_conntrack_index(const struct tcphdr *tcph)
- {
- if (tcph->rst) return TCP_RST_SET;
- else if (tcph->syn) return (tcph->ack ? TCP_SYNACK_SET : TCP_SYN_SET);
- else if (tcph->fin) return TCP_FIN_SET;
- else if (tcph->ack) return TCP_ACK_SET;
- else return TCP_NONE_SET;
- }
-
-extern bool tcp_in_window(const struct nf_conn *ct,
- struct ip_ct_tcp *state,
- enum ip_conntrack_dir dir,
- unsigned int index,
- const struct sk_buff *skb,
- unsigned int dataoff,
- const struct tcphdr *tcph,
- u_int8_t pf);
-
-static inline struct nf_conn *
-rtl_resolve_normal_ct(struct net *net,
- struct sk_buff *skb,
- unsigned int dataoff,
- u_int16_t l3num,
- u_int8_t protonum,
- struct nf_conntrack_l3proto *l3proto,
- struct nf_conntrack_l4proto *l4proto,
- int *set_reply,
- enum ip_conntrack_info *ctinfo)
-{
- struct nf_conntrack_tuple tuple;
- struct nf_conntrack_tuple_hash *h;
- struct nf_conn *ct;
-
- if (!nf_ct_get_tuple(skb, skb_network_offset(skb),
- dataoff, l3num, protonum, &tuple, l3proto,
- l4proto)) {
- pr_debug("resolve_normal_ct: Can't get tuple\n");
- return NULL;
- }
-
- /* look for tuple match */
- h = nf_conntrack_find_get(net, &tuple);
-
- if (!h) {
- //h = init_conntrack(net, &tuple, l3proto, l4proto, skb, dataoff);
- //if (!h)
- return NULL;
- //if (IS_ERR(h))
- // return (void *)h;
- }
- ct = nf_ct_tuplehash_to_ctrack(h);
-
- /* It exists; we have (non-exclusive) reference. */
- if (NF_CT_DIRECTION(h) == IP_CT_DIR_REPLY) {
- *ctinfo = IP_CT_ESTABLISHED + IP_CT_IS_REPLY;
- } else {
- /* Once we've had two way comms, always ESTABLISHED. */
- if (test_bit(IPS_SEEN_REPLY_BIT, &ct->status)) {
- pr_debug("nf_conntrack_in: normal packet for %p\n", ct);
- *ctinfo = IP_CT_ESTABLISHED;
- } else if (test_bit(IPS_EXPECTED_BIT, &ct->status)) {
- pr_debug("nf_conntrack_in: related packet for %p\n",
- ct);
- *ctinfo = IP_CT_RELATED;
- } else {
- pr_debug("nf_conntrack_in: new packet for %p\n", ct);
- *ctinfo = IP_CT_NEW;
- }
- }
- skb->nfct = &ct->ct_general;
- skb->nfctinfo = *ctinfo;
- return ct;
-}
-
-
-unsigned int
-rtl_nf_conntrack_in(struct net *net, unsigned int dataoff, unsigned int hooknum,
- struct sk_buff *skb)
-{
- struct nf_conn *ct;
- enum ip_conntrack_info ctinfo;
- struct nf_conntrack_l3proto *l3proto;
- struct nf_conntrack_l4proto *l4proto;
- int set_reply = 0;
- enum ip_conntrack_dir dir;
- const struct tcphdr *th;
- struct tcphdr _tcph;
- unsigned int index;
-
-
- /* Previously seen (loopback or untracked)? Ignore. */
- if (skb->nfct) {
- NF_CT_STAT_INC_ATOMIC(net, ignore);
- return NF_ACCEPT;
- }
-
-
- /* rcu_read_lock()ed by nf_hook_slow */
- l3proto = rcu_dereference(nf_ct_l3protos[PF_INET]);
-
- l4proto = rcu_dereference(nf_ct_protos[PF_INET][IPPROTO_TCP]);
-
- ct = rtl_resolve_normal_ct(net, skb, dataoff, PF_INET, IPPROTO_TCP,
- l3proto, l4proto, &set_reply, &ctinfo);
-
- if (!ct) {
- /* Not valid part of a connection */
- return NF_ACCEPT;
- }
-
- if (IS_ERR(ct)) {
- /* Too stressed to deal. */
- return NF_DROP;
- }
-
- NF_CT_ASSERT(skb->nfct);
-
-
- th = skb_header_pointer(skb, dataoff, sizeof(_tcph), &_tcph);
- BUG_ON(th == NULL);
-
- dir = CTINFO2DIR(ctinfo);
-
- index = rtl_spi_get_conntrack_index(th);
-
- NF_CT_ASSERT(skb->nfct);
-
- if (!tcp_in_window(ct, &ct->proto.tcp, dir, index,
- skb, dataoff, th, PF_INET)) {
- return NF_DROP;
- }
- return NF_ACCEPT;
-
-}
-#endif
-
-
-#if defined(CONFIG_RTL_HARDWARE_NAT)
-/*2007-12-19*/
- int syn_asic_arp(struct neighbour *n, int add)
-{
-#ifdef CONFIG_RTL_LAYERED_DRIVER_L3
- u32 arp_ip = htonl(*((u32 *)n->primary_key));
- int rc;
-
- rc = add? rtl865x_addArp(arp_ip, (void *)n->ha): rtl865x_delArp(arp_ip);
-#endif
- return 0;
-}
-
-#if defined(CONFIG_RTL_MULTIPLE_WAN)
-int rtl_get_ps_arp_mapping(u32 ip, void *arp_entry_tmp)
-{
- rtl865x_arpMapping_entry_t *arp_entry;
- struct neighbour *dst_n;
- struct net_device *wanDev;
- wanDev=rtl865x_getWanDev();
-
- if(wanDev == NULL)
- return FAILED;
-
- arp_entry = (rtl865x_arpMapping_entry_t*)arp_entry_tmp;
-
- dst_n = neigh_lookup(&arp_tbl,&ip,wanDev);
- dev_put(wanDev);
- if(dst_n != NULL)
- {
- arp_entry->ip = ip;
- memcpy(arp_entry->mac.octet,dst_n->ha,ETHER_ADDR_LEN);
- return SUCCESS;
- }
-
- return FAILED;
-}
-#endif
-
-#if defined(CONFIG_RTL_IPTABLES_RULE_2_ACL) || defined(CONFIG_RTL_HARDWARE_NAT)
-/*get the chain number of the ipt_entry*/
-static int get_hookNum(struct ipt_entry *e, unsigned char *base, const unsigned int valid_hooks,const unsigned int *hook_entries)
-{
- int h;
- unsigned int offset = 0;
- int hook_num = -1;
-
- offset = (void *)e - (void *)base;
- for(h = 0; h < NF_INET_NUMHOOKS; h++)
- {
- if(!(valid_hooks & (1 << h)))
- continue;
-
- if(offset >= hook_entries[h])
- hook_num = h;
- }
-
- return hook_num;
-}
-#endif
-
-#ifdef CONFIG_RTL_HARDWARE_NAT
-rtl_masq_if rtl_masq_info[RTL_MULTIPLE_WAN_NUM];
-
-rtl_masq_if *rtl_get_masq_info_by_devName(const char* name)
-{
- int i;
- if(name == NULL)
- return NULL;
-
- for(i = 0; i < RTL_MULTIPLE_WAN_NUM;i++)
- {
- if(rtl_masq_info[i].valid == 1 &&strcmp(rtl_masq_info[i].ifName,name) == 0)
- return &rtl_masq_info[i];
- }
-
- return NULL;
-}
-
-int rtl_add_masq_info(const char *name,int ipAddr)
-{
- int i;
- if(strlen(name) >=IFNAMSIZ || ipAddr ==0)
- return FAILED;
-
- for(i = 0; i < RTL_MULTIPLE_WAN_NUM;i++)
- {
- if(rtl_masq_info[i].valid == 0)
- break;
- }
-
- if(i == RTL_MULTIPLE_WAN_NUM)
- return FAILED;
-
- rtl_masq_info[i].valid = 1;
- rtl_masq_info[i].ipAddr = ipAddr;
- memcpy(rtl_masq_info[i].ifName,name,strlen(name));
- rtl_masq_info[i].ifName[strlen(name)] ='\0';
- return SUCCESS;
-}
-
-int rtl_init_masq_info(void)
-{
- int i;
- for(i = 0; i < RTL_MULTIPLE_WAN_NUM;i++)
- {
- memset(&rtl_masq_info[i],0,sizeof(rtl_masq_if));
- }
-
- return SUCCESS;
-}
-
-/* Performance critical */
-static inline struct ipt_entry *
-get_entry(void *base, unsigned int offset)
-{
- return (struct ipt_entry *)(base + offset);
-}
-
-#ifdef CONFIG_NETFILTER_DEBUG
-#define IP_NF_ASSERT(x) \
-do { \
- if (!(x)) \
- printk("IP_NF_ASSERT: %s:%s:%u\n", \
- __func__, __FILE__, __LINE__); \
-} while(0)
-#else
-#define IP_NF_ASSERT(x)
-#endif
-
-static int rtl_get_masquerade_netif(struct xt_table_info *private,struct ipt_entry *masq_entry)
-{
- void *table_base;
- struct ipt_entry *e, *back;
- struct ipt_entry_target *t;
- struct net_device *dev;
- char masq_name[IFNAMSIZ]={'\0'};
-
- if(masq_entry && masq_entry->ip.outiface[0] !='\0')
- {
- memcpy(masq_name, masq_entry->ip.outiface, IFNAMSIZ);
- //return 0;
- }
- else
- {
- table_base = private->entries[smp_processor_id()];
- e = get_entry(table_base, private->hook_entry[NF_INET_POST_ROUTING]);
- back = get_entry(table_base, private->underflow[NF_INET_POST_ROUTING]);
-
- //clear masq_name;
- memset(masq_name,0,IFNAMSIZ);
- while(e)
- {
-
- if(e == masq_entry)
- break;
-
- //record the entry's outif name
- if(e->ip.outiface[0] !='\0')
- memcpy(masq_name,e->ip.outiface,IFNAMSIZ);
-
- //target
- t = ipt_get_target(e);
- IP_NF_ASSERT(t->u.kernel.target);
-
-
- //if error target
- if(strcmp(t->u.kernel.target->name, "ERROR") == 0)
- {
- memset(masq_name,0,IFNAMSIZ);
- break;
- }
-
- /* Standard target? */
- if (!t->u.kernel.target->target)
- {
- int v;
- v = ((struct ipt_standard_target *)t)->verdict;
-
- if (v < 0 )
- {
- if(v == IPT_RETURN)
- {
- e = back;
- back = get_entry(table_base, back->comefrom);
- }
- else
- {
- e = (void *)e + e->next_offset;
- }
-
- continue;
- }
-
- //jump ?
- if (table_base + v != (void *)e + e->next_offset
- && !(e->ip.flags & IPT_F_GOTO)) {
- /* Save old back ptr in next entry */
- struct ipt_entry *next
- = (void *)e + e->next_offset;
- next->comefrom
- = (void *)back - table_base;
- /* set back pointer to next entry */
- back = next;
- }
- e = get_entry(table_base, v);
- continue;
- }
-
- /*user define target?*/
- e = (void *)e + e->next_offset;
- }
-
- }
-
- if(masq_name[0] !='\0')
- {
- struct in_ifaddr *ina;
- dev = __dev_get_by_name(&init_net,masq_name);
- if ((dev)&&(dev->ip_ptr))
- {
-
- ina=(struct in_ifaddr *)(((struct in_device *)(dev->ip_ptr))->ifa_list);
- if (ina!=NULL)
- {
- rtl_add_masq_info(masq_name,ina->ifa_local);
- }
- }
- }
-
-
- return 0;
-}
-
-static int rtl_check_for_masquerade_entry(struct ipt_entry *e,
- unsigned char *base,
- const char *name,
- unsigned int size,
- const unsigned int valid_hooks,
- const unsigned int *hook_entries,
- struct xt_table_info *private)
-{
- struct ipt_entry_target *t;
- unsigned int hook;
- int ret = 0;
-
- t = ipt_get_target(e);
- if ( !t)
- {
- goto err;
- }
-
- hook = get_hookNum(e,base,valid_hooks,hook_entries);
- if ((hook == NF_INET_POST_ROUTING) &&
- ((strcmp(t->u.kernel.target->name, "MASQUERADE") == 0)))
- {
- rtl_get_masquerade_netif(private,e);
- }
- err:
- return ret;
-}
-
-int rtl_check_for_extern_ip(const char *name,
- unsigned int valid_hooks,
- struct xt_table_info *newinfo,
- void *entry0,
- unsigned int size,
- unsigned int number,
- const unsigned int *hook_entries,
- const unsigned int *underflows)
-{
- int i;
- IPT_ENTRY_ITERATE(entry0, size,rtl_check_for_masquerade_entry, entry0,name,size,valid_hooks,hook_entries,newinfo);
-
- //found masq entry
- for(i = 0; i < RTL_MULTIPLE_WAN_NUM;i++)
- {
- if(rtl_masq_info[i].valid == 1 && rtl_masq_info[i].ipAddr)
- {
- rtl865x_addIp(0,rtl_masq_info[i].ipAddr,IP_TYPE_NAPT);
- }
- }
-
- return 0;
-}
-
- int rtl_flush_extern_ip(void)
-{
- int i;
- for(i = 0; i < RTL_MULTIPLE_WAN_NUM;i++)
- {
- if(rtl_masq_info[i].valid == 1)
- {
- //delete....
- rtl865x_delIp(rtl_masq_info[i].ipAddr);
- }
- }
-
- return SUCCESS;
-}
-
-int32 rtl_update_ip_tables(char *name, unsigned long event, struct in_ifaddr *ina)
-{
- rtl_masq_if *entry;
-
- /*2007-12-19*/
- #ifdef CONFIG_HARDWARE_NAT_DEBUG
- /*2007-12-19*/
- printk("%s:%d\n",__FUNCTION__,__LINE__);
- #endif
- if (ina==NULL)
- return SUCCESS;
-
- entry = rtl_get_masq_info_by_devName(name);
- if (entry!=NULL)
- {
- if (event == NETDEV_UP )
- {
- rtl865x_addIp(0,(u32)(ina->ifa_local),IP_TYPE_NAPT);
- //update the ip address
- entry->ipAddr = ina->ifa_local;
- }
- else if(event == NETDEV_DOWN)
- {
- if(rtl865x_delIp(ina->ifa_local)==SUCCESS)
- {
- rtl865x_nat_init();
- }
- }
- }
-
- return SUCCESS;
-}
-
-int32 rtl_fn_insert(struct fib_table *tb, struct fib_config *cfg, struct fib_info *fi)
-{
- int rc;
- unsigned int ipDst, ipMask, ipGw;
- unsigned int srcIp,srcMask;
- struct net_device *netif;
- char *dev_t;
-
- /*2007-12-19*/
- if ((tb->tb_id == RT_TABLE_MAIN) && (gHwNatEnabled !=0)) {
- if(cfg->fc_oif) {
- netif = __dev_get_by_index(&init_net,cfg->fc_oif);
- } else {
- netif=NULL;
- }
-
- dev_t = (netif)? netif->name: NULL;
- ipDst = cfg->fc_dst ;
- ipMask = inet_make_mask(cfg->fc_dst_len);
- ipGw = cfg->fc_gw;
- rtl865x_getDevIpAndNetmask(netif,&srcIp,&srcMask);
- if (!ipDst || (!MULTICAST(ipDst) && !LOOPBACK(ipDst) && (ipDst != 0xffffffff)))
- {
- #ifdef CONFIG_RTL_LAYERED_DRIVER_L3
- //printk("-------------------%s(%d)\n",__FUNCTION__,__LINE__);
- rc = rtl865x_addRoute(ipDst,ipMask,ipGw,dev_t,srcIp);
- //printk("-------------------%s(%d),rc(%d)\n",__FUNCTION__,__LINE__,rc);
- #endif
- #ifdef CONFIG_HARDWARE_NAT_DEBUG
- /*2007-12-19*/
- printk("%s:%d:(%s): dst:%u.%u.%u.%u/%u, gw:%u.%u.%u.%u, dev: %s, errno=%d\n",
- __FUNCTION__,__LINE__,"add_rt", NIPQUAD(ipDst), cfg->fc_dst_len, NIPQUAD(ipGw), dev_t? dev_t: "null", rc
- );
- #endif
-
- }
- }
-
- return SUCCESS;
-}
-
-int32 rtl_fn_delete(struct fib_table *tb, struct fib_config *cfg)
-{
- int rc;
- unsigned int ipDst, ipMask;
-
- /*2007-12-19*/
- if (tb->tb_id == RT_TABLE_MAIN) {
- ipDst = cfg->fc_dst;
- ipMask = inet_make_mask(cfg->fc_dst_len);
-
- if (!ipDst || (!MULTICAST(ipDst) && !LOOPBACK(ipDst) && (ipDst != 0xffffffff))) {
- rc = 0;
- #ifdef CONFIG_RTL_LAYERED_DRIVER_L3
- rc = rtl865x_delRoute(ipDst, ipMask);
- #endif
- }
- }
-
- return SUCCESS;
-}
-
-int32 rtl_fn_flush(int fz_order, int idx, u32 tb_id, u32 fn_key)
-{
- int rc;
- unsigned int ipDst, ipMask;
- /*2007-12-19*/
- if (tb_id==RT_TABLE_MAIN) {
- ipDst =fn_key;
- ipMask = inet_make_mask(fz_order);
-
- if (!ipDst || (!MULTICAST(ipDst) && !LOOPBACK(ipDst) && (ipDst != 0xffffffff))) {
- rc = 0;
- #ifdef CONFIG_RTL_LAYERED_DRIVER_L3
- rc = rtl865x_delRoute(ipDst, ipMask);
- #endif
- }
- }
-
- return SUCCESS;
-}
-
-int32 rtl_ip_vs_conn_expire_check(struct ip_vs_conn *cp)
-{
- u_int32_t timeval;
- rtl865x_napt_entry rtl865xNaptEntry;
-
-/* chhuang:
- printk("ip_vs_conn_expire: c:(%u.%u.%u.%u:%d), v:(%u.%u.%u.%u:%d), \n\td:(%u.%u.%u.%u:%d), p:(%x), f: %x, s: %x\n",
- NIPQUAD(cp->caddr), cp->cport, NIPQUAD(cp->vaddr), cp->vport, NIPQUAD(cp->daddr), cp->dport,
- cp->protocol, cp->flags, cp->state);
-*/
- if (cp->hw_acc) {
- rtl865xNaptEntry.protocol=((cp->protocol==IPPROTO_TCP)? 1: 0);
- rtl865xNaptEntry.intIp=cp->daddr.ip;
- rtl865xNaptEntry.intPort=cp->dport;
- rtl865xNaptEntry.extIp=cp->vaddr.ip;
- rtl865xNaptEntry.extPort=cp->vport;
- rtl865xNaptEntry.remIp=cp->caddr.ip;
- rtl865xNaptEntry.remPort=cp->cport;
-
- timeval = rtl865x_naptSync(&rtl865xNaptEntry, 0);
-
- if (timeval > 0 && (cp->protocol==IPPROTO_UDP))
- {
- cp->timer.expires = jiffies + (timeval)*HZ;
- add_timer(&cp->timer);
- #ifdef CONFIG_HARDWARE_NAT_DEBUG
- /*2007-12-19*/
- printk("%s:%d:(%s): expired time = %d\n %s (%u.%u.%u.%u:%u -> %u.%u.%u.%u:%u) g:(%u.%u.%u.%u:%u)\n",
- __FUNCTION__,__LINE__,"poll_nat", timeval, (cp->protocol==IPPROTO_TCP)? "tcp": "udp",
- NIPQUAD(cp->daddr), cp->dport, NIPQUAD(cp->caddr), cp->cport,
- NIPQUAD(cp->vaddr), cp->vport
- );
- #endif
-
- return FAILED;
- }
- }
-
- return SUCCESS;
-}
-
-
-int32 rtl_ip_vs_conn_expire_check_delete(struct ip_vs_conn *cp)
-{
- rtl865x_napt_entry rtl865xNaptEntry;
-
- if (cp->hw_acc) {
- int rc;
-
- rtl865xNaptEntry.protocol=((cp->protocol==IPPROTO_TCP)? 1: 0);
- rtl865xNaptEntry.intIp=cp->daddr.ip;
- rtl865xNaptEntry.intPort=cp->dport;
- rtl865xNaptEntry.extIp=cp->vaddr.ip;
- rtl865xNaptEntry.extPort=cp->vport;
- rtl865xNaptEntry.remIp=cp->caddr.ip;
- rtl865xNaptEntry.remPort=cp->cport;
-
- rc = rtl865x_delNaptConnection(&rtl865xNaptEntry);
-
- #ifdef CONFIG_HARDWARE_NAT_DEBUG
- /*2007-12-19*/
- printk("%s:%d:(%s): errno=%d\n %s (%u.%u.%u.%u:%u -> %u.%u.%u.%u:%u) g:(%u.%u.%u.%u:%u)\n",
- __FUNCTION__,__LINE__,"del_nat", rc, (cp->protocol==IPPROTO_TCP)? "tcp": "udp",
- NIPQUAD(cp->daddr.ip), cp->dport, NIPQUAD(cp->caddr.ip), cp->cport,
- NIPQUAD(cp->vaddr.ip), cp->vport
- );
- #endif
- }
-
- return SUCCESS;
-}
-
-int32 rtl_tcp_state_transition_check(struct ip_vs_conn *cp, int direction, const struct sk_buff *skb, struct ip_vs_protocol *pp)
-{
- #if defined(CONFIG_RTL_HW_QOS_SUPPORT)
- uint32 ret;
- struct net_device *lanDev, *wanDev;
- #endif
-
- #if defined(CONFIG_RTL_LAYERED_DRIVER_L4)
- rtl865x_napt_entry rtl865xNaptEntry;
- rtl865x_priority rtl865xPrio;
- rtl865x_qos_mark rtl865xQosMark;
- #endif
-
- /*2007-12-19*/
- /*
- printk("ip_vs_set_state: c:(%u.%u.%u.%u:%d), v:(%u.%u.%u.%u:%d), \n\td:(%u.%u.%u.%u:%d), p:(%x), f: %x, s: %x, master: %s\n\tapp_data: %x, app: %x\n",
- NIPQUAD(cp->caddr), cp->cport, NIPQUAD(cp->vaddr), cp->vport, NIPQUAD(cp->daddr), cp->dport, cp->protocol, cp->flags, cp->state,
- cp->control? "yes": "no", cp->app_data, cp->app);
- */
- #if 0
- if (!cp->hw_acc && !cp->app &&
- cp->state==IP_VS_S_ESTABLISHED)
- #else
- if (!cp->hw_acc && !cp->app &&
- cp->state==IP_VS_TCP_S_ESTABLISHED)
- #endif
- {
- int rc;
- rc = 0;
-
- #if defined(CONFIG_RTL_HW_QOS_SUPPORT)
- if (NULL!=skb)
- {
- rtl865xNaptEntry.protocol=RTL865X_PROTOCOL_TCP;
- rtl865xNaptEntry.intIp=cp->daddr.ip;
- rtl865xNaptEntry.intPort=cp->dport;
- rtl865xNaptEntry.extIp=cp->vaddr.ip;
- rtl865xNaptEntry.extPort=cp->vport;
- rtl865xNaptEntry.remIp=cp->caddr.ip;
- rtl865xNaptEntry.remPort=cp->cport;
-
- rtl865xQosMark.downlinkMark=0; //Initial
- rtl865xQosMark.uplinkMark=0; //Initial
- ret=rtl_qosGetSkbMarkByNaptEntry(&rtl865xNaptEntry, &rtl865xQosMark, skb);
-
- lanDev=rtl865x_getLanDev();
- wanDev=rtl865x_getWanDev();
- rtl865xPrio.downlinkPrio=rtl_qosGetPriorityByMark(lanDev->name, rtl865xQosMark.downlinkMark);
- rtl865xPrio.uplinkPrio=rtl_qosGetPriorityByMark(wanDev->name, rtl865xQosMark.uplinkMark);
-
- if(lanDev)
- dev_put(lanDev);
-
- if(wanDev)
- dev_put(wanDev);
- }else
- #endif
- {
- rtl865xPrio.downlinkPrio=0;
- rtl865xPrio.uplinkPrio=0;
- }
-
- #if defined(CONFIG_RTL_LAYERED_DRIVER_L4)
- rtl865xNaptEntry.protocol=RTL865X_PROTOCOL_TCP;
- rtl865xNaptEntry.intIp=cp->daddr.ip;
- rtl865xNaptEntry.intPort=cp->dport;
- rtl865xNaptEntry.extIp=cp->vaddr.ip;
- rtl865xNaptEntry.extPort=cp->vport;
- rtl865xNaptEntry.remIp=cp->caddr.ip;
- rtl865xNaptEntry.remPort=cp->cport;
- rc = rtl865x_addNaptConnection(&rtl865xNaptEntry, &rtl865xPrio);
- #endif
- if (!rc)
- cp->hw_acc = 1;
- #ifdef CONFIG_HARDWARE_NAT_DEBUG
- /*2007-12-19*/
- printk("%s:%d:(%s): errno=%d\n %s (%u.%u.%u.%u:%u -> %u.%u.%u.%u:%u) g:(%u.%u.%u.%u:%u)\n",
- __FUNCTION__,__LINE__,"add_nat", rc, "tcp", NIPQUAD(cp->daddr), cp->dport,
- NIPQUAD(cp->caddr), cp->cport, NIPQUAD(cp->vaddr), cp->vport
- );
- #endif
- }
-}
-
-int32 rtl_udp_state_transition_check(struct ip_vs_conn *cp, int direction, const struct sk_buff *skb, struct ip_vs_protocol *pp)
-{
- #if defined(CONFIG_RTL_HW_QOS_SUPPORT)
- uint32 ret;
- struct net_device *lanDev, *wanDev;
- #endif
- #if defined(CONFIG_RTL_LAYERED_DRIVER_L4)
- rtl865x_napt_entry rtl865xNaptEntry;
- rtl865x_priority rtl865xPrio;
- rtl865x_qos_mark rtl865xQosMark;
- #endif
-
- /*2007-12-19*/
- if (!cp->hw_acc && !cp->app)
- {
- int rc;
- rc = 0;
- #if defined(CONFIG_RTL_HW_QOS_SUPPORT)
- if (NULL!=skb)
- {
- rtl865xNaptEntry.protocol=RTL865X_PROTOCOL_UDP;
- rtl865xNaptEntry.intIp=cp->daddr.ip;
- rtl865xNaptEntry.intPort=cp->dport;
- rtl865xNaptEntry.extIp=cp->vaddr.ip;
- rtl865xNaptEntry.extPort=cp->vport;
- rtl865xNaptEntry.remIp=cp->caddr.ip;
- rtl865xNaptEntry.remPort=cp->cport;
-
- rtl865xQosMark.downlinkMark=0; //Initial
- rtl865xQosMark.uplinkMark=0; //Initial
- ret=rtl_qosGetSkbMarkByNaptEntry(&rtl865xNaptEntry, &rtl865xQosMark, skb);
-
- lanDev=rtl865x_getLanDev();
- wanDev=rtl865x_getWanDev();
- rtl865xPrio.downlinkPrio=rtl_qosGetPriorityByMark(lanDev->name, rtl865xQosMark.downlinkMark);
- rtl865xPrio.uplinkPrio=rtl_qosGetPriorityByMark(wanDev->name, rtl865xQosMark.uplinkMark);
-
- if(lanDev)
- dev_put(lanDev);
-
- if(wanDev)
- dev_put(wanDev);
- } else
- #endif
- {
- rtl865xPrio.downlinkPrio=0;
- rtl865xPrio.uplinkPrio=0;
- }
-
- #if defined(CONFIG_RTL_LAYERED_DRIVER_L4)
- rtl865xNaptEntry.protocol=RTL865X_PROTOCOL_UDP;
- rtl865xNaptEntry.intIp=cp->daddr.ip;
- rtl865xNaptEntry.intPort=cp->dport;
- rtl865xNaptEntry.extIp=cp->vaddr.ip;
- rtl865xNaptEntry.extPort=cp->vport;
- rtl865xNaptEntry.remIp=cp->caddr.ip;
- rtl865xNaptEntry.remPort=cp->cport;
-
- rc = rtl865x_addNaptConnection(&rtl865xNaptEntry, &rtl865xPrio);
- #endif
- if (!rc)
- cp->hw_acc = 1;
- #ifdef CONFIG_HARDWARE_NAT_DEBUG
- /*2007-12-19*/
- printk("%s:%d:(%s): errno=%d\n %s (%u.%u.%u.%u:%u -> %u.%u.%u.%u:%u) g:(%u.%u.%u.%u:%u)\n",
- __FUNCTION__,__LINE__,"add_nat", rc, "udp", NIPQUAD(cp->daddr), cp->dport,
- NIPQUAD(cp->caddr), cp->cport, NIPQUAD(cp->vaddr), cp->vport
- );
- #endif
- }
-}
-
-#endif
-#endif
-
-#if defined(CONFIG_PROC_FS) && defined(CONFIG_RTL_NF_CONNTRACK_GARBAGE_NEW)
-static struct proc_dir_entry *proc_gc_overflow_timout=NULL;
-static int gc_overflow_timout_read_proc(char *page, char **start, off_t off,
- int count, int *eof, void *data)
-{
- int len;
-
- len = sprintf(page, "rtl_gc_overflow_timout(%d), HZ(%d)\n", rtl_gc_overflow_timout, HZ);
-
- if (len <= off+count) *eof = 1;
- *start = page + off;
- len -= off;
- if (len>count) len = count;
- if (len<0) len = 0;
- return len;
-}
-
-static int gc_overflow_timout_write_proc(struct file *file, const char *buffer,
- unsigned long count, void *data)
-{
- uint32 tmpBuf[32];
-
- if (count < 2)
- return -EFAULT;
-
- if (buffer && !copy_from_user(tmpBuf, buffer, count)) {
- tmpBuf[count-1]=0;
- rtl_gc_overflow_timout=simple_strtol((const char *)tmpBuf, NULL, 0);
-
- return count;
- }
- return -EFAULT;
-}
-
-void gc_overflow_timout_proc_init(void)
-{
- proc_gc_overflow_timout = create_proc_entry("gc_overflow_timout", 0, NULL);
- if (proc_gc_overflow_timout) {
- proc_gc_overflow_timout->read_proc = gc_overflow_timout_read_proc;
- proc_gc_overflow_timout->write_proc = gc_overflow_timout_write_proc;
- }
-}
-#endif
-
-
diff --git a/target/linux/realtek/files/net/rtl/features/96C/rtl_ps_hooks.c b/target/linux/realtek/files/net/rtl/features/96C/rtl_ps_hooks.c
deleted file mode 100644
index 609c349da..000000000
--- a/target/linux/realtek/files/net/rtl/features/96C/rtl_ps_hooks.c
+++ /dev/null
@@ -1,819 +0,0 @@
-#include <linux/types.h>
-#include <linux/netfilter.h>
-#include <linux/module.h>
-#include <linux/skbuff.h>
-#include <linux/moduleparam.h>
-#include <linux/notifier.h>
-#include <linux/kernel.h>
-#include <linux/netdevice.h>
-#include <linux/ip.h>
-#include <linux/tcp.h>
-#include <linux/inetdevice.h>
-
-#include <net/ip_fib.h>
-#include <net/netfilter/nf_nat.h>
-#include <net/netfilter/nf_conntrack.h>
-#include <net/netfilter/nf_conntrack_core.h>
-#include <net/netfilter/nf_nat_protocol.h>
-#include <net/ip_vs.h>
-#include <linux/ip_vs.h>
-
-#include <net/rtl/rtl_types.h>
-#include <net/rtl/fastpath/fastpath_core.h>
-#include <net/rtl/features/rtl_features.h>
-#include <net/rtl/features/rtl_ps_hooks.h>
-
-#ifdef CONFIG_RTL_LAYERED_DRIVER_L3
-#include <net/rtl/rtl865x_ppp.h>
-#include <net/rtl/rtl865x_route_api.h>
-#include <net/rtl/rtl865x_arp_api.h>
-#endif
-
-#if defined(CONFIG_RTL_HW_QOS_SUPPORT) && defined(CONFIG_RTL_HARDWARE_NAT)
-#include <net/rtl/rtl865x_netif.h>
-#include <net/rtl/rtl865x_outputQueue.h>
-#endif
-
-#ifdef CONFIG_BRIDGE
-#include <bridge/br_private.h>
-#endif
-
-#ifdef CONFIG_RTL_HARDWARE_NAT
-//#define CONFIG_HARDWARE_NAT_DEBUG
-#ifdef CONFIG_RTL_LAYERED_DRIVER_L3
-#include <net/rtl/rtl865x_ppp.h>
-#include <net/rtl/rtl865x_route_api.h>
-#endif
-//unsigned int ldst, lmask, wdst, wmask;
-extern int gHwNatEnabled;
-#endif
-
-#ifdef CONFIG_RTL_HARDWARE_NAT
-/*2007-12-19*/
-#ifdef CONFIG_RTL_LAYERED_DRIVER_L3
-#include <net/rtl/rtl865x_ip_api.h>
-#endif
-#ifdef CONFIG_RTL_LAYERED_DRIVER_L4
-#include <net/rtl/rtl865x_nat.h>
-#endif
-extern char masq_if[];
-extern unsigned int hw_napt_ip;
-#endif
-
-#if defined(CONFIG_RTL_IPTABLES_FAST_PATH) && defined(CONFIG_FAST_PATH_MODULE)
-enum LR_RESULT (*FastPath_hook5)( ipaddr_t ip, ether_addr_t* mac, enum ARP_FLAGS flags )=NULL;
-enum LR_RESULT (*FastPath_hook7)( ipaddr_t ip )=NULL;
-enum LR_RESULT (*FastPath_hook8)( ipaddr_t ip, ether_addr_t* mac, enum ARP_FLAGS flags )=NULL;
-EXPORT_SYMBOL(FastPath_hook8);
-EXPORT_SYMBOL(FastPath_hook7);
-EXPORT_SYMBOL(FastPath_hook5);
-#endif
-
-
-int32 rtl_nf_conntrack_in_hooks(rtl_nf_conntrack_inso_s *info)
-{
- #if !defined(IMPROVE_QOS) && defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- rtl_fpAddConnCache(info->ct, info->skb);
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl_nf_conntrack_death_by_timeout_hooks(rtl_nf_conntrack_inso_s *info)
-{
- int ret;
-
- ret = RTL_PS_HOOKS_CONTINUE;
- #if defined(CONFIG_RTL_IPTABLES_FAST_PATH) || defined(CONFIG_RTL_HARDWARE_NAT)
- if (rtl_connCache_timer_update(info->ct)==SUCCESS) {
- ret = RTL_PS_HOOKS_RETURN;
- }
- #endif
-
- return ret;
-}
-
-int32 rtl_nf_conntrack_destroy_hooks(rtl_nf_conntrack_inso_s *info)
-{
- #if defined(CONFIG_RTL_IPTABLES_FAST_PATH) || defined(CONFIG_RTL_HARDWARE_NAT)
- rtl_delConnCache(info->ct);
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl_nf_conntrack_confirm_hooks(rtl_nf_conntrack_inso_s *info)
-{
- #if defined(CONFIG_RTL_NF_CONNTRACK_GARBAGE_NEW)
- rtl_connGC_addList(info->skb, info->ct);
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl_nf_init_conntrack_hooks(rtl_nf_conntrack_inso_s *info)
-{
-
- #if defined(CONFIG_RTL_NF_CONNTRACK_GARBAGE_NEW)
- INIT_LIST_HEAD(&info->ct->state_tuple);
- #endif
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-
-int32 rtl_nf_conntrack_init_hooks(void)
-{
- #if defined(CONFIG_RTL_NF_CONNTRACK_GARBAGE_NEW)
- rtl_nf_conn_GC_init();
- #endif
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl_tcp_packet_hooks(rtl_nf_conntrack_inso_s *info)
-{
- #if defined(CONFIG_RTL_HARDWARE_NAT)
- if (info->new_state==TCP_CONNTRACK_LAST_ACK) {
- rtl865x_handle_nat(info->ct, 0, NULL);
- }
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl_nf_nat_packet_hooks(rtl_nf_conntrack_inso_s *info)
-{
- #if (defined(IMPROVE_QOS) && defined(CONFIG_RTL_IPTABLES_FAST_PATH)) || defined(CONFIG_RTL_HARDWARE_NAT)
- rtl_addConnCache(info->ct, info->skb);
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl_nat_init_hooks(void)
-{
- rtl_nat_init();
- #if defined(CONFIG_NET_SCHED)
- rtl_qos_init();
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl_nat_cleanup_hooks(void)
-{
- #if defined(CONFIG_NET_SCHED)
- rtl_qos_cleanup();
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl_fn_hash_insert_hooks(struct fib_table *tb, struct fib_config *cfg, struct fib_info *fi)
-{
-#if defined( CONFIG_RTL_IPTABLES_FAST_PATH)
- #if defined(CONFIG_FAST_PATH_MODULE)
- if(FastPath_hook3!=NULL)
- {
- FastPath_hook3(cfg->fc_dst? cfg->fc_dst: 0, inet_make_mask(cfg->fc_dst_len),cfg->fc_gw ? cfg->fc_gw : 0, (uint8 *)fi->fib_dev->name, RT_NONE);
- }
- #else
- rtk_addRoute(cfg->fc_dst? cfg->fc_dst: 0, inet_make_mask(cfg->fc_dst_len),cfg->fc_gw ? cfg->fc_gw : 0, (uint8 *)fi->fib_dev->name, RT_NONE);
- #endif
-#endif
-
-
- #if defined(CONFIG_RTL_HARDWARE_NAT)
- rtl_fn_insert(tb, cfg, fi);
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl_fn_hash_delete_hooks(struct fib_table *tb, struct fib_config *cfg)
-{
- #if defined(CONFIG_RTK_IPTABLES_FAST_PATH)
- #ifdef CONFIG_FAST_PATH_MODULE
- if(FastPath_hook1!=NULL)
- {
- FastPath_hook1(cfg->fc_dst? cfg->fc_dst : 0, inet_make_mask(cfg->fc_dst_len));
- }
- #else
- rtk_delRoute(cfg->fc_dst? cfg->fc_dst : 0, inet_make_mask(cfg->fc_dst_len));
- #endif
- #endif
-
- #if defined(CONFIG_RTL_HARDWARE_NAT)
- rtl_fn_delete(tb, cfg);
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-
-int32 rtl_fn_flush_list_hooks(int fz_order, int idx, u32 tb_id, u32 fn_key)
-{
- #if defined(CONFIG_RTL_HARDWARE_NAT)
- rtl_fn_flush(fz_order, idx, tb_id, fn_key);
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl_fn_hash_replace_hooks(struct fib_table *tb, struct fib_config *cfg, struct fib_info *fi)
-{
-#if defined( CONFIG_RTL_IPTABLES_FAST_PATH)
- #if defined(CONFIG_FAST_PATH_MODULE)
- if(FastPath_hook2!=NULL)
- {
- FastPath_hook2(cfg->fc_dst? cfg->fc_dst: 0, inet_make_mask(cfg->fc_dst_len),cfg->fc_gw ? cfg->fc_gw : 0, (uint8 *)fi->fib_dev->name, RT_NONE);
- }
- #else
- rtk_modifyRoute(cfg->fc_dst? cfg->fc_dst: 0, inet_make_mask(cfg->fc_dst_len),cfg->fc_gw ? cfg->fc_gw : 0, (uint8 *)fi->fib_dev->name, RT_NONE);
- #endif
-#endif
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl_dev_queue_xmit_hooks(struct sk_buff *skb, struct net_device *dev)
-{
- #if defined( CONFIG_RTL_IPTABLES_FAST_PATH)
- rtl_fp_dev_queue_xmit_check(skb, dev);
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl_dev_hard_start_xmit_hooks(struct sk_buff *skb, struct net_device *dev, struct netdev_queue *txq)
-{
- #if defined( CONFIG_RTL_IPTABLES_FAST_PATH)
- rtl_fp_dev_hard_start_xmit_check(skb, dev, txq);
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl_netif_receive_skb_hooks(struct sk_buff *skb)
-{
- int ret;
-
- #if defined(CONFIG_RTL_FAST_BRIDGE)
- if(skb->dev->br_port && (rtl_fast_br_forwarding(skb)==RTL_FAST_BR_SUCCESS)) {
- ret = RTL_PS_HOOKS_RETURN;
- } else
- #endif
- #if defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- if (FastPath_Enter(&skb)== NET_RX_DROP) {
- ret = RTL_PS_HOOKS_RETURN;
- } else
- #endif
- {
- ret = RTL_PS_HOOKS_CONTINUE;
- }
-
- return ret;
-}
-
-int32 rtl_br_dev_queue_push_xmit_before_xmit_hooks(struct sk_buff *skb)
-{
- #if defined(CONFIG_RTL_FAST_BRIDGE)
- rtl_fb_add_br_entry(skb);
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-
-int32 rtl_neigh_forced_gc_hooks(struct neigh_table *tbl, struct neighbour *n)
-{
- #if defined(CONFIG_RTL_HARDWARE_NAT) && defined(CONFIG_RTL_LAYERED_DRIVER) && defined(CONFIG_RTL_LAYERED_DRIVER_L3)
- syn_asic_arp(n, 0);
- #endif
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl_neigh_flush_dev_hooks(struct neigh_table *tbl, struct net_device *dev, struct neighbour *n)
-{
- #if (defined(CONFIG_RTL_HARDWARE_NAT) && defined(CONFIG_RTL_LAYERED_DRIVER) && defined(CONFIG_RTL_LAYERED_DRIVER_L3)) || defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- if (n->nud_state & NUD_VALID) {
- #if defined(CONFIG_RTL_HARDWARE_NAT) && defined(CONFIG_RTL_LAYERED_DRIVER) && defined(CONFIG_RTL_LAYERED_DRIVER_L3)
- syn_asic_arp(n, 0);
- #endif
-
- #if defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- #ifdef CONFIG_FAST_PATH_MODULE
- if(FastPath_hook7!=NULL) {
- FastPath_hook7(*(u32*)n->primary_key);
- }
- #else
- rtk_delArp(*(u32*)n->primary_key);
- #endif
- #endif
- }
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl_neigh_destroy_hooks(struct neighbour *n)
-{
- #if defined(CONFIG_RTL_HARDWARE_NAT) && defined(CONFIG_RTL_LAYERED_DRIVER) && defined(CONFIG_RTL_LAYERED_DRIVER_L3)
- syn_asic_arp(n, 0);
- #endif
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl_neigh_connect_hooks(struct neighbour *neigh)
-{
- #if defined(CONFIG_RTL_HARDWARE_NAT) && defined(CONFIG_RTL_LAYERED_DRIVER) && defined(CONFIG_RTL_LAYERED_DRIVER_L3)
- if (neigh->nud_state & NUD_REACHABLE) {
- syn_asic_arp(neigh, 1);
- }
- #endif
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl_neigh_update_hooks(struct neighbour *neigh, const u8 *lladdr, uint8 old)
-{
- #if defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- if (old & NUD_VALID) {
- #ifdef CONFIG_FAST_PATH_MODULE
- if(FastPath_hook8!=NULL) {
- FastPath_hook8(*(u32*)neigh->primary_key, (ether_addr_t*)lladdr, ARP_NONE);
- }
- #else
- rtk_modifyArp(*(u32*)neigh->primary_key, (ether_addr_t*)lladdr, ARP_NONE);
- #endif
- }
- #endif
-
- #if defined(CONFIG_RTL_HARDWARE_NAT) && defined(CONFIG_RTL_LAYERED_DRIVER) && defined(CONFIG_RTL_LAYERED_DRIVER_L3)
- syn_asic_arp(neigh, 1);
- #endif
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl_neigh_update_post_hooks(struct neighbour *neigh, const u8 *lladdr, uint8 old)
-{
- #if defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- if ((neigh->nud_state & NUD_VALID) && !(old & NUD_VALID)) {
- #if defined(CONFIG_FAST_PATH_MODULE)
- if(FastPath_hook5!=NULL)
- {
- FastPath_hook5(*(u32*)neigh->primary_key, (ether_addr_t*)neigh->ha, ARP_NONE);
- }
- #else
- rtk_addArp(*(u32*)neigh->primary_key, (ether_addr_t*)neigh->ha, ARP_NONE);
- #endif
- } else if ((old & NUD_VALID) && !(neigh->nud_state & NUD_VALID)) {
- #if defined(CONFIG_FAST_PATH_MODULE)
- if(FastPath_hook7!=NULL)
- {
- FastPath_hook7(*(u32*)neigh->primary_key);
- }
- #else
- rtk_delArp(*(u32*)neigh->primary_key);
- #endif
- }
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-static __inline__ int neigh_max_probes(struct neighbour *n)
-{
- struct neigh_parms *p = n->parms;
- return (n->nud_state & NUD_PROBE ?
- p->ucast_probes :
- p->ucast_probes + p->app_probes + p->mcast_probes);
-}
-
-int32 rtl_neigh_periodic_timer_hooks(struct neighbour *n, unsigned int refresh)
-{
- int ret;
-
- if (!(n->nud_state & NUD_VALID))
- return RTL_PS_HOOKS_CONTINUE;
-
- ret = RTL_PS_HOOKS_CONTINUE;
- #if defined(CONFIG_RTL_HARDWARE_NAT) && defined(CONFIG_RTL_LAYERED_DRIVER) && defined(CONFIG_RTL_LAYERED_DRIVER_L3)
- if (rtl865x_arpSync(htonl(*((u32 *)n->primary_key)), refresh)>0) {
- n->used = jiffies;
- n->dead=0;
- ret = RTL_PS_HOOKS_BREAK;
- }
- else
- #endif
-
- #if defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- {
- #ifdef CONFIG_FAST_PATH_MODULE
- if(FastPath_hook7!=NULL)
- {
- FastPath_hook7(*(u32*)n->primary_key);
- }
- #else
- rtk_delArp(*(u32*)n->primary_key);
- #endif
- }
- #endif
-
- return ret;
-}
-
-int32 rtl_neigh_timer_handler_pre_update_hooks(struct neighbour *neigh, unsigned state)
-{
- #if defined(CONFIG_RTL_HARDWARE_NAT) && defined(CONFIG_RTL_LAYERED_DRIVER) && defined(CONFIG_RTL_LAYERED_DRIVER_L3)
- int32 tval;
- #endif
-
- if (state & NUD_REACHABLE) {
- #if defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- if (neigh->nud_state & NUD_VALID) {
- #ifdef CONFIG_FAST_PATH_MODULE
- if(FastPath_hook7!=NULL)
- {
- FastPath_hook7(*(u32*)neigh->primary_key);
- }
- #else
- rtk_delArp(*(u32*)neigh->primary_key);
- #endif
- }
- #endif
-
- #if defined(CONFIG_RTL_HARDWARE_NAT) && defined(CONFIG_RTL_LAYERED_DRIVER) && defined(CONFIG_RTL_LAYERED_DRIVER_L3)
- tval = rtl865x_arpSync(htonl(*((u32 *)neigh->primary_key)), 0);
- if (tval > 0)
- {
- neigh->confirmed = jiffies;
- }
- #if 0
- printk("%s:%d: ip:%u.%u.%u.%u, mac:%x:%x:%x:%x:%x:%x, tval is %d\n",
- __FUNCTION__,__LINE__,NIPQUAD(htonl(*((u32 *)neigh->primary_key))), neigh->ha[0], neigh->ha[1],
- neigh->ha[2], neigh->ha[3], neigh->ha[4], neigh->ha[5],tval);
- #endif
- #endif
-
- } else if (state & NUD_DELAY) {
- #if defined(CONFIG_RTL_HARDWARE_NAT) && defined(CONFIG_RTL_LAYERED_DRIVER) && defined(CONFIG_RTL_LAYERED_DRIVER_L3)
- tval = rtl865x_arpSync(htonl(*((u32 *)neigh->primary_key)), 0);
- if (tval > 0)
- {
- neigh->confirmed = jiffies;
- }
- #if 0
- printk("%s:%d: ip:%u.%u.%u.%u, mac:%x:%x:%x:%x:%x:%x, tval is %d",
- __FUNCTION__,__LINE__,NIPQUAD(htonl(*((u32 *)neigh->primary_key))), neigh->ha[0], neigh->ha[1],
- neigh->ha[2], neigh->ha[3], neigh->ha[4], neigh->ha[5],tval);
- #endif
- #endif
- }
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl_neigh_timer_handler_during_update_hooks(struct neighbour *neigh, unsigned state)
-{
- #if defined(CONFIG_RTL_HARDWARE_NAT) && defined(CONFIG_RTL_LAYERED_DRIVER) && defined(CONFIG_RTL_LAYERED_DRIVER_L3)
- if ((neigh->nud_state & (NUD_INCOMPLETE | NUD_PROBE)) &&
- atomic_read(&neigh->probes) >= neigh_max_probes(neigh)) {
- if (neigh->nud_state & NUD_VALID) {
- /*delete asic arp entry*/
- syn_asic_arp(neigh, 0);
- #if 0
- printk("%s:%d: ip:%u.%u.%u.%u, mac:%x:%x:%x:%x:%x:%x\n",
- __FUNCTION__,__LINE__,NIPQUAD(htonl(*((u32 *)neigh->primary_key))), neigh->ha[0], neigh->ha[1],
- neigh->ha[2], neigh->ha[3], neigh->ha[4],neigh->ha[5]);
- #endif
- }
- }
- #endif
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl_neigh_timer_handler_post_update_hooks(struct neighbour *neigh, unsigned state)
-{
- #if defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- if ((neigh->nud_state & NUD_VALID) && !(state & NUD_VALID)) {
- #ifdef CONFIG_FAST_PATH_MODULE
- if(FastPath_hook5!=NULL)
- {
- FastPath_hook5(*(u32*)neigh->primary_key, (ether_addr_t*)neigh->ha, ARP_NONE);
- }
- #else
- rtk_addArp(*(u32*)neigh->primary_key, (ether_addr_t*)neigh->ha, ARP_NONE);
- #endif
- } else if ((state & NUD_VALID) && !(neigh->nud_state & NUD_VALID)) {
- #ifdef CONFIG_FAST_PATH_MODULE
- if(FastPath_hook7!=NULL)
- {
- FastPath_hook7(*(u32*)neigh->primary_key);
- }
- #else
- rtk_delArp(*(u32*)neigh->primary_key);
- #endif
- }
- #endif
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl___neigh_event_send_pre_hooks(struct neighbour *neigh, struct sk_buff *skb)
-{
- #if defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- if (!(neigh->nud_state & (NUD_STALE | NUD_INCOMPLETE))) {
- if (neigh->nud_state & NUD_VALID) {
- #if defined(CONFIG_FAST_PATH_MODULE)
- if(FastPath_hook7!=NULL) {
- FastPath_hook7(*(u32*)neigh->primary_key);
- }
- #else
- rtk_delArp(*(u32*)neigh->primary_key);
- #endif
- }
- }
- #endif
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl___neigh_event_send_post_hooks(struct neighbour *neigh, struct sk_buff *skb)
-{
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl_neigh_init_hooks(void)
-{
- #if defined(CONFIG_RTL_MULTIPLE_WAN)
- rtl_set_callback_for_ps_arp(rtl_get_ps_arp_mapping);
- #endif
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-#if defined(CONFIG_BRIDGE)
-int32 rtl___br_fdb_get_timeout_hooks(struct net_bridge *br, struct net_bridge_fdb_entry *fdb, const unsigned char *addr)
-{
- #if defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- if (rtl_br_fdb_time_update((void*)br, (void*)fdb, addr)==FAILED) {
- return RTL_PS_HOOKS_BREAK;
- }
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-#endif
-
-int32 rtl_masq_device_event_hooks(struct notifier_block *this, struct net_device *dev, unsigned long event)
-{
- #if defined(CONFIG_RTL_HARDWARE_NAT)
- if (dev!=NULL && dev->ip_ptr!=NULL)
- rtl_update_ip_tables(dev->name, event, (struct in_ifaddr *)(((struct in_device *)(dev->ip_ptr))->ifa_list));
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-
- int32 rtl_masq_inet_event_hooks(struct notifier_block *this, unsigned long event, void *ptr)
- {
- #if defined(CONFIG_RTL_HARDWARE_NAT)
- struct in_ifaddr *ina;
-
- ina = (struct in_ifaddr*)ptr;
-
- #ifdef CONFIG_HARDWARE_NAT_DEBUG
- /*2007-12-19*/
- printk("%s:%d\n",__FUNCTION__,__LINE__);
- printk("ptr->ifa_dev->dev->name is %s\n", ina->ifa_dev->dev->name);
- #endif
-
- rtl_update_ip_tables(ina->ifa_dev->dev->name, event, ina);
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
- }
-
-
-int32 rtl_translate_table_hooks(const char *name,
- unsigned int valid_hooks,
- struct xt_table_info *newinfo,
- void *entry0,
- unsigned int size,
- unsigned int number,
- const unsigned int *hook_entries,
- const unsigned int *underflows)
-{
-#if defined(CONFIG_RTL_HARDWARE_NAT)
- //hyking:check masquerade and add ip
- if(strcmp(name,"nat") == 0)
- {
- rtl_flush_extern_ip();
- rtl_init_masq_info();
- rtl_check_for_extern_ip(name,valid_hooks,newinfo,entry0,size,number,hook_entries,underflows);
- }
-#endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl_ip_tables_init_hooks(void)
-{
- #if defined(CONFIG_RTL_HARDWARE_NAT)
- rtl_init_masq_info();
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-
-int32 rtl_ip_vs_conn_expire_hooks1(struct ip_vs_conn *cp)
-{
- int32 ret;
-
- ret = RTL_PS_HOOKS_CONTINUE;
- #if defined(CONFIG_RTL_HARDWARE_NAT)
- if (FAILED==rtl_ip_vs_conn_expire_check(cp)) {
- ret = RTL_PS_HOOKS_RETURN;
- }
- #endif
-
- return ret;
-}
-
-int32 rtl_ip_vs_conn_expire_hooks2(struct ip_vs_conn *cp)
-{
- #if defined(CONFIG_RTL_HARDWARE_NAT)
- rtl_ip_vs_conn_expire_check_delete(cp);
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-#if defined(CONFIG_IP_VS_PROTO_TCP)
-int32 rtl_tcp_state_transition_hooks(struct ip_vs_conn *cp, int direction, const struct sk_buff *skb, struct ip_vs_protocol *pp)
-{
- #if defined(CONFIG_RTL_HARDWARE_NAT)
- rtl_tcp_state_transition_check(cp, direction, skb, pp);
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-#endif
-
-#if defined(CONFIG_IP_VS_PROTO_UDP)
-int32 rtl_udp_state_transition_hooks(struct ip_vs_conn *cp, int direction, const struct sk_buff *skb, struct ip_vs_protocol *pp)
-{
- #if defined(CONFIG_RTL_HARDWARE_NAT)
- rtl_udp_state_transition_check(cp, direction, skb, pp);
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-#endif
-
-#ifdef CONFIG_PROC_FS
-int rtl_ct_seq_show_hooks(struct seq_file *s, struct nf_conn *ct)
-{
- //hyking add for hw use
- #if defined(CONFIG_RTL_HARDWARE_NAT)
- struct nf_conn_nat *nat;
- char *state[2]={"Hardware","software"};
-
- nat = nfct_nat(ct);
- if(seq_printf(s,"[%s] ",nat->hw_acc?state[0]:state[1]) != 0)
- return RTL_PS_HOOKS_BREAK;
- #endif
- return RTL_PS_HOOKS_CONTINUE;
-}
-#endif
-
-#if defined(CONFIG_RTL_NF_CONNTRACK_GARBAGE_NEW)
-//When do garbage collection and dst cache overflow, should not do garbage collection for rtl_gc_overflow_timout(default 3s)
-//Note: rtl_gc_overflow_timout can be modified by user via /proc/gc_overflow_timout
-unsigned long rtl_gc_overflow_timout=3*HZ;
-static unsigned long rtl_gc_overflow_timeout=0;
-#endif
-
-//Before do garbage collection, do rtl_dst_alloc_gc_pre_check_hooks
-int32 rtl_dst_alloc_gc_pre_check_hooks(struct dst_ops * ops)
-{
-#if defined(CONFIG_RTL_NF_CONNTRACK_GARBAGE_NEW)
- if((rtl_gc_overflow_timeout > 0)&& time_after_eq(rtl_gc_overflow_timeout, jiffies)){
- return RTL_PS_HOOKS_RETURN;
- }
-#endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-//After do garbage collection and dst cache overflow, do rtl_dst_alloc_gc_post_check1_hooks
-int32 rtl_dst_alloc_gc_post_check1_hooks(struct dst_ops * ops)
-{
-#if defined(CONFIG_RTL_NF_CONNTRACK_GARBAGE_NEW)
- rtl_gc_overflow_timeout=jiffies+rtl_gc_overflow_timout;
-#endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-//After [do garbage collection and dst cache not overflow] and dst alloc success, do rtl_dst_alloc_gc_post_check2_hooks
-int32 rtl_dst_alloc_gc_post_check2_hooks(struct dst_ops * ops, struct dst_entry * dst)
-{
-#if defined(CONFIG_RTL_NF_CONNTRACK_GARBAGE_NEW)
- rtl_gc_overflow_timeout=0;
-#endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-#if defined(CONFIG_RTL_NF_CONNTRACK_GARBAGE_NEW)
-// hooks in clean_from_lists at rtl_nf_connGC.c
-int32 clean_from_lists_hooks(struct nf_conn *ct, struct net *net)
-{
- #if defined(CONFIG_RTL_IPTABLES_FAST_PATH) || defined(CONFIG_RTL_HARDWARE_NAT)
- rtl_delConnCache(ct);
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-// hooks in __nf_ct_refresh_acct_proto at rtl_nf_connGC.c
-int32 __nf_ct_refresh_acct_proto_hooks(struct nf_conn *ct,
- enum ip_conntrack_info ctinfo,
- const struct sk_buff *skb,
- int do_acct,
- int *event)
-{
-#ifdef CONFIG_IP_NF_CT_ACCT
- if (do_acct) {
- ct->counters[CTINFO2DIR(ctinfo)].packets++;
- ct->counters[CTINFO2DIR(ctinfo)].bytes +=
- ntohs(skb->nh.iph->tot_len);
- if ((ct->counters[CTINFO2DIR(ctinfo)].packets & 0x80000000)
- || (ct->counters[CTINFO2DIR(ctinfo)].bytes & 0x80000000))
- *event |= IPCT_COUNTER_FILLING;
- }
-#endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-// hooks1 in __drop_one_conntrack_process at rtl_nf_connGC.c
-int32 __drop_one_conntrack_process_hooks1(struct nf_conn* ct, int dropPrioIdx, int factor, int checkFlags, int tcpUdpState)
-{
-#if defined(CONFIG_RTL_IPTABLES_FAST_PATH) || defined(CONFIG_RTL_HARDWARE_NAT)
- if (checkFlags==TRUE && drop_priority[dropPrioIdx].state==tcpUdpState) {
- #if defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- if (FAILED==rtl_fpTimer_update(ct)) {
- read_unlock_bh(&nf_conntrack_lock);
- rtl_death_action(ct);
- return RTL_PS_HOOKS_RETURN;
- }
- #endif
-
- #if defined(CONFIG_RTL_HARDWARE_NAT)
- if (FAILED==rtl_hwnat_timer_update(ct)) {
- read_unlock_bh(&nf_conntrack_lock);
- rtl_death_action(ct);
- return RTL_PS_HOOKS_RETURN;
- }
- #endif
- }
-
-#if (HZ==100)
- if (((ct->timeout.expires - jiffies) >> (factor+7))<=drop_priority[dropPrioIdx].threshold)
-#elif (HZ==1000)
- if (((ct->timeout.expires - jiffies) >> (factor+10))<=drop_priority[dropPrioIdx].threshold)
-#else
- #error "Please Check the HZ defination."
-#endif
- {
- read_unlock_bh(&nf_conntrack_lock);
- rtl_death_action(ct);
- return RTL_PS_HOOKS_RETURN;
- }
-
- return RTL_PS_HOOKS_CONTINUE;
-#else
- return RTL_PS_HOOKS_BREAK;
-#endif
-}
-
-// hooks2 in __drop_one_conntrack_process at rtl_nf_connGC.c
-int32 __drop_one_conntrack_process_hooks2(struct nf_conn* ct, int dropPrioIdx, int factor, int checkFlags, int tcpUdpState)
-{
-#if defined(CONFIG_RTL_IPTABLES_FAST_PATH) || defined(CONFIG_RTL_HARDWARE_NAT)
- add_timer(&ct->timeout);
-#endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-// hooks in rtl_nf_conn_GC_init at rtl_nf_connGC.c
-int32 rtl_nf_conn_GC_init_hooks(void)
-{
-#if defined(CONFIG_PROC_FS)
- gc_overflow_timout_proc_init();
-#endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-#endif
-
diff --git a/target/linux/realtek/files/net/rtl/features/96C/rtl_nf_connGC.S b/target/linux/realtek/files/net/rtl/features/96E/rtl_nf_connGC.S
index 9d58519ff..4f61b36c1 100644
--- a/target/linux/realtek/files/net/rtl/features/96C/rtl_nf_connGC.S
+++ b/target/linux/realtek/files/net/rtl/features/96E/rtl_nf_connGC.S
@@ -91,16 +91,16 @@ drop_priority:
.half 120
.byte 11
.space 1
- .half 60
+ .half 85
.byte 1
.space 1
- .half 90
+ .half 110
.byte 2
.space 1
.half 30
.byte 12
.space 1
- .half 20
+ .half 10
.byte 3
.space 1
.half 120
@@ -295,14 +295,13 @@ $L8:
beq $2,$0,$L16
lui $2,%hi(rtl_newGC_session_status_flags)
- lui $2,%hi(init_net+468)
- lw $3,%lo(init_net+468)($2)
- lw $2,%lo(rtl_nf_conntrack_threshold)($4)
- nop
- slt $2,$2,$3
- beq $2,$0,$L9
- lui $4,%hi(rtl_newGC_session_status_flags)
+ jal rtl_gc_threshold_check
+ move $4,$0
+ bne $2,$0,$L9
+ lui $2,%hi(rtl_newGC_session_status_flags)
+
+ lui $4,%hi(rtl_newGC_session_status_flags)
lw $2,%lo(rtl_newGC_session_status_flags)($4)
li $3,3 # 0x3
beq $2,$3,$L3
@@ -316,7 +315,6 @@ $L8:
sw $2,%lo(rtl_newGC_session_status_time)($3)
$L9:
- lui $2,%hi(rtl_newGC_session_status_flags)
$L16:
sw $0,%lo(rtl_newGC_session_status_flags)($2)
$L3:
@@ -406,14 +404,13 @@ $L24:
beq $2,$0,$L32
lui $2,%hi(rtl_newGC_session_status_flags)
- lui $2,%hi(init_net+468)
- lw $3,%lo(init_net+468)($2)
- lw $2,%lo(rtl_nf_conntrack_threshold)($4)
- nop
- slt $2,$2,$3
- beq $2,$0,$L25
- lui $4,%hi(rtl_newGC_session_status_flags)
+ jal rtl_gc_threshold_check
+ move $4,$0
+
+ bne $2,$0,$L25
+ lui $2,%hi(rtl_newGC_session_status_flags)
+ lui $4,%hi(rtl_newGC_session_status_flags)
lw $2,%lo(rtl_newGC_session_status_flags)($4)
li $3,3 # 0x3
beq $2,$3,$L19
@@ -427,7 +424,6 @@ $L24:
sw $2,%lo(rtl_newGC_session_status_time)($3)
$L25:
- lui $2,%hi(rtl_newGC_session_status_flags)
$L32:
sw $0,%lo(rtl_newGC_session_status_flags)($2)
$L19:
@@ -455,57 +451,45 @@ clean_from_lists:
addiu $sp,$sp,-32
sw $17,20($sp)
sw $16,16($sp)
- sw $31,24($sp)
- lw $3,4($4)
- addiu $6,$4,4
- move $16,$4
- lw $4,4($6)
- andi $2,$3,0x1
move $17,$5
+ move $16,$4
+ sw $31,24($sp)
.set noreorder
.set nomacro
- bne $2,$0,$L38
- sw $3,0($4)
+ jal rtl_hlist_nulls_del_rcu
+ move $5,$0
.set macro
.set reorder
- sw $4,4($3)
-$L38:
- li $2,2097152 # 0x200000
- ori $7,$2,0x200
- sw $7,4($6)
- lw $3,52($16)
- addiu $5,$16,52
- lw $4,4($5)
- andi $2,$3,0x1
+ move $4,$16
.set noreorder
.set nomacro
- bne $2,$0,$L42
- sw $3,0($4)
+ jal rtl_hlist_nulls_del_rcu
+ li $5,1 # 0x1
.set macro
.set reorder
- sw $4,4($3)
-$L42:
+ jal local_bh_disable
+ move $4,$16
.set noreorder
.set nomacro
- jal local_bh_disable
- sw $7,4($5)
+ jal rtl_new_gc_get_ct_protonum
+ move $5,$0
.set macro
.set reorder
- lbu $3,50($16)
+ move $3,$2
li $2,6 # 0x6
.set noreorder
.set nomacro
- beq $3,$2,$L48
+ beq $3,$2,$L40
slt $2,$3,7
.set macro
.set reorder
.set noreorder
.set nomacro
- beq $2,$0,$L57
+ beq $2,$0,$L49
li $2,17 # 0x11
.set macro
.set reorder
@@ -513,22 +497,22 @@ $L42:
li $2,1 # 0x1
.set noreorder
.set nomacro
- beq $3,$2,$L54
- li $2,6 # 0x6
+ beq $3,$2,$L46
+ move $4,$16
.set macro
.set reorder
- j $L68
-$L57:
+ j $L58
+$L49:
.set noreorder
.set nomacro
- beq $3,$2,$L51
- lui $4,%hi(prot_counters+8)
+ beq $3,$2,$L43
+ move $4,$16
.set macro
.set reorder
- j $L47
-$L48:
+ j $L58
+$L40:
lui $4,%hi(prot_counters+4)
#APP
raw_local_irq_save $3
@@ -537,8 +521,9 @@ $L48:
#nop
addiu $2,$2,-1
sw $2,%lo(prot_counters+4)($4)
- j $L67
-$L51:
+ j $L57
+$L43:
+ lui $4,%hi(prot_counters+8)
#APP
raw_local_irq_save $3
#NO_APP
@@ -546,8 +531,8 @@ $L51:
#nop
addiu $2,$2,-1
sw $2,%lo(prot_counters+8)($4)
- j $L67
-$L54:
+ j $L57
+$L46:
lui $4,%hi(prot_counters)
#APP
raw_local_irq_save $3
@@ -556,24 +541,43 @@ $L54:
#nop
addiu $2,$2,-1
sw $2,%lo(prot_counters)($4)
-$L67:
+$L57:
#APP
raw_local_irq_restore $3
#NO_APP
-$L47:
- lbu $3,50($16)
- li $2,6 # 0x6
-$L68:
+ move $4,$16
+$L58:
.set noreorder
.set nomacro
- beq $3,$2,$L59
- li $2,17 # 0x11
+ jal rtl_new_gc_get_ct_protonum
+ move $5,$0
.set macro
.set reorder
- bne $3,$2,$L66
-$L59:
+ li $3,6 # 0x6
+ .set noreorder
+ .set nomacro
+ beq $2,$3,$L59
+ move $4,$16
+ .set macro
+ .set reorder
+
+ .set noreorder
+ .set nomacro
+ jal rtl_new_gc_get_ct_protonum
+ move $5,$0
+ .set macro
+ .set reorder
+
+ li $3,17 # 0x11
+ .set noreorder
+ .set nomacro
+ bne $2,$3,$L56
move $4,$16
+ .set macro
+ .set reorder
+
+$L59:
.set noreorder
.set nomacro
jal clean_from_lists_hooks
@@ -581,44 +585,43 @@ $L59:
.set macro
.set reorder
- addiu $5,$16,204
- lw $4,4($5)
- lw $3,204($16)
- li $2,1048576 # 0x100000
- ori $2,$2,0x100
- sw $3,0($4)
- sw $2,204($16)
- li $2,2097152 # 0x200000
- ori $2,$2,0x200
- sw $4,4($3)
- sw $2,4($5)
+ .set noreorder
+ .set nomacro
+ jal rtl_list_del
+ move $4,$16
+ .set macro
+ .set reorder
+
lui $2,%hi(nf_conntrack_max)
lw $2,%lo(nf_conntrack_max)($2)
#nop
.set noreorder
.set nomacro
- beq $2,$0,$L69
+ beq $2,$0,$L60
lui $2,%hi(rtl_newGC_session_status_flags)
.set macro
.set reorder
- lui $2,%hi(rtl_nf_conntrack_threshold)
- lw $3,468($17)
- lw $2,%lo(rtl_nf_conntrack_threshold)($2)
- #nop
- slt $2,$2,$3
.set noreorder
.set nomacro
- beq $2,$0,$L62
- lui $4,%hi(rtl_newGC_session_status_flags)
+ jal rtl_gc_threshold_check
+ move $4,$17
+ .set macro
+ .set reorder
+
+ .set noreorder
+ .set nomacro
+ bne $2,$0,$L52
+ lui $2,%hi(rtl_newGC_session_status_flags)
.set macro
.set reorder
+ lui $4,%hi(rtl_newGC_session_status_flags)
lw $2,%lo(rtl_newGC_session_status_flags)($4)
li $3,3 # 0x3
.set noreorder
.set nomacro
- beq $2,$3,$L66
+ beq $2,$3,$L56
lui $2,%hi(jiffies)
.set macro
.set reorder
@@ -629,16 +632,15 @@ $L59:
addiu $2,$2,1
.set noreorder
.set nomacro
- j $L66
+ j $L56
sw $2,%lo(rtl_newGC_session_status_time)($3)
.set macro
.set reorder
-$L62:
- lui $2,%hi(rtl_newGC_session_status_flags)
-$L69:
+$L52:
+$L60:
sw $0,%lo(rtl_newGC_session_status_flags)($2)
-$L66:
+$L56:
jal local_bh_enable
move $4,$16
lw $31,24($sp)
@@ -671,7 +673,7 @@ rtl_death_action:
move $16,$4
.set noreorder
.set nomacro
- beq $3,$0,$L77
+ beq $3,$0,$L68
addiu $17,$2,%lo(init_net)
.set macro
.set reorder
@@ -680,36 +682,38 @@ rtl_death_action:
#nop
.set noreorder
.set nomacro
- beq $2,$0,$L77
+ beq $2,$0,$L68
addu $3,$3,$2
.set macro
.set reorder
- beq $3,$0,$L77
+ beq $3,$0,$L68
lw $2,0($3)
#nop
- beq $2,$0,$L77
+ beq $2,$0,$L68
lw $2,64($2)
#nop
- beq $2,$0,$L77
+ beq $2,$0,$L68
jal $2
-$L77:
+$L68:
jal local_bh_disable
- lw $3,488($17)
- move $5,$17
+ .set noreorder
+ .set nomacro
+ jal rtl_nf_ct_stat_inc
+ move $4,$17
+ .set macro
+ .set reorder
+
move $4,$16
- lw $2,24($3)
- #nop
- addiu $2,$2,1
.set noreorder
.set nomacro
jal clean_from_lists
- sw $2,24($3)
+ move $5,$17
.set macro
.set reorder
jal local_bh_enable
- beq $16,$0,$L70
+ beq $16,$0,$L61
#APP
raw_local_irq_save $3
#NO_APP
@@ -722,7 +726,7 @@ $L77:
#NO_APP
.set noreorder
.set nomacro
- bne $2,$0,$L70
+ bne $2,$0,$L61
move $4,$16
.set macro
.set reorder
@@ -737,7 +741,7 @@ $L77:
.set macro
.set reorder
-$L70:
+$L61:
lw $31,24($sp)
lw $17,20($sp)
lw $16,16($sp)
@@ -756,69 +760,83 @@ $L70:
.type rtl_connGC_addList, @function
rtl_connGC_addList:
.set nomips16
- .frame $sp,0,$31 # vars= 0, regs= 0/0, args= 0, gp= 0
- .mask 0x00000000,0
+ .frame $sp,32,$31 # vars= 0, regs= 3/0, args= 16, gp= 0
+ .mask 0x80030000,-8
.fmask 0x00000000,0
- lw $2,156($4)
- #nop
- beq $2,$0,$L98
- lbu $3,9($2)
+ addiu $sp,$sp,-32
+ sw $17,20($sp)
+ sw $16,16($sp)
+ sw $31,24($sp)
+ move $17,$5
+ .set noreorder
+ .set nomacro
+ jal rtl_new_gc_ip_hdr
+ move $16,$4
+ .set macro
+ .set reorder
+
+ beq $2,$0,$L89
+ .set noreorder
+ .set nomacro
+ jal rtl_new_gc_get_skb_protocol
+ move $4,$16
+ .set macro
+ .set reorder
+
+ move $3,$2
li $2,6 # 0x6
.set noreorder
.set nomacro
- beq $3,$2,$L103
+ beq $3,$2,$L92
slt $2,$3,7
.set macro
.set reorder
.set noreorder
.set nomacro
- beq $2,$0,$L123
+ beq $2,$0,$L104
li $2,17 # 0x11
.set macro
.set reorder
li $2,1 # 0x1
+ beq $3,$2,$L101
+ j $L89
+$L104:
+ beq $3,$2,$L96
+ j $L89
+$L92:
.set noreorder
.set nomacro
- beq $3,$2,$L118
- lui $4,%hi(prot_counters)
+ jal rtl_new_gc_get_ct_tcp_state
+ move $4,$17
.set macro
.set reorder
+ lui $3,%hi(Tcp_State_Hash_Head)
+ sll $2,$2,3
+ addiu $3,$3,%lo(Tcp_State_Hash_Head)
+ addu $2,$2,$3
+ lw $2,4($2)
+ #nop
.set noreorder
.set nomacro
- j $31
- move $2,$0
+ beq $2,$0,$L107
+ lui $4,%hi(prot_counters+4)
.set macro
.set reorder
-$L123:
+ move $4,$17
+ li $5,1 # 0x1
.set noreorder
.set nomacro
- beq $3,$2,$L109
- move $2,$0
+ jal rtl_list_add_tail
+ move $6,$0
.set macro
.set reorder
- j $L126
-$L103:
- lbu $3,176($5)
- lui $2,%hi(Tcp_State_Hash_Head)
- addiu $2,$2,%lo(Tcp_State_Hash_Head)
- sll $3,$3,3
- addu $3,$3,$2
- lw $4,4($3)
- #nop
- beq $4,$0,$L104
- lw $3,4($4)
- addiu $2,$5,204
- sw $4,204($5)
- sw $2,4($4)
- sw $2,0($3)
- sw $3,4($2)
-$L104:
lui $4,%hi(prot_counters+4)
+$L107:
#APP
raw_local_irq_save $3
#NO_APP
@@ -826,31 +844,36 @@ $L104:
#nop
addiu $2,$2,1
sw $2,%lo(prot_counters+4)($4)
- j $L125
-$L109:
- lw $2,100($5)
- addiu $4,$5,204
+ j $L106
+$L96:
+ .set noreorder
+ .set nomacro
+ jal rtl_new_gc_get_ct_udp_status
+ move $4,$17
+ .set macro
+ .set reorder
+
andi $2,$2,0x2
.set noreorder
.set nomacro
- beq $2,$0,$L110
- lui $3,%hi(Udp_State_Hash_Head)
+ beq $2,$0,$L97
+ move $4,$17
.set macro
.set reorder
- addiu $2,$3,%lo(Udp_State_Hash_Head)
- lw $2,12($2)
- j $L124
-$L110:
- addiu $2,$3,%lo(Udp_State_Hash_Head)
- lw $2,4($2)
- #nop
-$L124:
- lw $3,4($2)
- sw $2,204($5)
- sw $4,4($2)
- sw $4,0($3)
- sw $3,4($4)
+ li $5,2 # 0x2
+ .set noreorder
+ .set nomacro
+ j $L105
+ li $6,1 # 0x1
+ .set macro
+ .set reorder
+
+$L97:
+ li $5,2 # 0x2
+ move $6,$0
+$L105:
+ jal rtl_list_add_tail
lui $4,%hi(prot_counters+8)
#APP
raw_local_irq_save $3
@@ -859,8 +882,9 @@ $L124:
#nop
addiu $2,$2,1
sw $2,%lo(prot_counters+8)($4)
- j $L125
-$L118:
+ j $L106
+$L101:
+ lui $4,%hi(prot_counters)
#APP
raw_local_irq_save $3
#NO_APP
@@ -868,14 +892,22 @@ $L118:
#nop
addiu $2,$2,1
sw $2,%lo(prot_counters)($4)
-$L125:
+$L106:
#APP
raw_local_irq_restore $3
#NO_APP
-$L98:
+$L89:
+ lw $31,24($sp)
+ lw $17,20($sp)
+ lw $16,16($sp)
move $2,$0
-$L126:
+ .set noreorder
+ .set nomacro
j $31
+ addiu $sp,$sp,32
+ .set macro
+ .set reorder
+
.end rtl_connGC_addList
.section .text.__nf_ct_refresh_acct_proto,"ax",@progbits
.align 2
@@ -884,462 +916,561 @@ $L126:
.type __nf_ct_refresh_acct_proto, @function
__nf_ct_refresh_acct_proto:
.set nomips16
- .frame $sp,64,$31 # vars= 8, regs= 7/0, args= 24, gp= 0
- .mask 0x803f0000,-8
+ .frame $sp,56,$31 # vars= 8, regs= 6/0, args= 24, gp= 0
+ .mask 0x801f0000,-4
.fmask 0x00000000,0
.set noreorder
.set nomacro
- addiu $sp,$sp,-64
- sw $17,36($sp)
- move $17,$4
- sw $21,52($sp)
+ addiu $sp,$sp,-56
+ sw $16,32($sp)
+ move $16,$4
sw $20,48($sp)
sw $19,44($sp)
sw $18,40($sp)
- sw $31,56($sp)
- sw $16,32($sp)
- move $20,$5
- move $21,$6
+ sw $17,36($sp)
+ move $19,$5
+ sw $31,52($sp)
+ move $20,$6
sw $0,24($sp)
- lbu $18,87($sp)
+ lbu $17,79($sp)
jal local_bh_disable
- move $19,$7
+ move $18,$7
- lw $2,100($17)
- nop
- srl $2,$2,10
- andi $2,$2,0x1
- bne $2,$0,$L163
- nop
+ move $4,$16
+ jal rtl_test_bit
+ li $5,10 # 0xa
- lw $2,100($17)
- nop
- srl $2,$2,3
- andi $2,$2,0x1
- bne $2,$0,$L136
- li $2,8 # 0x8
+ beq $2,$0,$L128
+ move $4,$16
+
+ jal rtl_test_bit
+ li $5,3 # 0x3
+
+ li $3,-1 # 0xffffffffffffffff
+ bne $2,$3,$L115
+ move $5,$18
- sw $19,116($17)
- j $L139
+ jal rtl_new_gc_set_ct_timeout_expires
+ move $4,$16
+
+ li $2,8 # 0x8
+ j $L116
sw $2,24($sp)
-$L136:
- addiu $16,$17,108
- jal del_timer
+$L115:
+ jal rtl_del_ct_timer
move $4,$16
- beq $2,$0,$L139
+ beq $2,$0,$L116
lui $2,%hi(jiffies)
- lw $2,%lo(jiffies)($2)
+ lw $5,%lo(jiffies)($2)
+ move $4,$16
+ jal rtl_new_gc_set_ct_timeout_expires
+ addu $5,$5,$18
+
+ jal rtl_add_ct_timer
move $4,$16
- addu $2,$2,$19
- jal add_timer
- sw $2,116($17)
li $2,8 # 0x8
sw $2,24($sp)
li $2,6 # 0x6
- beq $18,$2,$L142
+ beq $17,$2,$L119
li $2,17 # 0x11
- beq $18,$2,$L147
+ beq $17,$2,$L120
nop
- j $L139
+ j $L116
nop
-$L142:
- lw $3,92($sp)
- lui $2,%hi(Tcp_State_Hash_Head)
- addiu $4,$17,204
- addiu $2,$2,%lo(Tcp_State_Hash_Head)
- sll $3,$3,3
- lw $6,4($4)
- lw $5,204($17)
- addu $3,$3,$2
- lw $2,4($3)
- sw $6,4($5)
- sw $5,0($6)
- lw $3,4($2)
- sw $2,204($17)
- sw $4,4($2)
- sw $4,0($3)
- j $L139
- sw $3,4($4)
-
-$L147:
- lw $2,100($17)
- lw $6,204($17)
+$L119:
+ lw $6,84($sp)
+ move $4,$16
+ j $L127
+ li $5,1 # 0x1
+
+$L120:
+ jal rtl_new_gc_get_ct_udp_status
+ move $4,$16
+
andi $2,$2,0x2
- beq $2,$0,$L148
- addiu $5,$17,204
-
- lw $2,4($5)
- lui $3,%hi(udp_assured_list)
- j $L162
- addiu $3,$3,%lo(udp_assured_list)
-
-$L148:
- lw $2,4($5)
- lui $3,%hi(udp_unreply_list)
- addiu $3,$3,%lo(udp_unreply_list)
-$L162:
- sw $2,4($6)
- lw $4,4($3)
- sw $6,0($2)
- sw $5,4($3)
- sw $3,204($17)
- sw $4,4($5)
- sw $5,0($4)
-$L139:
- lw $7,80($sp)
+ beq $2,$0,$L121
+ move $4,$16
+
+ li $5,2 # 0x2
+ j $L127
+ li $6,1 # 0x1
+
+$L121:
+ li $5,2 # 0x2
+ move $6,$0
+$L127:
+ jal rtl_list_move_tail
+ nop
+
+$L116:
+ lw $7,72($sp)
addiu $2,$sp,24
- move $4,$17
- move $5,$20
- move $6,$21
+ move $4,$16
+ move $5,$19
+ move $6,$20
jal __nf_ct_refresh_acct_proto_hooks
sw $2,16($sp)
-$L163:
+$L128:
jal local_bh_enable
nop
- lw $31,56($sp)
- lw $21,52($sp)
+ lw $31,52($sp)
lw $20,48($sp)
lw $19,44($sp)
lw $18,40($sp)
lw $17,36($sp)
lw $16,32($sp)
j $31
- addiu $sp,$sp,64
+ addiu $sp,$sp,56
.set macro
.set reorder
.end __nf_ct_refresh_acct_proto
- .section .text.drop_one_conntrack,"ax",@progbits
+ .section .text.__conntrack_drop_check,"ax",@progbits
.align 2
- .globl drop_one_conntrack
- .ent drop_one_conntrack
- .type drop_one_conntrack, @function
-drop_one_conntrack:
+ .globl __conntrack_drop_check
+ .ent __conntrack_drop_check
+ .type __conntrack_drop_check, @function
+__conntrack_drop_check:
.set nomips16
- .frame $sp,64,$31 # vars= 0, regs= 9/0, args= 24, gp= 0
+ .frame $sp,56,$31 # vars= 0, regs= 9/0, args= 16, gp= 0
.mask 0x80ff0000,-8
.fmask 0x00000000,0
.set noreorder
.set nomacro
- addiu $sp,$sp,-64
- sw $31,56($sp)
- sw $23,52($sp)
- sw $22,48($sp)
- sw $21,44($sp)
- sw $20,40($sp)
- sw $19,36($sp)
- sw $18,32($sp)
- sw $17,28($sp)
- sw $16,24($sp)
- lhu $3,16($4)
+ addiu $sp,$sp,-56
+ sw $16,16($sp)
+ move $5,$0
+ move $16,$4
+ sw $31,48($sp)
+ sw $23,44($sp)
+ sw $22,40($sp)
+ sw $21,36($sp)
+ sw $20,32($sp)
+ sw $19,28($sp)
+ sw $18,24($sp)
+ jal rtl_new_gc_get_ct_protonum
+ sw $17,20($sp)
+
+ move $4,$16
+ move $5,$0
+ jal rtl_new_gc_get_ct_port_by_dir
+ move $6,$0
+
+ move $4,$16
+ move $5,$0
+ li $6,1 # 0x1
+ jal rtl_new_gc_get_ct_port_by_dir
+ move $23,$2
+
+ move $4,$16
+ li $5,1 # 0x1
+ move $6,$0
+ jal rtl_new_gc_get_ct_port_by_dir
+ move $22,$2
+
+ move $4,$16
+ li $5,1 # 0x1
+ li $6,1 # 0x1
+ jal rtl_new_gc_get_ct_port_by_dir
+ move $21,$2
+
+ move $4,$16
+ move $5,$0
+ move $6,$0
+ jal rtl_new_gc_get_ct_ip_by_dir
+ move $20,$2
+
+ move $4,$16
+ move $5,$0
+ li $6,1 # 0x1
+ jal rtl_new_gc_get_ct_ip_by_dir
+ move $19,$2
+
+ move $4,$16
+ li $5,1 # 0x1
+ move $6,$0
+ jal rtl_new_gc_get_ct_ip_by_dir
+ move $17,$2
+
+ move $4,$16
+ li $5,1 # 0x1
+ li $6,1 # 0x1
+ jal rtl_new_gc_get_ct_ip_by_dir
+ move $18,$2
+
+ li $5,-268435456 # 0xfffffffff0000000
+ move $3,$2
+ li $4,-536870912 # 0xffffffffe0000000
+ and $2,$17,$5
+ beq $2,$4,$L131
+ and $2,$3,$5
+
+ beq $2,$4,$L129
+ li $2,-1 # 0xffffffffffffffff
+
+ bne $19,$3,$L134
+ sltu $2,$23,1024
+
+ beq $17,$18,$L131
nop
- sltu $2,$3,1024
- bne $2,$0,$L164
- li $2,1 # 0x1
- li $6,8080 # 0x1f90
- beq $3,$6,$L164
+$L134:
+ bne $2,$0,$L129
+ li $2,-1 # 0xffffffffffffffff
+
+ sltu $2,$22,1024
+ bne $2,$0,$L129
+ li $2,-1 # 0xffffffffffffffff
+
+ sltu $2,$21,1024
+ bne $2,$0,$L129
+ li $2,-1 # 0xffffffffffffffff
+
+ sltu $2,$20,1024
+ bne $2,$0,$L131
+ li $3,8080 # 0x1f90
+
+ beq $23,$3,$L131
nop
- lhu $3,36($4)
+ beq $22,$3,$L131
nop
- sltu $2,$3,1024
- bne $2,$0,$L164
+
+ beq $21,$3,$L129
+ li $2,-1 # 0xffffffffffffffff
+
+ bne $20,$3,$L129
+ move $2,$0
+
+$L131:
+ li $2,-1 # 0xffffffffffffffff
+$L129:
+ lw $31,48($sp)
+ lw $23,44($sp)
+ lw $22,40($sp)
+ lw $21,36($sp)
+ lw $20,32($sp)
+ lw $19,28($sp)
+ lw $18,24($sp)
+ lw $17,20($sp)
+ lw $16,16($sp)
+ j $31
+ addiu $sp,$sp,56
+
+ .set macro
+ .set reorder
+ .end __conntrack_drop_check
+ .section .text.isReservedConntrack,"ax",@progbits
+ .align 2
+ .globl isReservedConntrack
+ .ent isReservedConntrack
+ .type isReservedConntrack, @function
+isReservedConntrack:
+ .set nomips16
+ .frame $sp,0,$31 # vars= 0, regs= 0/0, args= 0, gp= 0
+ .mask 0x00000000,0
+ .fmask 0x00000000,0
+ .set noreorder
+ .set nomacro
+
+ lbu $3,38($4)
li $2,1 # 0x1
+ beq $3,$2,$L135
+ li $7,1 # 0x1
- beq $3,$6,$L164
+ lw $6,20($4)
+ li $8,-268435456 # 0xfffffffff0000000
+ li $9,-536870912 # 0xffffffffe0000000
+ and $2,$6,$8
+ lw $3,0($4)
+ beq $2,$9,$L146
+ li $7,-1 # 0xffffffffffffffff
+
+ beq $6,$7,$L146
nop
- lhu $3,16($5)
+ beq $3,$0,$L146
nop
- sltu $2,$3,1024
- bne $2,$0,$L164
- li $2,1 # 0x1
- beq $3,$6,$L164
+ lw $3,20($5)
+ lw $6,0($5)
+ and $2,$3,$8
+ beq $2,$9,$L146
nop
- lhu $3,36($5)
+ beq $3,$7,$L146
nop
- sltu $2,$3,1024
- bne $2,$0,$L164
- li $2,1 # 0x1
- beq $3,$6,$L164
- li $7,-268435456 # 0xfffffffff0000000
+ beq $6,$0,$L146
+ li $3,80 # 0x50
- lw $3,20($4)
- li $8,-536870912 # 0xffffffffe0000000
- and $2,$3,$7
- lw $4,0($4)
- beq $2,$8,$L401
- li $6,-1 # 0xffffffffffffffff
+ lhu $2,16($4)
+ nop
+ beq $2,$3,$L146
+ li $6,8080 # 0x1f90
- beq $3,$6,$L164
- li $2,1 # 0x1
+ beq $2,$6,$L146
+ nop
- beq $4,$0,$L164
+ lhu $4,36($4)
+ nop
+ beq $4,$3,$L146
nop
- lw $3,20($5)
- lw $5,0($5)
- and $2,$3,$7
- beq $2,$8,$L164
- li $2,1 # 0x1
+ beq $4,$6,$L146
+ nop
- beq $3,$6,$L164
+ lhu $2,16($5)
+ nop
+ beq $2,$3,$L146
nop
- beq $5,$0,$L164
- lui $3,%hi(prot_counters+4)
+ beq $2,$6,$L146
+ nop
+
+ lhu $5,36($5)
+ nop
+ beq $5,$3,$L163
+ li $7,1 # 0x1
+
+ bne $5,$6,$L135
+ move $7,$0
+$L146:
+ li $7,1 # 0x1
+$L135:
+$L163:
+ j $31
+ move $2,$7
+
+ .set macro
+ .set reorder
+ .end isReservedConntrack
+ .section .text.drop_one_conntrack,"ax",@progbits
+ .align 2
+ .globl drop_one_conntrack
+ .ent drop_one_conntrack
+ .type drop_one_conntrack, @function
+drop_one_conntrack:
+ .set nomips16
+ .frame $sp,64,$31 # vars= 0, regs= 10/0, args= 24, gp= 0
+ .mask 0xc0ff0000,-4
+ .fmask 0x00000000,0
+ .set noreorder
+ .set nomacro
+
+ addiu $sp,$sp,-64
+ sw $31,60($sp)
+ sw $fp,56($sp)
+ sw $23,52($sp)
+ sw $22,48($sp)
+ sw $21,44($sp)
+ sw $20,40($sp)
+ sw $19,36($sp)
+ sw $18,32($sp)
+ sw $17,28($sp)
+ sw $16,24($sp)
lui $2,%hi(_prot_limit+4)
+ lui $3,%hi(prot_counters+4)
lw $2,%lo(_prot_limit+4)($2)
lw $3,%lo(prot_counters+4)($3)
nop
slt $2,$2,$3
- beq $2,$0,$L454
+ beq $2,$0,$L350
lui $2,%hi(_prot_limit+8)
jal local_bh_disable
+ lui $20,%hi(drop_priority_max_idx)
+
+ lw $2,%lo(drop_priority_max_idx)($20)
+ nop
+ blez $2,$L311
move $19,$0
lui $3,%hi(drop_priority)
-$L456:
+$L351:
addiu $3,$3,%lo(drop_priority)
sll $2,$19,2
addu $2,$2,$3
lbu $3,0($2)
nop
sltu $2,$3,10
- beq $2,$0,$L193
+ beq $2,$0,$L171
lui $2,%hi(Tcp_State_Hash_Head)
- sll $3,$3,3
addiu $2,$2,%lo(Tcp_State_Hash_Head)
+ sll $3,$3,3
addu $3,$3,$2
lw $18,4($3)
nop
- lw $4,0($18)
+ lw $2,0($18)
nop
- beq $4,$18,$L193
- move $17,$4
+ beq $2,$18,$L171
+ move $17,$2
-$L444:
- beq $17,$18,$L193
+$L339:
+ beq $17,$18,$L171
addiu $16,$17,-204
- lw $6,32($16)
- li $11,-268435456 # 0xfffffffff0000000
- li $12,-536870912 # 0xffffffffe0000000
- and $2,$6,$11
- lhu $7,28($16)
- lhu $8,48($16)
- lhu $9,76($16)
- lhu $10,96($16)
- lw $4,12($16)
- lw $5,60($16)
- lw $3,80($16)
- beq $2,$12,$L199
- and $2,$3,$11
-
- beq $2,$12,$L199
- nop
-
- bne $4,$3,$L455
- sltu $2,$7,1024
-
- beq $6,$5,$L199
- nop
-
-$L455:
- bne $2,$0,$L199
- sltu $2,$8,1024
-
- bne $2,$0,$L199
- sltu $2,$9,1024
-
- bne $2,$0,$L199
- sltu $2,$10,1024
-
- bne $2,$0,$L199
- li $2,8080 # 0x1f90
-
- beq $7,$2,$L199
- nop
+ lb $3,212($16)
+ li $2,-1 # 0xffffffffffffffff
+ bne $3,$2,$L178
+ move $4,$16
- beq $8,$2,$L199
+ jal __conntrack_drop_check
nop
- beq $9,$2,$L199
+ sb $2,212($16)
+$L178:
+ lb $2,212($16)
nop
+ bne $2,$0,$L177
+ move $4,$16
- beq $10,$2,$L199
+ jal rtl_del_ct_timer
nop
- jal del_timer
- addiu $4,$17,-96
-
- bne $2,$0,$L419
+ bne $2,$0,$L325
nop
-$L199:
+$L177:
lw $17,0($17)
- j $L444
+ j $L339
nop
-$L193:
+$L171:
+ lw $2,%lo(drop_priority_max_idx)($20)
addiu $19,$19,1
- sltu $2,$19,10
- bne $2,$0,$L456
+ slt $2,$19,$2
+ bne $2,$0,$L351
lui $3,%hi(drop_priority)
+$L311:
jal local_bh_enable
nop
lui $2,%hi(_prot_limit+8)
-$L454:
+$L350:
lui $3,%hi(prot_counters+8)
lw $2,%lo(_prot_limit+8)($2)
lw $3,%lo(prot_counters+8)($3)
nop
slt $2,$2,$3
- beq $2,$0,$L223
- nop
+ beq $2,$0,$L189
+ lui $fp,%hi(drop_priority_max_idx)
jal local_bh_disable
+ lui $20,%hi(drop_priority_max_idx)
+
+ lw $2,%lo(drop_priority_max_idx)($20)
+ nop
+ blez $2,$L314
move $19,$0
lui $3,%hi(drop_priority)
-$L458:
+$L352:
addiu $3,$3,%lo(drop_priority)
sll $2,$19,2
addu $2,$2,$3
lbu $3,0($2)
nop
sltu $2,$3,11
- bne $2,$0,$L229
+ bne $2,$0,$L195
lui $2,%hi(Udp_State_Hash_Head)
- sll $3,$3,3
addiu $2,$2,%lo(Udp_State_Hash_Head)
+ sll $3,$3,3
addu $3,$3,$2
lw $18,-84($3)
nop
- lw $4,0($18)
+ lw $2,0($18)
nop
- beq $4,$18,$L229
- move $17,$4
+ beq $2,$18,$L195
+ move $17,$2
-$L445:
- beq $17,$18,$L229
+$L340:
+ beq $17,$18,$L195
addiu $16,$17,-204
- lw $6,32($16)
- li $11,-268435456 # 0xfffffffff0000000
- li $12,-536870912 # 0xffffffffe0000000
- and $2,$6,$11
- lhu $7,28($16)
- lhu $8,48($16)
- lhu $9,76($16)
- lhu $10,96($16)
- lw $4,12($16)
- lw $5,60($16)
- lw $3,80($16)
- beq $2,$12,$L235
- and $2,$3,$11
-
- beq $2,$12,$L235
- nop
-
- bne $4,$3,$L457
- sltu $2,$7,1024
-
- beq $6,$5,$L235
- nop
-
-$L457:
- bne $2,$0,$L235
- sltu $2,$8,1024
-
- bne $2,$0,$L235
- sltu $2,$9,1024
-
- bne $2,$0,$L235
- sltu $2,$10,1024
-
- bne $2,$0,$L235
- li $2,8080 # 0x1f90
-
- beq $7,$2,$L235
- nop
+ lb $3,212($16)
+ li $2,-1 # 0xffffffffffffffff
+ bne $3,$2,$L202
+ move $4,$16
- beq $8,$2,$L235
+ jal __conntrack_drop_check
nop
- beq $9,$2,$L235
+ sb $2,212($16)
+$L202:
+ lb $2,212($16)
nop
+ bne $2,$0,$L201
+ move $4,$16
- beq $10,$2,$L235
+ jal rtl_del_ct_timer
nop
- jal del_timer
- addiu $4,$17,-96
-
- bne $2,$0,$L419
+ bne $2,$0,$L325
nop
-$L235:
+$L201:
lw $17,0($17)
- j $L445
+ j $L340
nop
-$L229:
+$L195:
+ lw $2,%lo(drop_priority_max_idx)($20)
addiu $19,$19,1
- sltu $2,$19,10
- bne $2,$0,$L458
+ slt $2,$19,$2
+ bne $2,$0,$L352
lui $3,%hi(drop_priority)
+$L314:
jal local_bh_enable
- nop
+ lui $fp,%hi(drop_priority_max_idx)
- j $L223
+ j $L348
nop
-$L419:
+$L325:
jal local_bh_enable
nop
jal rtl_death_action
move $4,$16
- j $L453
+ j $L349
lui $4,%hi(rtl_newGC_session_status_flags)
-$L223:
+$L189:
+$L348:
jal local_bh_disable
move $19,$0
+ lw $2,%lo(drop_priority_max_idx)($fp)
+ nop
+ blez $2,$L317
lui $22,%hi(drop_priority)
-$L463:
+
+$L353:
sll $21,$19,2
addiu $2,$22,%lo(drop_priority)
addu $2,$21,$2
lbu $2,0($2)
nop
sltu $3,$2,10
- beq $3,$0,$L267
+ beq $3,$0,$L221
sll $4,$2,3
lui $2,%hi(Tcp_State_Hash_Head)
@@ -1347,264 +1478,211 @@ $L463:
addu $2,$4,$2
lw $18,4($2)
nop
- lw $4,0($18)
+ lw $2,0($18)
nop
- beq $4,$18,$L300
+ beq $2,$18,$L242
li $23,3 # 0x3
- move $17,$4
+ move $17,$2
move $20,$0
-$L446:
- beq $17,$18,$L300
+$L341:
+ beq $17,$18,$L242
addiu $16,$17,-204
- lw $6,32($16)
- li $11,-268435456 # 0xfffffffff0000000
- li $12,-536870912 # 0xffffffffe0000000
- and $2,$6,$11
- lhu $7,28($16)
- lhu $8,48($16)
- lhu $9,76($16)
- lhu $10,96($16)
- lw $4,12($16)
- lw $5,60($16)
- lw $3,80($16)
- beq $2,$12,$L273
+ lb $3,212($16)
+ li $2,-1 # 0xffffffffffffffff
+ move $4,$16
+ bne $3,$2,$L228
addiu $20,$20,1
- and $2,$3,$11
- beq $2,$12,$L273
+ jal __conntrack_drop_check
nop
- bne $4,$3,$L459
- sltu $2,$7,1024
-
- beq $6,$5,$L273
+ sb $2,212($16)
+$L228:
+ lb $2,212($16)
nop
+ bne $2,$0,$L227
+ move $4,$16
-$L459:
- bne $2,$0,$L273
- sltu $2,$8,1024
-
- bne $2,$0,$L273
- sltu $2,$9,1024
-
- bne $2,$0,$L273
- sltu $2,$10,1024
-
- bne $2,$0,$L273
- li $2,8080 # 0x1f90
-
- beq $7,$2,$L273
+ jal rtl_get_ct_timer_expires
nop
- beq $8,$2,$L273
- nop
+ lui $3,%hi(jiffies)
+ lw $4,%lo(jiffies)($3)
+ addiu $3,$22,%lo(drop_priority)
+ addu $3,$21,$3
+ lhu $3,2($3)
+ subu $2,$2,$4
+ srl $2,$2,7
+ sltu $3,$3,$2
+ bne $3,$0,$L230
+ move $4,$16
- beq $9,$2,$L273
+ jal rtl_del_ct_timer
nop
- beq $10,$2,$L273
- lui $2,%hi(jiffies)
-
- lw $4,%lo(jiffies)($2)
- lw $3,116($16)
- addiu $2,$22,%lo(drop_priority)
- addu $2,$21,$2
- lhu $2,2($2)
- subu $3,$3,$4
- srl $3,$3,7
- sltu $2,$2,$3
- bne $2,$0,$L460
- slt $2,$20,1025
-
- jal del_timer
- addiu $4,$17,-96
-
- beq $2,$0,$L460
- slt $2,$20,1025
-
move $4,$16
move $5,$19
move $6,$0
+ beq $2,$0,$L230
li $7,1 # 0x1
+
jal __drop_one_conntrack_process_hooks1
sw $23,16($sp)
move $3,$2
li $2,1 # 0x1
- beq $3,$2,$L420
- li $2,2 # 0x2
-
- beq $3,$2,$L447
- move $5,$19
-
move $4,$16
+ move $5,$19
move $6,$0
+ beq $3,$2,$L326
li $7,1 # 0x1
+
+ li $2,2 # 0x2
+ beq $3,$2,$L253
+ li $3,1 # 0x1
+
jal __drop_one_conntrack_process_hooks2
sw $23,16($sp)
- slt $2,$20,1025
-$L460:
- beq $2,$0,$L323
+$L230:
+ slt $2,$20,129
+ beq $2,$0,$L253
move $3,$0
-$L273:
+$L227:
lw $17,0($17)
- j $L446
+ j $L341
nop
-$L420:
+$L326:
jal local_bh_enable
nop
jal rtl_death_action
move $4,$16
-$L447:
- j $L323
+ j $L253
li $3,1 # 0x1
-$L267:
+$L221:
lui $2,%hi(Udp_State_Hash_Head)
addiu $2,$2,%lo(Udp_State_Hash_Head)
addu $2,$4,$2
lw $18,-84($2)
nop
- lw $4,0($18)
+ lw $2,0($18)
nop
- beq $4,$18,$L300
+ beq $2,$18,$L242
li $23,12 # 0xc
- move $17,$4
+ move $17,$2
move $20,$0
-$L448:
- beq $17,$18,$L300
+$L343:
+ beq $17,$18,$L242
addiu $16,$17,-204
- lw $6,32($16)
- li $11,-268435456 # 0xfffffffff0000000
- li $12,-536870912 # 0xffffffffe0000000
- and $2,$6,$11
- lhu $7,28($16)
- lhu $8,48($16)
- lhu $9,76($16)
- lhu $10,96($16)
- lw $4,12($16)
- lw $5,60($16)
- lw $3,80($16)
- beq $2,$12,$L304
+ lb $3,212($16)
+ li $2,-1 # 0xffffffffffffffff
+ move $4,$16
+ bne $3,$2,$L247
addiu $20,$20,1
- and $2,$3,$11
- beq $2,$12,$L304
+ jal __conntrack_drop_check
nop
- bne $4,$3,$L461
- sltu $2,$7,1024
-
- beq $6,$5,$L304
+ sb $2,212($16)
+$L247:
+ lb $2,212($16)
nop
+ bne $2,$0,$L246
+ move $4,$16
-$L461:
- bne $2,$0,$L304
- sltu $2,$8,1024
-
- bne $2,$0,$L304
- sltu $2,$9,1024
-
- bne $2,$0,$L304
- sltu $2,$10,1024
-
- bne $2,$0,$L304
- li $2,8080 # 0x1f90
-
- beq $7,$2,$L304
+ jal rtl_get_ct_timer_expires
nop
- beq $8,$2,$L304
- nop
+ lui $3,%hi(jiffies)
+ lw $4,%lo(jiffies)($3)
+ addiu $3,$22,%lo(drop_priority)
+ addu $3,$21,$3
+ lhu $3,2($3)
+ subu $2,$2,$4
+ srl $2,$2,7
+ sltu $3,$3,$2
+ bne $3,$0,$L249
+ move $4,$16
- beq $9,$2,$L304
+ jal rtl_del_ct_timer
nop
- beq $10,$2,$L304
- lui $2,%hi(jiffies)
-
- lw $4,%lo(jiffies)($2)
- lw $3,116($16)
- addiu $2,$22,%lo(drop_priority)
- addu $2,$21,$2
- lhu $2,2($2)
- subu $3,$3,$4
- srl $3,$3,7
- sltu $2,$2,$3
- bne $2,$0,$L462
- slt $2,$20,1025
-
- jal del_timer
- addiu $4,$17,-96
-
- beq $2,$0,$L462
- slt $2,$20,1025
-
move $4,$16
move $5,$19
move $6,$0
+ beq $2,$0,$L249
li $7,1 # 0x1
+
jal __drop_one_conntrack_process_hooks1
sw $23,16($sp)
move $3,$2
li $2,1 # 0x1
- beq $3,$2,$L420
- li $2,2 # 0x2
-
- beq $3,$2,$L447
- move $5,$19
-
move $4,$16
+ move $5,$19
move $6,$0
+ beq $3,$2,$L326
li $7,1 # 0x1
+
+ li $2,2 # 0x2
+ beq $3,$2,$L253
+ li $3,1 # 0x1
+
jal __drop_one_conntrack_process_hooks2
sw $23,16($sp)
- slt $2,$20,1025
-$L462:
- beq $2,$0,$L323
+$L249:
+ slt $2,$20,129
+ beq $2,$0,$L253
move $3,$0
-$L304:
+$L246:
lw $17,0($17)
- j $L448
+ j $L343
nop
-$L300:
+$L242:
move $3,$0
-$L323:
+$L253:
li $2,1 # 0x1
- beq $3,$2,$L260
+ beq $3,$2,$L214
addiu $19,$19,1
- sltu $2,$19,10
- bne $2,$0,$L463
+ lw $2,%lo(drop_priority_max_idx)($fp)
+ nop
+ slt $2,$19,$2
+ bne $2,$0,$L353
lui $22,%hi(drop_priority)
+$L317:
jal local_bh_enable
- move $19,$0
+ lui $fp,%hi(drop_priority_max_idx)
jal local_bh_disable
+ move $19,$0
+
+ lw $2,%lo(drop_priority_max_idx)($fp)
+ nop
+ blez $2,$L321
lui $22,%hi(drop_priority)
-$L468:
+$L354:
sll $21,$19,2
addiu $2,$22,%lo(drop_priority)
addu $2,$21,$2
lbu $2,0($2)
nop
sltu $3,$2,10
- beq $3,$0,$L337
+ beq $3,$0,$L267
sll $4,$2,3
lui $2,%hi(Tcp_State_Hash_Head)
@@ -1612,259 +1690,200 @@ $L468:
addu $2,$4,$2
lw $18,4($2)
nop
- lw $4,0($18)
+ lw $2,0($18)
nop
- beq $4,$18,$L370
+ beq $2,$18,$L288
li $23,3 # 0x3
- move $17,$4
+ move $17,$2
move $20,$0
-$L449:
- beq $17,$18,$L370
+$L344:
+ beq $17,$18,$L288
addiu $16,$17,-204
- lw $6,32($16)
- li $11,-268435456 # 0xfffffffff0000000
- li $12,-536870912 # 0xffffffffe0000000
- and $2,$6,$11
- lhu $7,28($16)
- lhu $8,48($16)
- lhu $9,76($16)
- lhu $10,96($16)
- lw $4,12($16)
- lw $5,60($16)
- lw $3,80($16)
- beq $2,$12,$L343
+ lb $3,212($16)
+ li $2,-1 # 0xffffffffffffffff
+ move $4,$16
+ bne $3,$2,$L274
addiu $20,$20,1
- and $2,$3,$11
- beq $2,$12,$L343
+ jal __conntrack_drop_check
nop
- bne $4,$3,$L464
- sltu $2,$7,1024
-
- beq $6,$5,$L343
+ sb $2,212($16)
+$L274:
+ lb $2,212($16)
nop
+ bne $2,$0,$L273
+ move $4,$16
-$L464:
- bne $2,$0,$L343
- sltu $2,$8,1024
-
- bne $2,$0,$L343
- sltu $2,$9,1024
-
- bne $2,$0,$L343
- sltu $2,$10,1024
-
- bne $2,$0,$L343
- li $2,8080 # 0x1f90
-
- beq $7,$2,$L343
+ jal rtl_get_ct_timer_expires
nop
- beq $8,$2,$L343
- nop
+ lui $3,%hi(jiffies)
+ lw $4,%lo(jiffies)($3)
+ addiu $3,$22,%lo(drop_priority)
+ addu $3,$21,$3
+ lhu $3,2($3)
+ subu $2,$2,$4
+ srl $2,$2,9
+ sltu $3,$3,$2
+ bne $3,$0,$L276
+ move $4,$16
- beq $9,$2,$L343
+ jal rtl_del_ct_timer
nop
- beq $10,$2,$L343
- lui $2,%hi(jiffies)
-
- lw $4,%lo(jiffies)($2)
- lw $3,116($16)
- addiu $2,$22,%lo(drop_priority)
- addu $2,$21,$2
- lhu $2,2($2)
- subu $3,$3,$4
- srl $3,$3,9
- sltu $2,$2,$3
- bne $2,$0,$L465
- slt $2,$20,1025
-
- jal del_timer
- addiu $4,$17,-96
-
- beq $2,$0,$L465
- slt $2,$20,1025
-
move $4,$16
move $5,$19
li $6,2 # 0x2
+ beq $2,$0,$L276
move $7,$0
+
jal __drop_one_conntrack_process_hooks1
sw $23,16($sp)
move $3,$2
li $2,1 # 0x1
- beq $3,$2,$L425
- li $2,2 # 0x2
-
- beq $3,$2,$L450
- move $5,$19
-
move $4,$16
+ move $5,$19
li $6,2 # 0x2
+ beq $3,$2,$L331
move $7,$0
+
+ li $2,2 # 0x2
+ beq $3,$2,$L299
+ li $3,1 # 0x1
+
jal __drop_one_conntrack_process_hooks2
sw $23,16($sp)
- slt $2,$20,1025
-$L465:
- beq $2,$0,$L393
+$L276:
+ slt $2,$20,129
+ beq $2,$0,$L299
move $3,$0
-$L343:
+$L273:
lw $17,0($17)
- j $L449
+ j $L344
nop
-$L425:
+$L331:
jal local_bh_enable
nop
jal rtl_death_action
move $4,$16
-$L450:
- j $L393
+ j $L299
li $3,1 # 0x1
-$L337:
+$L267:
lui $2,%hi(Udp_State_Hash_Head)
addiu $2,$2,%lo(Udp_State_Hash_Head)
addu $2,$4,$2
lw $18,-84($2)
nop
- lw $4,0($18)
+ lw $2,0($18)
nop
- beq $4,$18,$L370
+ beq $2,$18,$L288
li $23,12 # 0xc
- move $17,$4
+ move $17,$2
move $20,$0
-$L451:
- beq $17,$18,$L370
+$L346:
+ beq $17,$18,$L288
addiu $16,$17,-204
- lw $6,32($16)
- li $11,-268435456 # 0xfffffffff0000000
- li $12,-536870912 # 0xffffffffe0000000
- and $2,$6,$11
- lhu $7,28($16)
- lhu $8,48($16)
- lhu $9,76($16)
- lhu $10,96($16)
- lw $4,12($16)
- lw $5,60($16)
- lw $3,80($16)
- beq $2,$12,$L374
+ lb $3,212($16)
+ li $2,-1 # 0xffffffffffffffff
+ move $4,$16
+ bne $3,$2,$L293
addiu $20,$20,1
- and $2,$3,$11
- beq $2,$12,$L374
+ jal __conntrack_drop_check
nop
- bne $4,$3,$L466
- sltu $2,$7,1024
-
- beq $6,$5,$L374
+ sb $2,212($16)
+$L293:
+ lb $2,212($16)
nop
+ bne $2,$0,$L292
+ move $4,$16
-$L466:
- bne $2,$0,$L374
- sltu $2,$8,1024
-
- bne $2,$0,$L374
- sltu $2,$9,1024
-
- bne $2,$0,$L374
- sltu $2,$10,1024
-
- bne $2,$0,$L374
- li $2,8080 # 0x1f90
-
- beq $7,$2,$L374
+ jal rtl_get_ct_timer_expires
nop
- beq $8,$2,$L374
- nop
+ lui $3,%hi(jiffies)
+ lw $4,%lo(jiffies)($3)
+ addiu $3,$22,%lo(drop_priority)
+ addu $3,$21,$3
+ lhu $3,2($3)
+ subu $2,$2,$4
+ srl $2,$2,9
+ sltu $3,$3,$2
+ bne $3,$0,$L295
+ move $4,$16
- beq $9,$2,$L374
+ jal rtl_del_ct_timer
nop
- beq $10,$2,$L374
- lui $2,%hi(jiffies)
-
- lw $4,%lo(jiffies)($2)
- lw $3,116($16)
- addiu $2,$22,%lo(drop_priority)
- addu $2,$21,$2
- lhu $2,2($2)
- subu $3,$3,$4
- srl $3,$3,9
- sltu $2,$2,$3
- bne $2,$0,$L467
- slt $2,$20,1025
-
- jal del_timer
- addiu $4,$17,-96
-
- beq $2,$0,$L467
- slt $2,$20,1025
-
move $4,$16
move $5,$19
li $6,2 # 0x2
+ beq $2,$0,$L295
move $7,$0
+
jal __drop_one_conntrack_process_hooks1
sw $23,16($sp)
move $3,$2
li $2,1 # 0x1
- beq $3,$2,$L425
- li $2,2 # 0x2
-
- beq $3,$2,$L450
- move $5,$19
-
move $4,$16
+ move $5,$19
li $6,2 # 0x2
+ beq $3,$2,$L331
move $7,$0
+
+ li $2,2 # 0x2
+ beq $3,$2,$L299
+ li $3,1 # 0x1
+
jal __drop_one_conntrack_process_hooks2
sw $23,16($sp)
- slt $2,$20,1025
-$L467:
- beq $2,$0,$L393
+$L295:
+ slt $2,$20,129
+ beq $2,$0,$L299
move $3,$0
-$L374:
+$L292:
lw $17,0($17)
- j $L451
+ j $L346
nop
-$L370:
+$L288:
move $3,$0
-$L393:
+$L299:
li $2,1 # 0x1
- beq $3,$2,$L260
+ beq $3,$2,$L214
addiu $19,$19,1
- sltu $2,$19,10
- bne $2,$0,$L468
+ lw $2,%lo(drop_priority_max_idx)($fp)
+ nop
+ slt $2,$19,$2
+ bne $2,$0,$L354
lui $22,%hi(drop_priority)
- j $L443
+ j $L321
nop
-$L260:
+$L214:
lui $4,%hi(rtl_newGC_session_status_flags)
-$L453:
+$L349:
lw $2,%lo(rtl_newGC_session_status_flags)($4)
nop
- bne $2,$0,$L401
+ bne $2,$0,$L307
nop
lui $2,%hi(jiffies)
@@ -1874,18 +1893,18 @@ $L453:
addiu $3,$3,1
lui $2,%hi(rtl_newGC_session_status_time)
sw $3,%lo(rtl_newGC_session_status_time)($2)
-$L401:
+$L307:
j $L164
li $2,1 # 0x1
-$L443:
+$L321:
jal local_bh_enable
nop
lui $4,%hi(rtl_newGC_session_status_flags)
lw $2,%lo(rtl_newGC_session_status_flags)($4)
li $3,1 # 0x1
- beq $2,$3,$L403
+ beq $2,$3,$L309
lui $2,%hi(jiffies)
lw $2,%lo(jiffies)($2)
@@ -1893,10 +1912,11 @@ $L443:
lui $3,%hi(rtl_newGC_session_status_time)
addiu $2,$2,200
sw $2,%lo(rtl_newGC_session_status_time)($3)
-$L403:
+$L309:
move $2,$0
$L164:
- lw $31,56($sp)
+ lw $31,60($sp)
+ lw $fp,56($sp)
lw $23,52($sp)
lw $22,48($sp)
lw $21,44($sp)
@@ -1918,45 +1938,46 @@ $L164:
.type rtl_nf_conn_GC_init, @function
rtl_nf_conn_GC_init:
.set nomips16
- .frame $sp,24,$31 # vars= 0, regs= 2/0, args= 16, gp= 0
- .mask 0x80010000,-4
+ .frame $sp,32,$31 # vars= 0, regs= 3/0, args= 16, gp= 0
+ .mask 0x80030000,-8
.fmask 0x00000000,0
.set noreorder
.set nomacro
lui $2,%hi(Tcp_State_Hash_Head)
- addiu $sp,$sp,-24
+ addiu $sp,$sp,-32
addiu $2,$2,%lo(Tcp_State_Hash_Head)
- sw $31,20($sp)
+ sw $31,24($sp)
+ sw $17,20($sp)
sw $16,16($sp)
addiu $2,$2,4
li $5,10 # 0xa
-$L475:
+$L361:
lw $3,0($2)
addiu $5,$5,-1
- beq $3,$0,$L472
+ beq $3,$0,$L358
addiu $2,$2,8
sw $3,4($3)
sw $3,0($3)
-$L472:
- bgez $5,$L475
+$L358:
+ bgez $5,$L361
nop
lui $2,%hi(Udp_State_Hash_Head)
addiu $2,$2,%lo(Udp_State_Hash_Head)
addiu $2,$2,4
li $5,1 # 0x1
-$L481:
+$L367:
lw $3,0($2)
addiu $5,$5,-1
- beq $3,$0,$L478
+ beq $3,$0,$L364
addiu $2,$2,8
sw $3,4($3)
sw $3,0($3)
-$L478:
- bgez $5,$L481
+$L364:
+ bgez $5,$L367
lui $16,%hi(prot_limit)
move $5,$0
@@ -1970,47 +1991,50 @@ $L478:
addiu $6,$2,%lo(_prot_limit)
move $5,$0
sll $2,$5,2
-$L504:
+$L390:
addiu $5,$5,1
addu $4,$2,$6
slt $3,$5,3
addu $2,$2,$7
sw $0,0($2)
sw $0,0($4)
- bne $3,$0,$L504
+ bne $3,$0,$L390
sll $2,$5,2
lui $2,%hi(nf_conntrack_max)
lw $6,%lo(nf_conntrack_max)($2)
+ li $3,10 # 0xa
+ lui $2,%hi(drop_priority_max_idx)
+ sw $3,%lo(drop_priority_max_idx)($2)
li $2,2 # 0x2
- addiu $3,$16,%lo(prot_limit)
+ addiu $4,$16,%lo(prot_limit)
sw $2,%lo(prot_limit)($16)
li $2,90 # 0x5a
- sw $2,4($3)
+ sw $2,4($4)
li $2,60 # 0x3c
- sw $2,8($3)
+ sw $2,8($4)
lui $2,%hi(_prot_limit)
- lui $7,%hi(rtl_newGC_session_status_flags)
- addiu $10,$2,%lo(_prot_limit)
+ lui $17,%hi(rtl_newGC_session_status_flags)
+ addiu $9,$2,%lo(_prot_limit)
li $2,1374355456 # 0x51eb0000
- sw $0,%lo(rtl_newGC_session_status_flags)($7)
- move $9,$3
- ori $8,$2,0x851f
+ sw $0,%lo(rtl_newGC_session_status_flags)($17)
+ move $8,$4
+ ori $7,$2,0x851f
move $5,$0
sll $3,$5,2
-$L505:
- addu $2,$3,$9
+$L391:
+ addu $2,$3,$8
lw $2,0($2)
addiu $5,$5,1
- addu $3,$3,$10
+ addu $3,$3,$9
mult $6,$2
slt $4,$5,3
mflo $2
- multu $2,$8
+ multu $2,$7
mfhi $2
srl $2,$2,5
sw $2,0($3)
- bne $4,$0,$L505
+ bne $4,$0,$L391
sll $3,$5,2
li $3,-859045888 # 0xffffffffcccc0000
@@ -2022,48 +2046,48 @@ $L505:
srl $2,$2,2
subu $3,$6,$2
sltu $3,$3,65
- bne $3,$0,$L491
+ bne $3,$0,$L377
sw $2,%lo(rtl_nf_conntrack_threshold)($4)
addiu $2,$6,-64
sw $2,%lo(rtl_nf_conntrack_threshold)($4)
-$L491:
+$L377:
lui $2,%hi(nf_conntrack_max)
lw $2,%lo(nf_conntrack_max)($2)
nop
- beq $2,$0,$L492
- lui $2,%hi(init_net+468)
-
- lw $3,%lo(init_net+468)($2)
- lw $2,%lo(rtl_nf_conntrack_threshold)($4)
+ beq $2,$0,$L378
nop
- slt $2,$2,$3
- beq $2,$0,$L492
+
+ jal rtl_gc_threshold_check
+ move $4,$0
+
+ bne $2,$0,$L378
li $3,3 # 0x3
- lw $2,%lo(rtl_newGC_session_status_flags)($7)
+ lw $2,%lo(rtl_newGC_session_status_flags)($17)
nop
- beq $2,$3,$L495
+ beq $2,$3,$L381
lui $2,%hi(jiffies)
lw $2,%lo(jiffies)($2)
- sw $3,%lo(rtl_newGC_session_status_flags)($7)
+ sw $3,%lo(rtl_newGC_session_status_flags)($17)
lui $3,%hi(rtl_newGC_session_status_time)
addiu $2,$2,1
- j $L495
+ j $L381
sw $2,%lo(rtl_newGC_session_status_time)($3)
-$L492:
- sw $0,%lo(rtl_newGC_session_status_flags)($7)
-$L495:
+$L378:
+ sw $0,%lo(rtl_newGC_session_status_flags)($17)
+$L381:
jal rtl_nf_conn_GC_init_hooks
nop
- lw $31,20($sp)
+ lw $31,24($sp)
+ lw $17,20($sp)
lw $16,16($sp)
move $2,$0
j $31
- addiu $sp,$sp,24
+ addiu $sp,$sp,32
.set macro
.set reorder
@@ -2075,6 +2099,12 @@ $L495:
.size rtl_nf_conntrack_threshold, 4
rtl_nf_conntrack_threshold:
.space 4
+ .globl drop_priority_max_idx
+ .align 2
+ .type drop_priority_max_idx, @object
+ .size drop_priority_max_idx, 4
+drop_priority_max_idx:
+ .space 4
.globl rtl_newGC_session_status_flags
.section .dram-fwd,"aw",@progbits
.align 2
diff --git a/target/linux/realtek/files/net/rtl/features/98/rtl_features.c b/target/linux/realtek/files/net/rtl/features/98/rtl_features.c
deleted file mode 100644
index 1a5983521..000000000
--- a/target/linux/realtek/files/net/rtl/features/98/rtl_features.c
+++ /dev/null
@@ -1,2202 +0,0 @@
-#include <linux/types.h>
-#include <linux/netfilter.h>
-#include <linux/module.h>
-#include <linux/skbuff.h>
-#include <linux/moduleparam.h>
-#include <linux/notifier.h>
-#include <linux/kernel.h>
-#include <linux/inetdevice.h>
-#include <linux/netdevice.h>
-#include <linux/ip.h>
-#include <linux/tcp.h>
-
-#if defined(CONFIG_PROC_FS)
-#include <linux/proc_fs.h>
-#endif
-
-#if defined(CONFIG_RTL_HARDWARE_NAT )&&defined(CONFIG_RTL_MULTIPLE_WAN)
-#include <net/arp.h>
-#endif
-#include <net/netfilter/nf_conntrack.h>
-#include <net/netfilter/nf_conntrack_core.h>
-#include <net/netfilter/nf_conntrack_helper.h>
-#if defined(CONFIG_RTL_HARDWARE_NAT)
-#include <net/ip_fib.h>
-#include <net/ip_vs.h>
-#include <net/netfilter/nf_nat.h>
-#include <net/netfilter/nf_nat_core.h>
-#endif
-#include <net/rtl/rtl_types.h>
-#include <net/rtl/rtl_nic.h>
-#if defined(CONFIG_RTL_HARDWARE_NAT)
-#include <net/rtl/rtl865x_nat.h>
-#endif
-
-#ifdef CONFIG_RTL_LAYERED_DRIVER_L3
-#include <net/rtl/rtl865x_ppp.h>
-#include <net/rtl/rtl865x_route_api.h>
-#include <net/rtl/rtl865x_arp_api.h>
-#endif
-
-#include <net/rtl/features/rtl_features.h>
-
-#if defined(CONFIG_RTL_IPTABLES_FAST_PATH) || defined(CONFIG_RTL_HARDWARE_NAT)
-#include <linux/netfilter/nf_conntrack_tcp.h>
-#endif
-
-#if defined(CONFIG_RTL_IPTABLES_FAST_PATH)
-#include <net/rtl/fastpath/fastpath_core.h>
-#endif
-
-#if defined(CONFIG_RTL_LOCAL_PUBLIC) || defined(CONFIG_RTL_MULTIPLE_WAN) || (defined(CONFIG_NET_SCHED)&&defined(CONFIG_RTL_IPTABLES_FAST_PATH)) || defined(CONFIG_RTL_HW_QOS_SUPPORT)
-#include <net/rtl/rtl865x_netif.h>
-#endif
-
-#if defined(CONFIG_RTL_HW_QOS_SUPPORT)
-#include <net/rtl/rtl865x_outputQueue.h>
-#endif
-
-#if defined (CONFIG_RTL_LOCAL_PUBLIC)
-#include <net/rtl/rtl865x_localPublic.h>
-extern int rtl865x_curOpMode;
-#endif
-
-#if defined(CONFIG_RTL_FAST_BRIDGE)
-#include <net/rtl/fastpath/fast_br.h>
-#endif
-
-#if defined(CONFIG_NET_SCHED)
-__DRAM_GEN int gQosEnabled;
-#endif
-
-#ifdef CONFIG_RTL_HARDWARE_NAT
-/*2007-12-19*/
-#ifdef CONFIG_RTL_LAYERED_DRIVER_L3
-#include <net/rtl/rtl865x_ip_api.h>
-#endif
-#endif
-
-#include <linux/netfilter_ipv4.h>
-#include <linux/netfilter_ipv4/ip_tables.h>
-
-#if defined(CONFIG_FAST_PATH_MODULE) && defined(CONFIG_RTL_IPTABLES_FAST_PATH)
-#include <fast_l2tp_core.h>
-enum LR_RESULT (*FastPath_hook4)( rtl_fp_napt_entry *fpNaptEntry)=NULL;
-enum LR_RESULT (*FastPath_hook6)( rtl_fp_napt_entry *fpNaptEntry,
-#if defined(IMPROVE_QOS)
- struct sk_buff *pskb, struct nf_conn *ct,
-#endif
- enum NP_FLAGS flags)=NULL;
-enum LR_RESULT (*FastPath_hook11)(rtl_fp_napt_entry *fpNaptEntry, uint32 interval)=NULL;
-int (*fast_path_hook)(struct sk_buff **pskb) = NULL;
-EXPORT_SYMBOL(FastPath_hook4);
-EXPORT_SYMBOL(FastPath_hook6);
-EXPORT_SYMBOL(FastPath_hook11);
-EXPORT_SYMBOL(fast_path_hook);
-#endif
-
-#ifdef FAST_PPTP
- void (*sync_tx_pptp_gre_seqno_hook)(struct sk_buff *skb) = NULL;
-#ifdef CONFIG_FAST_PATH_MODULE
-EXPORT_SYMBOL(sync_tx_pptp_gre_seqno_hook);
-#endif
-#endif
-
-#if defined(CONFIG_RTL_HARDWARE_NAT)
-__DRAM_GEN int gHwNatEnabled;
-
-int rtl865x_handle_nat(struct nf_conn *ct, int act, struct sk_buff *skb)
-{
- struct nf_conn_nat *nat;
- u_int32_t sip, dip, gip;
- u_int16_t sp, dp, gp, proto=0;
- u_int32_t timeval;
- int rc=0;
-
-#if defined(CONFIG_RTL_HW_QOS_SUPPORT)
- uint32 ret;
- struct net_device *lanDev, *wanDev;
-#endif
-
-#if defined(CONFIG_RTL_LAYERED_DRIVER_L4)
- rtl865x_napt_entry rtl865xNaptEntry;
- rtl865x_priority rtl865xPrio;
- rtl865x_qos_mark rtl865xQosMark;
-#endif
-
- if (gHwNatEnabled!=1)
- return -1;
-
- proto = (ct->tuplehash[0].tuple.dst.protonum==IPPROTO_TCP)? 1: 0;
-
- if (ct->status & IPS_SRC_NAT)
- { /* outbound flow */
- sip = ct->tuplehash[0].tuple.src.u3.ip;
- dip = ct->tuplehash[0].tuple.dst.u3.ip;
- gip = ct->tuplehash[1].tuple.dst.u3.ip;
- sp = (proto)? ct->tuplehash[0].tuple.src.u.tcp.port: ct->tuplehash[0].tuple.src.u.udp.port;
- dp = (proto)? ct->tuplehash[0].tuple.dst.u.tcp.port: ct->tuplehash[0].tuple.dst.u.udp.port;
- gp = (proto)? ct->tuplehash[1].tuple.dst.u.tcp.port: ct->tuplehash[1].tuple.dst.u.udp.port;
- }
- else if (ct->status & IPS_DST_NAT)
- { /* inbound flow */
- sip = ct->tuplehash[1].tuple.src.u3.ip;
- dip = ct->tuplehash[1].tuple.dst.u3.ip;
- gip = ct->tuplehash[0].tuple.dst.u3.ip;
- sp = (proto)? ct->tuplehash[1].tuple.src.u.tcp.port: ct->tuplehash[1].tuple.src.u.udp.port;
- dp = (proto)? ct->tuplehash[1].tuple.dst.u.tcp.port: ct->tuplehash[1].tuple.dst.u.udp.port;
- gp = (proto)? ct->tuplehash[0].tuple.dst.u.tcp.port: ct->tuplehash[0].tuple.dst.u.udp.port;
- }
- else
- return -1;
-
- /* do not add hardware NAPT table if protocol is UDP and source IP address is equal to gateway IP address */
- if ((act == 1) && (proto == 0) && (sip == gip))
- return -1;
-
- /* for TZO DDNS */
- if ((act == 1) && (proto == 1) && (dp == 21347)) {
- return -1;
- }
-
- if (act == 2) {
- /* query for idle */
- timeval = 0;
-#ifdef CONFIG_RTL_LAYERED_DRIVER_L4
- rtl865xNaptEntry.protocol=proto;
- rtl865xNaptEntry.intIp=sip;
- rtl865xNaptEntry.intPort=sp;
- rtl865xNaptEntry.extIp=gip;
- rtl865xNaptEntry.extPort=gp;
- rtl865xNaptEntry.remIp=dip;
- rtl865xNaptEntry.remPort=dp;
-
- timeval = rtl865x_naptSync(&rtl865xNaptEntry, 0);
-#endif
- if (timeval > 0)
- return 0;
- else
- return -1;
- }
- else if (act == 0) {
- /* delete */
- rc = 0;
-#ifdef CONFIG_RTL_LAYERED_DRIVER_L4
- rtl865xNaptEntry.protocol=proto;
- rtl865xNaptEntry.intIp=sip;
- rtl865xNaptEntry.intPort=sp;
- rtl865xNaptEntry.extIp=gip;
- rtl865xNaptEntry.extPort=gp;
- rtl865xNaptEntry.remIp=dip;
- rtl865xNaptEntry.remPort=dp;
-
- rc = rtl865x_delNaptConnection(&rtl865xNaptEntry);
-#endif
- }
- else {
- #if defined(CONFIG_RTL_HW_QOS_SUPPORT)
- if (NULL!=skb)
- {
- rtl865xNaptEntry.protocol=proto;
- rtl865xNaptEntry.intIp=sip;
- rtl865xNaptEntry.intPort=sp;
- rtl865xNaptEntry.extIp=gip;
- rtl865xNaptEntry.extPort=gp;
- rtl865xNaptEntry.remIp=dip;
- rtl865xNaptEntry.remPort=dp;
-
- rtl865xQosMark.downlinkMark=0; //Initial
- rtl865xQosMark.uplinkMark=0; //Initial
- ret=rtl_qosGetSkbMarkByNaptEntry(&rtl865xNaptEntry, &rtl865xQosMark, skb);
-
- lanDev=rtl865x_getLanDev();
- wanDev=rtl865x_getWanDev();
- rtl865xPrio.downlinkPrio=rtl_qosGetPriorityByMark(lanDev->name, rtl865xQosMark.downlinkMark);
- rtl865xPrio.uplinkPrio=rtl_qosGetPriorityByMark(wanDev->name, rtl865xQosMark.uplinkMark);
-
- if(lanDev)
- dev_put(lanDev);
-
- if(wanDev)
- dev_put(wanDev);
- } else
- #endif
- {
- rtl865xPrio.downlinkPrio=0;
- rtl865xPrio.uplinkPrio=0;
- }
-
-#if defined(CONFIG_RTL_LAYERED_DRIVER_L4)
- rtl865xNaptEntry.protocol=proto;
- rtl865xNaptEntry.intIp=sip;
- rtl865xNaptEntry.intPort=sp;
- rtl865xNaptEntry.extIp=gip;
- rtl865xNaptEntry.extPort=gp;
- rtl865xNaptEntry.remIp=dip;
- rtl865xNaptEntry.remPort=dp;
-#endif
-
- /* add */
-#if defined(CONFIG_PROC_FS) && defined(CONFIG_NET_SCHED) && !defined(CONFIG_RTL_HW_QOS_SUPPORT)
- if (gQosEnabled == 0)
- {
-#ifdef CONFIG_RTL_LAYERED_DRIVER_L4
- rc = rtl865x_addNaptConnection(&rtl865xNaptEntry, &rtl865xPrio);
-#endif
- }
- else
- {
- act = 0;
- }
-#else
-#ifdef CONFIG_RTL_LAYERED_DRIVER_L4
- rc = rtl865x_addNaptConnection(&rtl865xNaptEntry, &rtl865xPrio);
-#endif
-
-#endif
- }
-
- nat = nfct_nat(ct);
- if (!rc && nat && act == 1) /* mark it as an asic entry */
- nat->hw_acc = 1;
- if (!rc && nat && act == 0) /* unmark it */
- nat->hw_acc = 0;
-
- #ifdef CONFIG_HARDWARE_NAT_DEBUG
- /*2007-12-19*/
- DEBUGP("%s:%d:(%s): errno=%d\n %s (%u.%u.%u.%u:%u -> %u.%u.%u.%u:%u) g:(%u.%u.%u.%u:%u)\n",
- __FUNCTION__,__LINE__,((is_add)?"add_nat": "del_nat"), rc, ((proto)? "tcp": "udp"),
- NIPQUAD(sip), sp, NIPQUAD(dip), dp, NIPQUAD(gip), gp);
- #endif
-
- return 0;
-}
-
-/* return value:
- FAILED: ct should be delete
- SUCCESS: ct should NOT be delete.
-*/
-int rtl_hwnat_timer_update(struct nf_conn *ct)
-{
- unsigned long expires, now;
- struct nf_conn_nat *nat;
-
- if (gHwNatEnabled!=1)
- return FAILED;
-
- nat = nfct_nat(ct);
- if (nat==NULL || nat->hw_acc!=1)
- return FAILED;
-
- now = jiffies;
- //read_lock_bh(&nf_conntrack_lock);
- if (ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum == IPPROTO_UDP) {
- if(ct->status & IPS_SEEN_REPLY)
- expires = nf_ct_udp_timeout_stream;
- else
- expires = nf_ct_udp_timeout;
- } else if (ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum == IPPROTO_TCP &&
- ct->proto.tcp.state < TCP_CONNTRACK_LAST_ACK) {
- expires = tcp_get_timeouts_by_state(ct->proto.tcp.state);
- } else {
- //read_unlock_bh(&nf_conntrack_lock);
- return FAILED;
- }
- //read_unlock_bh(&nf_conntrack_lock);
-
- if (!rtl865x_handle_nat(ct, 2, NULL)) {
- /* update ct expires time */
- ct->timeout.expires = now+expires;
- rtl_check_for_acc(ct, (now+expires));
- return SUCCESS;
- } else
- return FAILED;
-
-}
-#endif
-
-
-#if defined(CONFIG_RTL_IPTABLES_FAST_PATH) || defined(CONFIG_RTL_HARDWARE_NAT)
-int smart_count=0;
-unsigned long smart_count_start_timer;
-unsigned int _br0_ip;
-unsigned int _br0_mask;
-static void get_br0_ip_mask(void)
-{
- struct in_device *in_dev;
- struct net_device *landev;
- struct in_ifaddr *ifap = NULL;
-
- if ((landev = __dev_get_by_name(&init_net, RTL_PS_BR0_DEV_NAME)) != NULL){
- in_dev=(struct in_device *)(landev->ip_ptr);
- if (in_dev != NULL) {
- for (ifap=in_dev->ifa_list; ifap != NULL; ifap=ifap->ifa_next) {
- if (strcmp(RTL_PS_BR0_DEV_NAME, ifap->ifa_label) == 0){
- _br0_ip = ifap->ifa_address;
- _br0_mask = ifap->ifa_mask;
- return;
- }
- }
-
- }
- }
-}
-
-/* return value:
- FAILED: ct should be delete
- SUCCESS: ct should NOT be delete.
-*/
-void rtl_delConnCache(struct nf_conn *ct)
-{
- #if defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- enum NP_PROTOCOL protocol;
- rtl_fp_napt_entry rtlFpNaptEntry;
- #endif
- #ifdef CONFIG_RTL_HARDWARE_NAT
- struct nf_conn_nat *nat;
- #endif
-
- if (ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum == IPPROTO_TCP) {
- #if defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- protocol = NP_TCP;
- #endif
- } else if (ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum == IPPROTO_UDP) {
- #if defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- protocol = NP_UDP;
- #endif
- } else {
- return;
- }
-
- spin_lock_bh(&nf_conntrack_lock);
- #if defined(CONFIG_RTL_HARDWARE_NAT)
- nat = nfct_nat(ct);
- if ((nat!=NULL) && (nat->hw_acc==1)) {
- rtl865x_handle_nat(ct, 0, NULL);
- }
- #endif
-
- #if defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- if(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip
- == ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip) {
- /*case WAN->LAN(BC->AB) use C|A-B*/
-
- rtlFpNaptEntry.protocol=protocol;
- rtlFpNaptEntry.intIp=ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3.ip;
- rtlFpNaptEntry.intPort=ntohs(ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u.all);
- rtlFpNaptEntry.extIp=ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.u3.ip;
- rtlFpNaptEntry.extPort=ntohs(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.u.all);
- rtlFpNaptEntry.remIp=ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip;
- rtlFpNaptEntry.remPort=ntohs(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u.all);
-
- #ifdef CONFIG_FAST_PATH_MODULE
- if(FastPath_hook4!=NULL)
- {
- FastPath_hook4(&rtlFpNaptEntry) ;
- }
- #else
- rtk_delNaptConnection(&rtlFpNaptEntry) ;
- #endif
- } else if (ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.u3.ip
- == ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3.ip) {
- /*case LAN->WAN(AB->BC) use A|C-B*/
-
- rtlFpNaptEntry.protocol=protocol;
- rtlFpNaptEntry.intIp=ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip;
- rtlFpNaptEntry.intPort=ntohs(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u.all);
- rtlFpNaptEntry.extIp=ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip;
- rtlFpNaptEntry.extPort=ntohs(ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u.all);
- rtlFpNaptEntry.remIp=ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3.ip;
- rtlFpNaptEntry.remPort=ntohs(ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u.all);
-
- #ifdef CONFIG_FAST_PATH_MODULE
- if(FastPath_hook4!=NULL)
- {
- FastPath_hook4(&rtlFpNaptEntry);
- }
- #else
- rtk_delNaptConnection(&rtlFpNaptEntry);
- #endif
- }
- #endif
- spin_unlock_bh(&nf_conntrack_lock);
-}
-
-void rtl_check_for_acc(struct nf_conn *ct, unsigned long expires)
-{
- #if defined(CONFIG_RTL_NF_CONNTRACK_GARBAGE_NEW)
- int newstate;
- struct list_head* state_hash;
-
- write_lock_bh(&nf_conntrack_lock);
- if (ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum == IPPROTO_TCP) {
- newstate = ct->proto.tcp.state;
- state_hash = Tcp_State_Hash_Head[newstate].state_hash;
- } else if (ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum == IPPROTO_UDP) {
- if(ct->status & IPS_SEEN_REPLY)
- newstate = 1;
- else
- newstate = 0;
- state_hash = Udp_State_Hash_Head[newstate].state_hash;
- } else {
- write_unlock_bh(&nf_conntrack_lock);
- return;
- }
-
- list_move_tail(&ct->state_tuple, state_hash);
- write_unlock_bh(&nf_conntrack_lock);
- #endif
-}
-
-int32 rtl_connCache_timer_update(struct nf_conn *ct)
-{
- spin_lock_bh(&nf_conntrack_lock);
- if (time_after_eq(jiffies, ct->timeout.expires)) {
- #if defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- if (SUCCESS==rtl_fpTimer_update(ct)) {
- add_timer(&ct->timeout);
- spin_unlock_bh(&nf_conntrack_lock);
- return SUCCESS;
- }
- #endif
-
- #if defined(CONFIG_RTL_HARDWARE_NAT)
- if (SUCCESS==rtl_hwnat_timer_update(ct)) {
- add_timer(&ct->timeout);
- spin_unlock_bh(&nf_conntrack_lock);
- return SUCCESS;
- }
- #endif
- }
- spin_unlock_bh(&nf_conntrack_lock);
- return FAILED;
-}
-
-#if defined(IMPROVE_QOS)
-/*
- * ### for iperf application test ###
- * the behavior of iperf UDP test is LAN PC (client) will burst UDP from LAN to WAN (by one way),
- * WAN PC (server) will only send one UDP packet (statistics) at the end of test.
- * so the fastpath or hardware NAT will create link at the end of test.
- *
- * the purpose for adding the following code is to create fastpath or hardware NAT link
- * when we only get one packet from LAN to WAN in UDP case.
- */
-static inline int32 rtl_addConnCheck(struct nf_conn *ct, struct iphdr *iph, struct sk_buff *skb)
-{
- extern unsigned int _br0_ip;
- extern unsigned int _br0_mask;
- extern int smart_count;
- extern unsigned long smart_count_start_timer;
- struct tcphdr *tcph;
- uint32 sip, dip;
- int32 create_conn;
-
- sip = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip;
- dip = ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3.ip;
- create_conn = FALSE;
-
- if (((ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.u3.ip
- == ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3.ip) ||
- (ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip
- == ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip))
- #if defined(UNNUMBER_IP)
- && (is_unnumber_ip(dip)==FALSE)
- #endif
- ) {
- /* UDP and "LAN to WAN" */
- /* ignore some cases:
- * 1. sip = br0's ip -----> (ex. sip 192.168.1.254 ==> dip 239.255.255.250)
- * 2. (sip & br0's mask) != (br0's ip & br0's mask) -----> sip is not in br0's subnet
- * 3. (dip & br0's mask) = (br0's ip & br0's mask) -----> dip is in br0's subnet
- * 4. dip != multicast IP address
- * 5. sip != gip
- */
- if (iph->protocol == IPPROTO_UDP) {
- if ((ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.u3.ip
- == ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3.ip)&&
- (sip != _br0_ip) &&
- ((sip & _br0_mask) == (_br0_ip & _br0_mask)) &&
- ((dip & _br0_mask) != (_br0_ip & _br0_mask)) &&
- ((dip & 0xf0000000) != 0xe0000000) &&
- (sip != (ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip))) {
- create_conn = TRUE;
- } else if ((ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip
- == ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip)&&
- ((sip & _br0_mask) != (_br0_ip & _br0_mask))&&
- ((dip & _br0_mask) == (_br0_ip & _br0_mask))&&
- (iph->daddr ==dip)) {
- create_conn = TRUE;
- }
- } else if (iph->protocol == IPPROTO_TCP) {
- tcph=(void *) iph + iph->ihl*4;
- if (!tcph->fin && !tcph->syn && !tcph->rst && tcph->psh==1 &&
- tcph->ack ==1 &&
- (((ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.u3.ip==ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3.ip) &&
- (iph->daddr !=_br0_ip) && ((sip & _br0_mask) == (_br0_ip & _br0_mask)) &&
- ((dip & _br0_mask) != (_br0_ip & _br0_mask)) && (sip != (ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip)))||
- ((ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip==ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip) &&
- ((sip & _br0_mask) != (_br0_ip & _br0_mask)) &&
- ((dip & _br0_mask) == (_br0_ip & _br0_mask))&& (sip == iph->saddr)))) {
-
- if (smart_count==0) {
- smart_count_start_timer = jiffies+HZ;
- }
-
- if (time_after(jiffies, smart_count_start_timer)) {
- smart_count_start_timer = jiffies+HZ;
- smart_count=0;
- }
-
- smart_count++;
- if(smart_count >810){
- //panic_printk("the case hit for mart flow:tcp state=%d, assured=%d\n",ct->proto.tcp.state,test_bit(IPS_ASSURED_BIT, &ct->status));
- create_conn=TRUE;
- }
- }
- } else {
- return create_conn;
- }
-
-#if defined(UNNUMBER_IP)
- if ((!create_conn)
- && (is_unnumber_ip(sip)==TRUE))
- ){
- create_conn = TRUE;
- }
-#endif
- }
-
- return create_conn;
-}
-
-void rtl_addConnCache(struct nf_conn *ct, struct sk_buff *skb)
-{
- int assured;
- int create_conn;
- struct iphdr *iph;
- #if defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- enum NP_PROTOCOL protocol;
- rtl_fp_napt_entry rtlFpNaptEntry;
- #endif
-
- if (nfct_help(ct))
- return;
-
- iph=ip_hdr(skb);
- if (iph->protocol== IPPROTO_TCP) {
- assured = ((ct->proto.tcp.state==TCP_CONNTRACK_ESTABLISHED)&&
- (test_bit(IPS_DST_NAT_DONE_BIT, &ct->status) ||
- test_bit(IPS_SRC_NAT_DONE_BIT, &ct->status)));
-
- #if defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- protocol = NP_TCP;
- #endif
- } else if (iph->protocol== IPPROTO_UDP) {
- assured = (test_bit(IPS_DST_NAT_DONE_BIT, &ct->status) ||
- test_bit(IPS_SRC_NAT_DONE_BIT, &ct->status));
-
- #if defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- protocol = NP_UDP;
- #endif
- } else {
- return;
- }
-
-
- if (!assured) {
- create_conn = rtl_addConnCheck(ct, iph, skb);
- } else
- create_conn = 0;
-
- #if defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- /*1.add "!(ct->helper)" to fix ftp-cmd type packet
- 2.add identify case LAN->WAN(AB->BC) or WAN->LAN(BC->AB)
- 3.add !(ct->nat.info.helper) for best ALG avoid
- */
- if (assured || create_conn) {
- if(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip
- == ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip) {
- /*case BC->AB*/
- /* wan->lan */
-
- rtlFpNaptEntry.protocol=protocol;
- rtlFpNaptEntry.intIp=ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3.ip;
- rtlFpNaptEntry.intPort=ntohs(ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u.all);
- rtlFpNaptEntry.extIp=ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.u3.ip;
- rtlFpNaptEntry.extPort=ntohs(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.u.all);
- rtlFpNaptEntry.remIp=ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip;
- rtlFpNaptEntry.remPort=ntohs(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u.all);
-
- #ifdef CONFIG_FAST_PATH_MODULE
- if(FastPath_hook6!=NULL)
- {
- FastPath_hook6(&rtlFpNaptEntry,
- skb, ct,
- NP_NONE);
- }
- #else
- rtk_addNaptConnection(&rtlFpNaptEntry,
- skb, ct,
- NP_NONE);
- #endif
- } else if (ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.u3.ip
- == ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3.ip) {
- /*case AB->BC*/
- /* lan->wan */
-
- rtlFpNaptEntry.protocol=protocol;
- rtlFpNaptEntry.intIp=ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip;
- rtlFpNaptEntry.intPort=ntohs(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u.all);
- rtlFpNaptEntry.extIp=ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip;
- rtlFpNaptEntry.extPort=ntohs(ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u.all);
- rtlFpNaptEntry.remIp=ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3.ip;
- rtlFpNaptEntry.remPort=ntohs(ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u.all);
-
- #ifdef CONFIG_FAST_PATH_MODULE
- if(FastPath_hook6!=NULL)
- {
- FastPath_hook6(&rtlFpNaptEntry,
- skb, ct,
- NP_NONE);
- }
- #else
- rtk_addNaptConnection(&rtlFpNaptEntry,
- skb, ct,
- NP_NONE);
- #endif
- }
- }
- #endif
-
- #if defined(CONFIG_RTL_HARDWARE_NAT)
- /*2007-12-19*/
- #if !defined(CONFIG_RTL865x_TCPFLOW_NONE_STATUS_CHECK)
- if (assured || create_conn)
- #endif
- {
- rtl865x_handle_nat(ct, 1, skb);
- }
- #endif
-}
-#else /* !defined(IMPROVE_QOS) */
-/*
- * ### for iperf application test ###
- * the behavior of iperf UDP test is LAN PC (client) will burst UDP from LAN to WAN (by one way),
- * WAN PC (server) will only send one UDP packet (statistics) at the end of test.
- * so the fastpath or hardware NAT will create link at the end of test.
- *
- * the purpose for adding the following code is to create fastpath or hardware NAT link
- * when we only get one packet from LAN to WAN in UDP case.
- */
-static int32 rtl_fpAddConnCheck(struct nf_conn *ct, struct iphdr *iph, struct sk_buff *skb)
-{
- extern unsigned int _br0_ip;
- extern unsigned int _br0_mask;
- struct tcphdr *tcph;
- uint32 sip, dip;
- int32 create_conn;
-
- sip = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip;
- dip = ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3.ip;
- create_conn = FALSE;
-
- if ((ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.u3.ip
- == ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3.ip)
- #if defined(UNNUMBER_IP)
- && (is_unnumber_ip(dip)==FALSE)
- #endif
- ) {
- /* lan -> wan */
- if (iph->protocol == IPPROTO_UDP &&
- (sip != _br0_ip) &&
- ((sip & _br0_mask) == (_br0_ip & _br0_mask)) &&
- ((dip & _br0_mask) != (_br0_ip & _br0_mask)) &&
- (!IS_CLASSD_ADDR(dip)) &&
- (sip != (ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip))
- ) {
- create_conn = TRUE;
- /* copied from last 2 line of this function **/
- set_bit(IPS_SEEN_REPLY_BIT, &ct->status);
- /* next 3 lines are copied from udp_packet() in ip_conntrack_proto_udp.c */
- nf_ct_refresh(ct,skb, nf_ct_udp_timeout_stream);
- /* Also, more likely to be important, and not a probe */
- set_bit(IPS_ASSURED_BIT, &ct->status);
- } else if (iph->protocol == IPPROTO_TCP) {
- tcph=(void *) iph + iph->ihl*4;
- if (!tcph->fin && !tcph->syn && !tcph->rst && tcph->psh==1 &&
- tcph->ack ==TRUE && (iph->daddr !=_br0_ip) && ((sip & _br0_mask) == (_br0_ip & _br0_mask)) &&
- ((dip & _br0_mask) != (_br0_ip & _br0_mask)) && (sip != (ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip))) {
-
- if (smart_count==0) {
- smart_count_start_timer = jiffies+HZ;
- }
-
- if (time_after(jiffies, smart_count_start_timer)) {
- smart_count_start_timer = jiffies+HZ;
- smart_count=0;
- }
-
- smart_count++;
- if(smart_count >810){
- //panic_printk("the case hit for mart flow:tcp state=%d, assured=%d\n",ct->proto.tcp.state,test_bit(IPS_ASSURED_BIT, &ct->status));
- create_conn=TRUE;
- }
- }
- } else {
- return FALSE;
- }
-
-#if defined(UNNUMBER_IP)
- if ((!create_conn)
- && (is_unnumber_ip(sip)==TRUE))
- ){
- create_conn = TRUE;
- }
-#endif
- }
-
- return create_conn;
-}
-
-void rtl_fpAddConnCache(struct nf_conn *ct, struct sk_buff *skb)
-{
- int assured;
- int create_conn;
- struct iphdr *iph;
- enum NP_PROTOCOL protocol;
- rtl_fp_napt_entry rtlFpNaptEntry;
-
- if (nfct_help(ct))
- return;
-
- iph=ip_hdr(skb);
- create_conn = rtl_fpAddConnCheck(ct, iph, skb);
- assured = test_bit(IPS_ASSURED_BIT, &ct->status);
-
- /*1.add "!(ct->helper)" to fix ftp-cmd type packet
- 2.add identify case LAN->WAN(AB->BC) or WAN->LAN(BC->AB)
- 3.add !(ct->nat.info.helper) for best ALG avoid
- */
-
- if ((assured) || (TRUE==create_conn))
- {
- if (ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum == IPPROTO_TCP) {
- protocol = NP_TCP;
- } else if (ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum == IPPROTO_UDP) {
- protocol = NP_UDP;
- }
-
- if(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip
- == ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip) {
- /*case BC->AB*/
- /* wan->lan */
-
- rtlFpNaptEntry.protocol=protocol;
- rtlFpNaptEntry.intIp=ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3.ip;
- rtlFpNaptEntry.intPort=ntohs(ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u.all);
- rtlFpNaptEntry.extIp=ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.u3.ip;
- rtlFpNaptEntry.extPort=ntohs(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.u.all);
- rtlFpNaptEntry.remIp=ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip;
- rtlFpNaptEntry.remPort=ntohs(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u.all);
-
- #ifdef CONFIG_FAST_PATH_MODULE
- if(FastPath_hook6!=NULL)
- {
- FastPath_hook6(&rtlFpNaptEntry,
- NP_NONE);
- }
- #else
- rtk_addNaptConnection(&rtlFpNaptEntry,
- NP_NONE);
- #endif
- } else if (ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.u3.ip
- == ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3.ip) {
- /*case AB->BC*/
- /* lan->wan */
-
- rtlFpNaptEntry.protocol=protocol;
- rtlFpNaptEntry.intIp=ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip;
- rtlFpNaptEntry.intPort=ntohs(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u.all);
- rtlFpNaptEntry.extIp=ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip;
- rtlFpNaptEntry.extPort=ntohs(ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u.all);
- rtlFpNaptEntry.remIp=ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3.ip;
- rtlFpNaptEntry.remPort=ntohs(ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u.all);
-
- #ifdef CONFIG_FAST_PATH_MODULE
- if(FastPath_hook6!=NULL)
- {
- FastPath_hook6(&rtlFpNaptEntry,
- NP_NONE);
- }
- #else
- rtk_addNaptConnection(&rtlFpNaptEntry,
- NP_NONE);
- #endif
- }
- }
-
-}
-#endif /* defined(IMPROVE_QOS) */
-
-#endif
-
-#if defined(CONFIG_PROC_FS) && defined(CONFIG_RTL_HARDWARE_NAT )
-static struct proc_dir_entry *proc_hw_nat=NULL;
-static char gHwNatSetting[16];
-//extern unsigned int ldst, lmask, wdst, wmask;
-
-static int hw_nat_read_proc(char *page, char **start, off_t off,
- int count, int *eof, void *data)
-{
- int len;
-
- len = sprintf(page, "%s\n", gHwNatSetting);
-
- if (len <= off+count) *eof = 1;
- *start = page + off;
- len -= off;
- if (len>count) len = count;
- if (len<0) len = 0;
- return len;
-}
-
-static int hw_nat_write_proc(struct file *file, const char *buffer,
- unsigned long count, void *data)
-{
- if (count < 2)
- return -EFAULT;
-
- if (buffer && !copy_from_user(&gHwNatSetting, buffer, 8)) {
- if (gHwNatSetting[0] == '0') { /* hardware NAT disabled, operation mode = gateway */
- gHwNatEnabled = 0;
- rtl865x_nat_reinit();
- rtl865x_changeOpMode(GATEWAY_MODE);
- //rtl8651_setAsicOperationLayer(4);
- }
- else if (gHwNatSetting[0] == '1') { /* hardware NAT enabled, operation mode = gateway */
-
- rtl865x_changeOpMode(GATEWAY_MODE);
- //rtl8651_setAsicOperationLayer(4);
- gHwNatEnabled = 1;
- }
- else if (gHwNatSetting[0] == '2') { /* hardware NAT enabled, operation mode = bridge mode*/
- //rtl865x_delRoute(wdst, wmask);
- //rtl865x_delRoute(ldst, lmask);
- rtl865x_changeOpMode(BRIDGE_MODE);
- //rtl8651_setAsicOperationLayer(3);
- gHwNatEnabled = 2;
- }
- else if(gHwNatSetting[0] == '3'){ /* hardware NAT enabled, operation mode = wisp mode */
- rtl865x_changeOpMode(WISP_MODE);
- //rtl8651_setAsicOperationLayer(3);
- gHwNatEnabled = 3;
- }
- else if ((gHwNatSetting[0] == '8')&&
- ((gHwNatSetting[1] == '5') /* L2TP */
- ||(gHwNatSetting[1] == '4') /* PPTP */))
- {
- gHwNatEnabled = 0;
- }
- #if defined(CONFIG_RTL_HARDWARE_NAT) || defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- else if (gHwNatSetting[0] == '9') {
- get_br0_ip_mask();
- }
- #endif
- return count;
- }
- return -EFAULT;
-}
-#endif
-
-#if defined(CONFIG_RTL_819X) && (defined(CONFIG_PROC_FS) && !defined(CONFIG_RTL_HARDWARE_NAT))
-static struct proc_dir_entry *proc_sw_nat=NULL;
-static char gSwNatSetting[16];
-
-static int sw_nat_read_proc(char *page, char **start, off_t off,
- int count, int *eof, void *data)
-{
- int len;
-
- len = sprintf(page, "%s\n", gSwNatSetting);
-
- if (len <= off+count) *eof = 1;
- *start = page + off;
- len -= off;
- if (len>count) len = count;
- if (len<0) len = 0;
- return len;
-}
-
-static int sw_nat_write_proc(struct file *file, const char *buffer,
- unsigned long count, void *data)
-{
- if (count < 2)
- return -EFAULT;
-
- if (buffer && !copy_from_user(&gSwNatSetting, buffer, 8)) {
- if (gSwNatSetting[0] == '0'){ /* operation mode = GATEWAY */
- //SoftNAT_OP_Mode(2);
- rtl865x_changeOpMode(GATEWAY_MODE);
- //rtl8651_setAsicOperationLayer(2);
- }
- else if (gSwNatSetting[0] == '1'){ /* operation mode = BRIDGE*/
- //SoftNAT_OP_Mode(1);
- rtl865x_changeOpMode(BRIDGE_MODE);
- //rtl8651_setAsicOperationLayer(2);
- }
- else if(gSwNatSetting[0] == '2'){ /* operation mode = WISP */
- rtl865x_changeOpMode(WISP_MODE);
- //rtl8651_setAsicOperationLayer(2);
- }
-#if defined(CONFIG_RTL_HARDWARE_NAT) || defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- else if(gSwNatSetting[0] == '9'){
- get_br0_ip_mask();
- }
-#endif
- return count;
- }
- return -EFAULT;
-}
-#endif /* defined(CONFIG_RTL_819X) && (defined(CONFIG_PROC_FS) && !defined(CONFIG_RTL_HARDWARE_NAT)) */
-
-#if defined(CONFIG_RTL_819X)
-int32 rtl_nat_init(void)
-{
- #if defined(CONFIG_PROC_FS) && defined(CONFIG_RTL_HARDWARE_NAT)
- proc_hw_nat = create_proc_entry("hw_nat", 0, NULL);
- if (proc_hw_nat) {
- proc_hw_nat->read_proc = hw_nat_read_proc;
- proc_hw_nat->write_proc = hw_nat_write_proc;
- }
- #endif
-
- #if defined(CONFIG_PROC_FS) && !defined(CONFIG_RTL_HARDWARE_NAT)
- proc_sw_nat = create_proc_entry("sw_nat", 0, NULL);
- if (proc_sw_nat) {
- proc_sw_nat->read_proc = sw_nat_read_proc;
- proc_sw_nat->write_proc = sw_nat_write_proc;
- }
- #endif
-
- #if defined(CONFIG_RTL_HARDWARE_NAT)
- gHwNatEnabled=1;
- #endif
-
- return SUCCESS;
-}
-#endif
-
-#if defined(CONFIG_RTL_LOCAL_PUBLIC) || defined(CONFIG_RTL_MULTIPLE_WAN) || (defined(CONFIG_NET_SCHED)&&defined(CONFIG_RTL_IPTABLES_FAST_PATH))
-extern int rtl865x_curOpMode;
-struct net_device *rtl865x_getWanDev(void )
-{
- struct net_device * wanDev=NULL;
-
- if(rtl865x_curOpMode==GATEWAY_MODE)
- {
-#if defined(CONFIG_RTL_PUBLIC_SSID)
- wanDev=dev_get_by_name(&init_net,RTL_GW_WAN_DEVICE_NAME);
-#else
- //Try ppp0 first
- wanDev=dev_get_by_name(&init_net,RTL_PS_PPP0_DEV_NAME);
- if(wanDev==NULL)
- {
- //Try eth1 then
- wanDev=dev_get_by_name(&init_net,RTL_PS_WAN0_DEV_NAME);
- }
-#endif
- }
- else if(rtl865x_curOpMode==WISP_MODE)
- {
-#if defined(CONFIG_RTL_PUBLIC_SSID)
- wanDev=dev_get_by_name(&init_net,RTL_WISP_WAN_DEVICE_NAME);
-#else
- wanDev=dev_get_by_name(&init_net,RTL_PS_WLAN0_DEV_NAME);
-#endif
- }
- else if(rtl865x_curOpMode==BRIDGE_MODE)
- {
-#if defined(CONFIG_RTL_PUBLIC_SSID)
- wanDev=dev_get_by_name(&init_net,RTL_BR_WAN_DEVICE_NAME);
-#else
- wanDev=dev_get_by_name(&init_net,RTL_PS_BR0_DEV_NAME);
-#endif
- }
-
- return wanDev;
-}
-
-struct net_device *rtl865x_getLanDev(void )
-{
- struct net_device * lanDev=NULL;
- lanDev=dev_get_by_name(&init_net,RTL_PS_BR0_DEV_NAME);
- return lanDev;
-}
-#endif
-
-#if defined (CONFIG_RTL_LOCAL_PUBLIC) || defined(CONFIG_RTL_HW_QOS_SUPPORT)
-int rtl865x_attainDevType(unsigned char *devName, unsigned int *isLanDev, unsigned int *isWanDev)
-{
- *isLanDev=0;
- *isWanDev=0;
- if(rtl865x_curOpMode==GATEWAY_MODE)
- {
-#if defined(CONFIG_RTL_PUBLIC_SSID)
- if(strncmp(devName, RTL_PS_WAN0_DEV_NAME, 4) ==0 || strncmp(devName, RTL_GW_WAN_DEVICE_NAME, 3) ==0 ||
- rtl865x_from_public_ssid_device(devName)
- )
-#else
- if(strncmp(devName, RTL_PS_WAN0_DEV_NAME, 4) ==0)
-#endif
- {
- *isWanDev=1;
- }
- else if( (strncmp(devName, RTL_PS_BR0_DEV_NAME, 3) ==0)||
- (strncmp(devName, RTL_PS_ETH_NAME, 3) ==0) ||
- (strncmp(devName, RTL_PS_WLAN_NAME, 4) ==0))
- {
- *isLanDev=1;
- }
- else
- {
- return -1;
- }
-
- }
- else if(rtl865x_curOpMode==WISP_MODE)
- {
- if(strncmp(devName, RTL_PS_WAN0_DEV_NAME, 4)==0)
- {
- *isWanDev=1;
- }
- else if( (strncmp(devName, RTL_PS_BR0_DEV_NAME, 3) ==0) ||
- (strncmp(devName, RTL_PS_ETH_NAME, 3) ==0))
- {
- *isLanDev=1;
- }
- else
- {
- return -1;
- }
- }
- else if(rtl865x_curOpMode==BRIDGE_MODE)
- {
- if( (strncmp(devName, RTL_PS_BR0_DEV_NAME, 3) ==0) ||
- (strncmp(devName, RTL_PS_ETH_NAME, 3) ==0) ||
- (strncmp(devName, RTL_PS_WLAN_NAME, 4) ==0))
- {
- *isLanDev=0;
- }
- else
- {
- return -1;
- }
- }
- else
- {
- return -1;
- }
-
- return 0;
-}
-#endif
-
-#if defined (CONFIG_RTL_LOCAL_PUBLIC)
-int rtl865x_localPublicRx(struct sk_buff *skb)
-{
- struct rtl865x_pktInfo pktInfo;
- unsigned int rxFromLan, rxFromWan;
-
- if(rtl865x_localPublicEnabled() ==0)
- {
- goto end_of_local_public_rx;
- }
-
- if(rtl865x_attainDevType(skb->dev->name, &rxFromLan, &rxFromWan))
- {
- return NET_RX_SUCCESS;
- }
-
- if(skb->localPublicFlags == 0x1)
- {
- //local public has done
- return NET_RX_SUCCESS;
- }
- #if 0
- printk("%s:%d,skb->dev->name is %s,rxFromLan is %d,rxFromWan is %d\n",__FUNCTION__,__LINE__,skb->dev->name,rxFromLan,rxFromWan);
- printk("EtherType: 0x%x\n", *((uint16*)&skb->mac.raw[12]));
- printk("%x:%x:%x:%x:%x:%x ==> %x:%x:%x:%x:%x:%x \n\n",
- skb->mac.raw[6], skb->mac.raw[7], skb->mac.raw[8],
- skb->mac.raw[9], skb->mac.raw[10], skb->mac.raw[11],
- skb->mac.raw[0], skb->mac.raw[1], skb->mac.raw[2],
- skb->mac.raw[3], skb->mac.raw[4], skb->mac.raw[5]);
- #endif
- if(rxFromWan)
- {
- /*rx from ethernet wan*/
- /*direction WAN--->LAN*/
- //pktInfo.data=skb->mac.raw;
- pktInfo.data=skb_mac_header(skb);
- pktInfo.action=RX_WAN_PACKET;
- rtl865x_checkLocalPublic(&pktInfo);
-
- if(pktInfo.fromLocalPublic==1)
- {
- kfree_skb(skb);
- return NET_RX_DROP;
- }
- else if(pktInfo.toLocalPublic==1)
- {
-
- skb->pkt_type=PACKET_HOST;
- //printk("%s:%d,pktInfo.fromLocalPublic is %d,pktInfo.toLocalPublic is %d\n",__FUNCTION__,__LINE__,pktInfo.fromLocalPublic,pktInfo.toLocalPublic );
- memcpy(eth_hdr(skb)->h_dest, skb->dev->dev_addr, 6);
- }
-
- }
- else if (rxFromLan)
- {
- /*rx from ethernet lan*/
- pktInfo.data=skb_mac_header(skb);
- pktInfo.port=skb->srcPort;
- pktInfo.action=RX_LAN_PACKET;
- strcpy(pktInfo.dev, skb->dev->name);
- rtl865x_checkLocalPublic(&pktInfo);
- //printk("%s:%d,pktInfo.fromLocalPublic is %d,pktInfo.toLocalPublic is %d\n",__FUNCTION__,__LINE__,pktInfo.fromLocalPublic,pktInfo.toLocalPublic );
- if(pktInfo.fromLocalPublic==1)
- {
- skb->fromLocalPublic=1;
- skb->srcLocalPublicIp=pktInfo.srcIp;
- //if(pktInfo.toLocalPublic==1)
- {
- skb->pkt_type=PACKET_HOST;
- memcpy(eth_hdr(skb)->h_dest, skb->dev->dev_addr, 6);
- #if 0
- dest = eth_hdr(skb)->h_dest;
- src = eth_hdr(skb)->h_source;
- printk("=========%s(%d),dst(%x:%x:%x:%x:%x:%x),src(%x:%x:%x:%x:%x:%x)\n",__FUNCTION__,__LINE__,
- dest[0],dest[1],dest[2],dest[3],dest[4],dest[5],
- src[0],src[1],src[2],src[3],src[4],src[5]);
- #endif
-
- }
- }
-
- }
- skb->localPublicFlags = 0x1;
-
-end_of_local_public_rx:
- return NET_RX_SUCCESS;
-}
-
-int rtl865x_localPublicTx(struct sk_buff *skb, struct net_device *dev)
-{
- unsigned int txToLan, txToWan;
- if(rtl865x_attainDevType(skb->dev->name, &txToLan, &txToWan))
- {
- return NET_RX_SUCCESS;
- }
-
- if(txToWan)
- {
- if((skb->fromLocalPublic==1) && (skb->srcLocalPublicIp!=0))
- {
- rtl865x_getLocalPublicMac(skb->srcLocalPublicIp, eth_hdr(skb)->h_source);
- }
-
- }
- else if (txToLan)
- {
- /*needn't do anything*/
-
- }
- return NET_RX_SUCCESS;
-}
-
-#endif
-
-int rtl865x_getDevIpAndNetmask(struct net_device * dev, unsigned int *ipAddr, unsigned int *netMask )
-{
- struct in_device *in_dev;
- struct in_ifaddr *ifap = NULL;
-
- if((dev==NULL) || (ipAddr==NULL) || (netMask==NULL))
- {
- return FAILED;
- }
-
- *ipAddr=0;
- *netMask=0;
-
- in_dev=(struct net_device *)(dev->ip_ptr);
- if (in_dev != NULL) {
- for (ifap=in_dev->ifa_list; ifap != NULL; ifap=ifap->ifa_next) {
- if (strcmp(dev->name, ifap->ifa_label) == 0){
- *ipAddr = ifap->ifa_address;
- *netMask = ifap->ifa_mask;
- return SUCCESS;
- }
- }
-
- }
-
- return FAILED;
-
-}
-
-
-#if defined(CONFIG_PROC_FS) && defined(CONFIG_NET_SCHED)
-#define QOS_CLASSIFY_INFO_LEN 16
-typedef struct {
- /* classify */
- unsigned int protocol;
- struct in_addr local_ip;
- struct in_addr remote_ip;
- unsigned short lo_port;
- unsigned short re_port;
-
- /* tc */
- uint32 mark;
- unsigned char prio;
-} rtl865x_qos_cache_t;
-
-static struct proc_dir_entry *proc_qos=NULL;
-
-static char *gQosSetting = NULL;
-#ifdef CONFIG_FAST_PATH_MODULE
-EXPORT_SYMBOL(gQosEnabled);
-#endif
-
-static int qos_read_proc(char *page, char **start, off_t off,
- int count, int *eof, void *data)
-{
- int len;
-
- len = sprintf(page, "%s\n", gQosSetting);
-
- if (len <= off+count) *eof = 1;
- *start = page + off;
- len -= off;
- if (len>count) len = count;
- if (len<0) len = 0;
- return len;
-}
-
-static int qos_write_proc(struct file *file, const char *buffer,
- unsigned long count, void *data)
-{
- if ( gQosSetting==NULL || count < 2)
- return -EFAULT;
-
- if (buffer && !copy_from_user(gQosSetting, buffer, count)) {
- gQosSetting[count-1] = 0; /* remove 0x0a */
- if (gQosSetting[0] == '0')
- gQosEnabled = 0;
- else
- gQosEnabled = 1;
-
-#if defined (CONFIG_RTL_HW_QOS_SUPPORT) && defined(CONFIG_RTL_QOS_PATCH)
- if(gQosEnabled == 1){
- rtl865x_reinitOutputQueuePatchForQoS(TRUE);
- }
- else{
- rtl865x_reinitOutputQueuePatchForQoS(FALSE);
- }
-#endif
-
- return count;
- }
- return -EFAULT;
-}
-#endif
-
-#if defined(CONFIG_NET_SCHED)
-#define RTL_QOS_PROC_MAX_LEN 1024
-int32 rtl_qos_init(void)
-{
- #if defined(CONFIG_PROC_FS)
- proc_qos = create_proc_entry("qos", 0, NULL);
- if (proc_qos) {
- proc_qos->read_proc = qos_read_proc;
- proc_qos->write_proc = qos_write_proc;
- }
- #endif
- gQosSetting = kmalloc(RTL_QOS_PROC_MAX_LEN, GFP_KERNEL);
- memset(gQosSetting, 0, RTL_QOS_PROC_MAX_LEN);
- gQosEnabled = 0;
-
- return SUCCESS;
-}
-
-int32 rtl_qos_cleanup(void)
-{
- kfree(gQosSetting);
-
- return SUCCESS;
-}
-#endif
-
-
-#if defined(CONFIG_RTL_FAST_BRIDGE)
-int32 rtl_fb_add_br_entry(skb)
-{
- struct net_bridge_fdb_entry *dst;
- const unsigned char *dest = eth_hdr(skb)->h_dest;
- if (!is_multicast_ether_addr(dest))
- {
- dst = __br_fdb_get(skb->dev->br_port->br, dest);
- if(dst != NULL && dst->dst->dev == skb->dev)
- {
- fast_br_cache_entry entry;
- memset(&entry,0,sizeof(fast_br_cache_entry));
- memcpy(&entry.mac_addr,dest,6);
- entry.ageing_timer = jiffies;
- entry.to_dev = skb->dev;
- entry.valid = 1;
-
- rtl_add_fast_br_entry(&entry);
- }
- }
-}
-#endif
-
-#if defined(FAST_PATH_SPI_ENABLED)
-enum tcp_bit_set {
- TCP_SYN_SET,
- TCP_SYNACK_SET,
- TCP_FIN_SET,
- TCP_ACK_SET,
- TCP_RST_SET,
- TCP_NONE_SET,
-};
-
-static unsigned int rtl_spi_get_conntrack_index(const struct tcphdr *tcph)
- {
- if (tcph->rst) return TCP_RST_SET;
- else if (tcph->syn) return (tcph->ack ? TCP_SYNACK_SET : TCP_SYN_SET);
- else if (tcph->fin) return TCP_FIN_SET;
- else if (tcph->ack) return TCP_ACK_SET;
- else return TCP_NONE_SET;
- }
-
-extern bool tcp_in_window(const struct nf_conn *ct,
- struct ip_ct_tcp *state,
- enum ip_conntrack_dir dir,
- unsigned int index,
- const struct sk_buff *skb,
- unsigned int dataoff,
- const struct tcphdr *tcph,
- u_int8_t pf);
-
-static inline struct nf_conn *
-rtl_resolve_normal_ct(struct net *net,
- struct sk_buff *skb,
- unsigned int dataoff,
- u_int16_t l3num,
- u_int8_t protonum,
- struct nf_conntrack_l3proto *l3proto,
- struct nf_conntrack_l4proto *l4proto,
- int *set_reply,
- enum ip_conntrack_info *ctinfo)
-{
- struct nf_conntrack_tuple tuple;
- struct nf_conntrack_tuple_hash *h;
- struct nf_conn *ct;
-
- if (!nf_ct_get_tuple(skb, skb_network_offset(skb),
- dataoff, l3num, protonum, &tuple, l3proto,
- l4proto)) {
- pr_debug("resolve_normal_ct: Can't get tuple\n");
- return NULL;
- }
-
- /* look for tuple match */
- h = nf_conntrack_find_get(net, &tuple);
-
- if (!h) {
- //h = init_conntrack(net, &tuple, l3proto, l4proto, skb, dataoff);
- //if (!h)
- return NULL;
- //if (IS_ERR(h))
- // return (void *)h;
- }
- ct = nf_ct_tuplehash_to_ctrack(h);
-
- /* It exists; we have (non-exclusive) reference. */
- if (NF_CT_DIRECTION(h) == IP_CT_DIR_REPLY) {
- *ctinfo = IP_CT_ESTABLISHED + IP_CT_IS_REPLY;
- } else {
- /* Once we've had two way comms, always ESTABLISHED. */
- if (test_bit(IPS_SEEN_REPLY_BIT, &ct->status)) {
- pr_debug("nf_conntrack_in: normal packet for %p\n", ct);
- *ctinfo = IP_CT_ESTABLISHED;
- } else if (test_bit(IPS_EXPECTED_BIT, &ct->status)) {
- pr_debug("nf_conntrack_in: related packet for %p\n",
- ct);
- *ctinfo = IP_CT_RELATED;
- } else {
- pr_debug("nf_conntrack_in: new packet for %p\n", ct);
- *ctinfo = IP_CT_NEW;
- }
- }
- skb->nfct = &ct->ct_general;
- skb->nfctinfo = *ctinfo;
- return ct;
-}
-
-
-unsigned int
-rtl_nf_conntrack_in(struct net *net, unsigned int dataoff, unsigned int hooknum,
- struct sk_buff *skb)
-{
- struct nf_conn *ct;
- enum ip_conntrack_info ctinfo;
- struct nf_conntrack_l3proto *l3proto;
- struct nf_conntrack_l4proto *l4proto;
- int set_reply = 0;
- enum ip_conntrack_dir dir;
- const struct tcphdr *th;
- struct tcphdr _tcph;
- unsigned int index;
-
-
- /* Previously seen (loopback or untracked)? Ignore. */
- if (skb->nfct) {
- NF_CT_STAT_INC_ATOMIC(net, ignore);
- return NF_ACCEPT;
- }
-
-
- /* rcu_read_lock()ed by nf_hook_slow */
- l3proto = rcu_dereference(nf_ct_l3protos[PF_INET]);
-
- l4proto = rcu_dereference(nf_ct_protos[PF_INET][IPPROTO_TCP]);
-
- ct = rtl_resolve_normal_ct(net, skb, dataoff, PF_INET, IPPROTO_TCP,
- l3proto, l4proto, &set_reply, &ctinfo);
-
- if (!ct) {
- /* Not valid part of a connection */
- return NF_ACCEPT;
- }
-
- if (IS_ERR(ct)) {
- /* Too stressed to deal. */
- return NF_DROP;
- }
-
- NF_CT_ASSERT(skb->nfct);
-
-
- th = skb_header_pointer(skb, dataoff, sizeof(_tcph), &_tcph);
- BUG_ON(th == NULL);
-
- dir = CTINFO2DIR(ctinfo);
-
- index = rtl_spi_get_conntrack_index(th);
-
- NF_CT_ASSERT(skb->nfct);
-
- if (!tcp_in_window(ct, &ct->proto.tcp, dir, index,
- skb, dataoff, th, PF_INET)) {
- return NF_DROP;
- }
- return NF_ACCEPT;
-
-}
-#endif
-
-
-#if defined(CONFIG_RTL_HARDWARE_NAT)
-/*2007-12-19*/
- int syn_asic_arp(struct neighbour *n, int add)
-{
-#ifdef CONFIG_RTL_LAYERED_DRIVER_L3
- u32 arp_ip = htonl(*((u32 *)n->primary_key));
- int rc;
-
- rc = add? rtl865x_addArp(arp_ip, (void *)n->ha): rtl865x_delArp(arp_ip);
-#endif
- return 0;
-}
-
-#if defined(CONFIG_RTL_MULTIPLE_WAN)
-int rtl_get_ps_arp_mapping(u32 ip, void *arp_entry_tmp)
-{
- rtl865x_arpMapping_entry_t *arp_entry;
- struct neighbour *dst_n;
- struct net_device *wanDev;
- wanDev=rtl865x_getWanDev();
-
- if(wanDev == NULL)
- return FAILED;
-
- arp_entry = (rtl865x_arpMapping_entry_t*)arp_entry_tmp;
-
- dst_n = neigh_lookup(&arp_tbl,&ip,wanDev);
- dev_put(wanDev);
- if(dst_n != NULL)
- {
- arp_entry->ip = ip;
- memcpy(arp_entry->mac.octet,dst_n->ha,ETHER_ADDR_LEN);
- return SUCCESS;
- }
-
- return FAILED;
-}
-#endif
-
-#if defined(CONFIG_RTL_IPTABLES_RULE_2_ACL) || defined(CONFIG_RTL_HARDWARE_NAT)
-/*get the chain number of the ipt_entry*/
-static int get_hookNum(struct ipt_entry *e, unsigned char *base, const unsigned int valid_hooks,const unsigned int *hook_entries)
-{
- int h;
- unsigned int offset = 0;
- int hook_num = -1;
-
- offset = (void *)e - (void *)base;
- for(h = 0; h < NF_INET_NUMHOOKS; h++)
- {
- if(!(valid_hooks & (1 << h)))
- continue;
-
- if(offset >= hook_entries[h])
- hook_num = h;
- }
-
- return hook_num;
-}
-#endif
-
-#ifdef CONFIG_RTL_HARDWARE_NAT
-rtl_masq_if rtl_masq_info[RTL_MULTIPLE_WAN_NUM];
-
-rtl_masq_if *rtl_get_masq_info_by_devName(const char* name)
-{
- int i;
- if(name == NULL)
- return NULL;
-
- for(i = 0; i < RTL_MULTIPLE_WAN_NUM;i++)
- {
- if(rtl_masq_info[i].valid == 1 &&strcmp(rtl_masq_info[i].ifName,name) == 0)
- return &rtl_masq_info[i];
- }
-
- return NULL;
-}
-
-int rtl_add_masq_info(const char *name,int ipAddr)
-{
- int i;
- if(strlen(name) >=IFNAMSIZ || ipAddr ==0)
- return FAILED;
-
- for(i = 0; i < RTL_MULTIPLE_WAN_NUM;i++)
- {
- if(rtl_masq_info[i].valid == 0)
- break;
- }
-
- if(i == RTL_MULTIPLE_WAN_NUM)
- return FAILED;
-
- rtl_masq_info[i].valid = 1;
- rtl_masq_info[i].ipAddr = ipAddr;
- memcpy(rtl_masq_info[i].ifName,name,strlen(name));
- rtl_masq_info[i].ifName[strlen(name)] ='\0';
- return SUCCESS;
-}
-
-int rtl_init_masq_info(void)
-{
- int i;
- for(i = 0; i < RTL_MULTIPLE_WAN_NUM;i++)
- {
- memset(&rtl_masq_info[i],0,sizeof(rtl_masq_if));
- }
-
- return SUCCESS;
-}
-
-/* Performance critical */
-static inline struct ipt_entry *
-get_entry(void *base, unsigned int offset)
-{
- return (struct ipt_entry *)(base + offset);
-}
-
-#ifdef CONFIG_NETFILTER_DEBUG
-#define IP_NF_ASSERT(x) \
-do { \
- if (!(x)) \
- printk("IP_NF_ASSERT: %s:%s:%u\n", \
- __func__, __FILE__, __LINE__); \
-} while(0)
-#else
-#define IP_NF_ASSERT(x)
-#endif
-
-static int rtl_get_masquerade_netif(struct xt_table_info *private,struct ipt_entry *masq_entry)
-{
- void *table_base;
- struct ipt_entry *e, *back;
- struct ipt_entry_target *t;
- struct net_device *dev;
- char masq_name[IFNAMSIZ]={'\0'};
-
- if(masq_entry && masq_entry->ip.outiface[0] !='\0')
- {
- memcpy(masq_name, masq_entry->ip.outiface, IFNAMSIZ);
- //return 0;
- }
- else
- {
- table_base = private->entries[smp_processor_id()];
- e = get_entry(table_base, private->hook_entry[NF_INET_POST_ROUTING]);
- back = get_entry(table_base, private->underflow[NF_INET_POST_ROUTING]);
-
- //clear masq_name;
- memset(masq_name,0,IFNAMSIZ);
- while(e)
- {
-
- if(e == masq_entry)
- break;
-
- //record the entry's outif name
- if(e->ip.outiface[0] !='\0')
- memcpy(masq_name,e->ip.outiface,IFNAMSIZ);
-
- //target
- t = ipt_get_target(e);
- IP_NF_ASSERT(t->u.kernel.target);
-
-
- //if error target
- if(strcmp(t->u.kernel.target->name, "ERROR") == 0)
- {
- memset(masq_name,0,IFNAMSIZ);
- break;
- }
-
- /* Standard target? */
- if (!t->u.kernel.target->target)
- {
- int v;
- v = ((struct ipt_standard_target *)t)->verdict;
-
- if (v < 0 )
- {
- if(v == IPT_RETURN)
- {
- e = back;
- back = get_entry(table_base, back->comefrom);
- }
- else
- {
- e = (void *)e + e->next_offset;
- }
-
- continue;
- }
-
- //jump ?
- if (table_base + v != (void *)e + e->next_offset
- && !(e->ip.flags & IPT_F_GOTO)) {
- /* Save old back ptr in next entry */
- struct ipt_entry *next
- = (void *)e + e->next_offset;
- next->comefrom
- = (void *)back - table_base;
- /* set back pointer to next entry */
- back = next;
- }
- e = get_entry(table_base, v);
- continue;
- }
-
- /*user define target?*/
- e = (void *)e + e->next_offset;
- }
-
- }
-
- if(masq_name[0] !='\0')
- {
- struct in_ifaddr *ina;
- dev = __dev_get_by_name(&init_net,masq_name);
- if ((dev)&&(dev->ip_ptr))
- {
-
- ina=(struct in_ifaddr *)(((struct in_device *)(dev->ip_ptr))->ifa_list);
- if (ina!=NULL)
- {
- rtl_add_masq_info(masq_name,ina->ifa_local);
- }
- }
- }
-
-
- return 0;
-}
-
-static int rtl_check_for_masquerade_entry(struct ipt_entry *e,
- unsigned char *base,
- const char *name,
- unsigned int size,
- const unsigned int valid_hooks,
- const unsigned int *hook_entries,
- struct xt_table_info *private)
-{
- struct ipt_entry_target *t;
- unsigned int hook;
- int ret = 0;
-
- t = ipt_get_target(e);
- if ( !t)
- {
- goto err;
- }
-
- hook = get_hookNum(e,base,valid_hooks,hook_entries);
- if ((hook == NF_INET_POST_ROUTING) &&
- ((strcmp(t->u.kernel.target->name, "MASQUERADE") == 0)))
- {
- rtl_get_masquerade_netif(private,e);
- }
- err:
- return ret;
-}
-
-int rtl_check_for_extern_ip(const char *name,
- unsigned int valid_hooks,
- struct xt_table_info *newinfo,
- void *entry0,
- unsigned int size,
- unsigned int number,
- const unsigned int *hook_entries,
- const unsigned int *underflows)
-{
- int i;
- IPT_ENTRY_ITERATE(entry0, size,rtl_check_for_masquerade_entry, entry0,name,size,valid_hooks,hook_entries,newinfo);
-
- //found masq entry
- for(i = 0; i < RTL_MULTIPLE_WAN_NUM;i++)
- {
- if(rtl_masq_info[i].valid == 1 && rtl_masq_info[i].ipAddr)
- {
- rtl865x_addIp(0,rtl_masq_info[i].ipAddr,IP_TYPE_NAPT);
- }
- }
-
- return 0;
-}
-
- int rtl_flush_extern_ip(void)
-{
- int i;
- for(i = 0; i < RTL_MULTIPLE_WAN_NUM;i++)
- {
- if(rtl_masq_info[i].valid == 1)
- {
- //delete....
- rtl865x_delIp(rtl_masq_info[i].ipAddr);
- }
- }
-
- return SUCCESS;
-}
-
-int32 rtl_update_ip_tables(char *name, unsigned long event, struct in_ifaddr *ina)
-{
- rtl_masq_if *entry;
-
- /*2007-12-19*/
- #ifdef CONFIG_HARDWARE_NAT_DEBUG
- /*2007-12-19*/
- printk("%s:%d\n",__FUNCTION__,__LINE__);
- #endif
- if (ina==NULL)
- return SUCCESS;
-
- entry = rtl_get_masq_info_by_devName(name);
- if (entry!=NULL)
- {
- if (event == NETDEV_UP )
- {
- rtl865x_addIp(0,(u32)(ina->ifa_local),IP_TYPE_NAPT);
- //update the ip address
- entry->ipAddr = ina->ifa_local;
- }
- else if(event == NETDEV_DOWN)
- {
- if(rtl865x_delIp(ina->ifa_local)==SUCCESS)
- {
- rtl865x_nat_init();
- }
- }
- }
-
- return SUCCESS;
-}
-
-int32 rtl_fn_insert(struct fib_table *tb, struct fib_config *cfg, struct fib_info *fi)
-{
- int rc;
- unsigned int ipDst, ipMask, ipGw;
- unsigned int srcIp,srcMask;
- struct net_device *netif;
- char *dev_t;
-
- /*2007-12-19*/
- if ((tb->tb_id == RT_TABLE_MAIN) && (gHwNatEnabled !=0)) {
- if(cfg->fc_oif) {
- netif = __dev_get_by_index(&init_net,cfg->fc_oif);
- } else {
- netif=NULL;
- }
-
- dev_t = (netif)? netif->name: NULL;
- ipDst = cfg->fc_dst ;
- ipMask = inet_make_mask(cfg->fc_dst_len);
- ipGw = cfg->fc_gw;
- rtl865x_getDevIpAndNetmask(netif,&srcIp,&srcMask);
- if (!ipDst || (!MULTICAST(ipDst) && !LOOPBACK(ipDst) && (ipDst != 0xffffffff)))
- {
- #ifdef CONFIG_RTL_LAYERED_DRIVER_L3
- //printk("-------------------%s(%d)\n",__FUNCTION__,__LINE__);
- rc = rtl865x_addRoute(ipDst,ipMask,ipGw,dev_t,srcIp);
- //printk("-------------------%s(%d),rc(%d)\n",__FUNCTION__,__LINE__,rc);
- #endif
- #ifdef CONFIG_HARDWARE_NAT_DEBUG
- /*2007-12-19*/
- printk("%s:%d:(%s): dst:%u.%u.%u.%u/%u, gw:%u.%u.%u.%u, dev: %s, errno=%d\n",
- __FUNCTION__,__LINE__,"add_rt", NIPQUAD(ipDst), cfg->fc_dst_len, NIPQUAD(ipGw), dev_t? dev_t: "null", rc
- );
- #endif
-
- }
- }
-
- return SUCCESS;
-}
-
-int32 rtl_fn_delete(struct fib_table *tb, struct fib_config *cfg)
-{
- int rc;
- unsigned int ipDst, ipMask;
-
- /*2007-12-19*/
- if (tb->tb_id == RT_TABLE_MAIN) {
- ipDst = cfg->fc_dst;
- ipMask = inet_make_mask(cfg->fc_dst_len);
-
- if (!ipDst || (!MULTICAST(ipDst) && !LOOPBACK(ipDst) && (ipDst != 0xffffffff))) {
- rc = 0;
- #ifdef CONFIG_RTL_LAYERED_DRIVER_L3
- rc = rtl865x_delRoute(ipDst, ipMask);
- #endif
- }
- }
-
- return SUCCESS;
-}
-
-int32 rtl_fn_flush(int fz_order, int idx, u32 tb_id, u32 fn_key)
-{
- int rc;
- unsigned int ipDst, ipMask;
- /*2007-12-19*/
- if (tb_id==RT_TABLE_MAIN) {
- ipDst =fn_key;
- ipMask = inet_make_mask(fz_order);
-
- if (!ipDst || (!MULTICAST(ipDst) && !LOOPBACK(ipDst) && (ipDst != 0xffffffff))) {
- rc = 0;
- #ifdef CONFIG_RTL_LAYERED_DRIVER_L3
- rc = rtl865x_delRoute(ipDst, ipMask);
- #endif
- }
- }
-
- return SUCCESS;
-}
-
-int32 rtl_ip_vs_conn_expire_check(struct ip_vs_conn *cp)
-{
- u_int32_t timeval;
- rtl865x_napt_entry rtl865xNaptEntry;
-
-/* chhuang:
- printk("ip_vs_conn_expire: c:(%u.%u.%u.%u:%d), v:(%u.%u.%u.%u:%d), \n\td:(%u.%u.%u.%u:%d), p:(%x), f: %x, s: %x\n",
- NIPQUAD(cp->caddr), cp->cport, NIPQUAD(cp->vaddr), cp->vport, NIPQUAD(cp->daddr), cp->dport,
- cp->protocol, cp->flags, cp->state);
-*/
- if (cp->hw_acc) {
- rtl865xNaptEntry.protocol=((cp->protocol==IPPROTO_TCP)? 1: 0);
- rtl865xNaptEntry.intIp=cp->daddr.ip;
- rtl865xNaptEntry.intPort=cp->dport;
- rtl865xNaptEntry.extIp=cp->vaddr.ip;
- rtl865xNaptEntry.extPort=cp->vport;
- rtl865xNaptEntry.remIp=cp->caddr.ip;
- rtl865xNaptEntry.remPort=cp->cport;
-
- timeval = rtl865x_naptSync(&rtl865xNaptEntry, 0);
-
- if (timeval > 0 && (cp->protocol==IPPROTO_UDP))
- {
- cp->timer.expires = jiffies + (timeval)*HZ;
- add_timer(&cp->timer);
- #ifdef CONFIG_HARDWARE_NAT_DEBUG
- /*2007-12-19*/
- printk("%s:%d:(%s): expired time = %d\n %s (%u.%u.%u.%u:%u -> %u.%u.%u.%u:%u) g:(%u.%u.%u.%u:%u)\n",
- __FUNCTION__,__LINE__,"poll_nat", timeval, (cp->protocol==IPPROTO_TCP)? "tcp": "udp",
- NIPQUAD(cp->daddr), cp->dport, NIPQUAD(cp->caddr), cp->cport,
- NIPQUAD(cp->vaddr), cp->vport
- );
- #endif
-
- return FAILED;
- }
- }
-
- return SUCCESS;
-}
-
-
-int32 rtl_ip_vs_conn_expire_check_delete(struct ip_vs_conn *cp)
-{
- rtl865x_napt_entry rtl865xNaptEntry;
-
- if (cp->hw_acc) {
- int rc;
-
- rtl865xNaptEntry.protocol=((cp->protocol==IPPROTO_TCP)? 1: 0);
- rtl865xNaptEntry.intIp=cp->daddr.ip;
- rtl865xNaptEntry.intPort=cp->dport;
- rtl865xNaptEntry.extIp=cp->vaddr.ip;
- rtl865xNaptEntry.extPort=cp->vport;
- rtl865xNaptEntry.remIp=cp->caddr.ip;
- rtl865xNaptEntry.remPort=cp->cport;
-
- rc = rtl865x_delNaptConnection(&rtl865xNaptEntry);
-
- #ifdef CONFIG_HARDWARE_NAT_DEBUG
- /*2007-12-19*/
- printk("%s:%d:(%s): errno=%d\n %s (%u.%u.%u.%u:%u -> %u.%u.%u.%u:%u) g:(%u.%u.%u.%u:%u)\n",
- __FUNCTION__,__LINE__,"del_nat", rc, (cp->protocol==IPPROTO_TCP)? "tcp": "udp",
- NIPQUAD(cp->daddr.ip), cp->dport, NIPQUAD(cp->caddr.ip), cp->cport,
- NIPQUAD(cp->vaddr.ip), cp->vport
- );
- #endif
- }
-
- return SUCCESS;
-}
-
-int32 rtl_tcp_state_transition_check(struct ip_vs_conn *cp, int direction, const struct sk_buff *skb, struct ip_vs_protocol *pp)
-{
- #if defined(CONFIG_RTL_HW_QOS_SUPPORT)
- uint32 ret;
- struct net_device *lanDev, *wanDev;
- #endif
-
- #if defined(CONFIG_RTL_LAYERED_DRIVER_L4)
- rtl865x_napt_entry rtl865xNaptEntry;
- rtl865x_priority rtl865xPrio;
- rtl865x_qos_mark rtl865xQosMark;
- #endif
-
- /*2007-12-19*/
- /*
- printk("ip_vs_set_state: c:(%u.%u.%u.%u:%d), v:(%u.%u.%u.%u:%d), \n\td:(%u.%u.%u.%u:%d), p:(%x), f: %x, s: %x, master: %s\n\tapp_data: %x, app: %x\n",
- NIPQUAD(cp->caddr), cp->cport, NIPQUAD(cp->vaddr), cp->vport, NIPQUAD(cp->daddr), cp->dport, cp->protocol, cp->flags, cp->state,
- cp->control? "yes": "no", cp->app_data, cp->app);
- */
- #if 0
- if (!cp->hw_acc && !cp->app &&
- cp->state==IP_VS_S_ESTABLISHED)
- #else
- if (!cp->hw_acc && !cp->app &&
- cp->state==IP_VS_TCP_S_ESTABLISHED)
- #endif
- {
- int rc;
- rc = 0;
-
- #if defined(CONFIG_RTL_HW_QOS_SUPPORT)
- if (NULL!=skb)
- {
- rtl865xNaptEntry.protocol=RTL865X_PROTOCOL_TCP;
- rtl865xNaptEntry.intIp=cp->daddr.ip;
- rtl865xNaptEntry.intPort=cp->dport;
- rtl865xNaptEntry.extIp=cp->vaddr.ip;
- rtl865xNaptEntry.extPort=cp->vport;
- rtl865xNaptEntry.remIp=cp->caddr.ip;
- rtl865xNaptEntry.remPort=cp->cport;
-
- rtl865xQosMark.downlinkMark=0; //Initial
- rtl865xQosMark.uplinkMark=0; //Initial
- ret=rtl_qosGetSkbMarkByNaptEntry(&rtl865xNaptEntry, &rtl865xQosMark, skb);
-
- lanDev=rtl865x_getLanDev();
- wanDev=rtl865x_getWanDev();
- rtl865xPrio.downlinkPrio=rtl_qosGetPriorityByMark(lanDev->name, rtl865xQosMark.downlinkMark);
- rtl865xPrio.uplinkPrio=rtl_qosGetPriorityByMark(wanDev->name, rtl865xQosMark.uplinkMark);
-
- if(lanDev)
- dev_put(lanDev);
-
- if(wanDev)
- dev_put(wanDev);
- }else
- #endif
- {
- rtl865xPrio.downlinkPrio=0;
- rtl865xPrio.uplinkPrio=0;
- }
-
- #if defined(CONFIG_RTL_LAYERED_DRIVER_L4)
- rtl865xNaptEntry.protocol=RTL865X_PROTOCOL_TCP;
- rtl865xNaptEntry.intIp=cp->daddr.ip;
- rtl865xNaptEntry.intPort=cp->dport;
- rtl865xNaptEntry.extIp=cp->vaddr.ip;
- rtl865xNaptEntry.extPort=cp->vport;
- rtl865xNaptEntry.remIp=cp->caddr.ip;
- rtl865xNaptEntry.remPort=cp->cport;
- rc = rtl865x_addNaptConnection(&rtl865xNaptEntry, &rtl865xPrio);
- #endif
- if (!rc)
- cp->hw_acc = 1;
- #ifdef CONFIG_HARDWARE_NAT_DEBUG
- /*2007-12-19*/
- printk("%s:%d:(%s): errno=%d\n %s (%u.%u.%u.%u:%u -> %u.%u.%u.%u:%u) g:(%u.%u.%u.%u:%u)\n",
- __FUNCTION__,__LINE__,"add_nat", rc, "tcp", NIPQUAD(cp->daddr), cp->dport,
- NIPQUAD(cp->caddr), cp->cport, NIPQUAD(cp->vaddr), cp->vport
- );
- #endif
- }
-}
-
-int32 rtl_udp_state_transition_check(struct ip_vs_conn *cp, int direction, const struct sk_buff *skb, struct ip_vs_protocol *pp)
-{
- #if defined(CONFIG_RTL_HW_QOS_SUPPORT)
- uint32 ret;
- struct net_device *lanDev, *wanDev;
- #endif
- #if defined(CONFIG_RTL_LAYERED_DRIVER_L4)
- rtl865x_napt_entry rtl865xNaptEntry;
- rtl865x_priority rtl865xPrio;
- rtl865x_qos_mark rtl865xQosMark;
- #endif
-
- /*2007-12-19*/
- if (!cp->hw_acc && !cp->app)
- {
- int rc;
- rc = 0;
- #if defined(CONFIG_RTL_HW_QOS_SUPPORT)
- if (NULL!=skb)
- {
- rtl865xNaptEntry.protocol=RTL865X_PROTOCOL_UDP;
- rtl865xNaptEntry.intIp=cp->daddr.ip;
- rtl865xNaptEntry.intPort=cp->dport;
- rtl865xNaptEntry.extIp=cp->vaddr.ip;
- rtl865xNaptEntry.extPort=cp->vport;
- rtl865xNaptEntry.remIp=cp->caddr.ip;
- rtl865xNaptEntry.remPort=cp->cport;
-
- rtl865xQosMark.downlinkMark=0; //Initial
- rtl865xQosMark.uplinkMark=0; //Initial
- ret=rtl_qosGetSkbMarkByNaptEntry(&rtl865xNaptEntry, &rtl865xQosMark, skb);
-
- lanDev=rtl865x_getLanDev();
- wanDev=rtl865x_getWanDev();
- rtl865xPrio.downlinkPrio=rtl_qosGetPriorityByMark(lanDev->name, rtl865xQosMark.downlinkMark);
- rtl865xPrio.uplinkPrio=rtl_qosGetPriorityByMark(wanDev->name, rtl865xQosMark.uplinkMark);
-
- if(lanDev)
- dev_put(lanDev);
-
- if(wanDev)
- dev_put(wanDev);
- } else
- #endif
- {
- rtl865xPrio.downlinkPrio=0;
- rtl865xPrio.uplinkPrio=0;
- }
-
- #if defined(CONFIG_RTL_LAYERED_DRIVER_L4)
- rtl865xNaptEntry.protocol=RTL865X_PROTOCOL_UDP;
- rtl865xNaptEntry.intIp=cp->daddr.ip;
- rtl865xNaptEntry.intPort=cp->dport;
- rtl865xNaptEntry.extIp=cp->vaddr.ip;
- rtl865xNaptEntry.extPort=cp->vport;
- rtl865xNaptEntry.remIp=cp->caddr.ip;
- rtl865xNaptEntry.remPort=cp->cport;
-
- rc = rtl865x_addNaptConnection(&rtl865xNaptEntry, &rtl865xPrio);
- #endif
- if (!rc)
- cp->hw_acc = 1;
- #ifdef CONFIG_HARDWARE_NAT_DEBUG
- /*2007-12-19*/
- printk("%s:%d:(%s): errno=%d\n %s (%u.%u.%u.%u:%u -> %u.%u.%u.%u:%u) g:(%u.%u.%u.%u:%u)\n",
- __FUNCTION__,__LINE__,"add_nat", rc, "udp", NIPQUAD(cp->daddr), cp->dport,
- NIPQUAD(cp->caddr), cp->cport, NIPQUAD(cp->vaddr), cp->vport
- );
- #endif
- }
-}
-
-#endif
-#endif
-
-#if defined(CONFIG_PROC_FS) && defined(CONFIG_RTL_NF_CONNTRACK_GARBAGE_NEW)
-static struct proc_dir_entry *proc_gc_overflow_timout=NULL;
-static int gc_overflow_timout_read_proc(char *page, char **start, off_t off,
- int count, int *eof, void *data)
-{
- int len;
-
- len = sprintf(page, "rtl_gc_overflow_timout(%d), HZ(%d)\n", rtl_gc_overflow_timout, HZ);
-
- if (len <= off+count) *eof = 1;
- *start = page + off;
- len -= off;
- if (len>count) len = count;
- if (len<0) len = 0;
- return len;
-}
-
-static int gc_overflow_timout_write_proc(struct file *file, const char *buffer,
- unsigned long count, void *data)
-{
- uint32 tmpBuf[32];
-
- if (count < 2)
- return -EFAULT;
-
- if (buffer && !copy_from_user(tmpBuf, buffer, count)) {
- tmpBuf[count-1]=0;
- rtl_gc_overflow_timout=simple_strtol((const char *)tmpBuf, NULL, 0);
-
- return count;
- }
- return -EFAULT;
-}
-
-void gc_overflow_timout_proc_init(void)
-{
- proc_gc_overflow_timout = create_proc_entry("gc_overflow_timout", 0, NULL);
- if (proc_gc_overflow_timout) {
- proc_gc_overflow_timout->read_proc = gc_overflow_timout_read_proc;
- proc_gc_overflow_timout->write_proc = gc_overflow_timout_write_proc;
- }
-}
-#endif
-
-
diff --git a/target/linux/realtek/files/net/rtl/features/98/rtl_ps_hooks.c b/target/linux/realtek/files/net/rtl/features/98/rtl_ps_hooks.c
deleted file mode 100644
index 609c349da..000000000
--- a/target/linux/realtek/files/net/rtl/features/98/rtl_ps_hooks.c
+++ /dev/null
@@ -1,819 +0,0 @@
-#include <linux/types.h>
-#include <linux/netfilter.h>
-#include <linux/module.h>
-#include <linux/skbuff.h>
-#include <linux/moduleparam.h>
-#include <linux/notifier.h>
-#include <linux/kernel.h>
-#include <linux/netdevice.h>
-#include <linux/ip.h>
-#include <linux/tcp.h>
-#include <linux/inetdevice.h>
-
-#include <net/ip_fib.h>
-#include <net/netfilter/nf_nat.h>
-#include <net/netfilter/nf_conntrack.h>
-#include <net/netfilter/nf_conntrack_core.h>
-#include <net/netfilter/nf_nat_protocol.h>
-#include <net/ip_vs.h>
-#include <linux/ip_vs.h>
-
-#include <net/rtl/rtl_types.h>
-#include <net/rtl/fastpath/fastpath_core.h>
-#include <net/rtl/features/rtl_features.h>
-#include <net/rtl/features/rtl_ps_hooks.h>
-
-#ifdef CONFIG_RTL_LAYERED_DRIVER_L3
-#include <net/rtl/rtl865x_ppp.h>
-#include <net/rtl/rtl865x_route_api.h>
-#include <net/rtl/rtl865x_arp_api.h>
-#endif
-
-#if defined(CONFIG_RTL_HW_QOS_SUPPORT) && defined(CONFIG_RTL_HARDWARE_NAT)
-#include <net/rtl/rtl865x_netif.h>
-#include <net/rtl/rtl865x_outputQueue.h>
-#endif
-
-#ifdef CONFIG_BRIDGE
-#include <bridge/br_private.h>
-#endif
-
-#ifdef CONFIG_RTL_HARDWARE_NAT
-//#define CONFIG_HARDWARE_NAT_DEBUG
-#ifdef CONFIG_RTL_LAYERED_DRIVER_L3
-#include <net/rtl/rtl865x_ppp.h>
-#include <net/rtl/rtl865x_route_api.h>
-#endif
-//unsigned int ldst, lmask, wdst, wmask;
-extern int gHwNatEnabled;
-#endif
-
-#ifdef CONFIG_RTL_HARDWARE_NAT
-/*2007-12-19*/
-#ifdef CONFIG_RTL_LAYERED_DRIVER_L3
-#include <net/rtl/rtl865x_ip_api.h>
-#endif
-#ifdef CONFIG_RTL_LAYERED_DRIVER_L4
-#include <net/rtl/rtl865x_nat.h>
-#endif
-extern char masq_if[];
-extern unsigned int hw_napt_ip;
-#endif
-
-#if defined(CONFIG_RTL_IPTABLES_FAST_PATH) && defined(CONFIG_FAST_PATH_MODULE)
-enum LR_RESULT (*FastPath_hook5)( ipaddr_t ip, ether_addr_t* mac, enum ARP_FLAGS flags )=NULL;
-enum LR_RESULT (*FastPath_hook7)( ipaddr_t ip )=NULL;
-enum LR_RESULT (*FastPath_hook8)( ipaddr_t ip, ether_addr_t* mac, enum ARP_FLAGS flags )=NULL;
-EXPORT_SYMBOL(FastPath_hook8);
-EXPORT_SYMBOL(FastPath_hook7);
-EXPORT_SYMBOL(FastPath_hook5);
-#endif
-
-
-int32 rtl_nf_conntrack_in_hooks(rtl_nf_conntrack_inso_s *info)
-{
- #if !defined(IMPROVE_QOS) && defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- rtl_fpAddConnCache(info->ct, info->skb);
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl_nf_conntrack_death_by_timeout_hooks(rtl_nf_conntrack_inso_s *info)
-{
- int ret;
-
- ret = RTL_PS_HOOKS_CONTINUE;
- #if defined(CONFIG_RTL_IPTABLES_FAST_PATH) || defined(CONFIG_RTL_HARDWARE_NAT)
- if (rtl_connCache_timer_update(info->ct)==SUCCESS) {
- ret = RTL_PS_HOOKS_RETURN;
- }
- #endif
-
- return ret;
-}
-
-int32 rtl_nf_conntrack_destroy_hooks(rtl_nf_conntrack_inso_s *info)
-{
- #if defined(CONFIG_RTL_IPTABLES_FAST_PATH) || defined(CONFIG_RTL_HARDWARE_NAT)
- rtl_delConnCache(info->ct);
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl_nf_conntrack_confirm_hooks(rtl_nf_conntrack_inso_s *info)
-{
- #if defined(CONFIG_RTL_NF_CONNTRACK_GARBAGE_NEW)
- rtl_connGC_addList(info->skb, info->ct);
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl_nf_init_conntrack_hooks(rtl_nf_conntrack_inso_s *info)
-{
-
- #if defined(CONFIG_RTL_NF_CONNTRACK_GARBAGE_NEW)
- INIT_LIST_HEAD(&info->ct->state_tuple);
- #endif
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-
-int32 rtl_nf_conntrack_init_hooks(void)
-{
- #if defined(CONFIG_RTL_NF_CONNTRACK_GARBAGE_NEW)
- rtl_nf_conn_GC_init();
- #endif
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl_tcp_packet_hooks(rtl_nf_conntrack_inso_s *info)
-{
- #if defined(CONFIG_RTL_HARDWARE_NAT)
- if (info->new_state==TCP_CONNTRACK_LAST_ACK) {
- rtl865x_handle_nat(info->ct, 0, NULL);
- }
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl_nf_nat_packet_hooks(rtl_nf_conntrack_inso_s *info)
-{
- #if (defined(IMPROVE_QOS) && defined(CONFIG_RTL_IPTABLES_FAST_PATH)) || defined(CONFIG_RTL_HARDWARE_NAT)
- rtl_addConnCache(info->ct, info->skb);
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl_nat_init_hooks(void)
-{
- rtl_nat_init();
- #if defined(CONFIG_NET_SCHED)
- rtl_qos_init();
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl_nat_cleanup_hooks(void)
-{
- #if defined(CONFIG_NET_SCHED)
- rtl_qos_cleanup();
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl_fn_hash_insert_hooks(struct fib_table *tb, struct fib_config *cfg, struct fib_info *fi)
-{
-#if defined( CONFIG_RTL_IPTABLES_FAST_PATH)
- #if defined(CONFIG_FAST_PATH_MODULE)
- if(FastPath_hook3!=NULL)
- {
- FastPath_hook3(cfg->fc_dst? cfg->fc_dst: 0, inet_make_mask(cfg->fc_dst_len),cfg->fc_gw ? cfg->fc_gw : 0, (uint8 *)fi->fib_dev->name, RT_NONE);
- }
- #else
- rtk_addRoute(cfg->fc_dst? cfg->fc_dst: 0, inet_make_mask(cfg->fc_dst_len),cfg->fc_gw ? cfg->fc_gw : 0, (uint8 *)fi->fib_dev->name, RT_NONE);
- #endif
-#endif
-
-
- #if defined(CONFIG_RTL_HARDWARE_NAT)
- rtl_fn_insert(tb, cfg, fi);
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl_fn_hash_delete_hooks(struct fib_table *tb, struct fib_config *cfg)
-{
- #if defined(CONFIG_RTK_IPTABLES_FAST_PATH)
- #ifdef CONFIG_FAST_PATH_MODULE
- if(FastPath_hook1!=NULL)
- {
- FastPath_hook1(cfg->fc_dst? cfg->fc_dst : 0, inet_make_mask(cfg->fc_dst_len));
- }
- #else
- rtk_delRoute(cfg->fc_dst? cfg->fc_dst : 0, inet_make_mask(cfg->fc_dst_len));
- #endif
- #endif
-
- #if defined(CONFIG_RTL_HARDWARE_NAT)
- rtl_fn_delete(tb, cfg);
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-
-int32 rtl_fn_flush_list_hooks(int fz_order, int idx, u32 tb_id, u32 fn_key)
-{
- #if defined(CONFIG_RTL_HARDWARE_NAT)
- rtl_fn_flush(fz_order, idx, tb_id, fn_key);
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl_fn_hash_replace_hooks(struct fib_table *tb, struct fib_config *cfg, struct fib_info *fi)
-{
-#if defined( CONFIG_RTL_IPTABLES_FAST_PATH)
- #if defined(CONFIG_FAST_PATH_MODULE)
- if(FastPath_hook2!=NULL)
- {
- FastPath_hook2(cfg->fc_dst? cfg->fc_dst: 0, inet_make_mask(cfg->fc_dst_len),cfg->fc_gw ? cfg->fc_gw : 0, (uint8 *)fi->fib_dev->name, RT_NONE);
- }
- #else
- rtk_modifyRoute(cfg->fc_dst? cfg->fc_dst: 0, inet_make_mask(cfg->fc_dst_len),cfg->fc_gw ? cfg->fc_gw : 0, (uint8 *)fi->fib_dev->name, RT_NONE);
- #endif
-#endif
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl_dev_queue_xmit_hooks(struct sk_buff *skb, struct net_device *dev)
-{
- #if defined( CONFIG_RTL_IPTABLES_FAST_PATH)
- rtl_fp_dev_queue_xmit_check(skb, dev);
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl_dev_hard_start_xmit_hooks(struct sk_buff *skb, struct net_device *dev, struct netdev_queue *txq)
-{
- #if defined( CONFIG_RTL_IPTABLES_FAST_PATH)
- rtl_fp_dev_hard_start_xmit_check(skb, dev, txq);
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl_netif_receive_skb_hooks(struct sk_buff *skb)
-{
- int ret;
-
- #if defined(CONFIG_RTL_FAST_BRIDGE)
- if(skb->dev->br_port && (rtl_fast_br_forwarding(skb)==RTL_FAST_BR_SUCCESS)) {
- ret = RTL_PS_HOOKS_RETURN;
- } else
- #endif
- #if defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- if (FastPath_Enter(&skb)== NET_RX_DROP) {
- ret = RTL_PS_HOOKS_RETURN;
- } else
- #endif
- {
- ret = RTL_PS_HOOKS_CONTINUE;
- }
-
- return ret;
-}
-
-int32 rtl_br_dev_queue_push_xmit_before_xmit_hooks(struct sk_buff *skb)
-{
- #if defined(CONFIG_RTL_FAST_BRIDGE)
- rtl_fb_add_br_entry(skb);
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-
-int32 rtl_neigh_forced_gc_hooks(struct neigh_table *tbl, struct neighbour *n)
-{
- #if defined(CONFIG_RTL_HARDWARE_NAT) && defined(CONFIG_RTL_LAYERED_DRIVER) && defined(CONFIG_RTL_LAYERED_DRIVER_L3)
- syn_asic_arp(n, 0);
- #endif
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl_neigh_flush_dev_hooks(struct neigh_table *tbl, struct net_device *dev, struct neighbour *n)
-{
- #if (defined(CONFIG_RTL_HARDWARE_NAT) && defined(CONFIG_RTL_LAYERED_DRIVER) && defined(CONFIG_RTL_LAYERED_DRIVER_L3)) || defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- if (n->nud_state & NUD_VALID) {
- #if defined(CONFIG_RTL_HARDWARE_NAT) && defined(CONFIG_RTL_LAYERED_DRIVER) && defined(CONFIG_RTL_LAYERED_DRIVER_L3)
- syn_asic_arp(n, 0);
- #endif
-
- #if defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- #ifdef CONFIG_FAST_PATH_MODULE
- if(FastPath_hook7!=NULL) {
- FastPath_hook7(*(u32*)n->primary_key);
- }
- #else
- rtk_delArp(*(u32*)n->primary_key);
- #endif
- #endif
- }
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl_neigh_destroy_hooks(struct neighbour *n)
-{
- #if defined(CONFIG_RTL_HARDWARE_NAT) && defined(CONFIG_RTL_LAYERED_DRIVER) && defined(CONFIG_RTL_LAYERED_DRIVER_L3)
- syn_asic_arp(n, 0);
- #endif
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl_neigh_connect_hooks(struct neighbour *neigh)
-{
- #if defined(CONFIG_RTL_HARDWARE_NAT) && defined(CONFIG_RTL_LAYERED_DRIVER) && defined(CONFIG_RTL_LAYERED_DRIVER_L3)
- if (neigh->nud_state & NUD_REACHABLE) {
- syn_asic_arp(neigh, 1);
- }
- #endif
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl_neigh_update_hooks(struct neighbour *neigh, const u8 *lladdr, uint8 old)
-{
- #if defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- if (old & NUD_VALID) {
- #ifdef CONFIG_FAST_PATH_MODULE
- if(FastPath_hook8!=NULL) {
- FastPath_hook8(*(u32*)neigh->primary_key, (ether_addr_t*)lladdr, ARP_NONE);
- }
- #else
- rtk_modifyArp(*(u32*)neigh->primary_key, (ether_addr_t*)lladdr, ARP_NONE);
- #endif
- }
- #endif
-
- #if defined(CONFIG_RTL_HARDWARE_NAT) && defined(CONFIG_RTL_LAYERED_DRIVER) && defined(CONFIG_RTL_LAYERED_DRIVER_L3)
- syn_asic_arp(neigh, 1);
- #endif
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl_neigh_update_post_hooks(struct neighbour *neigh, const u8 *lladdr, uint8 old)
-{
- #if defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- if ((neigh->nud_state & NUD_VALID) && !(old & NUD_VALID)) {
- #if defined(CONFIG_FAST_PATH_MODULE)
- if(FastPath_hook5!=NULL)
- {
- FastPath_hook5(*(u32*)neigh->primary_key, (ether_addr_t*)neigh->ha, ARP_NONE);
- }
- #else
- rtk_addArp(*(u32*)neigh->primary_key, (ether_addr_t*)neigh->ha, ARP_NONE);
- #endif
- } else if ((old & NUD_VALID) && !(neigh->nud_state & NUD_VALID)) {
- #if defined(CONFIG_FAST_PATH_MODULE)
- if(FastPath_hook7!=NULL)
- {
- FastPath_hook7(*(u32*)neigh->primary_key);
- }
- #else
- rtk_delArp(*(u32*)neigh->primary_key);
- #endif
- }
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-static __inline__ int neigh_max_probes(struct neighbour *n)
-{
- struct neigh_parms *p = n->parms;
- return (n->nud_state & NUD_PROBE ?
- p->ucast_probes :
- p->ucast_probes + p->app_probes + p->mcast_probes);
-}
-
-int32 rtl_neigh_periodic_timer_hooks(struct neighbour *n, unsigned int refresh)
-{
- int ret;
-
- if (!(n->nud_state & NUD_VALID))
- return RTL_PS_HOOKS_CONTINUE;
-
- ret = RTL_PS_HOOKS_CONTINUE;
- #if defined(CONFIG_RTL_HARDWARE_NAT) && defined(CONFIG_RTL_LAYERED_DRIVER) && defined(CONFIG_RTL_LAYERED_DRIVER_L3)
- if (rtl865x_arpSync(htonl(*((u32 *)n->primary_key)), refresh)>0) {
- n->used = jiffies;
- n->dead=0;
- ret = RTL_PS_HOOKS_BREAK;
- }
- else
- #endif
-
- #if defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- {
- #ifdef CONFIG_FAST_PATH_MODULE
- if(FastPath_hook7!=NULL)
- {
- FastPath_hook7(*(u32*)n->primary_key);
- }
- #else
- rtk_delArp(*(u32*)n->primary_key);
- #endif
- }
- #endif
-
- return ret;
-}
-
-int32 rtl_neigh_timer_handler_pre_update_hooks(struct neighbour *neigh, unsigned state)
-{
- #if defined(CONFIG_RTL_HARDWARE_NAT) && defined(CONFIG_RTL_LAYERED_DRIVER) && defined(CONFIG_RTL_LAYERED_DRIVER_L3)
- int32 tval;
- #endif
-
- if (state & NUD_REACHABLE) {
- #if defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- if (neigh->nud_state & NUD_VALID) {
- #ifdef CONFIG_FAST_PATH_MODULE
- if(FastPath_hook7!=NULL)
- {
- FastPath_hook7(*(u32*)neigh->primary_key);
- }
- #else
- rtk_delArp(*(u32*)neigh->primary_key);
- #endif
- }
- #endif
-
- #if defined(CONFIG_RTL_HARDWARE_NAT) && defined(CONFIG_RTL_LAYERED_DRIVER) && defined(CONFIG_RTL_LAYERED_DRIVER_L3)
- tval = rtl865x_arpSync(htonl(*((u32 *)neigh->primary_key)), 0);
- if (tval > 0)
- {
- neigh->confirmed = jiffies;
- }
- #if 0
- printk("%s:%d: ip:%u.%u.%u.%u, mac:%x:%x:%x:%x:%x:%x, tval is %d\n",
- __FUNCTION__,__LINE__,NIPQUAD(htonl(*((u32 *)neigh->primary_key))), neigh->ha[0], neigh->ha[1],
- neigh->ha[2], neigh->ha[3], neigh->ha[4], neigh->ha[5],tval);
- #endif
- #endif
-
- } else if (state & NUD_DELAY) {
- #if defined(CONFIG_RTL_HARDWARE_NAT) && defined(CONFIG_RTL_LAYERED_DRIVER) && defined(CONFIG_RTL_LAYERED_DRIVER_L3)
- tval = rtl865x_arpSync(htonl(*((u32 *)neigh->primary_key)), 0);
- if (tval > 0)
- {
- neigh->confirmed = jiffies;
- }
- #if 0
- printk("%s:%d: ip:%u.%u.%u.%u, mac:%x:%x:%x:%x:%x:%x, tval is %d",
- __FUNCTION__,__LINE__,NIPQUAD(htonl(*((u32 *)neigh->primary_key))), neigh->ha[0], neigh->ha[1],
- neigh->ha[2], neigh->ha[3], neigh->ha[4], neigh->ha[5],tval);
- #endif
- #endif
- }
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl_neigh_timer_handler_during_update_hooks(struct neighbour *neigh, unsigned state)
-{
- #if defined(CONFIG_RTL_HARDWARE_NAT) && defined(CONFIG_RTL_LAYERED_DRIVER) && defined(CONFIG_RTL_LAYERED_DRIVER_L3)
- if ((neigh->nud_state & (NUD_INCOMPLETE | NUD_PROBE)) &&
- atomic_read(&neigh->probes) >= neigh_max_probes(neigh)) {
- if (neigh->nud_state & NUD_VALID) {
- /*delete asic arp entry*/
- syn_asic_arp(neigh, 0);
- #if 0
- printk("%s:%d: ip:%u.%u.%u.%u, mac:%x:%x:%x:%x:%x:%x\n",
- __FUNCTION__,__LINE__,NIPQUAD(htonl(*((u32 *)neigh->primary_key))), neigh->ha[0], neigh->ha[1],
- neigh->ha[2], neigh->ha[3], neigh->ha[4],neigh->ha[5]);
- #endif
- }
- }
- #endif
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl_neigh_timer_handler_post_update_hooks(struct neighbour *neigh, unsigned state)
-{
- #if defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- if ((neigh->nud_state & NUD_VALID) && !(state & NUD_VALID)) {
- #ifdef CONFIG_FAST_PATH_MODULE
- if(FastPath_hook5!=NULL)
- {
- FastPath_hook5(*(u32*)neigh->primary_key, (ether_addr_t*)neigh->ha, ARP_NONE);
- }
- #else
- rtk_addArp(*(u32*)neigh->primary_key, (ether_addr_t*)neigh->ha, ARP_NONE);
- #endif
- } else if ((state & NUD_VALID) && !(neigh->nud_state & NUD_VALID)) {
- #ifdef CONFIG_FAST_PATH_MODULE
- if(FastPath_hook7!=NULL)
- {
- FastPath_hook7(*(u32*)neigh->primary_key);
- }
- #else
- rtk_delArp(*(u32*)neigh->primary_key);
- #endif
- }
- #endif
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl___neigh_event_send_pre_hooks(struct neighbour *neigh, struct sk_buff *skb)
-{
- #if defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- if (!(neigh->nud_state & (NUD_STALE | NUD_INCOMPLETE))) {
- if (neigh->nud_state & NUD_VALID) {
- #if defined(CONFIG_FAST_PATH_MODULE)
- if(FastPath_hook7!=NULL) {
- FastPath_hook7(*(u32*)neigh->primary_key);
- }
- #else
- rtk_delArp(*(u32*)neigh->primary_key);
- #endif
- }
- }
- #endif
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl___neigh_event_send_post_hooks(struct neighbour *neigh, struct sk_buff *skb)
-{
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl_neigh_init_hooks(void)
-{
- #if defined(CONFIG_RTL_MULTIPLE_WAN)
- rtl_set_callback_for_ps_arp(rtl_get_ps_arp_mapping);
- #endif
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-#if defined(CONFIG_BRIDGE)
-int32 rtl___br_fdb_get_timeout_hooks(struct net_bridge *br, struct net_bridge_fdb_entry *fdb, const unsigned char *addr)
-{
- #if defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- if (rtl_br_fdb_time_update((void*)br, (void*)fdb, addr)==FAILED) {
- return RTL_PS_HOOKS_BREAK;
- }
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-#endif
-
-int32 rtl_masq_device_event_hooks(struct notifier_block *this, struct net_device *dev, unsigned long event)
-{
- #if defined(CONFIG_RTL_HARDWARE_NAT)
- if (dev!=NULL && dev->ip_ptr!=NULL)
- rtl_update_ip_tables(dev->name, event, (struct in_ifaddr *)(((struct in_device *)(dev->ip_ptr))->ifa_list));
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-
- int32 rtl_masq_inet_event_hooks(struct notifier_block *this, unsigned long event, void *ptr)
- {
- #if defined(CONFIG_RTL_HARDWARE_NAT)
- struct in_ifaddr *ina;
-
- ina = (struct in_ifaddr*)ptr;
-
- #ifdef CONFIG_HARDWARE_NAT_DEBUG
- /*2007-12-19*/
- printk("%s:%d\n",__FUNCTION__,__LINE__);
- printk("ptr->ifa_dev->dev->name is %s\n", ina->ifa_dev->dev->name);
- #endif
-
- rtl_update_ip_tables(ina->ifa_dev->dev->name, event, ina);
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
- }
-
-
-int32 rtl_translate_table_hooks(const char *name,
- unsigned int valid_hooks,
- struct xt_table_info *newinfo,
- void *entry0,
- unsigned int size,
- unsigned int number,
- const unsigned int *hook_entries,
- const unsigned int *underflows)
-{
-#if defined(CONFIG_RTL_HARDWARE_NAT)
- //hyking:check masquerade and add ip
- if(strcmp(name,"nat") == 0)
- {
- rtl_flush_extern_ip();
- rtl_init_masq_info();
- rtl_check_for_extern_ip(name,valid_hooks,newinfo,entry0,size,number,hook_entries,underflows);
- }
-#endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-int32 rtl_ip_tables_init_hooks(void)
-{
- #if defined(CONFIG_RTL_HARDWARE_NAT)
- rtl_init_masq_info();
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-
-int32 rtl_ip_vs_conn_expire_hooks1(struct ip_vs_conn *cp)
-{
- int32 ret;
-
- ret = RTL_PS_HOOKS_CONTINUE;
- #if defined(CONFIG_RTL_HARDWARE_NAT)
- if (FAILED==rtl_ip_vs_conn_expire_check(cp)) {
- ret = RTL_PS_HOOKS_RETURN;
- }
- #endif
-
- return ret;
-}
-
-int32 rtl_ip_vs_conn_expire_hooks2(struct ip_vs_conn *cp)
-{
- #if defined(CONFIG_RTL_HARDWARE_NAT)
- rtl_ip_vs_conn_expire_check_delete(cp);
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-#if defined(CONFIG_IP_VS_PROTO_TCP)
-int32 rtl_tcp_state_transition_hooks(struct ip_vs_conn *cp, int direction, const struct sk_buff *skb, struct ip_vs_protocol *pp)
-{
- #if defined(CONFIG_RTL_HARDWARE_NAT)
- rtl_tcp_state_transition_check(cp, direction, skb, pp);
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-#endif
-
-#if defined(CONFIG_IP_VS_PROTO_UDP)
-int32 rtl_udp_state_transition_hooks(struct ip_vs_conn *cp, int direction, const struct sk_buff *skb, struct ip_vs_protocol *pp)
-{
- #if defined(CONFIG_RTL_HARDWARE_NAT)
- rtl_udp_state_transition_check(cp, direction, skb, pp);
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-#endif
-
-#ifdef CONFIG_PROC_FS
-int rtl_ct_seq_show_hooks(struct seq_file *s, struct nf_conn *ct)
-{
- //hyking add for hw use
- #if defined(CONFIG_RTL_HARDWARE_NAT)
- struct nf_conn_nat *nat;
- char *state[2]={"Hardware","software"};
-
- nat = nfct_nat(ct);
- if(seq_printf(s,"[%s] ",nat->hw_acc?state[0]:state[1]) != 0)
- return RTL_PS_HOOKS_BREAK;
- #endif
- return RTL_PS_HOOKS_CONTINUE;
-}
-#endif
-
-#if defined(CONFIG_RTL_NF_CONNTRACK_GARBAGE_NEW)
-//When do garbage collection and dst cache overflow, should not do garbage collection for rtl_gc_overflow_timout(default 3s)
-//Note: rtl_gc_overflow_timout can be modified by user via /proc/gc_overflow_timout
-unsigned long rtl_gc_overflow_timout=3*HZ;
-static unsigned long rtl_gc_overflow_timeout=0;
-#endif
-
-//Before do garbage collection, do rtl_dst_alloc_gc_pre_check_hooks
-int32 rtl_dst_alloc_gc_pre_check_hooks(struct dst_ops * ops)
-{
-#if defined(CONFIG_RTL_NF_CONNTRACK_GARBAGE_NEW)
- if((rtl_gc_overflow_timeout > 0)&& time_after_eq(rtl_gc_overflow_timeout, jiffies)){
- return RTL_PS_HOOKS_RETURN;
- }
-#endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-//After do garbage collection and dst cache overflow, do rtl_dst_alloc_gc_post_check1_hooks
-int32 rtl_dst_alloc_gc_post_check1_hooks(struct dst_ops * ops)
-{
-#if defined(CONFIG_RTL_NF_CONNTRACK_GARBAGE_NEW)
- rtl_gc_overflow_timeout=jiffies+rtl_gc_overflow_timout;
-#endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-//After [do garbage collection and dst cache not overflow] and dst alloc success, do rtl_dst_alloc_gc_post_check2_hooks
-int32 rtl_dst_alloc_gc_post_check2_hooks(struct dst_ops * ops, struct dst_entry * dst)
-{
-#if defined(CONFIG_RTL_NF_CONNTRACK_GARBAGE_NEW)
- rtl_gc_overflow_timeout=0;
-#endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-#if defined(CONFIG_RTL_NF_CONNTRACK_GARBAGE_NEW)
-// hooks in clean_from_lists at rtl_nf_connGC.c
-int32 clean_from_lists_hooks(struct nf_conn *ct, struct net *net)
-{
- #if defined(CONFIG_RTL_IPTABLES_FAST_PATH) || defined(CONFIG_RTL_HARDWARE_NAT)
- rtl_delConnCache(ct);
- #endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-// hooks in __nf_ct_refresh_acct_proto at rtl_nf_connGC.c
-int32 __nf_ct_refresh_acct_proto_hooks(struct nf_conn *ct,
- enum ip_conntrack_info ctinfo,
- const struct sk_buff *skb,
- int do_acct,
- int *event)
-{
-#ifdef CONFIG_IP_NF_CT_ACCT
- if (do_acct) {
- ct->counters[CTINFO2DIR(ctinfo)].packets++;
- ct->counters[CTINFO2DIR(ctinfo)].bytes +=
- ntohs(skb->nh.iph->tot_len);
- if ((ct->counters[CTINFO2DIR(ctinfo)].packets & 0x80000000)
- || (ct->counters[CTINFO2DIR(ctinfo)].bytes & 0x80000000))
- *event |= IPCT_COUNTER_FILLING;
- }
-#endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-// hooks1 in __drop_one_conntrack_process at rtl_nf_connGC.c
-int32 __drop_one_conntrack_process_hooks1(struct nf_conn* ct, int dropPrioIdx, int factor, int checkFlags, int tcpUdpState)
-{
-#if defined(CONFIG_RTL_IPTABLES_FAST_PATH) || defined(CONFIG_RTL_HARDWARE_NAT)
- if (checkFlags==TRUE && drop_priority[dropPrioIdx].state==tcpUdpState) {
- #if defined(CONFIG_RTL_IPTABLES_FAST_PATH)
- if (FAILED==rtl_fpTimer_update(ct)) {
- read_unlock_bh(&nf_conntrack_lock);
- rtl_death_action(ct);
- return RTL_PS_HOOKS_RETURN;
- }
- #endif
-
- #if defined(CONFIG_RTL_HARDWARE_NAT)
- if (FAILED==rtl_hwnat_timer_update(ct)) {
- read_unlock_bh(&nf_conntrack_lock);
- rtl_death_action(ct);
- return RTL_PS_HOOKS_RETURN;
- }
- #endif
- }
-
-#if (HZ==100)
- if (((ct->timeout.expires - jiffies) >> (factor+7))<=drop_priority[dropPrioIdx].threshold)
-#elif (HZ==1000)
- if (((ct->timeout.expires - jiffies) >> (factor+10))<=drop_priority[dropPrioIdx].threshold)
-#else
- #error "Please Check the HZ defination."
-#endif
- {
- read_unlock_bh(&nf_conntrack_lock);
- rtl_death_action(ct);
- return RTL_PS_HOOKS_RETURN;
- }
-
- return RTL_PS_HOOKS_CONTINUE;
-#else
- return RTL_PS_HOOKS_BREAK;
-#endif
-}
-
-// hooks2 in __drop_one_conntrack_process at rtl_nf_connGC.c
-int32 __drop_one_conntrack_process_hooks2(struct nf_conn* ct, int dropPrioIdx, int factor, int checkFlags, int tcpUdpState)
-{
-#if defined(CONFIG_RTL_IPTABLES_FAST_PATH) || defined(CONFIG_RTL_HARDWARE_NAT)
- add_timer(&ct->timeout);
-#endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-
-// hooks in rtl_nf_conn_GC_init at rtl_nf_connGC.c
-int32 rtl_nf_conn_GC_init_hooks(void)
-{
-#if defined(CONFIG_PROC_FS)
- gc_overflow_timout_proc_init();
-#endif
-
- return RTL_PS_HOOKS_CONTINUE;
-}
-#endif
-
diff --git a/target/linux/realtek/files/net/rtl/features/9xD/rtl_nf_connGC.S b/target/linux/realtek/files/net/rtl/features/9xD/rtl_nf_connGC.S
new file mode 100644
index 000000000..8bbbc758d
--- /dev/null
+++ b/target/linux/realtek/files/net/rtl/features/9xD/rtl_nf_connGC.S
@@ -0,0 +1,2169 @@
+ .file 1 "rtl_nf_connGC.c"
+ .section .mdebug.abi32
+ .previous
+ .gnu_attribute 4, 3
+#APP
+ .macro _ssnop; sll $0, $0, 1; .endm
+ .macro _ehb; sll $0, $0, 3; .endm
+ .macro mtc0_tlbw_hazard; nop; nop; .endm
+ .macro tlbw_use_hazard; nop; nop; nop; .endm
+ .macro tlb_probe_hazard; nop; nop; nop; .endm
+ .macro irq_enable_hazard; _ssnop; _ssnop; _ssnop;; .endm
+ .macro irq_disable_hazard; nop; nop; nop; .endm
+ .macro back_to_back_c0_hazard; _ssnop; _ssnop; _ssnop;; .endm
+ .macro raw_local_irq_enable
+ .set push
+ .set reorder
+ .set noat
+ mfc0 $1,$12
+ ori $1,0x1f
+ xori $1,0x1e
+ mtc0 $1,$12
+ irq_enable_hazard
+ .set pop
+ .endm
+ .macro raw_local_irq_disable
+ .set push
+ .set noat
+ mfc0 $1,$12
+ ori $1,0x1f
+ xori $1,0x1f
+ .set noreorder
+ mtc0 $1,$12
+ irq_disable_hazard
+ .set pop
+ .endm
+
+ .macro raw_local_save_flags flags
+ .set push
+ .set reorder
+ mfc0 \flags, $12
+ .set pop
+ .endm
+
+ .macro raw_local_irq_save result
+ .set push
+ .set reorder
+ .set noat
+ mfc0 \result, $12
+ ori $1, \result, 0x1f
+ xori $1, 0x1f
+ .set noreorder
+ mtc0 $1, $12
+ irq_disable_hazard
+ .set pop
+ .endm
+
+ .macro raw_local_irq_restore flags
+ .set push
+ .set noreorder
+ .set noat
+ mfc0 $1, $12
+ andi \flags, 1
+ ori $1, 0x1f
+ xori $1, 0x1f
+ or \flags, $1
+ mtc0 \flags, $12
+ irq_disable_hazard
+ .set pop
+ .endm
+
+#NO_APP
+ .section .text.isReservedConntrack,"ax",@progbits
+ .align 2
+ .globl isReservedConntrack
+ .set nomips16
+ .ent isReservedConntrack
+ .type isReservedConntrack, @function
+isReservedConntrack:
+ .frame $sp,0,$31 # vars= 0, regs= 0/0, args= 0, gp= 0
+ .mask 0x00000000,0
+ .fmask 0x00000000,0
+ .set noreorder
+ .set nomacro
+
+ lbu $2,38($4)
+ li $3,1 # 0x1
+ beq $2,$3,$L2
+ li $3,-268435456 # 0xf0000000
+
+ lw $6,20($4)
+ li $2,-536870912 # 0xe0000000
+ and $7,$6,$3
+ lw $8,0($4)
+ beq $7,$2,$L2
+ li $7,-1 # 0xffffffff
+
+ beq $6,$7,$L2
+ nop
+
+ beq $8,$0,$L2
+ nop
+
+ j $L28
+ nop
+
+$L20:
+ beq $6,$7,$L30
+ nop
+
+ beq $8,$0,$L30
+ nop
+
+ j $L29
+ li $2,80 # 0x50
+
+$L21:
+ bne $3,$6,$L17
+ nop
+
+ j $31
+ li $2,1 # 0x1
+
+$L22:
+ bne $3,$4,$L18
+ li $3,80 # 0x50
+
+ j $31
+ li $2,1 # 0x1
+
+$L23:
+ bne $2,$4,$L19
+ li $2,1 # 0x1
+
+ j $L30
+ nop
+
+$L24:
+ xori $2,$2,0x1f90
+ j $31
+ sltu $2,$2,1
+
+$L2:
+ li $2,1 # 0x1
+$L30:
+ j $31
+ nop
+
+$L28:
+ lw $6,20($5)
+ lw $8,0($5)
+ and $3,$6,$3
+ bne $3,$2,$L20
+ li $2,1 # 0x1
+
+ j $L30
+ nop
+
+$L29:
+ lhu $3,16($4)
+ bne $3,$2,$L21
+ li $6,8080 # 0x1f90
+
+ j $31
+ li $2,1 # 0x1
+
+$L17:
+ lhu $3,36($4)
+ bne $3,$2,$L22
+ li $4,8080 # 0x1f90
+
+ j $31
+ li $2,1 # 0x1
+
+$L18:
+ lhu $2,16($5)
+ bne $2,$3,$L23
+ nop
+
+ j $31
+ li $2,1 # 0x1
+
+$L19:
+ lhu $2,36($5)
+ bne $2,$3,$L24
+ nop
+
+ j $31
+ li $2,1 # 0x1
+
+ .set macro
+ .set reorder
+ .end isReservedConntrack
+ .size isReservedConntrack, .-isReservedConntrack
+ .section .text.rtl_nf_conn_GC_init,"ax",@progbits
+ .align 2
+ .globl rtl_nf_conn_GC_init
+ .set nomips16
+ .ent rtl_nf_conn_GC_init
+ .type rtl_nf_conn_GC_init, @function
+rtl_nf_conn_GC_init:
+ .frame $sp,24,$31 # vars= 0, regs= 1/0, args= 16, gp= 0
+ .mask 0x80000000,-4
+ .fmask 0x00000000,0
+ .set noreorder
+ .set nomacro
+
+ addiu $sp,$sp,-24
+ sw $31,20($sp)
+ lui $3,%hi(Tcp_State_Hash_Head+4)
+ lui $4,%hi(Tcp_State_Hash_Head+92)
+ addiu $3,$3,%lo(Tcp_State_Hash_Head+4)
+ j $L32
+ addiu $4,$4,%lo(Tcp_State_Hash_Head+92)
+
+$L34:
+ lw $2,0($3)
+ beq $2,$0,$L32
+ addiu $3,$3,8
+
+ sw $2,4($2)
+ sw $2,0($2)
+$L32:
+ bne $3,$4,$L34
+ nop
+
+ lui $3,%hi(Udp_State_Hash_Head+4)
+ lui $4,%hi(Udp_State_Hash_Head+20)
+ addiu $3,$3,%lo(Udp_State_Hash_Head+4)
+ j $L35
+ addiu $4,$4,%lo(Udp_State_Hash_Head+20)
+
+$L37:
+ lw $2,0($3)
+ beq $2,$0,$L35
+ addiu $3,$3,8
+
+ sw $2,4($2)
+ sw $2,0($2)
+$L35:
+ bne $3,$4,$L37
+ li $6,12 # 0xc
+
+ lui $4,%hi(prot_limit)
+ addiu $4,$4,%lo(prot_limit)
+ jal memset
+ move $5,$0
+
+ lui $6,%hi(prot_counters)
+ lui $4,%hi(_prot_limit)
+ addiu $6,$6,%lo(prot_counters)
+ addiu $4,$4,%lo(_prot_limit)
+ move $2,$0
+ li $3,12 # 0xc
+ addu $8,$6,$2
+$L46:
+ addu $7,$2,$4
+ move $5,$4
+ addiu $2,$2,4
+ sw $0,0($8)
+ sw $0,0($7)
+ bne $2,$3,$L46
+ addu $8,$6,$2
+
+ li $6,10 # 0xa
+ lui $3,%hi(drop_priority_max_idx)
+ sw $6,%lo(drop_priority_max_idx)($3)
+ lui $6,%hi(rtl_newGC_session_status_flags)
+ lui $4,%hi(prot_limit)
+ li $9,60 # 0x3c
+ sw $0,%lo(rtl_newGC_session_status_flags)($6)
+ li $6,2 # 0x2
+ addiu $2,$4,%lo(prot_limit)
+ move $3,$0
+ sw $6,%lo(prot_limit)($4)
+ li $6,90 # 0x5a
+ move $8,$2
+ sw $6,4($2)
+ lui $7,%hi(nf_conntrack_max)
+ li $4,100 # 0x64
+ li $6,12 # 0xc
+ sw $9,8($2)
+$L39:
+ addu $2,$8,$3
+ addu $9,$3,$5
+ lw $10,0($2)
+ addiu $3,$3,4
+ lw $2,%lo(nf_conntrack_max)($7)
+ mult $10,$2
+ mflo $10
+ divu $0,$10,$4
+ mflo $10
+ sw $10,0($9)
+ bne $3,$6,$L39
+ nop
+
+ sll $5,$2,2
+ li $4,5 # 0x5
+ lui $3,%hi(rtl_nf_conntrack_threshold)
+ divu $0,$5,$4
+ mflo $5
+ subu $4,$2,$5
+ sltu $4,$4,65
+ bne $4,$0,$L40
+ sw $5,%lo(rtl_nf_conntrack_threshold)($3)
+
+ addiu $4,$2,-64
+ sw $4,%lo(rtl_nf_conntrack_threshold)($3)
+$L40:
+ beq $2,$0,$L47
+ lui $2,%hi(rtl_newGC_session_status_flags)
+
+ jal rtl_gc_threshold_check
+ move $4,$0
+
+ bne $2,$0,$L41
+ lui $2,%hi(rtl_newGC_session_status_flags)
+
+ li $3,3 # 0x3
+ lw $4,%lo(rtl_newGC_session_status_flags)($2)
+ beq $4,$3,$L42
+ lui $4,%hi(jiffies)
+
+ lw $4,%lo(jiffies)($4)
+ sw $3,%lo(rtl_newGC_session_status_flags)($2)
+ lui $2,%hi(rtl_newGC_session_status_time)
+ addiu $3,$4,1
+ j $L42
+ sw $3,%lo(rtl_newGC_session_status_time)($2)
+
+$L41:
+$L47:
+ sw $0,%lo(rtl_newGC_session_status_flags)($2)
+$L42:
+ jal rtl_nf_conn_GC_init_hooks
+ nop
+
+ move $2,$0
+ lw $31,20($sp)
+ j $31
+ addiu $sp,$sp,24
+
+ .set macro
+ .set reorder
+ .end rtl_nf_conn_GC_init
+ .size rtl_nf_conn_GC_init, .-rtl_nf_conn_GC_init
+ .section .text.__conntrack_drop_check,"ax",@progbits
+ .align 2
+ .globl __conntrack_drop_check
+ .set nomips16
+ .ent __conntrack_drop_check
+ .type __conntrack_drop_check, @function
+__conntrack_drop_check:
+ .frame $sp,56,$31 # vars= 0, regs= 9/0, args= 16, gp= 0
+ .mask 0x80ff0000,-4
+ .fmask 0x00000000,0
+ .set noreorder
+ .set nomacro
+
+ addiu $sp,$sp,-56
+ sw $31,52($sp)
+ sw $23,48($sp)
+ sw $22,44($sp)
+ sw $21,40($sp)
+ sw $20,36($sp)
+ sw $19,32($sp)
+ sw $18,28($sp)
+ sw $17,24($sp)
+ sw $16,20($sp)
+ move $5,$0
+ jal rtl_new_gc_get_ct_protonum
+ move $16,$4
+
+ move $4,$16
+ move $5,$0
+ jal rtl_new_gc_get_ct_port_by_dir
+ move $6,$0
+
+ move $4,$16
+ move $5,$0
+ li $6,1 # 0x1
+ jal rtl_new_gc_get_ct_port_by_dir
+ move $20,$2
+
+ move $4,$16
+ li $5,1 # 0x1
+ move $6,$0
+ jal rtl_new_gc_get_ct_port_by_dir
+ move $19,$2
+
+ move $4,$16
+ li $5,1 # 0x1
+ li $6,1 # 0x1
+ jal rtl_new_gc_get_ct_port_by_dir
+ move $18,$2
+
+ move $4,$16
+ move $5,$0
+ move $6,$0
+ jal rtl_new_gc_get_ct_ip_by_dir
+ move $17,$2
+
+ move $4,$16
+ move $5,$0
+ li $6,1 # 0x1
+ jal rtl_new_gc_get_ct_ip_by_dir
+ move $23,$2
+
+ move $4,$16
+ li $5,1 # 0x1
+ move $6,$0
+ jal rtl_new_gc_get_ct_ip_by_dir
+ move $21,$2
+
+ move $4,$16
+ li $5,1 # 0x1
+ li $6,1 # 0x1
+ jal rtl_new_gc_get_ct_ip_by_dir
+ move $22,$2
+
+ li $4,-268435456 # 0xf0000000
+ and $5,$21,$4
+ li $3,-536870912 # 0xe0000000
+ beq $5,$3,$L49
+ and $4,$2,$4
+
+ beq $4,$3,$L49
+ nop
+
+ bne $23,$2,$L53
+ sltu $2,$20,1024
+
+ beq $21,$22,$L51
+ li $2,-1 # 0xffffffff
+
+ sltu $2,$20,1024
+$L53:
+ bne $2,$0,$L51
+ li $2,-1 # 0xffffffff
+
+ sltu $2,$19,1024
+ bne $2,$0,$L51
+ li $2,-1 # 0xffffffff
+
+ sltu $2,$18,1024
+ bne $2,$0,$L51
+ li $2,-1 # 0xffffffff
+
+ sltu $2,$17,1024
+ bne $2,$0,$L49
+ li $3,8080 # 0x1f90
+
+ beq $20,$3,$L49
+ nop
+
+ beq $19,$3,$L49
+ nop
+
+ beq $18,$3,$L51
+ li $2,-1 # 0xffffffff
+
+ bne $17,$3,$L51
+ move $2,$0
+
+$L49:
+ li $2,-1 # 0xffffffff
+$L51:
+ lw $31,52($sp)
+ lw $23,48($sp)
+ lw $22,44($sp)
+ lw $21,40($sp)
+ lw $20,36($sp)
+ lw $19,32($sp)
+ lw $18,28($sp)
+ lw $17,24($sp)
+ lw $16,20($sp)
+ j $31
+ addiu $sp,$sp,56
+
+ .set macro
+ .set reorder
+ .end __conntrack_drop_check
+ .size __conntrack_drop_check, .-__conntrack_drop_check
+ .section .text.__nf_ct_refresh_acct_proto,"ax",@progbits
+ .align 2
+ .globl __nf_ct_refresh_acct_proto
+ .set nomips16
+ .ent __nf_ct_refresh_acct_proto
+ .type __nf_ct_refresh_acct_proto, @function
+__nf_ct_refresh_acct_proto:
+ .frame $sp,56,$31 # vars= 8, regs= 6/0, args= 24, gp= 0
+ .mask 0x801f0000,-4
+ .fmask 0x00000000,0
+ .set noreorder
+ .set nomacro
+
+ addiu $sp,$sp,-56
+ sw $31,52($sp)
+ sw $20,48($sp)
+ sw $19,44($sp)
+ sw $18,40($sp)
+ sw $17,36($sp)
+ sw $16,32($sp)
+ move $16,$4
+ move $18,$5
+ sw $0,24($sp)
+ move $17,$6
+ lbu $19,79($sp)
+ jal local_bh_disable
+ move $20,$7
+
+ li $5,10 # 0xa
+ jal rtl_test_bit
+ move $4,$16
+
+ beq $2,$0,$L64
+ move $4,$16
+
+ jal rtl_test_bit
+ li $5,3 # 0x3
+
+ li $3,-1 # 0xffffffff
+ bne $2,$3,$L57
+ move $5,$20
+
+ jal rtl_new_gc_set_ct_timeout_expires
+ move $4,$16
+
+ li $2,8 # 0x8
+ j $L58
+ sw $2,24($sp)
+
+$L57:
+ jal rtl_del_ct_timer
+ move $4,$16
+
+ beq $2,$0,$L58
+ lui $2,%hi(jiffies)
+
+ move $4,$16
+ lw $5,%lo(jiffies)($2)
+ jal rtl_new_gc_set_ct_timeout_expires
+ addu $5,$20,$5
+
+ jal rtl_add_ct_timer
+ move $4,$16
+
+ li $2,8 # 0x8
+ sw $2,24($sp)
+ li $2,6 # 0x6
+ beq $19,$2,$L59
+ li $2,17 # 0x11
+
+ bne $19,$2,$L58
+ nop
+
+ j $L66
+ nop
+
+$L59:
+ lw $6,84($sp)
+ li $5,1 # 0x1
+ j $L63
+ move $4,$16
+
+$L66:
+ jal rtl_new_gc_get_ct_udp_status
+ move $4,$16
+
+ andi $2,$2,0x2
+ beq $2,$0,$L61
+ move $4,$16
+
+ li $5,2 # 0x2
+ j $L63
+ li $6,1 # 0x1
+
+$L61:
+ li $5,2 # 0x2
+ move $6,$0
+$L63:
+ jal rtl_list_move_tail
+ nop
+
+$L58:
+ lw $7,72($sp)
+ addiu $2,$sp,24
+ move $4,$16
+ move $5,$18
+ sw $2,16($sp)
+ jal __nf_ct_refresh_acct_proto_hooks
+ move $6,$17
+
+$L64:
+ jal local_bh_enable
+ nop
+
+ lw $31,52($sp)
+ lw $20,48($sp)
+ lw $19,44($sp)
+ lw $18,40($sp)
+ lw $17,36($sp)
+ lw $16,32($sp)
+ j $31
+ addiu $sp,$sp,56
+
+ .set macro
+ .set reorder
+ .end __nf_ct_refresh_acct_proto
+ .size __nf_ct_refresh_acct_proto, .-__nf_ct_refresh_acct_proto
+ .section .text.rtl_connGC_addList,"ax",@progbits
+ .align 2
+ .globl rtl_connGC_addList
+ .set nomips16
+ .ent rtl_connGC_addList
+ .type rtl_connGC_addList, @function
+rtl_connGC_addList:
+ .frame $sp,32,$31 # vars= 0, regs= 3/0, args= 16, gp= 0
+ .mask 0x80030000,-4
+ .fmask 0x00000000,0
+ addiu $sp,$sp,-32
+ sw $31,28($sp)
+ sw $17,24($sp)
+ sw $16,20($sp)
+ move $16,$5
+ .set noreorder
+ .set nomacro
+ jal rtl_new_gc_ip_hdr
+ move $17,$4
+ .set macro
+ .set reorder
+
+ beq $2,$0,$L68
+ .set noreorder
+ .set nomacro
+ jal rtl_new_gc_get_skb_protocol
+ move $4,$17
+ .set macro
+ .set reorder
+
+ li $3,6 # 0x6
+ .set noreorder
+ .set nomacro
+ beq $2,$3,$L70
+ li $3,17 # 0x11
+ .set macro
+ .set reorder
+
+ .set noreorder
+ .set nomacro
+ beq $2,$3,$L71
+ li $3,1 # 0x1
+ .set macro
+ .set reorder
+
+ bne $2,$3,$L68
+ j $L79
+$L70:
+ .set noreorder
+ .set nomacro
+ jal rtl_new_gc_get_ct_tcp_state
+ move $4,$16
+ .set macro
+ .set reorder
+
+ lui $3,%hi(Tcp_State_Hash_Head)
+ sll $2,$2,3
+ addiu $3,$3,%lo(Tcp_State_Hash_Head)
+ addu $2,$3,$2
+ lw $2,4($2)
+ .set noreorder
+ .set nomacro
+ beq $2,$0,$L72
+ move $4,$16
+ .set macro
+ .set reorder
+
+ li $5,1 # 0x1
+ .set noreorder
+ .set nomacro
+ jal rtl_list_add_tail
+ move $6,$0
+ .set macro
+ .set reorder
+
+$L72:
+#APP
+ # 56 "/backup_new/qian_yu/trunk_release_buildcode/96d/linux-2.6.30/arch/rlx/include/asm/atomic.h" 1
+
+
+ # 0 "" 2
+#NO_APP
+ lui $2,%hi(prot_counters)
+ addiu $2,$2,%lo(prot_counters)
+#APP
+ # 58 "/backup_new/qian_yu/trunk_release_buildcode/96d/linux-2.6.30/arch/rlx/include/asm/atomic.h" 1
+ 1: ll $3, 4($2) # atomic_add
+ nop
+ addu $3, 1
+ sc $3, 4($2)
+ beqz $3, 2f
+ .subsection 2
+2: b 1b
+ .previous
+
+ # 0 "" 2
+#NO_APP
+ j $L77
+$L71:
+ .set noreorder
+ .set nomacro
+ jal rtl_new_gc_get_ct_udp_status
+ move $4,$16
+ .set macro
+ .set reorder
+
+ andi $2,$2,0x2
+ .set noreorder
+ .set nomacro
+ beq $2,$0,$L73
+ move $4,$16
+ .set macro
+ .set reorder
+
+ li $5,2 # 0x2
+ .set noreorder
+ .set nomacro
+ j $L76
+ li $6,1 # 0x1
+ .set macro
+ .set reorder
+
+$L73:
+ li $5,2 # 0x2
+ move $6,$0
+$L76:
+ jal rtl_list_add_tail
+#APP
+ # 56 "/backup_new/qian_yu/trunk_release_buildcode/96d/linux-2.6.30/arch/rlx/include/asm/atomic.h" 1
+
+
+ # 0 "" 2
+#NO_APP
+ lui $2,%hi(prot_counters)
+ addiu $2,$2,%lo(prot_counters)
+#APP
+ # 58 "/backup_new/qian_yu/trunk_release_buildcode/96d/linux-2.6.30/arch/rlx/include/asm/atomic.h" 1
+ 1: ll $3, 8($2) # atomic_add
+ nop
+ addu $3, 1
+ sc $3, 8($2)
+ beqz $3, 2f
+ .subsection 2
+2: b 1b
+ .previous
+
+ # 0 "" 2
+#NO_APP
+ j $L77
+$L79:
+#APP
+ # 56 "/backup_new/qian_yu/trunk_release_buildcode/96d/linux-2.6.30/arch/rlx/include/asm/atomic.h" 1
+
+
+ # 0 "" 2
+#NO_APP
+ lui $2,%hi(prot_counters)
+#APP
+ # 58 "/backup_new/qian_yu/trunk_release_buildcode/96d/linux-2.6.30/arch/rlx/include/asm/atomic.h" 1
+ 1: ll $3, %lo(prot_counters)($2) # atomic_add
+ nop
+ addu $3, 1
+ sc $3, %lo(prot_counters)($2)
+ beqz $3, 2f
+ .subsection 2
+2: b 1b
+ .previous
+
+ # 0 "" 2
+#NO_APP
+$L77:
+#APP
+ # 72 "/backup_new/qian_yu/trunk_release_buildcode/96d/linux-2.6.30/arch/rlx/include/asm/atomic.h" 1
+
+
+ # 0 "" 2
+#NO_APP
+$L68:
+ lw $31,28($sp)
+ move $2,$0
+ lw $17,24($sp)
+ lw $16,20($sp)
+ .set noreorder
+ .set nomacro
+ j $31
+ addiu $sp,$sp,32
+ .set macro
+ .set reorder
+
+ .end rtl_connGC_addList
+ .size rtl_connGC_addList, .-rtl_connGC_addList
+ .section .text.clean_from_lists,"ax",@progbits
+ .align 2
+ .globl clean_from_lists
+ .set nomips16
+ .ent clean_from_lists
+ .type clean_from_lists, @function
+clean_from_lists:
+ .frame $sp,32,$31 # vars= 0, regs= 3/0, args= 16, gp= 0
+ .mask 0x80030000,-4
+ .fmask 0x00000000,0
+ addiu $sp,$sp,-32
+ sw $31,28($sp)
+ sw $17,24($sp)
+ sw $16,20($sp)
+ move $16,$4
+ move $17,$5
+ .set noreorder
+ .set nomacro
+ jal rtl_hlist_nulls_del_rcu
+ move $5,$0
+ .set macro
+ .set reorder
+
+ move $4,$16
+ .set noreorder
+ .set nomacro
+ jal rtl_hlist_nulls_del_rcu
+ li $5,1 # 0x1
+ .set macro
+ .set reorder
+
+ jal local_bh_disable
+ move $4,$16
+ .set noreorder
+ .set nomacro
+ jal rtl_new_gc_get_ct_protonum
+ move $5,$0
+ .set macro
+ .set reorder
+
+ li $3,6 # 0x6
+ .set noreorder
+ .set nomacro
+ beq $2,$3,$L83
+ li $3,17 # 0x11
+ .set macro
+ .set reorder
+
+ .set noreorder
+ .set nomacro
+ beq $2,$3,$L84
+ li $3,1 # 0x1
+ .set macro
+ .set reorder
+
+ .set noreorder
+ .set nomacro
+ bne $2,$3,$L92
+ move $4,$16
+ .set macro
+ .set reorder
+
+ j $L91
+$L83:
+#APP
+ # 94 "/backup_new/qian_yu/trunk_release_buildcode/96d/linux-2.6.30/arch/rlx/include/asm/atomic.h" 1
+
+
+ # 0 "" 2
+#NO_APP
+ lui $2,%hi(prot_counters)
+ addiu $2,$2,%lo(prot_counters)
+#APP
+ # 96 "/backup_new/qian_yu/trunk_release_buildcode/96d/linux-2.6.30/arch/rlx/include/asm/atomic.h" 1
+ 1: ll $3, 4($2) # atomic_sub
+ nop
+ subu $3, 1
+ sc $3, 4($2)
+ beqz $3, 2f
+ .subsection 2
+2: b 1b
+ .previous
+
+ # 0 "" 2
+#NO_APP
+ j $L89
+$L84:
+#APP
+ # 94 "/backup_new/qian_yu/trunk_release_buildcode/96d/linux-2.6.30/arch/rlx/include/asm/atomic.h" 1
+
+
+ # 0 "" 2
+#NO_APP
+ lui $2,%hi(prot_counters)
+ addiu $2,$2,%lo(prot_counters)
+#APP
+ # 96 "/backup_new/qian_yu/trunk_release_buildcode/96d/linux-2.6.30/arch/rlx/include/asm/atomic.h" 1
+ 1: ll $3, 8($2) # atomic_sub
+ nop
+ subu $3, 1
+ sc $3, 8($2)
+ beqz $3, 2f
+ .subsection 2
+2: b 1b
+ .previous
+
+ # 0 "" 2
+#NO_APP
+ j $L89
+$L91:
+#APP
+ # 94 "/backup_new/qian_yu/trunk_release_buildcode/96d/linux-2.6.30/arch/rlx/include/asm/atomic.h" 1
+
+
+ # 0 "" 2
+#NO_APP
+ lui $2,%hi(prot_counters)
+#APP
+ # 96 "/backup_new/qian_yu/trunk_release_buildcode/96d/linux-2.6.30/arch/rlx/include/asm/atomic.h" 1
+ 1: ll $3, %lo(prot_counters)($2) # atomic_sub
+ nop
+ subu $3, 1
+ sc $3, %lo(prot_counters)($2)
+ beqz $3, 2f
+ .subsection 2
+2: b 1b
+ .previous
+
+ # 0 "" 2
+#NO_APP
+$L89:
+#APP
+ # 110 "/backup_new/qian_yu/trunk_release_buildcode/96d/linux-2.6.30/arch/rlx/include/asm/atomic.h" 1
+
+
+ # 0 "" 2
+#NO_APP
+ move $4,$16
+$L92:
+ .set noreorder
+ .set nomacro
+ jal rtl_new_gc_get_ct_protonum
+ move $5,$0
+ .set macro
+ .set reorder
+
+ li $3,6 # 0x6
+ .set noreorder
+ .set nomacro
+ beq $2,$3,$L85
+ move $4,$16
+ .set macro
+ .set reorder
+
+ .set noreorder
+ .set nomacro
+ jal rtl_new_gc_get_ct_protonum
+ move $5,$0
+ .set macro
+ .set reorder
+
+ li $3,17 # 0x11
+ bne $2,$3,$L86
+$L85:
+ move $5,$17
+ .set noreorder
+ .set nomacro
+ jal clean_from_lists_hooks
+ move $4,$16
+ .set macro
+ .set reorder
+
+ .set noreorder
+ .set nomacro
+ jal rtl_list_del
+ move $4,$16
+ .set macro
+ .set reorder
+
+ lui $2,%hi(nf_conntrack_max)
+ lw $2,%lo(nf_conntrack_max)($2)
+ .set noreorder
+ .set nomacro
+ beq $2,$0,$L93
+ lui $2,%hi(rtl_newGC_session_status_flags)
+ .set macro
+ .set reorder
+
+ .set noreorder
+ .set nomacro
+ jal rtl_gc_threshold_check
+ move $4,$17
+ .set macro
+ .set reorder
+
+ .set noreorder
+ .set nomacro
+ bne $2,$0,$L87
+ lui $2,%hi(rtl_newGC_session_status_flags)
+ .set macro
+ .set reorder
+
+ li $3,3 # 0x3
+ lw $4,%lo(rtl_newGC_session_status_flags)($2)
+ .set noreorder
+ .set nomacro
+ beq $4,$3,$L86
+ lui $4,%hi(jiffies)
+ .set macro
+ .set reorder
+
+ lw $4,%lo(jiffies)($4)
+ sw $3,%lo(rtl_newGC_session_status_flags)($2)
+ lui $2,%hi(rtl_newGC_session_status_time)
+ addiu $3,$4,1
+ .set noreorder
+ .set nomacro
+ j $L86
+ sw $3,%lo(rtl_newGC_session_status_time)($2)
+ .set macro
+ .set reorder
+
+$L87:
+$L93:
+ sw $0,%lo(rtl_newGC_session_status_flags)($2)
+$L86:
+ jal local_bh_enable
+ move $4,$16
+ lw $31,28($sp)
+ lw $17,24($sp)
+ lw $16,20($sp)
+ .set noreorder
+ .set nomacro
+ j nf_ct_remove_expectations
+ addiu $sp,$sp,32
+ .set macro
+ .set reorder
+
+ .end clean_from_lists
+ .size clean_from_lists, .-clean_from_lists
+ .section .text.rtl_death_action,"ax",@progbits
+ .align 2
+ .globl rtl_death_action
+ .set nomips16
+ .ent rtl_death_action
+ .type rtl_death_action, @function
+rtl_death_action:
+ .frame $sp,32,$31 # vars= 0, regs= 3/0, args= 16, gp= 0
+ .mask 0x80030000,-4
+ .fmask 0x00000000,0
+ addiu $sp,$sp,-32
+ sw $31,28($sp)
+ sw $17,24($sp)
+ sw $16,20($sp)
+ lw $2,200($4)
+ .set noreorder
+ .set nomacro
+ beq $2,$0,$L97
+ move $16,$4
+ .set macro
+ .set reorder
+
+ lbu $3,8($2)
+ .set noreorder
+ .set nomacro
+ beq $3,$0,$L97
+ addu $2,$2,$3
+ .set macro
+ .set reorder
+
+ beq $2,$0,$L97
+ lw $2,0($2)
+ beq $2,$0,$L97
+ lw $2,64($2)
+ beq $2,$0,$L97
+ jalr $2
+$L97:
+ .set noreorder
+ .set nomacro
+ jal local_bh_disable
+ lui $17,%hi(init_net)
+ .set macro
+ .set reorder
+
+ .set noreorder
+ .set nomacro
+ jal rtl_nf_ct_stat_inc
+ addiu $4,$17,%lo(init_net)
+ .set macro
+ .set reorder
+
+ move $4,$16
+ .set noreorder
+ .set nomacro
+ jal clean_from_lists
+ addiu $5,$17,%lo(init_net)
+ .set macro
+ .set reorder
+
+ jal local_bh_enable
+ beq $16,$0,$L99
+#APP
+ # 167 "/backup_new/qian_yu/trunk_release_buildcode/96d/linux-2.6.30/arch/rlx/include/asm/atomic.h" 1
+
+
+ # 0 "" 2
+ # 169 "/backup_new/qian_yu/trunk_release_buildcode/96d/linux-2.6.30/arch/rlx/include/asm/atomic.h" 1
+ 1: ll $3, 0($16) # atomic_sub_return
+ nop
+ subu $2, $3, 1
+ sc $2, 0($16)
+ beqz $2, 2f
+ subu $2, $3, 1
+ .subsection 2
+2: b 1b
+ .previous
+
+ # 0 "" 2
+ # 185 "/backup_new/qian_yu/trunk_release_buildcode/96d/linux-2.6.30/arch/rlx/include/asm/atomic.h" 1
+
+
+ # 0 "" 2
+#NO_APP
+ .set noreorder
+ .set nomacro
+ bne $2,$0,$L99
+ move $4,$16
+ .set macro
+ .set reorder
+
+ lw $31,28($sp)
+ lw $17,24($sp)
+ lw $16,20($sp)
+ .set noreorder
+ .set nomacro
+ j nf_conntrack_destroy
+ addiu $sp,$sp,32
+ .set macro
+ .set reorder
+
+$L99:
+ lw $31,28($sp)
+ lw $17,24($sp)
+ lw $16,20($sp)
+ .set noreorder
+ .set nomacro
+ j $31
+ addiu $sp,$sp,32
+ .set macro
+ .set reorder
+
+ .end rtl_death_action
+ .size rtl_death_action, .-rtl_death_action
+ .section .text.drop_one_conntrack,"ax",@progbits
+ .align 2
+ .globl drop_one_conntrack
+ .set nomips16
+ .ent drop_one_conntrack
+ .type drop_one_conntrack, @function
+drop_one_conntrack:
+ .frame $sp,72,$31 # vars= 8, regs= 10/0, args= 24, gp= 0
+ .mask 0xc0ff0000,-4
+ .fmask 0x00000000,0
+ .set noreorder
+ .set nomacro
+
+ addiu $sp,$sp,-72
+ sw $31,68($sp)
+ sw $fp,64($sp)
+ sw $23,60($sp)
+ sw $22,56($sp)
+ sw $21,52($sp)
+ sw $20,48($sp)
+ sw $19,44($sp)
+ sw $18,40($sp)
+ sw $17,36($sp)
+ sw $16,32($sp)
+ lui $2,%hi(_prot_limit)
+ addiu $2,$2,%lo(_prot_limit)
+ lw $3,4($2)
+ lui $2,%hi(prot_counters)
+ addiu $2,$2,%lo(prot_counters)
+ lw $2,4($2)
+ slt $2,$3,$2
+ beq $2,$0,$L170
+ lui $2,%hi(_prot_limit)
+
+ lui $19,%hi(drop_priority)
+ jal local_bh_disable
+ lui $23,%hi(Tcp_State_Hash_Head)
+
+ addiu $19,$19,%lo(drop_priority)
+ addiu $23,$23,%lo(Tcp_State_Hash_Head)
+ move $18,$0
+ lui $22,%hi(drop_priority_max_idx)
+ j $L102
+ li $21,-1 # 0xffffffff
+
+$L110:
+ lbu $2,0($19)
+ sltu $3,$2,10
+ beq $3,$0,$L103
+ sll $2,$2,3
+
+ addu $2,$23,$2
+ lw $20,4($2)
+ lw $17,0($20)
+$L160:
+ beq $17,$20,$L103
+ addiu $16,$17,-204
+
+ lb $2,212($16)
+ bne $2,$21,$L171
+ nop
+
+ jal __conntrack_drop_check
+ move $4,$16
+
+ sb $2,212($16)
+ lb $2,212($16)
+$L171:
+ bne $2,$0,$L106
+ nop
+
+ jal rtl_del_ct_timer
+ move $4,$16
+
+ bne $2,$0,$L163
+ nop
+
+$L106:
+ lw $17,0($17)
+ j $L160
+ nop
+
+$L103:
+ addiu $18,$18,1
+ addiu $19,$19,4
+$L102:
+ lw $2,%lo(drop_priority_max_idx)($22)
+ slt $2,$18,$2
+ bne $2,$0,$L110
+ nop
+
+ jal local_bh_enable
+ nop
+
+ lui $2,%hi(_prot_limit)
+$L170:
+ addiu $2,$2,%lo(_prot_limit)
+ lw $3,8($2)
+ lui $2,%hi(prot_counters)
+ addiu $2,$2,%lo(prot_counters)
+ lw $2,8($2)
+ slt $2,$3,$2
+ beq $2,$0,$L112
+ nop
+
+ lui $19,%hi(drop_priority)
+ jal local_bh_disable
+ lui $23,%hi(Udp_State_Hash_Head)
+
+ addiu $19,$19,%lo(drop_priority)
+ addiu $23,$23,%lo(Udp_State_Hash_Head)
+ move $18,$0
+ lui $22,%hi(drop_priority_max_idx)
+ j $L113
+ li $21,-1 # 0xffffffff
+
+$L120:
+ lbu $2,0($19)
+ sltu $3,$2,11
+ bne $3,$0,$L114
+ addiu $2,$2,-11
+
+ sll $2,$2,3
+ addu $2,$23,$2
+ lw $20,4($2)
+ lw $17,0($20)
+$L161:
+ beq $17,$20,$L114
+ addiu $16,$17,-204
+
+ lb $2,212($16)
+ bne $2,$21,$L172
+ nop
+
+ jal __conntrack_drop_check
+ move $4,$16
+
+ sb $2,212($16)
+ lb $2,212($16)
+$L172:
+ bne $2,$0,$L117
+ nop
+
+ jal rtl_del_ct_timer
+ move $4,$16
+
+ bne $2,$0,$L163
+ nop
+
+$L117:
+ lw $17,0($17)
+ j $L161
+ nop
+
+$L114:
+ addiu $18,$18,1
+ addiu $19,$19,4
+$L113:
+ lw $2,%lo(drop_priority_max_idx)($22)
+ slt $2,$18,$2
+ bne $2,$0,$L120
+ nop
+
+ jal local_bh_enable
+ nop
+
+$L112:
+ lui $18,%hi(drop_priority+2)
+ move $17,$0
+ addiu $18,$18,%lo(drop_priority+2)
+ jal local_bh_disable
+ li $fp,-1 # 0xffffffff
+
+ move $19,$18
+ lui $23,%hi(jiffies)
+ li $22,2 # 0x2
+ j $L121
+ li $21,12 # 0xc
+
+$L137:
+ lbu $2,-2($19)
+ sltu $3,$2,10
+ beq $3,$0,$L122
+ lui $3,%hi(Udp_State_Hash_Head)
+
+ lui $3,%hi(Tcp_State_Hash_Head)
+ sll $2,$2,3
+ addiu $3,$3,%lo(Tcp_State_Hash_Head)
+ sw $0,28($sp)
+ addu $2,$3,$2
+ lw $2,4($2)
+ sw $2,24($sp)
+ lw $20,0($2)
+ bne $20,$2,$L124
+ nop
+
+ j $L167
+ addiu $17,$17,1
+
+$L130:
+ lw $2,28($sp)
+ addiu $2,$2,1
+ sw $2,28($sp)
+ lb $2,212($16)
+ bne $2,$fp,$L173
+ nop
+
+ jal __conntrack_drop_check
+ move $4,$16
+
+ sb $2,212($16)
+ lb $2,212($16)
+$L173:
+ bne $2,$0,$L126
+ nop
+
+ jal rtl_get_ct_timer_expires
+ move $4,$16
+
+ lw $4,%lo(jiffies)($23)
+ lhu $3,0($19)
+ subu $4,$2,$4
+ srl $4,$4,7
+ sltu $3,$3,$4
+ bne $3,$0,$L127
+ nop
+
+ jal rtl_del_ct_timer
+ move $4,$16
+
+ beq $2,$0,$L127
+ li $3,3 # 0x3
+
+ move $4,$16
+ move $6,$0
+ li $7,1 # 0x1
+ move $5,$17
+ jal __drop_one_conntrack_process_hooks1
+ sw $3,16($sp)
+
+ li $3,1 # 0x1
+ beq $2,$3,$L163
+ nop
+
+ beq $2,$22,$L129
+ li $2,3 # 0x3
+
+ move $4,$16
+ move $6,$0
+ li $7,1 # 0x1
+ move $5,$17
+ jal __drop_one_conntrack_process_hooks2
+ sw $2,16($sp)
+
+$L127:
+ lw $3,28($sp)
+ slt $2,$3,129
+ beq $2,$0,$L123
+ nop
+
+$L126:
+ lw $20,0($20)
+$L124:
+ lw $2,24($sp)
+ bne $20,$2,$L130
+ addiu $16,$20,-204
+
+ j $L167
+ addiu $17,$17,1
+
+$L122:
+ addiu $2,$2,-11
+ sll $2,$2,3
+ addiu $3,$3,%lo(Udp_State_Hash_Head)
+ sw $0,28($sp)
+ addu $2,$3,$2
+ lw $2,4($2)
+ sw $2,24($sp)
+ lw $20,0($2)
+ bne $20,$2,$L131
+ nop
+
+ j $L167
+ addiu $17,$17,1
+
+$L136:
+ lw $2,28($sp)
+ addiu $16,$20,-204
+ addiu $2,$2,1
+ sw $2,28($sp)
+ lb $2,212($16)
+ bne $2,$fp,$L174
+ nop
+
+ jal __conntrack_drop_check
+ move $4,$16
+
+ sb $2,212($16)
+ lb $2,212($16)
+$L174:
+ bne $2,$0,$L133
+ nop
+
+ jal rtl_get_ct_timer_expires
+ move $4,$16
+
+ lw $4,%lo(jiffies)($23)
+ lhu $3,0($19)
+ subu $4,$2,$4
+ srl $4,$4,7
+ sltu $3,$3,$4
+ bne $3,$0,$L134
+ nop
+
+ jal rtl_del_ct_timer
+ move $4,$16
+
+ beq $2,$0,$L134
+ move $4,$16
+
+ move $6,$0
+ li $7,1 # 0x1
+ move $5,$17
+ jal __drop_one_conntrack_process_hooks1
+ sw $21,16($sp)
+
+ li $3,1 # 0x1
+ beq $2,$3,$L163
+ nop
+
+ beq $2,$22,$L129
+ move $4,$16
+
+ move $6,$0
+ li $7,1 # 0x1
+ move $5,$17
+ jal __drop_one_conntrack_process_hooks2
+ sw $21,16($sp)
+
+$L134:
+ lw $3,28($sp)
+ slt $2,$3,129
+ beq $2,$0,$L123
+ nop
+
+$L133:
+ lw $20,0($20)
+$L131:
+ lw $2,24($sp)
+ bne $20,$2,$L136
+ nop
+
+$L123:
+ addiu $17,$17,1
+$L167:
+ addiu $19,$19,4
+$L121:
+ lui $3,%hi(drop_priority_max_idx)
+ lw $2,%lo(drop_priority_max_idx)($3)
+ slt $2,$17,$2
+ bne $2,$0,$L137
+ nop
+
+ jal local_bh_enable
+ move $17,$0
+
+ jal local_bh_disable
+ li $fp,-1 # 0xffffffff
+
+ lui $23,%hi(jiffies)
+ li $22,1 # 0x1
+ li $21,12 # 0xc
+ j $L138
+ li $20,3 # 0x3
+
+$L153:
+ lbu $2,-2($18)
+ sltu $3,$2,10
+ beq $3,$0,$L139
+ lui $3,%hi(Udp_State_Hash_Head)
+
+ lui $3,%hi(Tcp_State_Hash_Head)
+ sll $2,$2,3
+ addiu $3,$3,%lo(Tcp_State_Hash_Head)
+ sw $0,28($sp)
+ addu $2,$3,$2
+ lw $2,4($2)
+ sw $2,24($sp)
+ lw $19,0($2)
+ bne $19,$2,$L141
+ nop
+
+ j $L168
+ addiu $17,$17,1
+
+$L146:
+ lw $2,28($sp)
+ addiu $16,$19,-204
+ addiu $2,$2,1
+ sw $2,28($sp)
+ lb $2,212($16)
+ bne $2,$fp,$L175
+ nop
+
+ jal __conntrack_drop_check
+ move $4,$16
+
+ sb $2,212($16)
+ lb $2,212($16)
+$L175:
+ bne $2,$0,$L143
+ nop
+
+ jal rtl_get_ct_timer_expires
+ move $4,$16
+
+ lw $4,%lo(jiffies)($23)
+ lhu $3,0($18)
+ subu $4,$2,$4
+ srl $4,$4,9
+ sltu $3,$3,$4
+ bne $3,$0,$L144
+ nop
+
+ jal rtl_del_ct_timer
+ move $4,$16
+
+ beq $2,$0,$L144
+ move $4,$16
+
+ li $6,2 # 0x2
+ move $7,$0
+ move $5,$17
+ jal __drop_one_conntrack_process_hooks1
+ sw $20,16($sp)
+
+ beq $2,$22,$L163
+ li $3,2 # 0x2
+
+ beq $2,$3,$L129
+ move $4,$16
+
+ li $6,2 # 0x2
+ move $7,$0
+ move $5,$17
+ jal __drop_one_conntrack_process_hooks2
+ sw $20,16($sp)
+
+$L144:
+ lw $3,28($sp)
+ slt $2,$3,129
+ beq $2,$0,$L140
+ nop
+
+$L143:
+ lw $19,0($19)
+$L141:
+ lw $2,24($sp)
+ bne $19,$2,$L146
+ nop
+
+ j $L168
+ addiu $17,$17,1
+
+$L139:
+ addiu $2,$2,-11
+ sll $2,$2,3
+ addiu $3,$3,%lo(Udp_State_Hash_Head)
+ sw $0,28($sp)
+ addu $2,$3,$2
+ lw $2,4($2)
+ sw $2,24($sp)
+ lw $19,0($2)
+ bne $19,$2,$L147
+ nop
+
+ j $L168
+ addiu $17,$17,1
+
+$L152:
+ lw $2,28($sp)
+ addiu $16,$19,-204
+ addiu $2,$2,1
+ sw $2,28($sp)
+ lb $2,212($16)
+ bne $2,$fp,$L176
+ nop
+
+ jal __conntrack_drop_check
+ move $4,$16
+
+ sb $2,212($16)
+ lb $2,212($16)
+$L176:
+ bne $2,$0,$L149
+ nop
+
+ jal rtl_get_ct_timer_expires
+ move $4,$16
+
+ lw $4,%lo(jiffies)($23)
+ lhu $3,0($18)
+ subu $4,$2,$4
+ srl $4,$4,9
+ sltu $3,$3,$4
+ bne $3,$0,$L150
+ nop
+
+ jal rtl_del_ct_timer
+ move $4,$16
+
+ beq $2,$0,$L150
+ move $4,$16
+
+ li $6,2 # 0x2
+ move $7,$0
+ move $5,$17
+ jal __drop_one_conntrack_process_hooks1
+ sw $21,16($sp)
+
+ bne $2,$22,$L151
+ li $3,2 # 0x2
+
+$L163:
+ jal local_bh_enable
+ nop
+
+ jal rtl_death_action
+ move $4,$16
+
+ j $L169
+ lui $2,%hi(rtl_newGC_session_status_flags)
+
+$L151:
+ beq $2,$3,$L129
+ move $4,$16
+
+ li $6,2 # 0x2
+ move $7,$0
+ move $5,$17
+ jal __drop_one_conntrack_process_hooks2
+ sw $21,16($sp)
+
+$L150:
+ lw $3,28($sp)
+ slt $2,$3,129
+ beq $2,$0,$L140
+ nop
+
+$L149:
+ lw $19,0($19)
+$L147:
+ lw $2,24($sp)
+ bne $19,$2,$L152
+ nop
+
+$L140:
+ addiu $17,$17,1
+$L168:
+ addiu $18,$18,4
+$L138:
+ lui $3,%hi(drop_priority_max_idx)
+ lw $2,%lo(drop_priority_max_idx)($3)
+ slt $2,$17,$2
+ bne $2,$0,$L153
+ nop
+
+ jal local_bh_enable
+ nop
+
+ lui $3,%hi(rtl_newGC_session_status_flags)
+ lw $5,%lo(rtl_newGC_session_status_flags)($3)
+ li $4,1 # 0x1
+ bne $5,$4,$L166
+ move $2,$0
+
+ j $L111
+ nop
+
+$L129:
+ lui $2,%hi(rtl_newGC_session_status_flags)
+$L169:
+ lw $3,%lo(rtl_newGC_session_status_flags)($2)
+ bne $3,$0,$L108
+ lui $3,%hi(jiffies)
+
+ lw $4,%lo(jiffies)($3)
+ li $3,3 # 0x3
+ sw $3,%lo(rtl_newGC_session_status_flags)($2)
+ li $2,1 # 0x1
+ j $L164
+ addiu $4,$4,1
+
+$L166:
+ lui $2,%hi(jiffies)
+ lw $5,%lo(jiffies)($2)
+ move $2,$0
+ sw $4,%lo(rtl_newGC_session_status_flags)($3)
+ addiu $4,$5,200
+$L164:
+ lui $3,%hi(rtl_newGC_session_status_time)
+ j $L111
+ sw $4,%lo(rtl_newGC_session_status_time)($3)
+
+$L108:
+ li $2,1 # 0x1
+$L111:
+ lw $31,68($sp)
+ lw $fp,64($sp)
+ lw $23,60($sp)
+ lw $22,56($sp)
+ lw $21,52($sp)
+ lw $20,48($sp)
+ lw $19,44($sp)
+ lw $18,40($sp)
+ lw $17,36($sp)
+ lw $16,32($sp)
+ j $31
+ addiu $sp,$sp,72
+
+ .set macro
+ .set reorder
+ .end drop_one_conntrack
+ .size drop_one_conntrack, .-drop_one_conntrack
+ .section .text.conntrack_dointvec_minmax,"ax",@progbits
+ .align 2
+ .globl conntrack_dointvec_minmax
+ .set nomips16
+ .ent conntrack_dointvec_minmax
+ .type conntrack_dointvec_minmax, @function
+conntrack_dointvec_minmax:
+ .frame $sp,40,$31 # vars= 0, regs= 3/0, args= 24, gp= 0
+ .mask 0x80030000,-4
+ .fmask 0x00000000,0
+ .set noreorder
+ .set nomacro
+
+ addiu $sp,$sp,-40
+ sw $31,36($sp)
+ sw $17,32($sp)
+ sw $16,28($sp)
+ move $16,$5
+ lw $2,56($sp)
+ sw $2,16($sp)
+ lw $2,60($sp)
+ jal proc_dointvec_minmax
+ sw $2,20($sp)
+
+ bne $2,$0,$L178
+ move $17,$2
+
+ beq $16,$0,$L178
+ lui $8,%hi(_prot_limit)
+
+ lui $7,%hi(prot_limit)
+ addiu $8,$8,%lo(_prot_limit)
+ addiu $7,$7,%lo(prot_limit)
+ move $3,$0
+ lui $6,%hi(nf_conntrack_max)
+ li $4,100 # 0x64
+ li $5,12 # 0xc
+$L179:
+ addu $2,$7,$3
+ addu $9,$8,$3
+ lw $10,0($2)
+ addiu $3,$3,4
+ lw $2,%lo(nf_conntrack_max)($6)
+ mult $10,$2
+ mflo $10
+ divu $0,$10,$4
+ mflo $10
+ sw $10,0($9)
+ bne $3,$5,$L179
+ nop
+
+ sll $5,$2,2
+ li $4,5 # 0x5
+ lui $3,%hi(rtl_nf_conntrack_threshold)
+ divu $0,$5,$4
+ mflo $5
+ subu $4,$2,$5
+ sltu $4,$4,65
+ bne $4,$0,$L180
+ sw $5,%lo(rtl_nf_conntrack_threshold)($3)
+
+ addiu $4,$2,-64
+ sw $4,%lo(rtl_nf_conntrack_threshold)($3)
+$L180:
+ beq $2,$0,$L184
+ lui $2,%hi(rtl_newGC_session_status_flags)
+
+ jal rtl_gc_threshold_check
+ move $4,$0
+
+ bne $2,$0,$L181
+ lui $2,%hi(rtl_newGC_session_status_flags)
+
+ li $3,3 # 0x3
+ lw $4,%lo(rtl_newGC_session_status_flags)($2)
+ beq $4,$3,$L178
+ lui $4,%hi(jiffies)
+
+ lw $4,%lo(jiffies)($4)
+ sw $3,%lo(rtl_newGC_session_status_flags)($2)
+ lui $2,%hi(rtl_newGC_session_status_time)
+ addiu $3,$4,1
+ j $L178
+ sw $3,%lo(rtl_newGC_session_status_time)($2)
+
+$L181:
+$L184:
+ sw $0,%lo(rtl_newGC_session_status_flags)($2)
+$L178:
+ move $2,$17
+ lw $31,36($sp)
+ lw $17,32($sp)
+ lw $16,28($sp)
+ j $31
+ addiu $sp,$sp,40
+
+ .set macro
+ .set reorder
+ .end conntrack_dointvec_minmax
+ .size conntrack_dointvec_minmax, .-conntrack_dointvec_minmax
+ .section .text.conntrack_dointvec,"ax",@progbits
+ .align 2
+ .globl conntrack_dointvec
+ .set nomips16
+ .ent conntrack_dointvec
+ .type conntrack_dointvec, @function
+conntrack_dointvec:
+ .frame $sp,40,$31 # vars= 0, regs= 3/0, args= 24, gp= 0
+ .mask 0x80030000,-4
+ .fmask 0x00000000,0
+ .set noreorder
+ .set nomacro
+
+ addiu $sp,$sp,-40
+ sw $31,36($sp)
+ sw $17,32($sp)
+ sw $16,28($sp)
+ move $16,$5
+ lw $2,56($sp)
+ sw $2,16($sp)
+ lw $2,60($sp)
+ jal proc_dointvec
+ sw $2,20($sp)
+
+ bne $2,$0,$L186
+ move $17,$2
+
+ beq $16,$0,$L186
+ lui $8,%hi(_prot_limit)
+
+ lui $7,%hi(prot_limit)
+ addiu $8,$8,%lo(_prot_limit)
+ addiu $7,$7,%lo(prot_limit)
+ move $3,$0
+ lui $6,%hi(nf_conntrack_max)
+ li $4,100 # 0x64
+ li $5,12 # 0xc
+$L187:
+ addu $2,$7,$3
+ addu $9,$8,$3
+ lw $10,0($2)
+ addiu $3,$3,4
+ lw $2,%lo(nf_conntrack_max)($6)
+ mult $10,$2
+ mflo $10
+ divu $0,$10,$4
+ mflo $10
+ sw $10,0($9)
+ bne $3,$5,$L187
+ nop
+
+ sll $5,$2,2
+ li $4,5 # 0x5
+ lui $3,%hi(rtl_nf_conntrack_threshold)
+ divu $0,$5,$4
+ mflo $5
+ subu $4,$2,$5
+ sltu $4,$4,65
+ bne $4,$0,$L188
+ sw $5,%lo(rtl_nf_conntrack_threshold)($3)
+
+ addiu $4,$2,-64
+ sw $4,%lo(rtl_nf_conntrack_threshold)($3)
+$L188:
+ beq $2,$0,$L192
+ lui $2,%hi(rtl_newGC_session_status_flags)
+
+ jal rtl_gc_threshold_check
+ move $4,$0
+
+ bne $2,$0,$L189
+ lui $2,%hi(rtl_newGC_session_status_flags)
+
+ li $3,3 # 0x3
+ lw $4,%lo(rtl_newGC_session_status_flags)($2)
+ beq $4,$3,$L186
+ lui $4,%hi(jiffies)
+
+ lw $4,%lo(jiffies)($4)
+ sw $3,%lo(rtl_newGC_session_status_flags)($2)
+ lui $2,%hi(rtl_newGC_session_status_time)
+ addiu $3,$4,1
+ j $L186
+ sw $3,%lo(rtl_newGC_session_status_time)($2)
+
+$L189:
+$L192:
+ sw $0,%lo(rtl_newGC_session_status_flags)($2)
+$L186:
+ move $2,$17
+ lw $31,36($sp)
+ lw $17,32($sp)
+ lw $16,28($sp)
+ j $31
+ addiu $sp,$sp,40
+
+ .set macro
+ .set reorder
+ .end conntrack_dointvec
+ .size conntrack_dointvec, .-conntrack_dointvec
+ .globl conntrack_min
+ .section .bss,"aw",@nobits
+ .align 2
+ .type conntrack_min, @object
+ .size conntrack_min, 4
+conntrack_min:
+ .space 4
+ .globl conntrack_max
+ .data
+ .align 2
+ .type conntrack_max, @object
+ .size conntrack_max, 4
+conntrack_max:
+ .word 100
+ .globl Tcp_State_Hash_Head
+ .align 2
+ .type Tcp_State_Hash_Head, @object
+ .size Tcp_State_Hash_Head, 88
+Tcp_State_Hash_Head:
+ .word 0
+ .word 0
+ .word 1
+ .word syn_sent_list
+ .word 2
+ .word syn_recv_list
+ .word 3
+ .word established_list
+ .word 4
+ .word fin_wait_list
+ .word 5
+ .word close_wait_list
+ .word 6
+ .word last_ack_list
+ .word 7
+ .word time_wait_list
+ .word 8
+ .word close_list
+ .word 9
+ .word listen_list
+ .word 10
+ .word 0
+ .globl Udp_State_Hash_Head
+ .align 2
+ .type Udp_State_Hash_Head, @object
+ .size Udp_State_Hash_Head, 16
+Udp_State_Hash_Head:
+ .byte 11
+ .space 3
+ .word udp_unreply_list
+ .byte 12
+ .space 3
+ .word udp_assured_list
+ .globl drop_priority
+ .align 2
+ .type drop_priority, @object
+ .size drop_priority, 40
+drop_priority:
+ .byte 8
+ .space 1
+ .half 60
+ .byte 6
+ .space 1
+ .half 30
+ .byte 5
+ .space 1
+ .half 60
+ .byte 7
+ .space 1
+ .half 120
+ .byte 4
+ .space 1
+ .half 120
+ .byte 11
+ .space 1
+ .half 85
+ .byte 1
+ .space 1
+ .half 110
+ .byte 2
+ .space 1
+ .half 30
+ .byte 12
+ .space 1
+ .half 10
+ .byte 3
+ .space 1
+ .half 120
+ .local prot_counters
+ .comm prot_counters,12,4
+ .local _prot_limit
+ .comm _prot_limit,12,4
+ .globl rtl_nf_conntrack_threshold
+ .section .bss
+ .align 2
+ .type rtl_nf_conntrack_threshold, @object
+ .size rtl_nf_conntrack_threshold, 4
+rtl_nf_conntrack_threshold:
+ .space 4
+ .globl drop_priority_max_idx
+ .align 2
+ .type drop_priority_max_idx, @object
+ .size drop_priority_max_idx, 4
+drop_priority_max_idx:
+ .space 4
+ .globl rtl_newGC_session_status_flags
+ .section .dram-fwd,"aw",@progbits
+ .align 2
+ .type rtl_newGC_session_status_flags, @object
+ .size rtl_newGC_session_status_flags, 4
+rtl_newGC_session_status_flags:
+ .space 4
+ .globl rtl_newGC_session_status_time
+ .align 2
+ .type rtl_newGC_session_status_time, @object
+ .size rtl_newGC_session_status_time, 4
+rtl_newGC_session_status_time:
+ .space 4
+ .globl prot_limit
+ .section .bss
+ .align 2
+ .type prot_limit, @object
+ .size prot_limit, 12
+prot_limit:
+ .space 12
+ .data
+ .align 2
+ .type syn_sent_list, @object
+ .size syn_sent_list, 8
+syn_sent_list:
+ .word syn_sent_list
+ .word syn_sent_list
+ .align 2
+ .type syn_recv_list, @object
+ .size syn_recv_list, 8
+syn_recv_list:
+ .word syn_recv_list
+ .word syn_recv_list
+ .align 2
+ .type established_list, @object
+ .size established_list, 8
+established_list:
+ .word established_list
+ .word established_list
+ .align 2
+ .type fin_wait_list, @object
+ .size fin_wait_list, 8
+fin_wait_list:
+ .word fin_wait_list
+ .word fin_wait_list
+ .align 2
+ .type close_wait_list, @object
+ .size close_wait_list, 8
+close_wait_list:
+ .word close_wait_list
+ .word close_wait_list
+ .align 2
+ .type last_ack_list, @object
+ .size last_ack_list, 8
+last_ack_list:
+ .word last_ack_list
+ .word last_ack_list
+ .align 2
+ .type time_wait_list, @object
+ .size time_wait_list, 8
+time_wait_list:
+ .word time_wait_list
+ .word time_wait_list
+ .align 2
+ .type close_list, @object
+ .size close_list, 8
+close_list:
+ .word close_list
+ .word close_list
+ .align 2
+ .type listen_list, @object
+ .size listen_list, 8
+listen_list:
+ .word listen_list
+ .word listen_list
+ .align 2
+ .type udp_unreply_list, @object
+ .size udp_unreply_list, 8
+udp_unreply_list:
+ .word udp_unreply_list
+ .word udp_unreply_list
+ .align 2
+ .type udp_assured_list, @object
+ .size udp_assured_list, 8
+udp_assured_list:
+ .word udp_assured_list
+ .word udp_assured_list
+ .ident "GCC: (GNU) 4.4.5-1.5.5p4"
diff --git a/target/linux/realtek/files/net/rtl/features/lan_restrict.c b/target/linux/realtek/files/net/rtl/features/lan_restrict.c
new file mode 100644
index 000000000..8f09a9409
--- /dev/null
+++ b/target/linux/realtek/files/net/rtl/features/lan_restrict.c
@@ -0,0 +1,442 @@
+#include <linux/module.h>
+#include <linux/proc_fs.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/sched.h>
+#include <linux/kernel.h>
+#include <linux/kernel_stat.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <asm/uaccess.h>
+//#include <linux/brlock.h>
+#include <linux/net.h>
+#include <linux/socket.h>
+
+#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
+#include <linux/string.h>
+#include <net/ip.h>
+#include <net/protocol.h>
+#include <net/route.h>
+#include <net/sock.h>
+#include <net/arp.h>
+#include <net/raw.h>
+#include <net/checksum.h>
+#include <linux/netfilter.h>
+#include <linux/netfilter_ipv4.h>
+#include <linux/netlink.h>
+#include <linux/inetdevice.h>
+#include "lan_restrict.h"
+
+static char lan_restrict_flag[1024];
+int8 enable_lanrestrict = FALSE;
+static struct proc_dir_entry *res=NULL;
+
+static inline int _strncasecmp(const char *s1, const char *s2, unsigned int n)
+{
+ if (n == 0)
+ return 0;
+
+ while ((n-- != 0)
+ && (tolower(*(unsigned char *) s1) ==
+ tolower(*(unsigned char *) s2))) {
+ if (n == 0 || *s1 == '\0' || *s2 == '\0')
+ return 0;
+ s1++;
+ s2++;
+ }
+
+ return tolower(*(unsigned char *) s1) - tolower(*(unsigned char *) s2);
+}
+
+int lan_restrict_rcv(struct sk_buff *skb, struct net_device *dev)
+{
+ int32 found = FAILED;
+ ether_addr_t *macAddr;
+// int8 port_num;
+ int32 column;
+ int32 SrcBlk;
+
+ if ((memcmp(skb->dev->name, RTL_PS_BR0_DEV_NAME, 3) ==0) || (memcmp(skb->dev->name, RTL_PS_LAN_P0_DEV_NAME, 4) ==0) )
+ {
+ macAddr = (ether_addr_t *)(eth_hdr(skb)->h_source);
+ found = rtl_check_fdb_entry_check_exist(RTL_LAN_FID, macAddr, FDB_DYNAMIC);
+/* printk("\nrecv packet from dev:%s\n", skb->dev->name);*/
+ /*can found in asic , do noting here , in linux fdb module , it can be authed*/
+ if (found == SUCCESS )
+ {
+#if 0
+ port_num = rtl865x_ConvertPortMasktoPortNum(fdbEntry.memberPortMask);
+
+ if (lan_restrict_tbl[port_num].enable == TRUE)
+ {
+ if ((lan_restrict_tbl[port_num].curr_num < lan_restrict_tbl[port_num].max_num))
+ {
+/* printk("\nPASS:lan_restrict_tbl[%d] current number is %d\n", port_num, lan_restrict_tbl[port_num].curr_num);*/
+ return NET_RX_SUCCESS;
+ }
+ else
+ {
+ if (fdbEntry.auth == TRUE)
+ {
+/* printk("\nPASS1:lan_restrict_tbl[%d] current number is %d\n", port_num, lan_restrict_tbl[port_num].curr_num);*/
+ return NET_RX_SUCCESS;
+ }
+ else
+ {
+/* printk("\nDROP:lan_restrict_tbl[%d] current number is %d\n", port_num, lan_restrict_tbl[port_num].curr_num);*/
+ l2temp_entry.l2type = (fdbEntry.nhFlag==0)?RTL865x_L2_TYPEI: RTL865x_L2_TYPEII;
+ l2temp_entry.process = FDB_TYPE_FWD;
+ l2temp_entry.memberPortMask = fdbEntry.memberPortMask;
+ l2temp_entry.auth = FALSE;
+ l2temp_entry.SrcBlk = TRUE;
+ memcpy(&(l2temp_entry.macAddr), macAddr, sizeof(ether_addr_t));
+ rtl865x_addAuthFilterDatabaseEntryExtension(fdbEntry.fid, &l2temp_entry);
+ return NET_RX_AUTH_BLOCK;
+ }
+ }
+ }
+ else
+ {
+ return NET_RX_SUCCESS;
+ }
+#endif
+ return NET_RX_SUCCESS;
+ }
+ else
+ {
+/* printk(" \nnot found in hw table, src port is %d\n", skb->srcPort);*/
+ if (lan_restrict_tbl[skb->srcPort].enable == TRUE)
+ {
+ /*found in sw l2 table*/
+ if(rtl_check_fdb_entry_check_srcBlock(0, macAddr, &SrcBlk) == SUCCESS)
+ {
+ if (SrcBlk == TRUE)/*sw block*/
+ {
+ return NET_RX_AUTH_BLOCK;
+ }
+ else
+ {
+ return NET_RX_SUCCESS;
+ }
+ }
+ else /*not found in sw l2 table*/
+ {
+/* printk(" \nnot found ind hw and sw table\n");*/
+ if ((lan_restrict_tbl[skb->srcPort].curr_num < lan_restrict_tbl[skb->srcPort].max_num))
+ {
+ /*try to add into sw l2 table*/
+/* printk("\ntry to add into sw l2 table\n");*/
+ rtl865x_addAuthFDBEntry((unsigned char *)macAddr, TRUE, skb->srcPort);
+ return NET_RX_SUCCESS;
+ }
+ else
+ {
+ return NET_RX_AUTH_BLOCK;
+ }
+ }
+
+ }
+ else
+ {
+/* printk("dev name is %s\n", skb->dev->name);*/
+ return NET_RX_SUCCESS;
+ }
+ }
+ }
+ else
+ {
+ return NET_RX_SUCCESS;
+ }
+}
+#if 0
+static struct packet_type lan_restrict_packet_type = {
+ .type = __constant_htons(ETH_P_ALL),
+ .func = lan_restrict_rcv,
+};
+#endif
+static int lan_restrict_tbl_int(void)
+{
+ uint8 i;
+
+ for (i=0; i < LAN_RESTRICT_PORT_NUMBER; i++ )
+ {
+ lan_restrict_tbl[i].port_num = 0;
+ lan_restrict_tbl[i].enable = FALSE;
+ lan_restrict_tbl[i].max_num = 0;
+ lan_restrict_tbl[i].curr_num = 0;
+ }
+ return TRUE;
+}
+
+static int lan_restrict_tbl_reset(void)
+{
+ uint8 i;
+
+ for (i=0; i < LAN_RESTRICT_PORT_NUMBER; i++ )
+ {
+ lan_restrict_tbl[i].port_num = 0;
+ lan_restrict_tbl[i].enable = FALSE;
+ lan_restrict_tbl[i].max_num = 0;
+ lan_restrict_tbl[i].curr_num = 0;
+ }
+ return TRUE;
+}
+
+
+static int lan_restrict_set_singleport(uint8 portnum , int8 enable, int32 max_num)
+{
+ int32 ret;
+ if (enable == TRUE)
+ {
+ lan_restrict_tbl[portnum].max_num = max_num;
+ }
+ else
+ {
+ lan_restrict_tbl[portnum].max_num = 0;
+ }
+
+ ret =rtl865x_setRestrictPortNum(portnum, enable, max_num);
+ return ret;
+}
+
+static int lan_restrict_perport_setting(void)
+{
+ int i;
+ for (i=0; i < LAN_RESTRICT_PORT_NUMBER; i++ )
+ {
+ lan_restrict_set_singleport(lan_restrict_tbl[i].port_num, lan_restrict_tbl[i].enable, lan_restrict_tbl[i].max_num);
+ }
+ return TRUE;
+}
+
+static int lan_restrict_enable(void)
+{
+ /*
+ enable
+ */
+ rtl865x_enableLanPortNumRestrict(TRUE);
+ lan_restrict_perport_setting();
+ return TRUE;
+}
+
+static int lan_restrict_disable(void)
+{
+ /*
+ disable
+ */
+ rtl865x_enableLanPortNumRestrict(FALSE);
+ lan_restrict_tbl_reset();
+ lan_restrict_perport_setting();
+ return TRUE;
+}
+/*
+int32 lanrestrict_addfdbentry(const unsigned char *addr)
+{
+ int32 found = FAILED;
+ ether_addr_t *macAddr;
+ int32 ret=FAILED;
+ int8 port_num;
+ int32 column;
+ rtl865x_tblAsicDrv_l2Param_t fdbEntry;
+ rtl865x_filterDbTableEntry_t l2temp_entry;
+
+ macAddr = (ether_addr_t *)(addr);
+ found = rtl865x_Lookup_fdb_entry(0, macAddr, FDB_DYNAMIC, &column, &fdbEntry);
+ if (found == SUCCESS )
+ {
+ port_num = rtl865x_ConvertPortMasktoPortNum(fdbEntry.memberPortMask);
+
+ if (rtl865x_lookup_FilterDatabaseEntry(fdbEntry.fid, macAddr) != SUCCESS)
+ {
+ l2temp_entry.l2type = (fdbEntry.nhFlag==0)?RTL865x_L2_TYPEI: RTL865x_L2_TYPEII;
+ l2temp_entry.process = FDB_TYPE_FWD;
+ l2temp_entry.memberPortMask = fdbEntry.memberPortMask;
+ l2temp_entry.auth = TRUE;
+ l2temp_entry.SrcBlk = FALSE;
+ memcpy(&(l2temp_entry.macAddr), macAddr, sizeof(ether_addr_t));
+ ret =rtl865x_addAuthFilterDatabaseEntryExtension(fdbEntry.fid, &l2temp_entry);
+ }
+ }
+ return ret;
+}
+*/
+
+int32 lan_restrict_getBlockAddr(int32 port , const unsigned char *swap_addr)
+{
+ int32 ret = FAILED;
+
+ if (lan_restrict_tbl[port].enable == TRUE)
+ {
+ ret = rtl865x_check_authfdbentry_Byport(port , swap_addr);
+ }
+
+ return ret;
+}
+
+int32 lan_restrict_CheckStatusByport(int32 port)
+{
+ if (lan_restrict_tbl[port].enable == TRUE)
+ {
+ if (lan_restrict_tbl[port].curr_num < lan_restrict_tbl[port].max_num)
+ {
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+ }
+ else
+ {
+ return FAILED;
+ }
+}
+static int lan_restrict_read_proc(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
+{
+ int len, i ;
+ len = sprintf(page, "%s\n", "lan restrict table:");
+ if (len <= off+count)
+ *eof = 1;
+
+ for (i = 0; i < LAN_RESTRICT_PORT_NUMBER; i++)
+ {
+ len += sprintf(page + len, " PORT[%d] ", i);
+ len += sprintf(page + len,"%6s %6d %6d ",lan_restrict_tbl[i].enable?"ON":"OFF", lan_restrict_tbl[i].max_num, lan_restrict_tbl[i].curr_num);
+ len += sprintf(page + len,"\n");
+ }
+
+ return len;
+}
+
+static int lan_restrict_write_proc(struct file *file, const char *buffer,
+ unsigned long count, void *data)
+{
+ char tmpbuf[1024];
+ char *entryPtr, *portnumPtr, *enablePtr, *maxnumPtr, *strptr=tmpbuf;
+ int8 port, port_enable, maxnum;
+
+ if (count < 2)
+ return -EFAULT;
+ /*
+ format: entry1;entry2;entry3
+ entry format: port_num enable max_num curr_num;
+ port_num: 0,1,2...
+ enable: on/off
+ max_num: 0,1,2...
+ curr_num: 0,1,2..., can not write, can only read from proc file and write again, just for display
+ */
+
+ memset(lan_restrict_flag,0,strlen(lan_restrict_flag));
+ if (buffer && !copy_from_user(tmpbuf, buffer, count))
+ {
+ if(memcmp(strptr,"enable", strlen("enable")) == 0)
+ {
+ lan_restrict_enable();
+ enable_lanrestrict = TRUE;
+/* printk("Fun[%s][%d]\n", __FUNCTION__, __LINE__);*/
+ printk("enable lan restrict FUNC.....\n");
+ }
+ else if(memcmp(strptr,"disable", strlen("enable")) == 0)
+ {
+ lan_restrict_disable();
+ enable_lanrestrict = FALSE;
+/* printk("Fun[%s][%d]\n", __FUNCTION__, __LINE__);*/
+ printk("disable lan restrict FUNC.....\n");
+ }
+ else
+ {
+ if (lan_restrict_enable == FALSE)
+ return count;
+
+ /*
+ format: entry1;entry2;entry3
+ entry format: port_num enable max_num curr_num;
+ port_num: 0,1,2...
+ enable: on/off
+ max_num: 0,1,2...
+ curr_num: 0,1,2..., can not write, can only read from proc file and write again, just for display
+ */
+ entryPtr = strsep(&strptr,";");
+ while (entryPtr != NULL)
+ {
+ /*1. port_num*/
+ portnumPtr = strsep(&entryPtr," ");
+ if(portnumPtr == NULL)
+ {
+ printk("lan restrict setting format error1\n");
+ break;
+ }
+ port = simple_strtol(portnumPtr,NULL,0);
+ printk("set port num is %d\n", port);
+
+ /*2. enable or not*/
+ enablePtr = strsep(&entryPtr," ");
+ if(enablePtr == NULL)
+ {
+ printk("lan restrict setting format error2\n");
+ break;
+ }
+ if(_strncasecmp(enablePtr,"OFF",3) == 0)
+ {
+ port_enable = FALSE;
+ }
+ else if (_strncasecmp(enablePtr,"ON",3) == 0)
+ {
+ port_enable = TRUE;
+ }
+ else
+ {
+ printk("lan restrict setting format error3\n");
+ break;
+ }
+ printk("port_enable is %d\n", port_enable);
+
+ /*3max num*/
+ maxnumPtr = strsep(&entryPtr," ");
+ if(maxnumPtr == NULL)
+ {
+ printk("lan restrict setting format error4\n");
+ break;
+ }
+ maxnum = simple_strtol(maxnumPtr,NULL,0);
+ printk("set max num is %d\n", maxnum);
+
+ lan_restrict_tbl[port].enable = port_enable;
+ lan_restrict_tbl[port].max_num = maxnum;
+ /*
+ set Asic
+ */
+ lan_restrict_set_singleport(port, port_enable, maxnum);
+ }
+ }
+ }
+
+ return count;
+}
+
+static int lan_restrict_proc_init(void)
+{
+ res = create_proc_entry("lan_restrict_info",0,NULL);
+ if(res)
+ {
+ res->read_proc = lan_restrict_read_proc;
+ res->write_proc = lan_restrict_write_proc;
+ lanrestrict_unRegister_event();
+ lanrestrict_register_event();
+ return TRUE;
+ }
+ return FALSE;
+}
+
+int __init lan_restrict_init(void)
+{
+ lan_restrict_tbl_int();
+// dev_add_pack(&lan_restrict_packet_type);
+ lan_restrict_proc_init();
+ return 0;
+}
+
+
diff --git a/target/linux/realtek/files/net/rtl/features/lan_restrict.h b/target/linux/realtek/files/net/rtl/features/lan_restrict.h
new file mode 100644
index 000000000..0ad313b47
--- /dev/null
+++ b/target/linux/realtek/files/net/rtl/features/lan_restrict.h
@@ -0,0 +1,10 @@
+//#include <common/rtl865x_common.h>
+#include <net/rtl/rtl_types.h>
+#include <net/rtl/rtl_queue.h>
+#include <net/rtl/rtl_nic.h>
+#include <net/rtl/rtl865x_fdb_api.h>
+
+int32 lan_restrict_getBlockAddr(int32 port , const unsigned char *swap_addr);
+extern int __init lan_restrict_init(void);
+extern int lan_restrict_rcv(struct sk_buff *skb, struct net_device *dev);
+extern int32 lan_restrict_CheckStatusByport(int32 port);