aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/route.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2011-03-12 01:12:47 -0500
committerDavid S. Miller <davem@davemloft.net>2011-03-12 18:08:48 -0500
commit9d6ec938019c6b16cb9ec96598ebe8f20de435fe (patch)
tree9b850eb7fd48a6e5ffc15f47afd2e3edc93f5290 /net/ipv4/route.c
parent68a5e3dd0a0056d8b349f9eea3756adda53ec17a (diff)
ipv4: Use flowi4 in public route lookup interfaces.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/route.c')
-rw-r--r--net/ipv4/route.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 9e938f95cea8..5655095a89e0 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -2626,7 +2626,7 @@ out:
2626 return rth; 2626 return rth;
2627} 2627}
2628 2628
2629struct rtable *__ip_route_output_key(struct net *net, const struct flowi *flp) 2629struct rtable *__ip_route_output_key(struct net *net, const struct flowi4 *flp4)
2630{ 2630{
2631 struct rtable *rth; 2631 struct rtable *rth;
2632 unsigned int hash; 2632 unsigned int hash;
@@ -2634,17 +2634,17 @@ struct rtable *__ip_route_output_key(struct net *net, const struct flowi *flp)
2634 if (!rt_caching(net)) 2634 if (!rt_caching(net))
2635 goto slow_output; 2635 goto slow_output;
2636 2636
2637 hash = rt_hash(flp->fl4_dst, flp->fl4_src, flp->flowi_oif, rt_genid(net)); 2637 hash = rt_hash(flp4->daddr, flp4->saddr, flp4->flowi4_oif, rt_genid(net));
2638 2638
2639 rcu_read_lock_bh(); 2639 rcu_read_lock_bh();
2640 for (rth = rcu_dereference_bh(rt_hash_table[hash].chain); rth; 2640 for (rth = rcu_dereference_bh(rt_hash_table[hash].chain); rth;
2641 rth = rcu_dereference_bh(rth->dst.rt_next)) { 2641 rth = rcu_dereference_bh(rth->dst.rt_next)) {
2642 if (rth->rt_key_dst == flp->fl4_dst && 2642 if (rth->rt_key_dst == flp4->daddr &&
2643 rth->rt_key_src == flp->fl4_src && 2643 rth->rt_key_src == flp4->saddr &&
2644 rt_is_output_route(rth) && 2644 rt_is_output_route(rth) &&
2645 rth->rt_oif == flp->flowi_oif && 2645 rth->rt_oif == flp4->flowi4_oif &&
2646 rth->rt_mark == flp->flowi_mark && 2646 rth->rt_mark == flp4->flowi4_mark &&
2647 !((rth->rt_tos ^ flp->fl4_tos) & 2647 !((rth->rt_tos ^ flp4->flowi4_tos) &
2648 (IPTOS_RT_MASK | RTO_ONLINK)) && 2648 (IPTOS_RT_MASK | RTO_ONLINK)) &&
2649 net_eq(dev_net(rth->dst.dev), net) && 2649 net_eq(dev_net(rth->dst.dev), net) &&
2650 !rt_is_expired(rth)) { 2650 !rt_is_expired(rth)) {
@@ -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
2660slow_output: 2660slow_output:
2661 return ip_route_output_slow(net, &flp->u.ip4); 2661 return ip_route_output_slow(net, flp4);
2662} 2662}
2663EXPORT_SYMBOL_GPL(__ip_route_output_key); 2663EXPORT_SYMBOL_GPL(__ip_route_output_key);
2664 2664
@@ -2733,20 +2733,22 @@ struct dst_entry *ipv4_blackhole_route(struct net *net, struct dst_entry *dst_or
2733 return rt ? &rt->dst : ERR_PTR(-ENOMEM); 2733 return rt ? &rt->dst : ERR_PTR(-ENOMEM);
2734} 2734}
2735 2735
2736struct rtable *ip_route_output_flow(struct net *net, struct flowi *flp, 2736struct rtable *ip_route_output_flow(struct net *net, struct flowi4 *flp4,
2737 struct sock *sk) 2737 struct sock *sk)
2738{ 2738{
2739 struct rtable *rt = __ip_route_output_key(net, flp); 2739 struct rtable *rt = __ip_route_output_key(net, flp4);
2740 2740
2741 if (IS_ERR(rt)) 2741 if (IS_ERR(rt))
2742 return rt; 2742 return rt;
2743 2743
2744 if (flp->flowi_proto) { 2744 if (flp4->flowi4_proto) {
2745 if (!flp->fl4_src) 2745 if (!flp4->saddr)
2746 flp->fl4_src = rt->rt_src; 2746 flp4->saddr = rt->rt_src;
2747 if (!flp->fl4_dst) 2747 if (!flp4->daddr)
2748 flp->fl4_dst = rt->rt_dst; 2748 flp4->daddr = rt->rt_dst;
2749 rt = (struct rtable *) xfrm_lookup(net, &rt->dst, flp, sk, 0); 2749 rt = (struct rtable *) xfrm_lookup(net, &rt->dst,
2750 flowi4_to_flowi(flp4),
2751 sk, 0);
2750 } 2752 }
2751 2753
2752 return rt; 2754 return rt;
@@ -2920,7 +2922,7 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void
2920 .flowi4_oif = tb[RTA_OIF] ? nla_get_u32(tb[RTA_OIF]) : 0, 2922 .flowi4_oif = tb[RTA_OIF] ? nla_get_u32(tb[RTA_OIF]) : 0,
2921 .flowi4_mark = mark, 2923 .flowi4_mark = mark,
2922 }; 2924 };
2923 rt = ip_route_output_key(net, flowi4_to_flowi(&fl4)); 2925 rt = ip_route_output_key(net, &fl4);
2924 2926
2925 err = 0; 2927 err = 0;
2926 if (IS_ERR(rt)) 2928 if (IS_ERR(rt))