--- zzzz-none-000/linux-3.18.24/net/ipv4/fib_trie.c 2015-10-31 20:39:51.000000000 +0000 +++ rtl96-5690pro-762/linux-3.18.24/net/ipv4/fib_trie.c 2024-08-14 08:36:37.000000000 +0000 @@ -80,6 +80,9 @@ #include #include #include "fib_lookup.h" +#if defined(CONFIG_RTL867X_IPTABLES_FAST_PATH) +#include "fastpath/fastpath_core.h" +#endif #define MAX_STAT_DEPTH 32 @@ -1255,6 +1258,13 @@ if (new_fa == NULL) goto out; +#if defined(CONFIG_RTL867X_IPTABLES_FAST_PATH) + if (FastPath_Enabled()){ + //printk("\n=========================>mod route %x %x %s!!!\n",cfg->fc_dst ,inet_make_mask(cfg->fc_dst_len),(uint8 *)fi->fib_dev->name); + rtl867x_modifyRoute(cfg->fc_dst ? cfg->fc_dst : 0, inet_make_mask(cfg->fc_dst_len),cfg->fc_gw ? cfg->fc_gw : 0, (__u8 *)fi->fib_dev->name, RT_NONE,cfg->fc_type); + } +#endif + fi_drop = fa->fa_info; new_fa->fa_tos = fa->fa_tos; new_fa->fa_info = fi; @@ -1283,6 +1293,33 @@ if (!(cfg->fc_nlflags & NLM_F_APPEND)) fa = fa_first; } + +#if defined(CONFIG_RTL867X_IPTABLES_FAST_PATH) + /* + * QL 20111116 + * when policy route is inuse, we should only add main table default route to fastpath route table. + */ +#if 0 + //if (FastPath_Enabled()) + rtl867x_addRoute(cfg->fc_dst ? cfg->fc_dst : 0, inet_make_mask(cfg->fc_dst_len),cfg->fc_gw ? cfg->fc_gw : 0, (__u8 *)fi->fib_dev->name, RT_NONE,cfg->fc_type); +#else + if (FastPath_Enabled()) { + int flag=1; + if (0 == inet_make_mask(cfg->fc_dst_len)) { + //default route, maybe in a policy route table + if (tb->tb_id != RT_TABLE_MAIN) + flag = 0; + } + if (flag) { + //printk("\n=========================>add route %x %x %s %d!!!\n",cfg->fc_dst ,inet_make_mask(cfg->fc_dst_len),(uint8 *)fi->fib_dev->name, + // cfg->fc_type); + rtl867x_addRoute(cfg->fc_dst ? cfg->fc_dst : 0, inet_make_mask(cfg->fc_dst_len), + cfg->fc_gw ? cfg->fc_gw : 0, (__u8 *)fi->fib_dev->name, RT_NONE,cfg->fc_type); + } + } +#endif +#endif + err = -ENOENT; if (!(cfg->fc_nlflags & NLM_F_CREATE)) goto out; @@ -1630,6 +1667,26 @@ if (key & ~mask) return -EINVAL; +#if defined(CONFIG_RTL867X_IPTABLES_FAST_PATH) + /* For fixing the bug that system will be hang if keep changing secondary IP&netmask . */ + // Remove the redundant node in the list_inuse of table_route. +#if 0 + rtl867x_delRoute(cfg->fc_dst ? cfg->fc_dst : 0, inet_make_mask(cfg->fc_dst_len)); +#else + if (FastPath_Enabled()) { + int flag=1; + if (0 == inet_make_mask(cfg->fc_dst_len)) { + //default route, maybe in a policy route table + if (tb->tb_id != RT_TABLE_MAIN) + flag = 0; + } + if (flag) { + rtl867x_delRoute(cfg->fc_dst ? cfg->fc_dst : 0, inet_make_mask(cfg->fc_dst_len)); + } + } +#endif +#endif + key = key & mask; l = fib_find_node(t, key); @@ -1673,6 +1730,13 @@ if (!fa_to_delete) return -ESRCH; +#if defined(CONFIG_RTL867X_IPTABLES_FAST_PATH) + /* For fixing the bug that system will be hang if keep changing secondary IP&netmask . */ + // Move delRoute forward. +// if (FastPath_Enabled()) +// rtl867x_delRoute(cfg->fc_dst ? cfg->fc_dst : 0, inet_make_mask(cfg->fc_dst_len)); +#endif + fa = fa_to_delete; rtmsg_fib(RTM_DELROUTE, htonl(key), fa, plen, tb->tb_id, &cfg->fc_nlinfo, 0); @@ -1707,6 +1771,25 @@ struct fib_info *fi = fa->fa_info; if (fi && (fi->fib_flags & RTNH_F_DEAD)) { + +#if 0//defined(CONFIG_RTL867X_IPTABLES_FAST_PATH) +#ifndef CONFIG_RTL_HARDWARE_NAT + rtl867x_delRoute(f->fn_key, fz->fz_mask); +#else + if (FastPath_Enabled()) { + int flag=1; + if (0 == fz->fz_mask) { + //default route, maybe in a policy route table + if (tb_id != RT_TABLE_MAIN) + flag = 0; + } + if (flag) { + rtl867x_delRoute(f->fn_key, fz->fz_mask); + } + } +#endif +#endif + list_del_rcu(&fa->fa_list); fib_release_info(fa->fa_info); alias_free_mem_rcu(fa);