diff options
author | David S. Miller <davem@davemloft.net> | 2011-03-11 20:07:33 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-03-12 18:08:48 -0500 |
commit | 68a5e3dd0a0056d8b349f9eea3756adda53ec17a (patch) | |
tree | cca890c41eb5b914d026bbfcc38645a1a402e10b /net/ipv4/route.c | |
parent | 22bd5b9b13f2931ac80949f8bfbc40e8cab05be7 (diff) |
ipv4: Use struct flowi4 internally in routing lookups.
We will change the externally visible APIs next.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/route.c')
-rw-r--r-- | net/ipv4/route.c | 230 |
1 files changed, 115 insertions, 115 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 027b4cc0f4a0..9e938f95cea8 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
@@ -109,8 +109,8 @@ | |||
109 | #include <linux/sysctl.h> | 109 | #include <linux/sysctl.h> |
110 | #endif | 110 | #endif |
111 | 111 | ||
112 | #define RT_FL_TOS(oldflp) \ | 112 | #define RT_FL_TOS(oldflp4) \ |
113 | ((u32)(oldflp->fl4_tos & (IPTOS_RT_MASK | RTO_ONLINK))) | 113 | ((u32)(oldflp4->flowi4_tos & (IPTOS_RT_MASK | RTO_ONLINK))) |
114 | 114 | ||
115 | #define IP_MAX_MTU 0xFFF0 | 115 | #define IP_MAX_MTU 0xFFF0 |
116 | 116 | ||
@@ -1697,17 +1697,17 @@ void ip_rt_get_source(u8 *addr, struct rtable *rt) | |||
1697 | if (rt_is_output_route(rt)) | 1697 | if (rt_is_output_route(rt)) |
1698 | src = rt->rt_src; | 1698 | src = rt->rt_src; |
1699 | else { | 1699 | else { |
1700 | struct flowi fl = { | 1700 | struct flowi4 fl4 = { |
1701 | .fl4_dst = rt->rt_key_dst, | 1701 | .daddr = rt->rt_key_dst, |
1702 | .fl4_src = rt->rt_key_src, | 1702 | .saddr = rt->rt_key_src, |
1703 | .fl4_tos = rt->rt_tos, | 1703 | .flowi4_tos = rt->rt_tos, |
1704 | .flowi_oif = rt->rt_oif, | 1704 | .flowi4_oif = rt->rt_oif, |
1705 | .flowi_iif = rt->rt_iif, | 1705 | .flowi4_iif = rt->rt_iif, |
1706 | .flowi_mark = rt->rt_mark, | 1706 | .flowi4_mark = rt->rt_mark, |
1707 | }; | 1707 | }; |
1708 | 1708 | ||
1709 | rcu_read_lock(); | 1709 | rcu_read_lock(); |
1710 | if (fib_lookup(dev_net(rt->dst.dev), &fl.u.ip4, &res) == 0) | 1710 | if (fib_lookup(dev_net(rt->dst.dev), &fl4, &res) == 0) |
1711 | src = FIB_RES_PREFSRC(res); | 1711 | src = FIB_RES_PREFSRC(res); |
1712 | else | 1712 | else |
1713 | src = inet_select_addr(rt->dst.dev, rt->rt_gateway, | 1713 | src = inet_select_addr(rt->dst.dev, rt->rt_gateway, |
@@ -1757,7 +1757,7 @@ static unsigned int ipv4_default_mtu(const struct dst_entry *dst) | |||
1757 | return mtu; | 1757 | return mtu; |
1758 | } | 1758 | } |
1759 | 1759 | ||
1760 | static void rt_init_metrics(struct rtable *rt, const struct flowi *oldflp, | 1760 | static void rt_init_metrics(struct rtable *rt, const struct flowi4 *oldflp4, |
1761 | struct fib_info *fi) | 1761 | struct fib_info *fi) |
1762 | { | 1762 | { |
1763 | struct inet_peer *peer; | 1763 | struct inet_peer *peer; |
@@ -1766,7 +1766,7 @@ static void rt_init_metrics(struct rtable *rt, const struct flowi *oldflp, | |||
1766 | /* If a peer entry exists for this destination, we must hook | 1766 | /* If a peer entry exists for this destination, we must hook |
1767 | * it up in order to get at cached metrics. | 1767 | * it up in order to get at cached metrics. |
1768 | */ | 1768 | */ |
1769 | if (oldflp && (oldflp->flowi_flags & FLOWI_FLAG_PRECOW_METRICS)) | 1769 | if (oldflp4 && (oldflp4->flowi4_flags & FLOWI_FLAG_PRECOW_METRICS)) |
1770 | create = 1; | 1770 | create = 1; |
1771 | 1771 | ||
1772 | rt->peer = peer = inet_getpeer_v4(rt->rt_dst, create); | 1772 | rt->peer = peer = inet_getpeer_v4(rt->rt_dst, create); |
@@ -1793,7 +1793,7 @@ static void rt_init_metrics(struct rtable *rt, const struct flowi *oldflp, | |||
1793 | } | 1793 | } |
1794 | } | 1794 | } |
1795 | 1795 | ||
1796 | static void rt_set_nexthop(struct rtable *rt, const struct flowi *oldflp, | 1796 | static void rt_set_nexthop(struct rtable *rt, const struct flowi4 *oldflp4, |
1797 | const struct fib_result *res, | 1797 | const struct fib_result *res, |
1798 | struct fib_info *fi, u16 type, u32 itag) | 1798 | struct fib_info *fi, u16 type, u32 itag) |
1799 | { | 1799 | { |
@@ -1803,7 +1803,7 @@ static void rt_set_nexthop(struct rtable *rt, const struct flowi *oldflp, | |||
1803 | if (FIB_RES_GW(*res) && | 1803 | if (FIB_RES_GW(*res) && |
1804 | FIB_RES_NH(*res).nh_scope == RT_SCOPE_LINK) | 1804 | FIB_RES_NH(*res).nh_scope == RT_SCOPE_LINK) |
1805 | rt->rt_gateway = FIB_RES_GW(*res); | 1805 | rt->rt_gateway = FIB_RES_GW(*res); |
1806 | rt_init_metrics(rt, oldflp, fi); | 1806 | rt_init_metrics(rt, oldflp4, fi); |
1807 | #ifdef CONFIG_IP_ROUTE_CLASSID | 1807 | #ifdef CONFIG_IP_ROUTE_CLASSID |
1808 | dst->tclassid = FIB_RES_NH(*res).nh_tclassid; | 1808 | dst->tclassid = FIB_RES_NH(*res).nh_tclassid; |
1809 | #endif | 1809 | #endif |
@@ -2038,7 +2038,7 @@ static int __mkroute_input(struct sk_buff *skb, | |||
2038 | 2038 | ||
2039 | static int ip_mkroute_input(struct sk_buff *skb, | 2039 | static int ip_mkroute_input(struct sk_buff *skb, |
2040 | struct fib_result *res, | 2040 | struct fib_result *res, |
2041 | const struct flowi *fl, | 2041 | const struct flowi4 *fl4, |
2042 | struct in_device *in_dev, | 2042 | struct in_device *in_dev, |
2043 | __be32 daddr, __be32 saddr, u32 tos) | 2043 | __be32 daddr, __be32 saddr, u32 tos) |
2044 | { | 2044 | { |
@@ -2057,9 +2057,9 @@ static int ip_mkroute_input(struct sk_buff *skb, | |||
2057 | return err; | 2057 | return err; |
2058 | 2058 | ||
2059 | /* put it into the cache */ | 2059 | /* put it into the cache */ |
2060 | hash = rt_hash(daddr, saddr, fl->flowi_iif, | 2060 | hash = rt_hash(daddr, saddr, fl4->flowi4_iif, |
2061 | rt_genid(dev_net(rth->dst.dev))); | 2061 | rt_genid(dev_net(rth->dst.dev))); |
2062 | rth = rt_intern_hash(hash, rth, skb, fl->flowi_iif); | 2062 | rth = rt_intern_hash(hash, rth, skb, fl4->flowi4_iif); |
2063 | if (IS_ERR(rth)) | 2063 | if (IS_ERR(rth)) |
2064 | return PTR_ERR(rth); | 2064 | return PTR_ERR(rth); |
2065 | return 0; | 2065 | return 0; |
@@ -2081,7 +2081,7 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr, | |||
2081 | { | 2081 | { |
2082 | struct fib_result res; | 2082 | struct fib_result res; |
2083 | struct in_device *in_dev = __in_dev_get_rcu(dev); | 2083 | struct in_device *in_dev = __in_dev_get_rcu(dev); |
2084 | struct flowi fl; | 2084 | struct flowi4 fl4; |
2085 | unsigned flags = 0; | 2085 | unsigned flags = 0; |
2086 | u32 itag = 0; | 2086 | u32 itag = 0; |
2087 | struct rtable * rth; | 2087 | struct rtable * rth; |
@@ -2118,14 +2118,14 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr, | |||
2118 | /* | 2118 | /* |
2119 | * Now we are ready to route packet. | 2119 | * Now we are ready to route packet. |
2120 | */ | 2120 | */ |
2121 | fl.flowi_oif = 0; | 2121 | fl4.flowi4_oif = 0; |
2122 | fl.flowi_iif = dev->ifindex; | 2122 | fl4.flowi4_iif = dev->ifindex; |
2123 | fl.flowi_mark = skb->mark; | 2123 | fl4.flowi4_mark = skb->mark; |
2124 | fl.fl4_dst = daddr; | 2124 | fl4.flowi4_tos = tos; |
2125 | fl.fl4_src = saddr; | 2125 | fl4.flowi4_scope = RT_SCOPE_UNIVERSE; |
2126 | fl.fl4_tos = tos; | 2126 | fl4.daddr = daddr; |
2127 | fl.fl4_scope = RT_SCOPE_UNIVERSE; | 2127 | fl4.saddr = saddr; |
2128 | err = fib_lookup(net, &fl.u.ip4, &res); | 2128 | err = fib_lookup(net, &fl4, &res); |
2129 | if (err != 0) { | 2129 | if (err != 0) { |
2130 | if (!IN_DEV_FORWARD(in_dev)) | 2130 | if (!IN_DEV_FORWARD(in_dev)) |
2131 | goto e_hostunreach; | 2131 | goto e_hostunreach; |
@@ -2154,7 +2154,7 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr, | |||
2154 | if (res.type != RTN_UNICAST) | 2154 | if (res.type != RTN_UNICAST) |
2155 | goto martian_destination; | 2155 | goto martian_destination; |
2156 | 2156 | ||
2157 | err = ip_mkroute_input(skb, &res, &fl, in_dev, daddr, saddr, tos); | 2157 | err = ip_mkroute_input(skb, &res, &fl4, in_dev, daddr, saddr, tos); |
2158 | out: return err; | 2158 | out: return err; |
2159 | 2159 | ||
2160 | brd_input: | 2160 | brd_input: |
@@ -2205,8 +2205,8 @@ local_input: | |||
2205 | rth->rt_flags &= ~RTCF_LOCAL; | 2205 | rth->rt_flags &= ~RTCF_LOCAL; |
2206 | } | 2206 | } |
2207 | rth->rt_type = res.type; | 2207 | rth->rt_type = res.type; |
2208 | hash = rt_hash(daddr, saddr, fl.flowi_iif, rt_genid(net)); | 2208 | hash = rt_hash(daddr, saddr, fl4.flowi4_iif, rt_genid(net)); |
2209 | rth = rt_intern_hash(hash, rth, skb, fl.flowi_iif); | 2209 | rth = rt_intern_hash(hash, rth, skb, fl4.flowi4_iif); |
2210 | err = 0; | 2210 | err = 0; |
2211 | if (IS_ERR(rth)) | 2211 | if (IS_ERR(rth)) |
2212 | err = PTR_ERR(rth); | 2212 | err = PTR_ERR(rth); |
@@ -2335,25 +2335,25 @@ EXPORT_SYMBOL(ip_route_input_common); | |||
2335 | 2335 | ||
2336 | /* called with rcu_read_lock() */ | 2336 | /* called with rcu_read_lock() */ |
2337 | static struct rtable *__mkroute_output(const struct fib_result *res, | 2337 | static struct rtable *__mkroute_output(const struct fib_result *res, |
2338 | const struct flowi *fl, | 2338 | const struct flowi4 *fl4, |
2339 | const struct flowi *oldflp, | 2339 | const struct flowi4 *oldflp4, |
2340 | struct net_device *dev_out, | 2340 | struct net_device *dev_out, |
2341 | unsigned int flags) | 2341 | unsigned int flags) |
2342 | { | 2342 | { |
2343 | struct fib_info *fi = res->fi; | 2343 | struct fib_info *fi = res->fi; |
2344 | u32 tos = RT_FL_TOS(oldflp); | 2344 | u32 tos = RT_FL_TOS(oldflp4); |
2345 | struct in_device *in_dev; | 2345 | struct in_device *in_dev; |
2346 | u16 type = res->type; | 2346 | u16 type = res->type; |
2347 | struct rtable *rth; | 2347 | struct rtable *rth; |
2348 | 2348 | ||
2349 | if (ipv4_is_loopback(fl->fl4_src) && !(dev_out->flags & IFF_LOOPBACK)) | 2349 | if (ipv4_is_loopback(fl4->saddr) && !(dev_out->flags & IFF_LOOPBACK)) |
2350 | return ERR_PTR(-EINVAL); | 2350 | return ERR_PTR(-EINVAL); |
2351 | 2351 | ||
2352 | if (ipv4_is_lbcast(fl->fl4_dst)) | 2352 | if (ipv4_is_lbcast(fl4->daddr)) |
2353 | type = RTN_BROADCAST; | 2353 | type = RTN_BROADCAST; |
2354 | else if (ipv4_is_multicast(fl->fl4_dst)) | 2354 | else if (ipv4_is_multicast(fl4->daddr)) |
2355 | type = RTN_MULTICAST; | 2355 | type = RTN_MULTICAST; |
2356 | else if (ipv4_is_zeronet(fl->fl4_dst)) | 2356 | else if (ipv4_is_zeronet(fl4->daddr)) |
2357 | return ERR_PTR(-EINVAL); | 2357 | return ERR_PTR(-EINVAL); |
2358 | 2358 | ||
2359 | if (dev_out->flags & IFF_LOOPBACK) | 2359 | if (dev_out->flags & IFF_LOOPBACK) |
@@ -2368,8 +2368,8 @@ static struct rtable *__mkroute_output(const struct fib_result *res, | |||
2368 | fi = NULL; | 2368 | fi = NULL; |
2369 | } else if (type == RTN_MULTICAST) { | 2369 | } else if (type == RTN_MULTICAST) { |
2370 | flags |= RTCF_MULTICAST | RTCF_LOCAL; | 2370 | flags |= RTCF_MULTICAST | RTCF_LOCAL; |
2371 | if (!ip_check_mc_rcu(in_dev, oldflp->fl4_dst, oldflp->fl4_src, | 2371 | if (!ip_check_mc_rcu(in_dev, oldflp4->daddr, oldflp4->saddr, |
2372 | oldflp->flowi_proto)) | 2372 | oldflp4->flowi4_proto)) |
2373 | flags &= ~RTCF_LOCAL; | 2373 | flags &= ~RTCF_LOCAL; |
2374 | /* If multicast route do not exist use | 2374 | /* If multicast route do not exist use |
2375 | * default one, but do not gateway in this case. | 2375 | * default one, but do not gateway in this case. |
@@ -2384,20 +2384,20 @@ static struct rtable *__mkroute_output(const struct fib_result *res, | |||
2384 | if (!rth) | 2384 | if (!rth) |
2385 | return ERR_PTR(-ENOBUFS); | 2385 | return ERR_PTR(-ENOBUFS); |
2386 | 2386 | ||
2387 | rth->rt_key_dst = oldflp->fl4_dst; | 2387 | rth->rt_key_dst = oldflp4->daddr; |
2388 | rth->rt_tos = tos; | 2388 | rth->rt_tos = tos; |
2389 | rth->rt_key_src = oldflp->fl4_src; | 2389 | rth->rt_key_src = oldflp4->saddr; |
2390 | rth->rt_oif = oldflp->flowi_oif; | 2390 | rth->rt_oif = oldflp4->flowi4_oif; |
2391 | rth->rt_mark = oldflp->flowi_mark; | 2391 | rth->rt_mark = oldflp4->flowi4_mark; |
2392 | rth->rt_dst = fl->fl4_dst; | 2392 | rth->rt_dst = fl4->daddr; |
2393 | rth->rt_src = fl->fl4_src; | 2393 | rth->rt_src = fl4->saddr; |
2394 | rth->rt_iif = 0; | 2394 | rth->rt_iif = 0; |
2395 | /* get references to the devices that are to be hold by the routing | 2395 | /* get references to the devices that are to be hold by the routing |
2396 | cache entry */ | 2396 | cache entry */ |
2397 | rth->dst.dev = dev_out; | 2397 | rth->dst.dev = dev_out; |
2398 | dev_hold(dev_out); | 2398 | dev_hold(dev_out); |
2399 | rth->rt_gateway = fl->fl4_dst; | 2399 | rth->rt_gateway = fl4->daddr; |
2400 | rth->rt_spec_dst= fl->fl4_src; | 2400 | rth->rt_spec_dst= fl4->saddr; |
2401 | 2401 | ||
2402 | rth->dst.output=ip_output; | 2402 | rth->dst.output=ip_output; |
2403 | rth->rt_genid = rt_genid(dev_net(dev_out)); | 2403 | rth->rt_genid = rt_genid(dev_net(dev_out)); |
@@ -2406,10 +2406,10 @@ static struct rtable *__mkroute_output(const struct fib_result *res, | |||
2406 | 2406 | ||
2407 | if (flags & RTCF_LOCAL) { | 2407 | if (flags & RTCF_LOCAL) { |
2408 | rth->dst.input = ip_local_deliver; | 2408 | rth->dst.input = ip_local_deliver; |
2409 | rth->rt_spec_dst = fl->fl4_dst; | 2409 | rth->rt_spec_dst = fl4->daddr; |
2410 | } | 2410 | } |
2411 | if (flags & (RTCF_BROADCAST | RTCF_MULTICAST)) { | 2411 | if (flags & (RTCF_BROADCAST | RTCF_MULTICAST)) { |
2412 | rth->rt_spec_dst = fl->fl4_src; | 2412 | rth->rt_spec_dst = fl4->saddr; |
2413 | if (flags & RTCF_LOCAL && | 2413 | if (flags & RTCF_LOCAL && |
2414 | !(dev_out->flags & IFF_LOOPBACK)) { | 2414 | !(dev_out->flags & IFF_LOOPBACK)) { |
2415 | rth->dst.output = ip_mc_output; | 2415 | rth->dst.output = ip_mc_output; |
@@ -2418,7 +2418,7 @@ static struct rtable *__mkroute_output(const struct fib_result *res, | |||
2418 | #ifdef CONFIG_IP_MROUTE | 2418 | #ifdef CONFIG_IP_MROUTE |
2419 | if (type == RTN_MULTICAST) { | 2419 | if (type == RTN_MULTICAST) { |
2420 | if (IN_DEV_MFORWARD(in_dev) && | 2420 | if (IN_DEV_MFORWARD(in_dev) && |
2421 | !ipv4_is_local_multicast(oldflp->fl4_dst)) { | 2421 | !ipv4_is_local_multicast(oldflp4->daddr)) { |
2422 | rth->dst.input = ip_mr_input; | 2422 | rth->dst.input = ip_mr_input; |
2423 | rth->dst.output = ip_mc_output; | 2423 | rth->dst.output = ip_mc_output; |
2424 | } | 2424 | } |
@@ -2426,7 +2426,7 @@ static struct rtable *__mkroute_output(const struct fib_result *res, | |||
2426 | #endif | 2426 | #endif |
2427 | } | 2427 | } |
2428 | 2428 | ||
2429 | rt_set_nexthop(rth, oldflp, res, fi, type, 0); | 2429 | rt_set_nexthop(rth, oldflp4, res, fi, type, 0); |
2430 | 2430 | ||
2431 | rth->rt_flags = flags; | 2431 | rth->rt_flags = flags; |
2432 | return rth; | 2432 | return rth; |
@@ -2438,10 +2438,10 @@ static struct rtable *__mkroute_output(const struct fib_result *res, | |||
2438 | */ | 2438 | */ |
2439 | 2439 | ||
2440 | static struct rtable *ip_route_output_slow(struct net *net, | 2440 | static struct rtable *ip_route_output_slow(struct net *net, |
2441 | const struct flowi *oldflp) | 2441 | const struct flowi4 *oldflp4) |
2442 | { | 2442 | { |
2443 | u32 tos = RT_FL_TOS(oldflp); | 2443 | u32 tos = RT_FL_TOS(oldflp4); |
2444 | struct flowi fl; | 2444 | struct flowi4 fl4; |
2445 | struct fib_result res; | 2445 | struct fib_result res; |
2446 | unsigned int flags = 0; | 2446 | unsigned int flags = 0; |
2447 | struct net_device *dev_out = NULL; | 2447 | struct net_device *dev_out = NULL; |
@@ -2452,21 +2452,21 @@ static struct rtable *ip_route_output_slow(struct net *net, | |||
2452 | res.r = NULL; | 2452 | res.r = NULL; |
2453 | #endif | 2453 | #endif |
2454 | 2454 | ||
2455 | fl.flowi_oif = oldflp->flowi_oif; | 2455 | fl4.flowi4_oif = oldflp4->flowi4_oif; |
2456 | fl.flowi_iif = net->loopback_dev->ifindex; | 2456 | fl4.flowi4_iif = net->loopback_dev->ifindex; |
2457 | fl.flowi_mark = oldflp->flowi_mark; | 2457 | fl4.flowi4_mark = oldflp4->flowi4_mark; |
2458 | fl.fl4_dst = oldflp->fl4_dst; | 2458 | fl4.daddr = oldflp4->daddr; |
2459 | fl.fl4_src = oldflp->fl4_src; | 2459 | fl4.saddr = oldflp4->saddr; |
2460 | fl.fl4_tos = tos & IPTOS_RT_MASK; | 2460 | fl4.flowi4_tos = tos & IPTOS_RT_MASK; |
2461 | fl.fl4_scope = ((tos & RTO_ONLINK) ? | 2461 | fl4.flowi4_scope = ((tos & RTO_ONLINK) ? |
2462 | RT_SCOPE_LINK : RT_SCOPE_UNIVERSE); | 2462 | RT_SCOPE_LINK : RT_SCOPE_UNIVERSE); |
2463 | 2463 | ||
2464 | rcu_read_lock(); | 2464 | rcu_read_lock(); |
2465 | if (oldflp->fl4_src) { | 2465 | if (oldflp4->saddr) { |
2466 | rth = ERR_PTR(-EINVAL); | 2466 | rth = ERR_PTR(-EINVAL); |
2467 | if (ipv4_is_multicast(oldflp->fl4_src) || | 2467 | if (ipv4_is_multicast(oldflp4->saddr) || |
2468 | ipv4_is_lbcast(oldflp->fl4_src) || | 2468 | ipv4_is_lbcast(oldflp4->saddr) || |
2469 | ipv4_is_zeronet(oldflp->fl4_src)) | 2469 | ipv4_is_zeronet(oldflp4->saddr)) |
2470 | goto out; | 2470 | goto out; |
2471 | 2471 | ||
2472 | /* I removed check for oif == dev_out->oif here. | 2472 | /* I removed check for oif == dev_out->oif here. |
@@ -2477,11 +2477,11 @@ static struct rtable *ip_route_output_slow(struct net *net, | |||
2477 | of another iface. --ANK | 2477 | of another iface. --ANK |
2478 | */ | 2478 | */ |
2479 | 2479 | ||
2480 | if (oldflp->flowi_oif == 0 && | 2480 | if (oldflp4->flowi4_oif == 0 && |
2481 | (ipv4_is_multicast(oldflp->fl4_dst) || | 2481 | (ipv4_is_multicast(oldflp4->daddr) || |
2482 | ipv4_is_lbcast(oldflp->fl4_dst))) { | 2482 | ipv4_is_lbcast(oldflp4->daddr))) { |
2483 | /* It is equivalent to inet_addr_type(saddr) == RTN_LOCAL */ | 2483 | /* It is equivalent to inet_addr_type(saddr) == RTN_LOCAL */ |
2484 | dev_out = __ip_dev_find(net, oldflp->fl4_src, false); | 2484 | dev_out = __ip_dev_find(net, oldflp4->saddr, false); |
2485 | if (dev_out == NULL) | 2485 | if (dev_out == NULL) |
2486 | goto out; | 2486 | goto out; |
2487 | 2487 | ||
@@ -2500,20 +2500,20 @@ static struct rtable *ip_route_output_slow(struct net *net, | |||
2500 | Luckily, this hack is good workaround. | 2500 | Luckily, this hack is good workaround. |
2501 | */ | 2501 | */ |
2502 | 2502 | ||
2503 | fl.flowi_oif = dev_out->ifindex; | 2503 | fl4.flowi4_oif = dev_out->ifindex; |
2504 | goto make_route; | 2504 | goto make_route; |
2505 | } | 2505 | } |
2506 | 2506 | ||
2507 | if (!(oldflp->flowi_flags & FLOWI_FLAG_ANYSRC)) { | 2507 | if (!(oldflp4->flowi4_flags & FLOWI_FLAG_ANYSRC)) { |
2508 | /* It is equivalent to inet_addr_type(saddr) == RTN_LOCAL */ | 2508 | /* It is equivalent to inet_addr_type(saddr) == RTN_LOCAL */ |
2509 | if (!__ip_dev_find(net, oldflp->fl4_src, false)) | 2509 | if (!__ip_dev_find(net, oldflp4->saddr, false)) |
2510 | goto out; | 2510 | goto out; |
2511 | } | 2511 | } |
2512 | } | 2512 | } |
2513 | 2513 | ||
2514 | 2514 | ||
2515 | if (oldflp->flowi_oif) { | 2515 | if (oldflp4->flowi4_oif) { |
2516 | dev_out = dev_get_by_index_rcu(net, oldflp->flowi_oif); | 2516 | dev_out = dev_get_by_index_rcu(net, oldflp4->flowi4_oif); |
2517 | rth = ERR_PTR(-ENODEV); | 2517 | rth = ERR_PTR(-ENODEV); |
2518 | if (dev_out == NULL) | 2518 | if (dev_out == NULL) |
2519 | goto out; | 2519 | goto out; |
@@ -2523,37 +2523,37 @@ static struct rtable *ip_route_output_slow(struct net *net, | |||
2523 | rth = ERR_PTR(-ENETUNREACH); | 2523 | rth = ERR_PTR(-ENETUNREACH); |
2524 | goto out; | 2524 | goto out; |
2525 | } | 2525 | } |
2526 | if (ipv4_is_local_multicast(oldflp->fl4_dst) || | 2526 | if (ipv4_is_local_multicast(oldflp4->daddr) || |
2527 | ipv4_is_lbcast(oldflp->fl4_dst)) { | 2527 | ipv4_is_lbcast(oldflp4->daddr)) { |
2528 | if (!fl.fl4_src) | 2528 | if (!fl4.saddr) |
2529 | fl.fl4_src = inet_select_addr(dev_out, 0, | 2529 | fl4.saddr = inet_select_addr(dev_out, 0, |
2530 | RT_SCOPE_LINK); | 2530 | RT_SCOPE_LINK); |
2531 | goto make_route; | 2531 | goto make_route; |
2532 | } | 2532 | } |
2533 | if (!fl.fl4_src) { | 2533 | if (!fl4.saddr) { |
2534 | if (ipv4_is_multicast(oldflp->fl4_dst)) | 2534 | if (ipv4_is_multicast(oldflp4->daddr)) |
2535 | fl.fl4_src = inet_select_addr(dev_out, 0, | 2535 | fl4.saddr = inet_select_addr(dev_out, 0, |
2536 | fl.fl4_scope); | 2536 | fl4.flowi4_scope); |
2537 | else if (!oldflp->fl4_dst) | 2537 | else if (!oldflp4->daddr) |
2538 | fl.fl4_src = inet_select_addr(dev_out, 0, | 2538 | fl4.saddr = inet_select_addr(dev_out, 0, |
2539 | RT_SCOPE_HOST); | 2539 | RT_SCOPE_HOST); |
2540 | } | 2540 | } |
2541 | } | 2541 | } |
2542 | 2542 | ||
2543 | if (!fl.fl4_dst) { | 2543 | if (!fl4.daddr) { |
2544 | fl.fl4_dst = fl.fl4_src; | 2544 | fl4.daddr = fl4.saddr; |
2545 | if (!fl.fl4_dst) | 2545 | if (!fl4.daddr) |
2546 | fl.fl4_dst = fl.fl4_src = htonl(INADDR_LOOPBACK); | 2546 | fl4.daddr = fl4.saddr = htonl(INADDR_LOOPBACK); |
2547 | dev_out = net->loopback_dev; | 2547 | dev_out = net->loopback_dev; |
2548 | fl.flowi_oif = net->loopback_dev->ifindex; | 2548 | fl4.flowi4_oif = net->loopback_dev->ifindex; |
2549 | res.type = RTN_LOCAL; | 2549 | res.type = RTN_LOCAL; |
2550 | flags |= RTCF_LOCAL; | 2550 | flags |= RTCF_LOCAL; |
2551 | goto make_route; | 2551 | goto make_route; |
2552 | } | 2552 | } |
2553 | 2553 | ||
2554 | if (fib_lookup(net, &fl.u.ip4, &res)) { | 2554 | if (fib_lookup(net, &fl4, &res)) { |
2555 | res.fi = NULL; | 2555 | res.fi = NULL; |
2556 | if (oldflp->flowi_oif) { | 2556 | if (oldflp4->flowi4_oif) { |
2557 | /* Apparently, routing tables are wrong. Assume, | 2557 | /* Apparently, routing tables are wrong. Assume, |
2558 | that the destination is on link. | 2558 | that the destination is on link. |
2559 | 2559 | ||
@@ -2572,9 +2572,9 @@ static struct rtable *ip_route_output_slow(struct net *net, | |||
2572 | likely IPv6, but we do not. | 2572 | likely IPv6, but we do not. |
2573 | */ | 2573 | */ |
2574 | 2574 | ||
2575 | if (fl.fl4_src == 0) | 2575 | if (fl4.saddr == 0) |
2576 | fl.fl4_src = inet_select_addr(dev_out, 0, | 2576 | fl4.saddr = inet_select_addr(dev_out, 0, |
2577 | RT_SCOPE_LINK); | 2577 | RT_SCOPE_LINK); |
2578 | res.type = RTN_UNICAST; | 2578 | res.type = RTN_UNICAST; |
2579 | goto make_route; | 2579 | goto make_route; |
2580 | } | 2580 | } |
@@ -2583,42 +2583,42 @@ static struct rtable *ip_route_output_slow(struct net *net, | |||
2583 | } | 2583 | } |
2584 | 2584 | ||
2585 | if (res.type == RTN_LOCAL) { | 2585 | if (res.type == RTN_LOCAL) { |
2586 | if (!fl.fl4_src) { | 2586 | if (!fl4.saddr) { |
2587 | if (res.fi->fib_prefsrc) | 2587 | if (res.fi->fib_prefsrc) |
2588 | fl.fl4_src = res.fi->fib_prefsrc; | 2588 | fl4.saddr = res.fi->fib_prefsrc; |
2589 | else | 2589 | else |
2590 | fl.fl4_src = fl.fl4_dst; | 2590 | fl4.saddr = fl4.daddr; |
2591 | } | 2591 | } |
2592 | dev_out = net->loopback_dev; | 2592 | dev_out = net->loopback_dev; |
2593 | fl.flowi_oif = dev_out->ifindex; | 2593 | fl4.flowi4_oif = dev_out->ifindex; |
2594 | res.fi = NULL; | 2594 | res.fi = NULL; |
2595 | flags |= RTCF_LOCAL; | 2595 | flags |= RTCF_LOCAL; |
2596 | goto make_route; | 2596 | goto make_route; |
2597 | } | 2597 | } |
2598 | 2598 | ||
2599 | #ifdef CONFIG_IP_ROUTE_MULTIPATH | 2599 | #ifdef CONFIG_IP_ROUTE_MULTIPATH |
2600 | if (res.fi->fib_nhs > 1 && fl.flowi_oif == 0) | 2600 | if (res.fi->fib_nhs > 1 && fl4.flowi4_oif == 0) |
2601 | fib_select_multipath(&res); | 2601 | fib_select_multipath(&res); |
2602 | else | 2602 | else |
2603 | #endif | 2603 | #endif |
2604 | if (!res.prefixlen && res.type == RTN_UNICAST && !fl.flowi_oif) | 2604 | if (!res.prefixlen && res.type == RTN_UNICAST && !fl4.flowi4_oif) |
2605 | fib_select_default(&res); | 2605 | fib_select_default(&res); |
2606 | 2606 | ||
2607 | if (!fl.fl4_src) | 2607 | if (!fl4.saddr) |
2608 | fl.fl4_src = FIB_RES_PREFSRC(res); | 2608 | fl4.saddr = FIB_RES_PREFSRC(res); |
2609 | 2609 | ||
2610 | dev_out = FIB_RES_DEV(res); | 2610 | dev_out = FIB_RES_DEV(res); |
2611 | fl.flowi_oif = dev_out->ifindex; | 2611 | fl4.flowi4_oif = dev_out->ifindex; |
2612 | 2612 | ||
2613 | 2613 | ||
2614 | make_route: | 2614 | make_route: |
2615 | rth = __mkroute_output(&res, &fl, oldflp, dev_out, flags); | 2615 | rth = __mkroute_output(&res, &fl4, oldflp4, dev_out, flags); |
2616 | if (!IS_ERR(rth)) { | 2616 | if (!IS_ERR(rth)) { |
2617 | unsigned int hash; | 2617 | unsigned int hash; |
2618 | 2618 | ||
2619 | hash = rt_hash(oldflp->fl4_dst, oldflp->fl4_src, oldflp->flowi_oif, | 2619 | hash = rt_hash(oldflp4->daddr, oldflp4->saddr, oldflp4->flowi4_oif, |
2620 | rt_genid(dev_net(dev_out))); | 2620 | rt_genid(dev_net(dev_out))); |
2621 | rth = rt_intern_hash(hash, rth, NULL, oldflp->flowi_oif); | 2621 | rth = rt_intern_hash(hash, rth, NULL, oldflp4->flowi4_oif); |
2622 | } | 2622 | } |
2623 | 2623 | ||
2624 | out: | 2624 | out: |
@@ -2658,7 +2658,7 @@ struct rtable *__ip_route_output_key(struct net *net, const struct flowi *flp) | |||
2658 | rcu_read_unlock_bh(); | 2658 | rcu_read_unlock_bh(); |
2659 | 2659 | ||
2660 | slow_output: | 2660 | slow_output: |
2661 | return ip_route_output_slow(net, flp); | 2661 | return ip_route_output_slow(net, &flp->u.ip4); |
2662 | } | 2662 | } |
2663 | EXPORT_SYMBOL_GPL(__ip_route_output_key); | 2663 | EXPORT_SYMBOL_GPL(__ip_route_output_key); |
2664 | 2664 | ||
@@ -2913,14 +2913,14 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void | |||
2913 | if (err == 0 && rt->dst.error) | 2913 | if (err == 0 && rt->dst.error) |
2914 | err = -rt->dst.error; | 2914 | err = -rt->dst.error; |
2915 | } else { | 2915 | } else { |
2916 | struct flowi fl = { | 2916 | struct flowi4 fl4 = { |
2917 | .fl4_dst = dst, | 2917 | .daddr = dst, |
2918 | .fl4_src = src, | 2918 | .saddr = src, |
2919 | .fl4_tos = rtm->rtm_tos, | 2919 | .flowi4_tos = rtm->rtm_tos, |
2920 | .flowi_oif = tb[RTA_OIF] ? nla_get_u32(tb[RTA_OIF]) : 0, | 2920 | .flowi4_oif = tb[RTA_OIF] ? nla_get_u32(tb[RTA_OIF]) : 0, |
2921 | .flowi_mark = mark, | 2921 | .flowi4_mark = mark, |
2922 | }; | 2922 | }; |
2923 | rt = ip_route_output_key(net, &fl); | 2923 | rt = ip_route_output_key(net, flowi4_to_flowi(&fl4)); |
2924 | 2924 | ||
2925 | err = 0; | 2925 | err = 0; |
2926 | if (IS_ERR(rt)) | 2926 | if (IS_ERR(rt)) |