[TWSK]: Introduce struct timewait_sock_ops
So that we can share several timewait sockets related functions and make the timewait mini sockets infrastructure closer to the request mini sockets one. Next changesets will take advantage of this, moving more code out of TCP and DCCP v4 and v6 to common infrastructure. Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
fc44b98053
commit
6d6ee43e0b
@@ -1488,7 +1488,7 @@ int proto_register(struct proto *prot, int alloc_slab)
|
||||
}
|
||||
}
|
||||
|
||||
if (prot->twsk_obj_size) {
|
||||
if (prot->twsk_prot != NULL) {
|
||||
static const char mask[] = "tw_sock_%s";
|
||||
|
||||
timewait_sock_slab_name = kmalloc(strlen(prot->name) + sizeof(mask) - 1, GFP_KERNEL);
|
||||
@@ -1497,11 +1497,12 @@ int proto_register(struct proto *prot, int alloc_slab)
|
||||
goto out_free_request_sock_slab;
|
||||
|
||||
sprintf(timewait_sock_slab_name, mask, prot->name);
|
||||
prot->twsk_slab = kmem_cache_create(timewait_sock_slab_name,
|
||||
prot->twsk_obj_size,
|
||||
0, SLAB_HWCACHE_ALIGN,
|
||||
NULL, NULL);
|
||||
if (prot->twsk_slab == NULL)
|
||||
prot->twsk_prot->twsk_slab =
|
||||
kmem_cache_create(timewait_sock_slab_name,
|
||||
prot->twsk_prot->twsk_obj_size,
|
||||
0, SLAB_HWCACHE_ALIGN,
|
||||
NULL, NULL);
|
||||
if (prot->twsk_prot->twsk_slab == NULL)
|
||||
goto out_free_timewait_sock_slab_name;
|
||||
}
|
||||
}
|
||||
@@ -1548,12 +1549,12 @@ void proto_unregister(struct proto *prot)
|
||||
prot->rsk_prot->slab = NULL;
|
||||
}
|
||||
|
||||
if (prot->twsk_slab != NULL) {
|
||||
const char *name = kmem_cache_name(prot->twsk_slab);
|
||||
if (prot->twsk_prot != NULL && prot->twsk_prot->twsk_slab != NULL) {
|
||||
const char *name = kmem_cache_name(prot->twsk_prot->twsk_slab);
|
||||
|
||||
kmem_cache_destroy(prot->twsk_slab);
|
||||
kmem_cache_destroy(prot->twsk_prot->twsk_slab);
|
||||
kfree(name);
|
||||
prot->twsk_slab = NULL;
|
||||
prot->twsk_prot->twsk_slab = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user