aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/route.h
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2011-02-24 16:38:12 -0500
committerDavid S. Miller <davem@davemloft.net>2011-02-24 16:38:12 -0500
commitdca8b089c95d94afa1d715df257de0286350e99d (patch)
treef686fef8ef3d80f81bd9f91072ce8c5f347e3e7c /include/net/route.h
parent33765d06033cc4ba4d9ae6d3d606ef3f28773c1b (diff)
ipv4: Rearrange how ip_route_newports() gets port keys.
ip_route_newports() is the only place in the entire kernel that cares about the port members in the routing cache entry's lookup flow key. Therefore the only reason we store an entire flow inside of the struct rtentry is for this one special case. Rewrite ip_route_newports() such that: 1) The caller passes in the original port values, so we don't need to use the rth->fl.fl_ip_{s,d}port values to remember them. 2) The lookup flow is constructed by hand instead of being copied from the routing cache entry's flow. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/route.h')
-rw-r--r--include/net/route.h19
1 files changed, 11 insertions, 8 deletions
diff --git a/include/net/route.h b/include/net/route.h
index bf790c1c6ac8..b3f89ad04e0b 100644
--- a/include/net/route.h
+++ b/include/net/route.h
@@ -200,16 +200,19 @@ static inline int ip_route_connect(struct rtable **rp, __be32 dst,
200} 200}
201 201
202static inline int ip_route_newports(struct rtable **rp, u8 protocol, 202static inline int ip_route_newports(struct rtable **rp, u8 protocol,
203 __be16 orig_sport, __be16 orig_dport,
203 __be16 sport, __be16 dport, struct sock *sk) 204 __be16 sport, __be16 dport, struct sock *sk)
204{ 205{
205 if (sport != (*rp)->fl.fl_ip_sport || 206 if (sport != orig_sport || dport != orig_dport) {
206 dport != (*rp)->fl.fl_ip_dport) { 207 struct flowi fl = { .oif = (*rp)->fl.oif,
207 struct flowi fl; 208 .mark = (*rp)->fl.mark,
208 209 .fl4_dst = (*rp)->fl.fl4_dst,
209 memcpy(&fl, &(*rp)->fl, sizeof(fl)); 210 .fl4_src = (*rp)->fl.fl4_src,
210 fl.fl_ip_sport = sport; 211 .fl4_tos = (*rp)->fl.fl4_tos,
211 fl.fl_ip_dport = dport; 212 .proto = (*rp)->fl.proto,
212 fl.proto = protocol; 213 .fl_ip_sport = sport,
214 .fl_ip_dport = dport };
215
213 if (inet_sk(sk)->transparent) 216 if (inet_sk(sk)->transparent)
214 fl.flags |= FLOWI_FLAG_ANYSRC; 217 fl.flags |= FLOWI_FLAG_ANYSRC;
215 if (protocol == IPPROTO_TCP) 218 if (protocol == IPPROTO_TCP)