syncookies.c (f1673381b1481a409238d4552a0700d490c5b36c) | syncookies.c (f7b3bec6f5167efaf56b756abfafb924cb1d3050) |
---|---|
1/* 2 * Syncookies implementation for the Linux kernel 3 * 4 * Copyright (C) 1997 Andi Kleen 5 * Based on ideas by D.J.Bernstein and Eric Schenk. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License --- 259 unchanged lines hidden (view full) --- 268 tcp_opt->wscale_ok = 1; 269 tcp_opt->snd_wscale = options & TS_OPT_WSCALE_MASK; 270 271 return sysctl_tcp_window_scaling != 0; 272} 273EXPORT_SYMBOL(cookie_timestamp_decode); 274 275bool cookie_ecn_ok(const struct tcp_options_received *tcp_opt, | 1/* 2 * Syncookies implementation for the Linux kernel 3 * 4 * Copyright (C) 1997 Andi Kleen 5 * Based on ideas by D.J.Bernstein and Eric Schenk. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License --- 259 unchanged lines hidden (view full) --- 268 tcp_opt->wscale_ok = 1; 269 tcp_opt->snd_wscale = options & TS_OPT_WSCALE_MASK; 270 271 return sysctl_tcp_window_scaling != 0; 272} 273EXPORT_SYMBOL(cookie_timestamp_decode); 274 275bool cookie_ecn_ok(const struct tcp_options_received *tcp_opt, |
276 const struct net *net) | 276 const struct net *net, const struct dst_entry *dst) |
277{ 278 bool ecn_ok = tcp_opt->rcv_tsecr & TS_OPT_ECN; 279 280 if (!ecn_ok) 281 return false; 282 283 if (net->ipv4.sysctl_tcp_ecn) 284 return true; 285 | 277{ 278 bool ecn_ok = tcp_opt->rcv_tsecr & TS_OPT_ECN; 279 280 if (!ecn_ok) 281 return false; 282 283 if (net->ipv4.sysctl_tcp_ecn) 284 return true; 285 |
286 return false; | 286 return dst_feature(dst, RTAX_FEATURE_ECN); |
287} 288EXPORT_SYMBOL(cookie_ecn_ok); 289 290struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb) 291{ 292 struct ip_options *opt = &TCP_SKB_CB(skb)->header.h4.opt; 293 struct tcp_options_received tcp_opt; 294 struct inet_request_sock *ireq; --- 87 unchanged lines hidden (view full) --- 382 req->window_clamp = tp->window_clamp ? :dst_metric(&rt->dst, RTAX_WINDOW); 383 384 tcp_select_initial_window(tcp_full_space(sk), req->mss, 385 &req->rcv_wnd, &req->window_clamp, 386 ireq->wscale_ok, &rcv_wscale, 387 dst_metric(&rt->dst, RTAX_INITRWND)); 388 389 ireq->rcv_wscale = rcv_wscale; | 287} 288EXPORT_SYMBOL(cookie_ecn_ok); 289 290struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb) 291{ 292 struct ip_options *opt = &TCP_SKB_CB(skb)->header.h4.opt; 293 struct tcp_options_received tcp_opt; 294 struct inet_request_sock *ireq; --- 87 unchanged lines hidden (view full) --- 382 req->window_clamp = tp->window_clamp ? :dst_metric(&rt->dst, RTAX_WINDOW); 383 384 tcp_select_initial_window(tcp_full_space(sk), req->mss, 385 &req->rcv_wnd, &req->window_clamp, 386 ireq->wscale_ok, &rcv_wscale, 387 dst_metric(&rt->dst, RTAX_INITRWND)); 388 389 ireq->rcv_wscale = rcv_wscale; |
390 ireq->ecn_ok = cookie_ecn_ok(&tcp_opt, sock_net(sk)); | 390 ireq->ecn_ok = cookie_ecn_ok(&tcp_opt, sock_net(sk), &rt->dst); |
391 392 ret = get_cookie_sock(sk, skb, req, &rt->dst); 393 /* ip_queue_xmit() depends on our flow being setup 394 * Normal sockets get it right from inet_csk_route_child_sock() 395 */ 396 if (ret) 397 inet_sk(ret)->cork.fl.u.ip4 = fl4; 398out: return ret; 399} | 391 392 ret = get_cookie_sock(sk, skb, req, &rt->dst); 393 /* ip_queue_xmit() depends on our flow being setup 394 * Normal sockets get it right from inet_csk_route_child_sock() 395 */ 396 if (ret) 397 inet_sk(ret)->cork.fl.u.ip4 = fl4; 398out: return ret; 399} |