tcp_output.c (d06a99045837d3f4d5431793c4c390b0daf2a08d) tcp_output.c (ceef9ab6be7234f9e49f79769e0da88d1dccfcc7)
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * Implementation of the Transmission Control Protocol(TCP).
7 *
8 * Authors: Ross Biro

--- 31 unchanged lines hidden (view full) ---

40
41#include <linux/compiler.h>
42#include <linux/gfp.h>
43#include <linux/module.h>
44#include <linux/static_key.h>
45
46#include <trace/events/tcp.h>
47
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * Implementation of the Transmission Control Protocol(TCP).
7 *
8 * Authors: Ross Biro

--- 31 unchanged lines hidden (view full) ---

40
41#include <linux/compiler.h>
42#include <linux/gfp.h>
43#include <linux/module.h>
44#include <linux/static_key.h>
45
46#include <trace/events/tcp.h>
47
48/* People can turn this on to work with those rare, broken TCPs that
49 * interpret the window field as a signed quantity.
50 */
51int sysctl_tcp_workaround_signed_windows __read_mostly = 0;
52
53/* Default TSQ limit of four TSO segments */
54int sysctl_tcp_limit_output_bytes __read_mostly = 262144;
55
56static bool tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle,
57 int push_one, gfp_t gfp);
58
59/* Account for new data that has been sent to the network. */
60static void tcp_event_new_data_sent(struct sock *sk, struct sk_buff *skb)

--- 130 unchanged lines hidden (view full) ---

191
192/* Determine a window scaling and initial window to offer.
193 * Based on the assumption that the given amount of space
194 * will be offered. Store the results in the tp structure.
195 * NOTE: for smooth operation initial space offering should
196 * be a multiple of mss if possible. We assume here that mss >= 1.
197 * This MUST be enforced by all callers.
198 */
48/* Default TSQ limit of four TSO segments */
49int sysctl_tcp_limit_output_bytes __read_mostly = 262144;
50
51static bool tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle,
52 int push_one, gfp_t gfp);
53
54/* Account for new data that has been sent to the network. */
55static void tcp_event_new_data_sent(struct sock *sk, struct sk_buff *skb)

--- 130 unchanged lines hidden (view full) ---

