Skip to content

Commit

Permalink
tcp/dccp: add SLAB_DESTROY_BY_RCU flag for request sockets
Browse files Browse the repository at this point in the history
Before letting request sockets being put in TCP/DCCP regular
ehash table, we need to add either :

- SLAB_DESTROY_BY_RCU flag to their kmem_cache
- add RCU grace period before freeing them.

Since we carefully respected the SLAB_DESTROY_BY_RCU protocol
like ESTABLISH and TIMEWAIT sockets, use it here.

req_prot_init() being only used by TCP and DCCP, I did not add
a new slab_flags into their rsk_prot, but reuse prot->slab_flags

Since all reqsk_alloc() users are correctly dealing with a failure,
add the __GFP_NOWARN flag to avoid traces under pressure.

Fixes: 079096f ("tcp/dccp: install syn_recv requests into ehash table")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Oct 3, 2015
1 parent 4236e2a commit e96f78a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion include/net/request_sock.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ static inline struct sock *req_to_sk(struct request_sock *req)
static inline struct request_sock *
reqsk_alloc(const struct request_sock_ops *ops, struct sock *sk_listener)
{
struct request_sock *req = kmem_cache_alloc(ops->slab, GFP_ATOMIC);
struct request_sock *req;

req = kmem_cache_alloc(ops->slab, GFP_ATOMIC | __GFP_NOWARN);

if (req) {
req->rsk_ops = ops;
Expand Down
2 changes: 1 addition & 1 deletion net/core/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -2758,7 +2758,7 @@ static int req_prot_init(const struct proto *prot)

rsk_prot->slab = kmem_cache_create(rsk_prot->slab_name,
rsk_prot->obj_size, 0,
0, NULL);
prot->slab_flags, NULL);

if (!rsk_prot->slab) {
pr_crit("%s: Can't create request sock SLAB cache!\n",
Expand Down

0 comments on commit e96f78a

Please sign in to comment.