diff options
author | David S. Miller <davem@davemloft.net> | 2011-05-02 17:37:45 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-05-02 17:37:45 -0400 |
commit | 5615787257742aab42ecf17c11e3244d9536a48d (patch) | |
tree | f9c8a74398964690e3b9583cec99dfc7e7b45511 | |
parent | 14ad2513ed5b709e566a853f4b515d91c5d83311 (diff) |
ipv4: Make sure flowi4->{saddr,daddr} are always set.
Slow path output route resolution always makes sure that
->{saddr,daddr} are set, and also if we trigger into IPSEC resolution
we initialize them as well, because xfrm_lookup() expects them to be
fully resolved.
But if we hit the fast path and flowi4->flowi4_proto is zero, we won't
do this initialization.
Therefore, move the IPSEC path initialization to the route cache
lookup fast path to make sure these are always set.
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/ipv4/route.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 93f71be1d5d1..64f360d853fb 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
@@ -2675,6 +2675,10 @@ struct rtable *__ip_route_output_key(struct net *net, struct flowi4 *flp4) | |||
2675 | dst_use(&rth->dst, jiffies); | 2675 | dst_use(&rth->dst, jiffies); |
2676 | RT_CACHE_STAT_INC(out_hit); | 2676 | RT_CACHE_STAT_INC(out_hit); |
2677 | rcu_read_unlock_bh(); | 2677 | rcu_read_unlock_bh(); |
2678 | if (!flp4->saddr) | ||
2679 | flp4->saddr = rth->rt_src; | ||
2680 | if (!flp4->daddr) | ||
2681 | flp4->daddr = rth->rt_dst; | ||
2678 | return rth; | 2682 | return rth; |
2679 | } | 2683 | } |
2680 | RT_CACHE_STAT_INC(out_hlist_search); | 2684 | RT_CACHE_STAT_INC(out_hlist_search); |
@@ -2772,15 +2776,10 @@ struct rtable *ip_route_output_flow(struct net *net, struct flowi4 *flp4, | |||
2772 | if (IS_ERR(rt)) | 2776 | if (IS_ERR(rt)) |
2773 | return rt; | 2777 | return rt; |
2774 | 2778 | ||
2775 | if (flp4->flowi4_proto) { | 2779 | if (flp4->flowi4_proto) |
2776 | if (!flp4->saddr) | ||
2777 | flp4->saddr = rt->rt_src; | ||
2778 | if (!flp4->daddr) | ||
2779 | flp4->daddr = rt->rt_dst; | ||
2780 | rt = (struct rtable *) xfrm_lookup(net, &rt->dst, | 2780 | rt = (struct rtable *) xfrm_lookup(net, &rt->dst, |
2781 | flowi4_to_flowi(flp4), | 2781 | flowi4_to_flowi(flp4), |
2782 | sk, 0); | 2782 | sk, 0); |
2783 | } | ||
2784 | 2783 | ||
2785 | return rt; | 2784 | return rt; |
2786 | } | 2785 | } |