Skip to content

Commit e96f78a

Browse files
Eric Dumazetdavem330
authored andcommitted
tcp/dccp: add SLAB_DESTROY_BY_RCU flag for request sockets
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4236e2a commit e96f78a

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

include/net/request_sock.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ static inline struct sock *req_to_sk(struct request_sock *req)
8282
static inline struct request_sock *
8383
reqsk_alloc(const struct request_sock_ops *ops, struct sock *sk_listener)
8484
{
85-
struct request_sock *req = kmem_cache_alloc(ops->slab, GFP_ATOMIC);
85+
struct request_sock *req;
86+
87+
req = kmem_cache_alloc(ops->slab, GFP_ATOMIC | __GFP_NOWARN);
8688

8789
if (req) {
8890
req->rsk_ops = ops;

net/core/sock.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2758,7 +2758,7 @@ static int req_prot_init(const struct proto *prot)
27582758

27592759
rsk_prot->slab = kmem_cache_create(rsk_prot->slab_name,
27602760
rsk_prot->obj_size, 0,
2761-
0, NULL);
2761+
prot->slab_flags, NULL);
27622762

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

0 commit comments

Comments
 (0)