aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2012-03-18 23:29:41 -0400
committerDavid S. Miller <davem@davemloft.net>2012-03-18 23:29:41 -0400
commit4da0bd736552e6377b407b3c3d3ae518ebbdd269 (patch)
treef0da9f843b8033565c3ca4103fccb17a60688326 /net/ipv4
parent81a430ac1b88b0702c57d2513e247317e810e04d (diff)
parentc16fa4f2ad19908a47c63d8fa436a1178438c7e7 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/syncookies.c30
-rw-r--r--net/ipv4/tcp_ipv4.c10
2 files changed, 23 insertions, 17 deletions
diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c
index 51fdbb490437..eab2a7fb15d1 100644
--- a/net/ipv4/syncookies.c
+++ b/net/ipv4/syncookies.c
@@ -278,6 +278,7 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb,
278 struct rtable *rt; 278 struct rtable *rt;
279 __u8 rcv_wscale; 279 __u8 rcv_wscale;
280 bool ecn_ok = false; 280 bool ecn_ok = false;
281 struct flowi4 fl4;
281 282
282 if (!sysctl_tcp_syncookies || !th->ack || th->rst) 283 if (!sysctl_tcp_syncookies || !th->ack || th->rst)
283 goto out; 284 goto out;
@@ -346,20 +347,16 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb,
346 * hasn't changed since we received the original syn, but I see 347 * hasn't changed since we received the original syn, but I see
347 * no easy way to do this. 348 * no easy way to do this.
348 */ 349 */
349 { 350 flowi4_init_output(&fl4, 0, sk->sk_mark, RT_CONN_FLAGS(sk),
350 struct flowi4 fl4; 351 RT_SCOPE_UNIVERSE, IPPROTO_TCP,
351 352 inet_sk_flowi_flags(sk),
352 flowi4_init_output(&fl4, 0, sk->sk_mark, RT_CONN_FLAGS(sk), 353 (opt && opt->srr) ? opt->faddr : ireq->rmt_addr,
353 RT_SCOPE_UNIVERSE, IPPROTO_TCP, 354 ireq->loc_addr, th->source, th->dest);
354 inet_sk_flowi_flags(sk), 355 security_req_classify_flow(req, flowi4_to_flowi(&fl4));
355 (opt && opt->srr) ? opt->faddr : ireq->rmt_addr, 356 rt = ip_route_output_key(sock_net(sk), &fl4);
356 ireq->loc_addr, th->source, th->dest); 357 if (IS_ERR(rt)) {
357 security_req_classify_flow(req, flowi4_to_flowi(&fl4)); 358 reqsk_free(req);
358 rt = ip_route_output_key(sock_net(sk), &fl4); 359 goto out;
359 if (IS_ERR(rt)) {
360 reqsk_free(req);
361 goto out;
362 }
363 } 360 }
364 361
365 /* Try to redo what tcp_v4_send_synack did. */ 362 /* Try to redo what tcp_v4_send_synack did. */
@@ -373,5 +370,10 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb,
373 ireq->rcv_wscale = rcv_wscale; 370 ireq->rcv_wscale = rcv_wscale;
374 371
375 ret = get_cookie_sock(sk, skb, req, &rt->dst); 372 ret = get_cookie_sock(sk, skb, req, &rt->dst);
373 /* ip_queue_xmit() depends on our flow being setup
374 * Normal sockets get it right from inet_csk_route_child_sock()
375 */
376 if (ret)
377 inet_sk(ret)->cork.fl.u.ip4 = fl4;
376out: return ret; 378out: return ret;
377} 379}
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index fe9f604ed1e2..3a25cf743f8b 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1470,9 +1470,13 @@ struct sock *tcp_v4_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
1470 inet_csk(newsk)->icsk_ext_hdr_len = inet_opt->opt.optlen; 1470 inet_csk(newsk)->icsk_ext_hdr_len = inet_opt->opt.optlen;
1471 newinet->inet_id = newtp->write_seq ^ jiffies; 1471 newinet->inet_id = newtp->write_seq ^ jiffies;
1472 1472
1473 if (!dst && (dst = inet_csk_route_child_sock(sk, newsk, req)) == NULL) 1473 if (!dst) {
1474 goto put_and_exit; 1474 dst = inet_csk_route_child_sock(sk, newsk, req);
1475 1475 if (!dst)
1476 goto put_and_exit;
1477 } else {
1478 /* syncookie case : see end of cookie_v4_check() */
1479 }
1476 sk_setup_caps(newsk, dst); 1480 sk_setup_caps(newsk, dst);
1477 1481
1478 tcp_mtup_init(newsk); 1482 tcp_mtup_init(newsk);