aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/net/ip_fib.h2
-rw-r--r--net/ipv4/fib_rules.c2
-rw-r--r--net/ipv4/route.c32
3 files changed, 19 insertions, 17 deletions
diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
index b3019d89e8be..523a170b0ecb 100644
--- a/include/net/ip_fib.h
+++ b/include/net/ip_fib.h
@@ -202,7 +202,7 @@ extern int __net_init fib4_rules_init(struct net *net);
202extern void __net_exit fib4_rules_exit(struct net *net); 202extern void __net_exit fib4_rules_exit(struct net *net);
203 203
204#ifdef CONFIG_IP_ROUTE_CLASSID 204#ifdef CONFIG_IP_ROUTE_CLASSID
205extern u32 fib_rules_tclass(struct fib_result *res); 205extern u32 fib_rules_tclass(const struct fib_result *res);
206#endif 206#endif
207 207
208extern int fib_lookup(struct net *n, struct flowi *flp, struct fib_result *res); 208extern int fib_lookup(struct net *n, struct flowi *flp, struct fib_result *res);
diff --git a/net/ipv4/fib_rules.c b/net/ipv4/fib_rules.c
index 9cefe72029cf..3018efbaea77 100644
--- a/net/ipv4/fib_rules.c
+++ b/net/ipv4/fib_rules.c
@@ -47,7 +47,7 @@ struct fib4_rule {
47}; 47};
48 48
49#ifdef CONFIG_IP_ROUTE_CLASSID 49#ifdef CONFIG_IP_ROUTE_CLASSID
50u32 fib_rules_tclass(struct fib_result *res) 50u32 fib_rules_tclass(const struct fib_result *res)
51{ 51{
52 return res->r ? ((struct fib4_rule *) res->r)->tclassid : 0; 52 return res->r ? ((struct fib4_rule *) res->r)->tclassid : 0;
53} 53}
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 9841543c468d..2facde0985f9 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1787,10 +1787,10 @@ static void rt_init_metrics(struct rtable *rt, struct fib_info *fi)
1787 } 1787 }
1788} 1788}
1789 1789
1790static void rt_set_nexthop(struct rtable *rt, struct fib_result *res, u32 itag) 1790static void rt_set_nexthop(struct rtable *rt, const struct fib_result *res,
1791 struct fib_info *fi, u16 type, u32 itag)
1791{ 1792{
1792 struct dst_entry *dst = &rt->dst; 1793 struct dst_entry *dst = &rt->dst;
1793 struct fib_info *fi = res->fi;
1794 1794
1795 if (fi) { 1795 if (fi) {
1796 if (FIB_RES_GW(*res) && 1796 if (FIB_RES_GW(*res) &&
@@ -1813,7 +1813,7 @@ static void rt_set_nexthop(struct rtable *rt, struct fib_result *res, u32 itag)
1813#endif 1813#endif
1814 set_class_tag(rt, itag); 1814 set_class_tag(rt, itag);
1815#endif 1815#endif
1816 rt->rt_type = res->type; 1816 rt->rt_type = type;
1817} 1817}
1818 1818
1819static struct rtable *rt_dst_alloc(bool nopolicy, bool noxfrm) 1819static struct rtable *rt_dst_alloc(bool nopolicy, bool noxfrm)
@@ -1939,7 +1939,7 @@ static void ip_handle_martian_source(struct net_device *dev,
1939 1939
1940/* called in rcu_read_lock() section */ 1940/* called in rcu_read_lock() section */
1941static int __mkroute_input(struct sk_buff *skb, 1941static int __mkroute_input(struct sk_buff *skb,
1942 struct fib_result *res, 1942 const struct fib_result *res,
1943 struct in_device *in_dev, 1943 struct in_device *in_dev,
1944 __be32 daddr, __be32 saddr, u32 tos, 1944 __be32 daddr, __be32 saddr, u32 tos,
1945 struct rtable **result) 1945 struct rtable **result)
@@ -2018,7 +2018,7 @@ static int __mkroute_input(struct sk_buff *skb,
2018 rth->dst.output = ip_output; 2018 rth->dst.output = ip_output;
2019 rth->rt_genid = rt_genid(dev_net(rth->dst.dev)); 2019 rth->rt_genid = rt_genid(dev_net(rth->dst.dev));
2020 2020
2021 rt_set_nexthop(rth, res, itag); 2021 rt_set_nexthop(rth, res, res->fi, res->type, itag);
2022 2022
2023 rth->rt_flags = flags; 2023 rth->rt_flags = flags;
2024 2024
@@ -2319,23 +2319,25 @@ skip_cache:
2319EXPORT_SYMBOL(ip_route_input_common); 2319EXPORT_SYMBOL(ip_route_input_common);
2320 2320
2321/* called with rcu_read_lock() */ 2321/* called with rcu_read_lock() */
2322static struct rtable *__mkroute_output(struct fib_result *res, 2322static struct rtable *__mkroute_output(const struct fib_result *res,
2323 const struct flowi *fl, 2323 const struct flowi *fl,
2324 const struct flowi *oldflp, 2324 const struct flowi *oldflp,
2325 struct net_device *dev_out, 2325 struct net_device *dev_out,
2326 unsigned int flags) 2326 unsigned int flags)
2327{ 2327{
2328 struct fib_info *fi = res->fi;
2328 u32 tos = RT_FL_TOS(oldflp); 2329 u32 tos = RT_FL_TOS(oldflp);
2329 struct in_device *in_dev; 2330 struct in_device *in_dev;
2331 u16 type = res->type;
2330 struct rtable *rth; 2332 struct rtable *rth;
2331 2333
2332 if (ipv4_is_loopback(fl->fl4_src) && !(dev_out->flags & IFF_LOOPBACK)) 2334 if (ipv4_is_loopback(fl->fl4_src) && !(dev_out->flags & IFF_LOOPBACK))
2333 return ERR_PTR(-EINVAL); 2335 return ERR_PTR(-EINVAL);
2334 2336
2335 if (ipv4_is_lbcast(fl->fl4_dst)) 2337 if (ipv4_is_lbcast(fl->fl4_dst))
2336 res->type = RTN_BROADCAST; 2338 type = RTN_BROADCAST;
2337 else if (ipv4_is_multicast(fl->fl4_dst)) 2339 else if (ipv4_is_multicast(fl->fl4_dst))
2338 res->type = RTN_MULTICAST; 2340 type = RTN_MULTICAST;
2339 else if (ipv4_is_zeronet(fl->fl4_dst)) 2341 else if (ipv4_is_zeronet(fl->fl4_dst))
2340 return ERR_PTR(-EINVAL); 2342 return ERR_PTR(-EINVAL);
2341 2343
@@ -2346,10 +2348,10 @@ static struct rtable *__mkroute_output(struct fib_result *res,
2346 if (!in_dev) 2348 if (!in_dev)
2347 return ERR_PTR(-EINVAL); 2349 return ERR_PTR(-EINVAL);
2348 2350
2349 if (res->type == RTN_BROADCAST) { 2351 if (type == RTN_BROADCAST) {
2350 flags |= RTCF_BROADCAST | RTCF_LOCAL; 2352 flags |= RTCF_BROADCAST | RTCF_LOCAL;
2351 res->fi = NULL; 2353 fi = NULL;
2352 } else if (res->type == RTN_MULTICAST) { 2354 } else if (type == RTN_MULTICAST) {
2353 flags |= RTCF_MULTICAST | RTCF_LOCAL; 2355 flags |= RTCF_MULTICAST | RTCF_LOCAL;
2354 if (!ip_check_mc(in_dev, oldflp->fl4_dst, oldflp->fl4_src, 2356 if (!ip_check_mc(in_dev, oldflp->fl4_dst, oldflp->fl4_src,
2355 oldflp->proto)) 2357 oldflp->proto))
@@ -2358,8 +2360,8 @@ static struct rtable *__mkroute_output(struct fib_result *res,
2358 * default one, but do not gateway in this case. 2360 * default one, but do not gateway in this case.
2359 * Yes, it is hack. 2361 * Yes, it is hack.
2360 */ 2362 */
2361 if (res->fi && res->prefixlen < 4) 2363 if (fi && res->prefixlen < 4)
2362 res->fi = NULL; 2364 fi = NULL;
2363 } 2365 }
2364 2366
2365 rth = rt_dst_alloc(IN_DEV_CONF_GET(in_dev, NOPOLICY), 2367 rth = rt_dst_alloc(IN_DEV_CONF_GET(in_dev, NOPOLICY),
@@ -2399,7 +2401,7 @@ static struct rtable *__mkroute_output(struct fib_result *res,
2399 RT_CACHE_STAT_INC(out_slow_mc); 2401 RT_CACHE_STAT_INC(out_slow_mc);
2400 } 2402 }
2401#ifdef CONFIG_IP_MROUTE 2403#ifdef CONFIG_IP_MROUTE
2402 if (res->type == RTN_MULTICAST) { 2404 if (type == RTN_MULTICAST) {
2403 if (IN_DEV_MFORWARD(in_dev) && 2405 if (IN_DEV_MFORWARD(in_dev) &&
2404 !ipv4_is_local_multicast(oldflp->fl4_dst)) { 2406 !ipv4_is_local_multicast(oldflp->fl4_dst)) {
2405 rth->dst.input = ip_mr_input; 2407 rth->dst.input = ip_mr_input;
@@ -2409,7 +2411,7 @@ static struct rtable *__mkroute_output(struct fib_result *res,
2409#endif 2411#endif
2410 } 2412 }
2411 2413
2412 rt_set_nexthop(rth, res, 0); 2414 rt_set_nexthop(rth, res, fi, type, 0);
2413 2415
2414 rth->rt_flags = flags; 2416 rth->rt_flags = flags;
2415 return rth; 2417 return rth;