Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
c5dc7491
Commit
c5dc7491
authored
May 27, 2004
by
David S. Miller
Committed by
Dmitry Torokhov
May 27, 2004
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[TCP]: Grow socket receive buffer based upon estimated sender window.
parent
2a1ca0d0
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
0 deletions
+65
-0
include/linux/tcp.h
include/linux/tcp.h
+7
-0
include/net/tcp.h
include/net/tcp.h
+2
-0
net/ipv4/tcp.c
net/ipv4/tcp.c
+5
-0
net/ipv4/tcp_input.c
net/ipv4/tcp_input.c
+51
-0
No files found.
include/linux/tcp.h
View file @
c5dc7491
...
...
@@ -383,6 +383,13 @@ struct tcp_opt {
__u32
time
;
}
rcv_rtt_est
;
/* Receiver queue space */
struct
{
int
space
;
__u32
seq
;
__u32
time
;
}
rcvq_space
;
/* TCP Westwood structure */
struct
{
__u32
bw_ns_est
;
/* first bandwidth estimation..not too smoothed 8) */
...
...
include/net/tcp.h
View file @
c5dc7491
...
...
@@ -801,6 +801,8 @@ extern int tcp_rcv_established(struct sock *sk,
struct
tcphdr
*
th
,
unsigned
len
);
extern
void
tcp_rcv_space_adjust
(
struct
sock
*
sk
);
enum
tcp_ack_state_t
{
TCP_ACK_SCHED
=
1
,
...
...
net/ipv4/tcp.c
View file @
c5dc7491
...
...
@@ -1482,6 +1482,9 @@ int tcp_read_sock(struct sock *sk, read_descriptor_t *desc,
break
;
}
tp
->
copied_seq
=
seq
;
tcp_rcv_space_adjust
(
sk
);
/* Clean up data we have read: This will do ACK frames. */
if
(
copied
)
cleanup_rbuf
(
sk
,
copied
);
...
...
@@ -1742,6 +1745,8 @@ int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
copied
+=
used
;
len
-=
used
;
tcp_rcv_space_adjust
(
sk
);
skip_copy:
if
(
tp
->
urg_data
&&
after
(
tp
->
copied_seq
,
tp
->
urg_seq
))
{
tp
->
urg_data
=
0
;
...
...
net/ipv4/tcp_input.c
View file @
c5dc7491
...
...
@@ -305,6 +305,8 @@ static void tcp_init_buffer_space(struct sock *sk)
if
(
!
(
sk
->
sk_userlocks
&
SOCK_SNDBUF_LOCK
))
tcp_fixup_sndbuf
(
sk
);
tp
->
rcvq_space
.
space
=
tp
->
rcv_wnd
;
maxwin
=
tcp_full_space
(
sk
);
if
(
tp
->
window_clamp
>=
maxwin
)
{
...
...
@@ -431,6 +433,53 @@ static inline void tcp_rcv_rtt_measure_ts(struct tcp_opt *tp, struct sk_buff *sk
tcp_rcv_rtt_update
(
tp
,
tcp_time_stamp
-
tp
->
rcv_tsecr
,
0
);
}
/*
* This function should be called every time data is copied to user space.
* It calculates the appropriate TCP receive buffer space.
*/
void
tcp_rcv_space_adjust
(
struct
sock
*
sk
)
{
struct
tcp_opt
*
tp
=
tcp_sk
(
sk
);
int
time
;
int
space
;
if
(
tp
->
rcvq_space
.
time
==
0
)
goto
new_measure
;
time
=
tcp_time_stamp
-
tp
->
rcvq_space
.
time
;
if
(
time
<
(
tp
->
rcv_rtt_est
.
rtt
>>
3
)
||
tp
->
rcv_rtt_est
.
rtt
==
0
)
return
;
space
=
2
*
(
tp
->
copied_seq
-
tp
->
rcvq_space
.
seq
);
space
=
max
(
tp
->
rcvq_space
.
space
,
space
);
if
(
tp
->
rcvq_space
.
space
!=
space
)
{
int
rcvmem
;
tp
->
rcvq_space
.
space
=
space
;
/* Receive space grows, normalize in order to
* take into account packet headers and sk_buff
* structure overhead.
*/
space
/=
tp
->
advmss
;
if
(
!
space
)
space
=
1
;
rcvmem
=
(
tp
->
advmss
+
MAX_TCP_HEADER
+
16
+
sizeof
(
struct
sk_buff
));
space
*=
rcvmem
;
space
=
min
(
space
,
sysctl_tcp_rmem
[
2
]);
if
(
space
>
sk
->
sk_rcvbuf
)
sk
->
sk_rcvbuf
=
space
;
}
new_measure:
tp
->
rcvq_space
.
seq
=
tp
->
copied_seq
;
tp
->
rcvq_space
.
time
=
tcp_time_stamp
;
}
/* There is something which you must keep in mind when you analyze the
* behavior of the tp->ato delayed ack timeout interval. When a
* connection starts up, we want to ack as quickly as possible. The
...
...
@@ -3387,6 +3436,7 @@ static void tcp_data_queue(struct sock *sk, struct sk_buff *skb)
tp
->
ucopy
.
len
-=
chunk
;
tp
->
copied_seq
+=
chunk
;
eaten
=
(
chunk
==
skb
->
len
&&
!
th
->
fin
);
tcp_rcv_space_adjust
(
sk
);
}
local_bh_disable
();
}
...
...
@@ -3987,6 +4037,7 @@ static int tcp_copy_to_iovec(struct sock *sk, struct sk_buff *skb, int hlen)
if
(
!
err
)
{
tp
->
ucopy
.
len
-=
chunk
;
tp
->
copied_seq
+=
chunk
;
tcp_rcv_space_adjust
(
sk
);
}
local_bh_disable
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment