aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeal Cardwell <ncardwell@google.com>2012-06-28 08:34:19 -0400
committerDavid S. Miller <davem@davemloft.net>2012-06-28 20:53:50 -0400
commit3840a06e6046aaee95f33a120499d2dc8c054b9d (patch)
tree6a6acc85ad10729f25b4f3ac81f46facf03b978d
parent9247869ee661b046510c19a36cf0d91d9c2639d3 (diff)
tcp: pass fl6 to inet6_csk_route_req()
This commit changes inet_csk_route_req() so that it uses a pointer to a struct flowi6, rather than allocating its own on the stack. This brings its behavior in line with its IPv4 cousin, inet_csk_route_req(), and allows a follow-on patch to fix a dst leak. Signed-off-by: Neal Cardwell <ncardwell@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/net/inet6_connection_sock.h1
-rw-r--r--net/ipv6/inet6_connection_sock.c26
-rw-r--r--net/ipv6/tcp_ipv6.c9
3 files changed, 20 insertions, 16 deletions
diff --git a/include/net/inet6_connection_sock.h b/include/net/inet6_connection_sock.h
index 1866a676c810..df2a857e853d 100644
--- a/include/net/inet6_connection_sock.h
+++ b/include/net/inet6_connection_sock.h
@@ -26,6 +26,7 @@ extern int inet6_csk_bind_conflict(const struct sock *sk,
26 const struct inet_bind_bucket *tb, bool relax); 26 const struct inet_bind_bucket *tb, bool relax);
27 27
28extern struct dst_entry* inet6_csk_route_req(struct sock *sk, 28extern struct dst_entry* inet6_csk_route_req(struct sock *sk,
29 struct flowi6 *fl6,
29 const struct request_sock *req); 30 const struct request_sock *req);
30 31
31extern struct request_sock *inet6_csk_search_req(const struct sock *sk, 32extern struct request_sock *inet6_csk_search_req(const struct sock *sk,
diff --git a/net/ipv6/inet6_connection_sock.c b/net/ipv6/inet6_connection_sock.c
index e23d35424ca9..bceb14450a1d 100644
--- a/net/ipv6/inet6_connection_sock.c
+++ b/net/ipv6/inet6_connection_sock.c
@@ -55,26 +55,26 @@ int inet6_csk_bind_conflict(const struct sock *sk,
55EXPORT_SYMBOL_GPL(inet6_csk_bind_conflict); 55EXPORT_SYMBOL_GPL(inet6_csk_bind_conflict);
56 56
57struct dst_entry *inet6_csk_route_req(struct sock *sk, 57struct dst_entry *inet6_csk_route_req(struct sock *sk,
58 struct flowi6 *fl6,
58 const struct request_sock *req) 59 const struct request_sock *req)
59{ 60{
60 struct inet6_request_sock *treq = inet6_rsk(req); 61 struct inet6_request_sock *treq = inet6_rsk(req);
61 struct ipv6_pinfo *np = inet6_sk(sk); 62 struct ipv6_pinfo *np = inet6_sk(sk);
62 struct in6_addr *final_p, final; 63 struct in6_addr *final_p, final;
63 struct dst_entry *dst; 64 struct dst_entry *dst;
64 struct flowi6 fl6;
65
66 memset(&fl6, 0, sizeof(fl6));
67 fl6.flowi6_proto = IPPROTO_TCP;
68 fl6.daddr = treq->rmt_addr;
69 final_p = fl6_update_dst(&fl6, np->opt, &final);
70 fl6.saddr = treq->loc_addr;
71 fl6.flowi6_oif = treq->iif;
72 fl6.flowi6_mark = sk->sk_mark;
73 fl6.fl6_dport = inet_rsk(req)->rmt_port;
74 fl6.fl6_sport = inet_rsk(req)->loc_port;
75 security_req_classify_flow(req, flowi6_to_flowi(&fl6));
76 65
77 dst = ip6_dst_lookup_flow(sk, &fl6, final_p, false); 66 memset(fl6, 0, sizeof(*fl6));
67 fl6->flowi6_proto = IPPROTO_TCP;
68 fl6->daddr = treq->rmt_addr;
69 final_p = fl6_update_dst(fl6, np->opt, &final);
70 fl6->saddr = treq->loc_addr;
71 fl6->flowi6_oif = treq->iif;
72 fl6->flowi6_mark = sk->sk_mark;
73 fl6->fl6_dport = inet_rsk(req)->rmt_port;
74 fl6->fl6_sport = inet_rsk(req)->loc_port;
75 security_req_classify_flow(req, flowi6_to_flowi(fl6));
76
77 dst = ip6_dst_lookup_flow(sk, fl6, final_p, false);
78 if (IS_ERR(dst)) 78 if (IS_ERR(dst))
79 return NULL; 79 return NULL;
80 80
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index fc0b96bf9051..4e5fa5f6ec68 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -477,7 +477,8 @@ out:
477} 477}
478 478
479 479
480static int tcp_v6_send_synack(struct sock *sk, struct request_sock *req, 480static int tcp_v6_send_synack(struct sock *sk,
481 struct request_sock *req,
481 struct request_values *rvp, 482 struct request_values *rvp,
482 u16 queue_mapping) 483 u16 queue_mapping)
483{ 484{
@@ -1058,6 +1059,7 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
1058 struct tcp_sock *tp = tcp_sk(sk); 1059 struct tcp_sock *tp = tcp_sk(sk);
1059 __u32 isn = TCP_SKB_CB(skb)->when; 1060 __u32 isn = TCP_SKB_CB(skb)->when;
1060 struct dst_entry *dst = NULL; 1061 struct dst_entry *dst = NULL;
1062 struct flowi6 fl6;
1061 bool want_cookie = false; 1063 bool want_cookie = false;
1062 1064
1063 if (skb->protocol == htons(ETH_P_IP)) 1065 if (skb->protocol == htons(ETH_P_IP))
@@ -1177,7 +1179,7 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
1177 */ 1179 */
1178 if (tmp_opt.saw_tstamp && 1180 if (tmp_opt.saw_tstamp &&
1179 tcp_death_row.sysctl_tw_recycle && 1181 tcp_death_row.sysctl_tw_recycle &&
1180 (dst = inet6_csk_route_req(sk, req)) != NULL && 1182 (dst = inet6_csk_route_req(sk, &fl6, req)) != NULL &&
1181 (peer = rt6_get_peer((struct rt6_info *)dst)) != NULL && 1183 (peer = rt6_get_peer((struct rt6_info *)dst)) != NULL &&
1182 ipv6_addr_equal((struct in6_addr *)peer->daddr.addr.a6, 1184 ipv6_addr_equal((struct in6_addr *)peer->daddr.addr.a6,
1183 &treq->rmt_addr)) { 1185 &treq->rmt_addr)) {
@@ -1247,6 +1249,7 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
1247#ifdef CONFIG_TCP_MD5SIG 1249#ifdef CONFIG_TCP_MD5SIG
1248 struct tcp_md5sig_key *key; 1250 struct tcp_md5sig_key *key;
1249#endif 1251#endif
1252 struct flowi6 fl6;
1250 1253
1251 if (skb->protocol == htons(ETH_P_IP)) { 1254 if (skb->protocol == htons(ETH_P_IP)) {
1252 /* 1255 /*
@@ -1309,7 +1312,7 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
1309 goto out_overflow; 1312 goto out_overflow;
1310 1313
1311 if (!dst) { 1314 if (!dst) {
1312 dst = inet6_csk_route_req(sk, req); 1315 dst = inet6_csk_route_req(sk, &fl6, req);
1313 if (!dst) 1316 if (!dst)
1314 goto out; 1317 goto out;
1315 } 1318 }