186
187/* Determine a window scaling and initial window to offer.
188 * Based on the assumption that the given amount of space
189 * will be offered. Store the results in the tp structure.
190 * NOTE: for smooth operation initial space offering should
191 * be a multiple of mss if possible. We assume here that mss >= 1.
192 * This MUST be enforced by all callers.
193 */
199void tcp_select_initial_window(int __space, __u32 mss,
194void tcp_select_initial_window(const struct sock *sk, int __space, __u32 mss,
200 __u32 *rcv_wnd, __u32 *window_clamp,
201 int wscale_ok, __u8 *rcv_wscale,
202 __u32 init_rcv_wnd)
203{
204 unsigned int space = (__space < 0 ? 0 : __space);
205
206 /* If no clamp set the clamp to the max possible scaled window */
207 if (*window_clamp == 0)

--- 7 unchanged lines hidden (view full) ---

215 /* NOTE: offering an initial window larger than 32767
216 * will break some buggy TCP stacks. If the admin tells us
217 * it is likely we could be speaking with such a buggy stack
218 * we will truncate our initial window offering to 32K-1
219 * unless the remote has sent us a window scaling option,
220 * which we interpret as a sign the remote TCP is not
221 * misinterpreting the window field as a signed quantity.
222 */
195 __u32 *rcv_wnd, __u32 *window_clamp,
196 int wscale_ok, __u8 *rcv_wscale,
197 __u32 init_rcv_wnd)
198{
199 unsigned int space = (__space < 0 ? 0 : __space);
200
201 /* If no clamp set the clamp to the max possible scaled window */
202 if (*window_clamp == 0)

--- 7 unchanged lines hidden (view full) ---

210 /* NOTE: offering an initial window larger than 32767
211 * will break some buggy TCP stacks. If the admin tells us
212 * it is likely we could be speaking with such a buggy stack
213 * we will truncate our initial window offering to 32K-1
214 * unless the remote has sent us a window scaling option,
215 * which we interpret as a sign the remote TCP is not
216 * misinterpreting the window field as a signed quantity.
217 */
223 if (sysctl_tcp_workaround_signed_windows)
218 if (sock_net(sk)->ipv4.sysctl_tcp_workaround_signed_windows)
224 (*rcv_wnd) = min(space, MAX_TCP_WINDOW);
225 else
226 (*rcv_wnd) = space;
227
228 (*rcv_wscale) = 0;
229 if (wscale_ok) {
230 /* Set window scaling on max possible window */
231 space = max_t(u32, space, sysctl_tcp_rmem[2]);

--- 43 unchanged lines hidden (view full) ---

275 new_win = ALIGN(cur_win, 1 << tp->rx_opt.rcv_wscale);
276 }
277 tp->rcv_wnd = new_win;
278 tp->rcv_wup = tp->rcv_nxt;
279
280 /* Make sure we do not exceed the maximum possible
281 * scaled window.
282 */
219 (*rcv_wnd) = min(space, MAX_TCP_WINDOW);
220 else
221 (*rcv_wnd) = space;
222
223 (*rcv_wscale) = 0;
224 if (wscale_ok) {
225 /* Set window scaling on max possible window */
226 space = max_t(u32, space, sysctl_tcp_rmem[2]);

--- 43 unchanged lines hidden (view full) ---

270 new_win = ALIGN(cur_win, 1 << tp->rx_opt.rcv_wscale);
271 }
272 tp->rcv_wnd = new_win;
273 tp->rcv_wup = tp->rcv_nxt;
274
275 /* Make sure we do not exceed the maximum possible
276 * scaled window.
277 */
283 if (!tp->rx_opt.rcv_wscale && sysctl_tcp_workaround_signed_windows)
278 if (!tp->rx_opt.rcv_wscale &&
279 sock_net(sk)->ipv4.sysctl_tcp_workaround_signed_windows)
284 new_win = min(new_win, MAX_TCP_WINDOW);
285 else
286 new_win = min(new_win, (65535U << tp->rx_opt.rcv_wscale));
287
288 /* RFC1323 scaling applied */
289 new_win >>= tp->rx_opt.rcv_wscale;
290
291 /* If we advertise zero window, disable fast path. */

--- 3052 unchanged lines hidden (view full) ---

3344 if (sk->sk_userlocks & SOCK_RCVBUF_LOCK &&
3345 (tp->window_clamp > tcp_full_space(sk) || tp->window_clamp == 0))
3346 tp->window_clamp = tcp_full_space(sk);
3347
3348 rcv_wnd = tcp_rwnd_init_bpf(sk);
3349 if (rcv_wnd == 0)
3350 rcv_wnd = dst_metric(dst, RTAX_INITRWND);
3351
280 new_win = min(new_win, MAX_TCP_WINDOW);
281 else
282 new_win = min(new_win, (65535U << tp->rx_opt.rcv_wscale));
283
284 /* RFC1323 scaling applied */
285 new_win >>= tp->rx_opt.rcv_wscale;
286
287 /* If we advertise zero window, disable fast path. */

--- 3052 unchanged lines hidden (view full) ---

3340 if (sk->sk_userlocks & SOCK_RCVBUF_LOCK &&
3341 (tp->window_clamp > tcp_full_space(sk) || tp->window_clamp == 0))
3342 tp->window_clamp = tcp_full_space(sk);
3343
3344 rcv_wnd = tcp_rwnd_init_bpf(sk);
3345 if (rcv_wnd == 0)
3346 rcv_wnd = dst_metric(dst, RTAX_INITRWND);
3347
3352 tcp_select_initial_window(tcp_full_space(sk),
3348 tcp_select_initial_window(sk, tcp_full_space(sk),
3353 tp->advmss - (tp->rx_opt.ts_recent_stamp ? tp->tcp_header_len - sizeof(struct tcphdr) : 0),
3354 &tp->rcv_wnd,
3355 &tp->window_clamp,
3356 sock_net(sk)->ipv4.sysctl_tcp_window_scaling,
3357 &rcv_wscale,
3358 rcv_wnd);
3359
3360 tp->rx_opt.rcv_wscale = rcv_wscale;

--- 428 unchanged lines hidden ---
3349 tp->advmss - (tp->rx_opt.ts_recent_stamp ? tp->tcp_header_len - sizeof(struct tcphdr) : 0),
3350 &tp->rcv_wnd,
3351 &tp->window_clamp,
3352 sock_net(sk)->ipv4.sysctl_tcp_window_scaling,
3353 &rcv_wscale,
3354 rcv_wnd);
3355
3356 tp->rx_opt.rcv_wscale = rcv_wscale;

--- 428 unchanged lines hidden ---