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
Kirill Smelkov
linux
Commits
7ab50771
Commit
7ab50771
authored
Jun 23, 2004
by
David S. Miller
Browse files
Options
Browse Files
Download
Plain Diff
Merge
bk://kernel.bkbits.net/acme/net-2.6
into nuts.davemloft.net:/disk1/BK/net-2.6
parents
6ea12222
50bde7d0
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
191 additions
and
139 deletions
+191
-139
include/net/sock.h
include/net/sock.h
+62
-6
include/net/tcp.h
include/net/tcp.h
+7
-46
net/core/stream.c
net/core/stream.c
+13
-13
net/ipv4/proc.c
net/ipv4/proc.c
+2
-2
net/ipv4/sysctl_net_ipv4.c
net/ipv4/sysctl_net_ipv4.c
+6
-6
net/ipv4/tcp.c
net/ipv4/tcp.c
+42
-16
net/ipv4/tcp_input.c
net/ipv4/tcp_input.c
+14
-18
net/ipv4/tcp_ipv4.c
net/ipv4/tcp_ipv4.c
+12
-7
net/ipv4/tcp_minisocks.c
net/ipv4/tcp_minisocks.c
+1
-1
net/ipv4/tcp_output.c
net/ipv4/tcp_output.c
+1
-1
net/ipv4/tcp_timer.c
net/ipv4/tcp_timer.c
+1
-1
net/ipv6/tcp_ipv6.c
net/ipv6/tcp_ipv6.c
+30
-22
No files found.
include/net/sock.h
View file @
7ab50771
...
...
@@ -541,18 +541,19 @@ struct proto {
/* Memory pressure */
void
(
*
enter_memory_pressure
)(
void
);
atomic_t
memory_allocated
;
/* Current allocated memory. */
atomic_t
sockets_allocated
;
/* Current number of sockets. */
atomic_t
*
memory_allocated
;
/* Current allocated memory. */
atomic_t
*
sockets_allocated
;
/* Current number of sockets. */
/*
* Pressure flag: try to collapse.
* Technical note: it is used by multiple contexts non atomically.
* All the sk_stream_mem_schedule() is of this nature: accounting
* is strict, actions are advisory and have some latency.
*/
int
memory_pressure
;
int
sysctl_mem
[
3
];
int
sysctl_wmem
[
3
];
int
sysctl_rmem
[
3
];
int
*
memory_pressure
;
int
*
sysctl_mem
;
int
*
sysctl_wmem
;
int
*
sysctl_rmem
;
int
max_header
;
char
name
[
32
];
...
...
@@ -660,6 +661,21 @@ static inline void sk_stream_mem_reclaim(struct sock *sk)
__sk_stream_mem_reclaim
(
sk
);
}
static
inline
void
sk_stream_writequeue_purge
(
struct
sock
*
sk
)
{
struct
sk_buff
*
skb
;
while
((
skb
=
__skb_dequeue
(
&
sk
->
sk_write_queue
))
!=
NULL
)
sk_stream_free_skb
(
sk
,
skb
);
sk_stream_mem_reclaim
(
sk
);
}
static
inline
int
sk_stream_rmem_schedule
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
return
(
int
)
skb
->
truesize
<=
sk
->
sk_forward_alloc
||
sk_stream_mem_schedule
(
sk
,
skb
->
truesize
,
1
);
}
/* Used by processes to "lock" a socket state, so that
* interrupts and bottom half handlers won't change it
* from under us. It essentially blocks any incoming
...
...
@@ -1141,6 +1157,46 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
}
}
static
inline
struct
sk_buff
*
sk_stream_alloc_pskb
(
struct
sock
*
sk
,
int
size
,
int
mem
,
int
gfp
)
{
struct
sk_buff
*
skb
=
alloc_skb
(
size
+
sk
->
sk_prot
->
max_header
,
gfp
);
if
(
skb
)
{
skb
->
truesize
+=
mem
;
if
(
sk
->
sk_forward_alloc
>=
(
int
)
skb
->
truesize
||
sk_stream_mem_schedule
(
sk
,
skb
->
truesize
,
0
))
{
skb_reserve
(
skb
,
sk
->
sk_prot
->
max_header
);
return
skb
;
}
__kfree_skb
(
skb
);
}
else
{
sk
->
sk_prot
->
enter_memory_pressure
();
sk_stream_moderate_sndbuf
(
sk
);
}
return
NULL
;
}
static
inline
struct
sk_buff
*
sk_stream_alloc_skb
(
struct
sock
*
sk
,
int
size
,
int
gfp
)
{
return
sk_stream_alloc_pskb
(
sk
,
size
,
0
,
gfp
);
}
static
inline
struct
page
*
sk_stream_alloc_page
(
struct
sock
*
sk
)
{
struct
page
*
page
=
NULL
;
if
(
sk
->
sk_forward_alloc
>=
(
int
)
PAGE_SIZE
||
sk_stream_mem_schedule
(
sk
,
PAGE_SIZE
,
0
))
page
=
alloc_pages
(
sk
->
sk_allocation
,
0
);
else
{
sk
->
sk_prot
->
enter_memory_pressure
();
sk_stream_moderate_sndbuf
(
sk
);
}
return
page
;
}
#define sk_stream_for_retrans_queue(skb, sk) \
for (skb = (sk)->sk_write_queue.next; \
(skb != (sk)->sk_send_head) && \
...
...
include/net/tcp.h
View file @
7ab50771
...
...
@@ -594,6 +594,9 @@ extern int sysctl_tcp_fack;
extern
int
sysctl_tcp_reordering
;
extern
int
sysctl_tcp_ecn
;
extern
int
sysctl_tcp_dsack
;
extern
int
sysctl_tcp_mem
[
3
];
extern
int
sysctl_tcp_wmem
[
3
];
extern
int
sysctl_tcp_rmem
[
3
];
extern
int
sysctl_tcp_app_win
;
extern
int
sysctl_tcp_adv_win_scale
;
extern
int
sysctl_tcp_tw_reuse
;
...
...
@@ -611,6 +614,10 @@ extern int sysctl_tcp_bic_low_window;
extern
int
sysctl_tcp_default_win_scale
;
extern
int
sysctl_tcp_moderate_rcvbuf
;
extern
atomic_t
tcp_memory_allocated
;
extern
atomic_t
tcp_sockets_allocated
;
extern
int
tcp_memory_pressure
;
struct
open_request
;
struct
or_calltable
{
...
...
@@ -1862,52 +1869,6 @@ static __inline__ void tcp_openreq_init(struct open_request *req,
extern
void
tcp_enter_memory_pressure
(
void
);
static
inline
struct
sk_buff
*
tcp_alloc_pskb
(
struct
sock
*
sk
,
int
size
,
int
mem
,
int
gfp
)
{
struct
sk_buff
*
skb
=
alloc_skb
(
size
+
MAX_TCP_HEADER
,
gfp
);
if
(
skb
)
{
skb
->
truesize
+=
mem
;
if
(
sk
->
sk_forward_alloc
>=
(
int
)
skb
->
truesize
||
sk_stream_mem_schedule
(
sk
,
skb
->
truesize
,
0
))
{
skb_reserve
(
skb
,
MAX_TCP_HEADER
);
return
skb
;
}
__kfree_skb
(
skb
);
}
else
{
tcp_enter_memory_pressure
();
sk_stream_moderate_sndbuf
(
sk
);
}
return
NULL
;
}
static
inline
struct
sk_buff
*
tcp_alloc_skb
(
struct
sock
*
sk
,
int
size
,
int
gfp
)
{
return
tcp_alloc_pskb
(
sk
,
size
,
0
,
gfp
);
}
static
inline
struct
page
*
tcp_alloc_page
(
struct
sock
*
sk
)
{
if
(
sk
->
sk_forward_alloc
>=
(
int
)
PAGE_SIZE
||
sk_stream_mem_schedule
(
sk
,
PAGE_SIZE
,
0
))
{
struct
page
*
page
=
alloc_pages
(
sk
->
sk_allocation
,
0
);
if
(
page
)
return
page
;
}
tcp_enter_memory_pressure
();
sk_stream_moderate_sndbuf
(
sk
);
return
NULL
;
}
static
inline
void
tcp_writequeue_purge
(
struct
sock
*
sk
)
{
struct
sk_buff
*
skb
;
while
((
skb
=
__skb_dequeue
(
&
sk
->
sk_write_queue
))
!=
NULL
)
sk_stream_free_skb
(
sk
,
skb
);
sk_stream_mem_reclaim
(
sk
);
}
extern
void
tcp_listen_wlock
(
void
);
/* - We may sleep inside this lock.
...
...
net/core/stream.c
View file @
7ab50771
...
...
@@ -193,12 +193,12 @@ void __sk_stream_mem_reclaim(struct sock *sk)
{
if
(
sk
->
sk_forward_alloc
>=
SK_STREAM_MEM_QUANTUM
)
{
atomic_sub
(
sk
->
sk_forward_alloc
/
SK_STREAM_MEM_QUANTUM
,
&
sk
->
sk_prot
->
memory_allocated
);
sk
->
sk_prot
->
memory_allocated
);
sk
->
sk_forward_alloc
&=
SK_STREAM_MEM_QUANTUM
-
1
;
if
(
sk
->
sk_prot
->
memory_pressure
&&
(
atomic_read
(
&
sk
->
sk_prot
->
memory_allocated
)
<
if
(
*
sk
->
sk_prot
->
memory_pressure
&&
(
atomic_read
(
sk
->
sk_prot
->
memory_allocated
)
<
sk
->
sk_prot
->
sysctl_mem
[
0
]))
sk
->
sk_prot
->
memory_pressure
=
0
;
*
sk
->
sk_prot
->
memory_pressure
=
0
;
}
}
...
...
@@ -209,23 +209,23 @@ int sk_stream_mem_schedule(struct sock *sk, int size, int kind)
int
amt
=
sk_stream_pages
(
size
);
sk
->
sk_forward_alloc
+=
amt
*
SK_STREAM_MEM_QUANTUM
;
atomic_add
(
amt
,
&
sk
->
sk_prot
->
memory_allocated
);
atomic_add
(
amt
,
sk
->
sk_prot
->
memory_allocated
);
/* Under limit. */
if
(
atomic_read
(
&
sk
->
sk_prot
->
memory_allocated
)
<
sk
->
sk_prot
->
sysctl_mem
[
0
])
{
if
(
sk
->
sk_prot
->
memory_pressure
)
sk
->
sk_prot
->
memory_pressure
=
0
;
if
(
atomic_read
(
sk
->
sk_prot
->
memory_allocated
)
<
sk
->
sk_prot
->
sysctl_mem
[
0
])
{
if
(
*
sk
->
sk_prot
->
memory_pressure
)
*
sk
->
sk_prot
->
memory_pressure
=
0
;
return
1
;
}
/* Over hard limit. */
if
(
atomic_read
(
&
sk
->
sk_prot
->
memory_allocated
)
>
sk
->
sk_prot
->
sysctl_mem
[
2
])
{
if
(
atomic_read
(
sk
->
sk_prot
->
memory_allocated
)
>
sk
->
sk_prot
->
sysctl_mem
[
2
])
{
sk
->
sk_prot
->
enter_memory_pressure
();
goto
suppress_allocation
;
}
/* Under pressure. */
if
(
atomic_read
(
&
sk
->
sk_prot
->
memory_allocated
)
>
sk
->
sk_prot
->
sysctl_mem
[
1
])
if
(
atomic_read
(
sk
->
sk_prot
->
memory_allocated
)
>
sk
->
sk_prot
->
sysctl_mem
[
1
])
sk
->
sk_prot
->
enter_memory_pressure
();
if
(
kind
)
{
...
...
@@ -234,8 +234,8 @@ int sk_stream_mem_schedule(struct sock *sk, int size, int kind)
}
else
if
(
sk
->
sk_wmem_queued
<
sk
->
sk_prot
->
sysctl_wmem
[
0
])
return
1
;
if
(
!
sk
->
sk_prot
->
memory_pressure
||
sk
->
sk_prot
->
sysctl_mem
[
2
]
>
atomic_read
(
&
sk
->
sk_prot
->
sockets_allocated
)
*
if
(
!
*
sk
->
sk_prot
->
memory_pressure
||
sk
->
sk_prot
->
sysctl_mem
[
2
]
>
atomic_read
(
sk
->
sk_prot
->
sockets_allocated
)
*
sk_stream_pages
(
sk
->
sk_wmem_queued
+
atomic_read
(
&
sk
->
sk_rmem_alloc
)
+
sk
->
sk_forward_alloc
))
...
...
@@ -255,7 +255,7 @@ int sk_stream_mem_schedule(struct sock *sk, int size, int kind)
/* Alas. Undo changes. */
sk
->
sk_forward_alloc
-=
amt
*
SK_STREAM_MEM_QUANTUM
;
atomic_sub
(
amt
,
&
sk
->
sk_prot
->
memory_allocated
);
atomic_sub
(
amt
,
sk
->
sk_prot
->
memory_allocated
);
return
0
;
}
...
...
net/ipv4/proc.c
View file @
7ab50771
...
...
@@ -65,8 +65,8 @@ static int sockstat_seq_show(struct seq_file *seq, void *v)
socket_seq_show
(
seq
);
seq_printf
(
seq
,
"TCP: inuse %d orphan %d tw %d alloc %d mem %d
\n
"
,
fold_prot_inuse
(
&
tcp_prot
),
atomic_read
(
&
tcp_orphan_count
),
tcp_tw_count
,
atomic_read
(
&
tcp_
prot
.
sockets_allocated
),
atomic_read
(
&
tcp_
prot
.
memory_allocated
));
tcp_tw_count
,
atomic_read
(
&
tcp_sockets_allocated
),
atomic_read
(
&
tcp_memory_allocated
));
seq_printf
(
seq
,
"UDP: inuse %d
\n
"
,
fold_prot_inuse
(
&
udp_prot
));
seq_printf
(
seq
,
"RAW: inuse %d
\n
"
,
fold_prot_inuse
(
&
raw_prot
));
seq_printf
(
seq
,
"FRAG: inuse %d memory %d
\n
"
,
ip_frag_nqueues
,
...
...
net/ipv4/sysctl_net_ipv4.c
View file @
7ab50771
...
...
@@ -508,24 +508,24 @@ ctl_table ipv4_table[] = {
{
.
ctl_name
=
NET_TCP_MEM
,
.
procname
=
"tcp_mem"
,
.
data
=
&
tcp_prot
.
sysctl
_mem
,
.
maxlen
=
sizeof
(
tcp_prot
.
sysctl
_mem
),
.
data
=
&
sysctl_tcp
_mem
,
.
maxlen
=
sizeof
(
sysctl_tcp
_mem
),
.
mode
=
0644
,
.
proc_handler
=
&
proc_dointvec
},
{
.
ctl_name
=
NET_TCP_WMEM
,
.
procname
=
"tcp_wmem"
,
.
data
=
&
tcp_prot
.
sysctl
_wmem
,
.
maxlen
=
sizeof
(
tcp_prot
.
sysctl
_wmem
),
.
data
=
&
sysctl_tcp
_wmem
,
.
maxlen
=
sizeof
(
sysctl_tcp
_wmem
),
.
mode
=
0644
,
.
proc_handler
=
&
proc_dointvec
},
{
.
ctl_name
=
NET_TCP_RMEM
,
.
procname
=
"tcp_rmem"
,
.
data
=
&
tcp_prot
.
sysctl
_rmem
,
.
maxlen
=
sizeof
(
tcp_prot
.
sysctl
_rmem
),
.
data
=
&
sysctl_tcp
_rmem
,
.
maxlen
=
sizeof
(
sysctl_tcp
_rmem
),
.
mode
=
0644
,
.
proc_handler
=
&
proc_dointvec
},
...
...
net/ipv4/tcp.c
View file @
7ab50771
...
...
@@ -278,14 +278,40 @@ atomic_t tcp_orphan_count = ATOMIC_INIT(0);
int
sysctl_tcp_default_win_scale
=
7
;
int
sysctl_tcp_mem
[
3
];
int
sysctl_tcp_wmem
[
3
]
=
{
4
*
1024
,
16
*
1024
,
128
*
1024
};
int
sysctl_tcp_rmem
[
3
]
=
{
4
*
1024
,
87380
,
87380
*
2
};
EXPORT_SYMBOL
(
sysctl_tcp_mem
);
EXPORT_SYMBOL
(
sysctl_tcp_rmem
);
EXPORT_SYMBOL
(
sysctl_tcp_wmem
);
atomic_t
tcp_memory_allocated
;
/* Current allocated memory. */
atomic_t
tcp_sockets_allocated
;
/* Current number of TCP sockets. */
EXPORT_SYMBOL
(
tcp_memory_allocated
);
EXPORT_SYMBOL
(
tcp_sockets_allocated
);
/*
* Pressure flag: try to collapse.
* Technical note: it is used by multiple contexts non atomically.
* All the sk_stream_mem_schedule() is of this nature: accounting
* is strict, actions are advisory and have some latency.
*/
int
tcp_memory_pressure
;
EXPORT_SYMBOL
(
tcp_memory_pressure
);
void
tcp_enter_memory_pressure
(
void
)
{
if
(
!
tcp_
prot
.
memory_pressure
)
{
if
(
!
tcp_memory_pressure
)
{
NET_INC_STATS
(
TCPMemoryPressures
);
tcp_
prot
.
memory_pressure
=
1
;
tcp_memory_pressure
=
1
;
}
}
EXPORT_SYMBOL
(
tcp_enter_memory_pressure
);
/*
* LISTEN is a special case for poll..
*/
...
...
@@ -639,8 +665,8 @@ static ssize_t do_tcp_sendpages(struct sock *sk, struct page **pages, int poffse
if
(
!
sk_stream_memory_free
(
sk
))
goto
wait_for_sndbuf
;
skb
=
tcp
_alloc_pskb
(
sk
,
0
,
tp
->
mss_cache
,
sk
->
sk_allocation
);
skb
=
sk_stream
_alloc_pskb
(
sk
,
0
,
tp
->
mss_cache
,
sk
->
sk_allocation
);
if
(
!
skb
)
goto
wait_for_memory
;
...
...
@@ -806,8 +832,8 @@ int tcp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
if
(
!
sk_stream_memory_free
(
sk
))
goto
wait_for_sndbuf
;
skb
=
tcp
_alloc_pskb
(
sk
,
select_size
(
sk
,
tp
),
0
,
sk
->
sk_allocation
);
skb
=
sk_stream
_alloc_pskb
(
sk
,
select_size
(
sk
,
tp
),
0
,
sk
->
sk_allocation
);
if
(
!
skb
)
goto
wait_for_memory
;
...
...
@@ -868,7 +894,7 @@ int tcp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
if
(
!
page
)
{
/* Allocate new cache page. */
if
(
!
(
page
=
tcp
_alloc_page
(
sk
)))
if
(
!
(
page
=
sk_stream
_alloc_page
(
sk
)))
goto
wait_for_memory
;
off
=
0
;
}
...
...
@@ -1722,7 +1748,7 @@ void tcp_close(struct sock *sk, long timeout)
sk_stream_mem_reclaim
(
sk
);
if
(
atomic_read
(
&
tcp_orphan_count
)
>
sysctl_tcp_max_orphans
||
(
sk
->
sk_wmem_queued
>
SOCK_MIN_SNDBUF
&&
atomic_read
(
&
tcp_
prot
.
memory_allocated
)
>
tcp_prot
.
sysctl
_mem
[
2
]))
{
atomic_read
(
&
tcp_
memory_allocated
)
>
sysctl_tcp
_mem
[
2
]))
{
if
(
net_ratelimit
())
printk
(
KERN_INFO
"TCP: too many of orphaned "
"sockets
\n
"
);
...
...
@@ -1778,7 +1804,7 @@ int tcp_disconnect(struct sock *sk, int flags)
tcp_clear_xmit_timers
(
sk
);
__skb_queue_purge
(
&
sk
->
sk_receive_queue
);
tcp
_writequeue_purge
(
sk
);
sk_stream
_writequeue_purge
(
sk
);
__skb_queue_purge
(
&
tp
->
out_of_order_queue
);
inet
->
dport
=
0
;
...
...
@@ -2269,15 +2295,15 @@ void __init tcp_init(void)
}
tcp_port_rover
=
sysctl_local_port_range
[
0
]
-
1
;
tcp_prot
.
sysctl
_mem
[
0
]
=
768
<<
order
;
tcp_prot
.
sysctl
_mem
[
1
]
=
1024
<<
order
;
tcp_prot
.
sysctl
_mem
[
2
]
=
1536
<<
order
;
sysctl_tcp
_mem
[
0
]
=
768
<<
order
;
sysctl_tcp
_mem
[
1
]
=
1024
<<
order
;
sysctl_tcp
_mem
[
2
]
=
1536
<<
order
;
if
(
order
<
3
)
{
tcp_prot
.
sysctl
_wmem
[
2
]
=
64
*
1024
;
tcp_prot
.
sysctl
_rmem
[
0
]
=
PAGE_SIZE
;
tcp_prot
.
sysctl
_rmem
[
1
]
=
43689
;
tcp_prot
.
sysctl
_rmem
[
2
]
=
2
*
43689
;
sysctl_tcp
_wmem
[
2
]
=
64
*
1024
;
sysctl_tcp
_rmem
[
0
]
=
PAGE_SIZE
;
sysctl_tcp
_rmem
[
1
]
=
43689
;
sysctl_tcp
_rmem
[
2
]
=
2
*
43689
;
}
printk
(
KERN_INFO
"TCP: Hash tables configured "
...
...
net/ipv4/tcp_input.c
View file @
7ab50771
...
...
@@ -207,7 +207,7 @@ static void tcp_fixup_sndbuf(struct sock *sk)
sizeof
(
struct
sk_buff
);
if
(
sk
->
sk_sndbuf
<
3
*
sndmem
)
sk
->
sk_sndbuf
=
min
(
3
*
sndmem
,
tcp_prot
.
sysctl
_wmem
[
2
]);
sk
->
sk_sndbuf
=
min
(
3
*
sndmem
,
sysctl_tcp
_wmem
[
2
]);
}
/* 2. Tuning advertised window (window_clamp, rcv_ssthresh)
...
...
@@ -291,7 +291,7 @@ static void tcp_fixup_rcvbuf(struct sock *sk)
while
(
tcp_win_from_space
(
rcvmem
)
<
tp
->
advmss
)
rcvmem
+=
128
;
if
(
sk
->
sk_rcvbuf
<
4
*
rcvmem
)
sk
->
sk_rcvbuf
=
min
(
4
*
rcvmem
,
tcp_prot
.
sysctl
_rmem
[
2
]);
sk
->
sk_rcvbuf
=
min
(
4
*
rcvmem
,
sysctl_tcp
_rmem
[
2
]);
}
/* 4. Try to fixup all. It is made iimediately after connection enters
...
...
@@ -347,12 +347,12 @@ static void tcp_clamp_window(struct sock *sk, struct tcp_opt *tp)
* do not clamp window. Try to expand rcvbuf instead.
*/
if
(
ofo_win
)
{
if
(
sk
->
sk_rcvbuf
<
tcp_prot
.
sysctl
_rmem
[
2
]
&&
if
(
sk
->
sk_rcvbuf
<
sysctl_tcp
_rmem
[
2
]
&&
!
(
sk
->
sk_userlocks
&
SOCK_RCVBUF_LOCK
)
&&
!
tcp_prot
.
memory_pressure
&&
atomic_read
(
&
tcp_
prot
.
memory_allocated
)
<
tcp_prot
.
sysctl
_mem
[
0
])
atomic_read
(
&
tcp_
memory_allocated
)
<
sysctl_tcp
_mem
[
0
])
sk
->
sk_rcvbuf
=
min
(
atomic_read
(
&
sk
->
sk_rmem_alloc
),
tcp_prot
.
sysctl
_rmem
[
2
]);
sysctl_tcp
_rmem
[
2
]);
}
if
(
atomic_read
(
&
sk
->
sk_rmem_alloc
)
>
sk
->
sk_rcvbuf
)
{
app_win
+=
ofo_win
;
...
...
@@ -477,7 +477,7 @@ void tcp_rcv_space_adjust(struct sock *sk)
while
(
tcp_win_from_space
(
rcvmem
)
<
tp
->
advmss
)
rcvmem
+=
128
;
space
*=
rcvmem
;
space
=
min
(
space
,
tcp_prot
.
sysctl
_rmem
[
2
]);
space
=
min
(
space
,
sysctl_tcp
_rmem
[
2
]);
if
(
space
>
sk
->
sk_rcvbuf
)
{
sk
->
sk_rcvbuf
=
space
;
...
...
@@ -3398,12 +3398,6 @@ static void tcp_ofo_queue(struct sock *sk)
}
}
static
inline
int
tcp_rmem_schedule
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
{
return
(
int
)
skb
->
truesize
<=
sk
->
sk_forward_alloc
||
sk_stream_mem_schedule
(
sk
,
skb
->
truesize
,
1
);
}
static
int
tcp_prune_queue
(
struct
sock
*
sk
);
static
void
tcp_data_queue
(
struct
sock
*
sk
,
struct
sk_buff
*
skb
)
...
...
@@ -3457,8 +3451,9 @@ static void tcp_data_queue(struct sock *sk, struct sk_buff *skb)
queue_and_out:
if
(
eaten
<
0
&&
(
atomic_read
(
&
sk
->
sk_rmem_alloc
)
>
sk
->
sk_rcvbuf
||
!
tcp_rmem_schedule
(
sk
,
skb
)))
{
if
(
tcp_prune_queue
(
sk
)
<
0
||
!
tcp_rmem_schedule
(
sk
,
skb
))
!
sk_stream_rmem_schedule
(
sk
,
skb
)))
{
if
(
tcp_prune_queue
(
sk
)
<
0
||
!
sk_stream_rmem_schedule
(
sk
,
skb
))
goto
drop
;
}
sk_stream_set_owner_r
(
skb
,
sk
);
...
...
@@ -3530,8 +3525,9 @@ static void tcp_data_queue(struct sock *sk, struct sk_buff *skb)
TCP_ECN_check_ce
(
tp
,
skb
);
if
(
atomic_read
(
&
sk
->
sk_rmem_alloc
)
>
sk
->
sk_rcvbuf
||
!
tcp_rmem_schedule
(
sk
,
skb
))
{
if
(
tcp_prune_queue
(
sk
)
<
0
||
!
tcp_rmem_schedule
(
sk
,
skb
))
!
sk_stream_rmem_schedule
(
sk
,
skb
))
{
if
(
tcp_prune_queue
(
sk
)
<
0
||
!
sk_stream_rmem_schedule
(
sk
,
skb
))
goto
drop
;
}
...
...
@@ -3849,14 +3845,14 @@ static void tcp_new_space(struct sock *sk)
if
(
tp
->
packets_out
<
tp
->
snd_cwnd
&&
!
(
sk
->
sk_userlocks
&
SOCK_SNDBUF_LOCK
)
&&
!
tcp_prot
.
memory_pressure
&&
atomic_read
(
&
tcp_
prot
.
memory_allocated
)
<
tcp_prot
.
sysctl
_mem
[
0
])
{
atomic_read
(
&
tcp_
memory_allocated
)
<
sysctl_tcp
_mem
[
0
])
{
int
sndmem
=
max_t
(
u32
,
tp
->
mss_clamp
,
tp
->
mss_cache
)
+
MAX_TCP_HEADER
+
16
+
sizeof
(
struct
sk_buff
),
demanded
=
max_t
(
unsigned
int
,
tp
->
snd_cwnd
,
tp
->
reordering
+
1
);
sndmem
*=
2
*
demanded
;
if
(
sndmem
>
sk
->
sk_sndbuf
)
sk
->
sk_sndbuf
=
min
(
sndmem
,
tcp_prot
.
sysctl
_wmem
[
2
]);
sk
->
sk_sndbuf
=
min
(
sndmem
,
sysctl_tcp
_wmem
[
2
]);
tp
->
snd_cwnd_stamp
=
tcp_time_stamp
;
}
...
...
net/ipv4/tcp_ipv4.c
View file @
7ab50771
...
...
@@ -2086,10 +2086,10 @@ static int tcp_v4_init_sock(struct sock *sk)
tp
->
af_specific
=
&
ipv4_specific
;
sk
->
sk_sndbuf
=
tcp_prot
.
sysctl
_wmem
[
1
];
sk
->
sk_rcvbuf
=
tcp_prot
.
sysctl
_rmem
[
1
];
sk
->
sk_sndbuf
=
sysctl_tcp
_wmem
[
1
];
sk
->
sk_rcvbuf
=
sysctl_tcp
_rmem
[
1
];
atomic_inc
(
&
tcp_
prot
.
sockets_allocated
);
atomic_inc
(
&
tcp_sockets_allocated
);
return
0
;
}
...
...
@@ -2101,7 +2101,7 @@ static int tcp_v4_destroy_sock(struct sock *sk)
tcp_clear_xmit_timers
(
sk
);
/* Cleanup up the write buffer. */
tcp
_writequeue_purge
(
sk
);
sk_stream
_writequeue_purge
(
sk
);
/* Cleans up our, hopefully empty, out_of_order_queue. */
__skb_queue_purge
(
&
tp
->
out_of_order_queue
);
...
...
@@ -2113,7 +2113,7 @@ static int tcp_v4_destroy_sock(struct sock *sk)
if
(
tp
->
bind_hash
)
tcp_put_port
(
sk
);
atomic_dec
(
&
tcp_
prot
.
sockets_allocated
);
atomic_dec
(
&
tcp_sockets_allocated
);
return
0
;
}
...
...
@@ -2600,8 +2600,13 @@ struct proto tcp_prot = {
.
unhash
=
tcp_unhash
,
.
get_port
=
tcp_v4_get_port
,
.
enter_memory_pressure
=
tcp_enter_memory_pressure
,
.
sysctl_wmem
=
{
4
*
1024
,
16
*
1024
,
128
*
1024
},
.
sysctl_rmem
=
{
4
*
1024
,
87380
,
87380
*
2
},
.
sockets_allocated
=
&
tcp_sockets_allocated
,
.
memory_allocated
=
&
tcp_memory_allocated
,
.
memory_pressure
=
&
tcp_memory_pressure
,
.
sysctl_mem
=
sysctl_tcp_mem
,
.
sysctl_wmem
=
sysctl_tcp_wmem
,
.
sysctl_rmem
=
sysctl_tcp_rmem
,
.
max_header
=
MAX_TCP_HEADER
,
};
...
...
net/ipv4/tcp_minisocks.c
View file @
7ab50771
...
...
@@ -801,7 +801,7 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct open_request *req,
#ifdef INET_REFCNT_DEBUG
atomic_inc
(
&
inet_sock_nr
);
#endif
atomic_inc
(
&
tcp_
prot
.
sockets_allocated
);
atomic_inc
(
&
tcp_sockets_allocated
);
if
(
sock_flag
(
newsk
,
SOCK_KEEPOPEN
))
tcp_reset_keepalive_timer
(
newsk
,
...
...
net/ipv4/tcp_output.c
View file @
7ab50771
...
...
@@ -372,7 +372,7 @@ static int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len)
return
-
ENOMEM
;
/* Get a new skb... force flag on. */
buff
=
tcp
_alloc_skb
(
sk
,
nsize
,
GFP_ATOMIC
);
buff
=
sk_stream
_alloc_skb
(
sk
,
nsize
,
GFP_ATOMIC
);
if
(
buff
==
NULL
)
return
-
ENOMEM
;
/* We'll just try again later. */
sk_charge_skb
(
sk
,
buff
);
...
...
net/ipv4/tcp_timer.c
View file @
7ab50771
...
...
@@ -113,7 +113,7 @@ static int tcp_out_of_resources(struct sock *sk, int do_reset)
if
(
orphans
>=
sysctl_tcp_max_orphans
||
(
sk
->
sk_wmem_queued
>
SOCK_MIN_SNDBUF
&&
atomic_read
(
&
tcp_
prot
.
memory_allocated
)
>
tcp_prot
.
sysctl
_mem
[
2
]))
{
atomic_read
(
&
tcp_
memory_allocated
)
>
sysctl_tcp
_mem
[
2
]))
{
if
(
net_ratelimit
())
printk
(
KERN_INFO
"Out of socket memory
\n
"
);
...
...
net/ipv6/tcp_ipv6.c
View file @
7ab50771
...
...
@@ -1882,10 +1882,10 @@ static int tcp_v6_init_sock(struct sock *sk)
sk
->
sk_write_space
=
sk_stream_write_space
;
sk
->
sk_use_write_queue
=
1
;
sk
->
sk_sndbuf
=
tcp_prot
.
sysctl
_wmem
[
1
];
sk
->
sk_rcvbuf
=
tcp_prot
.
sysctl
_rmem
[
1
];
sk
->
sk_sndbuf
=
sysctl_tcp
_wmem
[
1
];
sk
->
sk_rcvbuf
=
sysctl_tcp
_rmem
[
1
];
atomic_inc
(
&
tcp_
prot
.
sockets_allocated
);
atomic_inc
(
&
tcp_sockets_allocated
);
return
0
;
}
...
...
@@ -1897,7 +1897,7 @@ static int tcp_v6_destroy_sock(struct sock *sk)
tcp_clear_xmit_timers
(
sk
);
/* Cleanup up the write buffer. */
tcp
_writequeue_purge
(
sk
);
sk_stream
_writequeue_purge
(
sk
);
/* Cleans up our, hopefully empty, out_of_order_queue. */
__skb_queue_purge
(
&
tp
->
out_of_order_queue
);
...
...
@@ -1909,7 +1909,7 @@ static int tcp_v6_destroy_sock(struct sock *sk)
if
(
tcp_sk
(
sk
)
->
bind_hash
)
tcp_put_port
(
sk
);
atomic_dec
(
&
tcp_
prot
.
sockets_allocated
);
atomic_dec
(
&
tcp_sockets_allocated
);
return
inet6_destroy_sock
(
sk
);
}
...
...
@@ -2078,23 +2078,31 @@ void tcp6_proc_exit(void)
#endif
struct
proto
tcpv6_prot
=
{
.
name
=
"TCPv6"
,
.
close
=
tcp_close
,
.
connect
=
tcp_v6_connect
,
.
disconnect
=
tcp_disconnect
,
.
accept
=
tcp_accept
,
.
ioctl
=
tcp_ioctl
,
.
init
=
tcp_v6_init_sock
,
.
destroy
=
tcp_v6_destroy_sock
,
.
shutdown
=
tcp_shutdown
,
.
setsockopt
=
tcp_setsockopt
,
.
getsockopt
=
tcp_getsockopt
,
.
sendmsg
=
tcp_sendmsg
,
.
recvmsg
=
tcp_recvmsg
,
.
backlog_rcv
=
tcp_v6_do_rcv
,
.
hash
=
tcp_v6_hash
,
.
unhash
=
tcp_unhash
,
.
get_port
=
tcp_v6_get_port
,
.
name
=
"TCPv6"
,
.
close
=
tcp_close
,
.
connect
=
tcp_v6_connect
,
.
disconnect
=
tcp_disconnect
,
.
accept
=
tcp_accept
,
.
ioctl
=
tcp_ioctl
,
.
init
=
tcp_v6_init_sock
,
.
destroy
=
tcp_v6_destroy_sock
,
.
shutdown
=
tcp_shutdown
,
.
setsockopt
=
tcp_setsockopt
,
.
getsockopt
=
tcp_getsockopt
,
.
sendmsg
=
tcp_sendmsg
,
.
recvmsg
=
tcp_recvmsg
,
.
backlog_rcv
=
tcp_v6_do_rcv
,
.
hash
=
tcp_v6_hash
,
.
unhash
=
tcp_unhash
,
.
get_port
=
tcp_v6_get_port
,
.
enter_memory_pressure
=
tcp_enter_memory_pressure
,
.
sockets_allocated
=
&
tcp_sockets_allocated
,
.
memory_allocated
=
&
tcp_memory_allocated
,
.
memory_pressure
=
&
tcp_memory_pressure
,
.
sysctl_mem
=
sysctl_tcp_mem
,
.
sysctl_wmem
=
sysctl_tcp_wmem
,
.
sysctl_rmem
=
sysctl_tcp_rmem
,
.
max_header
=
MAX_TCP_HEADER
,
};
static
struct
inet6_protocol
tcpv6_protocol
=
{
...
...
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