diff options
author | David S. Miller <davem@davemloft.net> | 2010-11-11 20:07:48 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-11-11 20:07:48 -0500 |
commit | c753796769e4fb0cd813b6e5801b3c01f4681d4f (patch) | |
tree | f137ec0b76593a2aa1a6a263bcc1e4cf82bdf7b5 /net/ipv4/route.c | |
parent | ed1deb7021b4dfee1d544b91edff4ef92f5c3b54 (diff) |
ipv4: Make rt->fl.iif tests lest obscure.
When we test rt->fl.iif against zero, we're seeing if it's
an output or an input route.
Make that explicit with some helper functions.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/route.c')
-rw-r--r-- | net/ipv4/route.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 5955965c7953..66610ea3c87b 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
@@ -623,7 +623,7 @@ static inline int rt_fast_clean(struct rtable *rth) | |||
623 | /* Kill broadcast/multicast entries very aggresively, if they | 623 | /* Kill broadcast/multicast entries very aggresively, if they |
624 | collide in hash table with more useful entries */ | 624 | collide in hash table with more useful entries */ |
625 | return (rth->rt_flags & (RTCF_BROADCAST | RTCF_MULTICAST)) && | 625 | return (rth->rt_flags & (RTCF_BROADCAST | RTCF_MULTICAST)) && |
626 | rth->fl.iif && rth->dst.rt_next; | 626 | rt_is_input_route(rth) && rth->dst.rt_next; |
627 | } | 627 | } |
628 | 628 | ||
629 | static inline int rt_valuable(struct rtable *rth) | 629 | static inline int rt_valuable(struct rtable *rth) |
@@ -668,7 +668,7 @@ static inline u32 rt_score(struct rtable *rt) | |||
668 | if (rt_valuable(rt)) | 668 | if (rt_valuable(rt)) |
669 | score |= (1<<31); | 669 | score |= (1<<31); |
670 | 670 | ||
671 | if (!rt->fl.iif || | 671 | if (rt_is_output_route(rt) || |
672 | !(rt->rt_flags & (RTCF_BROADCAST|RTCF_MULTICAST|RTCF_LOCAL))) | 672 | !(rt->rt_flags & (RTCF_BROADCAST|RTCF_MULTICAST|RTCF_LOCAL))) |
673 | score |= (1<<30); | 673 | score |= (1<<30); |
674 | 674 | ||
@@ -1126,7 +1126,7 @@ restart: | |||
1126 | */ | 1126 | */ |
1127 | 1127 | ||
1128 | rt->dst.flags |= DST_NOCACHE; | 1128 | rt->dst.flags |= DST_NOCACHE; |
1129 | if (rt->rt_type == RTN_UNICAST || rt->fl.iif == 0) { | 1129 | if (rt->rt_type == RTN_UNICAST || rt_is_output_route(rt)) { |
1130 | int err = arp_bind_neighbour(&rt->dst); | 1130 | int err = arp_bind_neighbour(&rt->dst); |
1131 | if (err) { | 1131 | if (err) { |
1132 | if (net_ratelimit()) | 1132 | if (net_ratelimit()) |
@@ -1224,7 +1224,7 @@ restart: | |||
1224 | /* Try to bind route to arp only if it is output | 1224 | /* Try to bind route to arp only if it is output |
1225 | route or unicast forwarding path. | 1225 | route or unicast forwarding path. |
1226 | */ | 1226 | */ |
1227 | if (rt->rt_type == RTN_UNICAST || rt->fl.iif == 0) { | 1227 | if (rt->rt_type == RTN_UNICAST || rt_is_output_route(rt)) { |
1228 | int err = arp_bind_neighbour(&rt->dst); | 1228 | int err = arp_bind_neighbour(&rt->dst); |
1229 | if (err) { | 1229 | if (err) { |
1230 | spin_unlock_bh(rt_hash_lock_addr(hash)); | 1230 | spin_unlock_bh(rt_hash_lock_addr(hash)); |
@@ -1406,7 +1406,7 @@ void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw, | |||
1406 | if (rth->fl.fl4_dst != daddr || | 1406 | if (rth->fl.fl4_dst != daddr || |
1407 | rth->fl.fl4_src != skeys[i] || | 1407 | rth->fl.fl4_src != skeys[i] || |
1408 | rth->fl.oif != ikeys[k] || | 1408 | rth->fl.oif != ikeys[k] || |
1409 | rth->fl.iif != 0 || | 1409 | rt_is_input_route(rth) || |
1410 | rt_is_expired(rth) || | 1410 | rt_is_expired(rth) || |
1411 | !net_eq(dev_net(rth->dst.dev), net)) { | 1411 | !net_eq(dev_net(rth->dst.dev), net)) { |
1412 | rthp = &rth->dst.rt_next; | 1412 | rthp = &rth->dst.rt_next; |
@@ -1666,7 +1666,7 @@ unsigned short ip_rt_frag_needed(struct net *net, struct iphdr *iph, | |||
1666 | rth->rt_dst != daddr || | 1666 | rth->rt_dst != daddr || |
1667 | rth->rt_src != iph->saddr || | 1667 | rth->rt_src != iph->saddr || |
1668 | rth->fl.oif != ikeys[k] || | 1668 | rth->fl.oif != ikeys[k] || |
1669 | rth->fl.iif != 0 || | 1669 | rt_is_input_route(rth) || |
1670 | dst_metric_locked(&rth->dst, RTAX_MTU) || | 1670 | dst_metric_locked(&rth->dst, RTAX_MTU) || |
1671 | !net_eq(dev_net(rth->dst.dev), net) || | 1671 | !net_eq(dev_net(rth->dst.dev), net) || |
1672 | rt_is_expired(rth)) | 1672 | rt_is_expired(rth)) |
@@ -1770,7 +1770,7 @@ void ip_rt_get_source(u8 *addr, struct rtable *rt) | |||
1770 | __be32 src; | 1770 | __be32 src; |
1771 | struct fib_result res; | 1771 | struct fib_result res; |
1772 | 1772 | ||
1773 | if (rt->fl.iif == 0) | 1773 | if (rt_is_output_route(rt)) |
1774 | src = rt->rt_src; | 1774 | src = rt->rt_src; |
1775 | else { | 1775 | else { |
1776 | rcu_read_lock(); | 1776 | rcu_read_lock(); |
@@ -2669,7 +2669,7 @@ int __ip_route_output_key(struct net *net, struct rtable **rp, | |||
2669 | rth = rcu_dereference_bh(rth->dst.rt_next)) { | 2669 | rth = rcu_dereference_bh(rth->dst.rt_next)) { |
2670 | if (rth->fl.fl4_dst == flp->fl4_dst && | 2670 | if (rth->fl.fl4_dst == flp->fl4_dst && |
2671 | rth->fl.fl4_src == flp->fl4_src && | 2671 | rth->fl.fl4_src == flp->fl4_src && |
2672 | rth->fl.iif == 0 && | 2672 | rt_is_output_route(rth) && |
2673 | rth->fl.oif == flp->oif && | 2673 | rth->fl.oif == flp->oif && |
2674 | rth->fl.mark == flp->mark && | 2674 | rth->fl.mark == flp->mark && |
2675 | !((rth->fl.fl4_tos ^ flp->fl4_tos) & | 2675 | !((rth->fl.fl4_tos ^ flp->fl4_tos) & |
@@ -2824,7 +2824,7 @@ static int rt_fill_info(struct net *net, | |||
2824 | if (rt->dst.tclassid) | 2824 | if (rt->dst.tclassid) |
2825 | NLA_PUT_U32(skb, RTA_FLOW, rt->dst.tclassid); | 2825 | NLA_PUT_U32(skb, RTA_FLOW, rt->dst.tclassid); |
2826 | #endif | 2826 | #endif |
2827 | if (rt->fl.iif) | 2827 | if (rt_is_input_route(rt)) |
2828 | NLA_PUT_BE32(skb, RTA_PREFSRC, rt->rt_spec_dst); | 2828 | NLA_PUT_BE32(skb, RTA_PREFSRC, rt->rt_spec_dst); |
2829 | else if (rt->rt_src != rt->fl.fl4_src) | 2829 | else if (rt->rt_src != rt->fl.fl4_src) |
2830 | NLA_PUT_BE32(skb, RTA_PREFSRC, rt->rt_src); | 2830 | NLA_PUT_BE32(skb, RTA_PREFSRC, rt->rt_src); |
@@ -2849,7 +2849,7 @@ static int rt_fill_info(struct net *net, | |||
2849 | } | 2849 | } |
2850 | } | 2850 | } |
2851 | 2851 | ||
2852 | if (rt->fl.iif) { | 2852 | if (rt_is_input_route(rt)) { |
2853 | #ifdef CONFIG_IP_MROUTE | 2853 | #ifdef CONFIG_IP_MROUTE |
2854 | __be32 dst = rt->rt_dst; | 2854 | __be32 dst = rt->rt_dst; |
2855 | 2855 | ||