--- zzzz-none-000/linux-2.6.32.61/net/ipv4/route.c 2013-06-10 09:43:48.000000000 +0000 +++ ar10-7272-687/linux-2.6.32.61/net/ipv4/route.c 2013-10-23 09:37:35.000000000 +0000 @@ -107,6 +107,9 @@ #ifdef CONFIG_SYSCTL #include #endif +#ifdef CONFIG_MAPPING +#include "proto_trans.h" +#endif #include #define RT_FL_TOS(oldflp) \ @@ -1516,7 +1519,9 @@ { struct rtable *rt = skb_rtable(skb); struct in_device *in_dev; +#ifdef CONFIG_IP_ROUTE_VERBOSE int log_martians; +#endif /*--- #ifdef CONFIG_IP_ROUTE_VERBOSE ---*/ rcu_read_lock(); in_dev = __in_dev_get_rcu(rt->u.dst.dev); @@ -1524,7 +1529,9 @@ rcu_read_unlock(); return; } +#ifdef CONFIG_IP_ROUTE_VERBOSE log_martians = IN_DEV_LOG_MARTIANS(in_dev); +#endif /*--- #ifdef CONFIG_IP_ROUTE_VERBOSE ---*/ rcu_read_unlock(); /* No redirected packets during ip_rt_redirect_silence; @@ -1970,6 +1977,7 @@ } +#ifndef CONFIG_MAPPING err = fib_validate_source(saddr, daddr, tos, FIB_RES_OIF(*res), in_dev->dev, &spec_dst, &itag, skb->mark); if (err < 0) { @@ -1982,7 +1990,9 @@ if (err) flags |= RTCF_DIRECTSRC; - +#else + err = 0; +#endif if (out_dev == in_dev && err && (IN_DEV_SHARED_MEDIA(out_dev) || inet_addr_onlink(out_dev, saddr, FIB_RES_GW(*res)))) @@ -2014,6 +2024,11 @@ rth->fl.fl4_dst = daddr; rth->rt_dst = daddr; rth->fl.fl4_tos = tos; +#ifdef CONFIG_MAPPING + rth->mapping = res->mapping; /* Make the mapping cache */ + rth->src_prefix = res->src_prefix; + rth->dst_prefix = res->dst_prefix; +#endif rth->fl.mark = skb->mark; rth->fl.fl4_src = saddr; rth->rt_src = saddr; @@ -2138,6 +2153,13 @@ free_res = 1; RT_CACHE_STAT_INC(in_slow_tot); +#ifdef CONFIG_MAPPING + if (res.mapping) { + if (!ip_mapping(skb, res.src_prefix, res.dst_prefix)) + printk("Mapping Failed!\n"); + goto e_inval; /* Stop the current stack running */ + } +#endif if (res.type == RTN_BROADCAST) goto brd_input; @@ -2155,8 +2177,10 @@ goto local_input; } +#ifndef CONFIG_MAPPING if (!IN_DEV_FORWARD(in_dev)) goto e_hostunreach; +#endif if (res.type != RTN_UNICAST) goto martian_destination; @@ -2289,6 +2313,16 @@ rth->fl.mark == skb->mark && net_eq(dev_net(rth->u.dst.dev), net) && !rt_is_expired(rth)) { +#ifdef CONFIG_MAPPING + if (rth->mapping) { + dst_hold(&rth->u.dst); + RT_CACHE_STAT_INC(in_hit); + if (!ip_mapping(skb, rth->src_prefix, rth->dst_prefix)) { + printk("Mapping Failed!\n"); + } + return -EINVAL; /* Stop the stack running */ + } +#endif dst_use(&rth->u.dst, jiffies); RT_CACHE_STAT_INC(in_hit); rcu_read_unlock(); @@ -2410,6 +2444,11 @@ rth->rt_iif = oldflp->oif ? : dev_out->ifindex; /* get references to the devices that are to be hold by the routing cache entry */ +#ifdef CONFIG_MAPPING + rth->mapping = res->mapping; + rth->src_prefix = res->src_prefix; + rth->dst_prefix = res->dst_prefix; +#endif rth->u.dst.dev = dev_out; dev_hold(dev_out); rth->idev = in_dev_get(dev_out);