Message ID | 20210311025736.77235-1-xiangxia.m.yue@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Commit | b80350f393703fa2e733921430276c98bbc092de |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net-next,v2] net: sock: simplify tw proto registration | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Clearly marked for net-next |
netdev/subject_prefix | success | Link |
netdev/cc_maintainers | warning | 6 maintainers not CCed: linmiaohe@huawei.com daniel@iogearbox.net edumazet@google.com pabeni@redhat.com davem@davemloft.net kuba@kernel.org |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 5 this patch: 5 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 56 lines checked |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 5 this patch: 5 |
netdev/header_inline | success | Link |
Hello: This patch was applied to netdev/net.git (refs/heads/master): On Thu, 11 Mar 2021 10:57:36 +0800 you wrote: > From: Tonghao Zhang <xiangxia.m.yue@gmail.com> > > Introduce the new function tw_prot_init (inspired by > req_prot_init) to simplify "proto_register" function. > > tw_prot_cleanup will take care of a partially initialized > timewait_sock_ops. > > [...] Here is the summary with links: - [net-next,v2] net: sock: simplify tw proto registration https://git.kernel.org/netdev/net/c/b80350f39370 You are awesome, thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
On 3/12/21 1:10 AM, patchwork-bot+netdevbpf@kernel.org wrote: > Hello: > > This patch was applied to netdev/net.git (refs/heads/master): > > On Thu, 11 Mar 2021 10:57:36 +0800 you wrote: >> From: Tonghao Zhang <xiangxia.m.yue@gmail.com> >> >> Introduce the new function tw_prot_init (inspired by >> req_prot_init) to simplify "proto_register" function. >> >> tw_prot_cleanup will take care of a partially initialized >> timewait_sock_ops. >> >> [...] > > Here is the summary with links: > - [net-next,v2] net: sock: simplify tw proto registration > https://git.kernel.org/netdev/net/c/b80350f39370 > > You are awesome, thank you! > -- > Deet-doot-dot, I am a bot. > https://korg.docs.kernel.org/patchwork/pwbot.html > > For some reason I see the patch in net tree, not in net-next I wonder what happened.
On Fri, Mar 12, 2021 at 10:15 PM Eric Dumazet <eric.dumazet@gmail.com> wrote: > > > > On 3/12/21 1:10 AM, patchwork-bot+netdevbpf@kernel.org wrote: > > Hello: > > > > This patch was applied to netdev/net.git (refs/heads/master): > > > > On Thu, 11 Mar 2021 10:57:36 +0800 you wrote: > >> From: Tonghao Zhang <xiangxia.m.yue@gmail.com> > >> > >> Introduce the new function tw_prot_init (inspired by > >> req_prot_init) to simplify "proto_register" function. > >> > >> tw_prot_cleanup will take care of a partially initialized > >> timewait_sock_ops. > >> > >> [...] > > > > Here is the summary with links: > > - [net-next,v2] net: sock: simplify tw proto registration > > https://git.kernel.org/netdev/net/c/b80350f39370 > > > > You are awesome, thank you! > > -- > > Deet-doot-dot, I am a bot. > > https://korg.docs.kernel.org/patchwork/pwbot.html > > > > > > For some reason I see the patch in net tree, not in net-next > > I wonder what happened. my mistake, In the patch v1, I use the "net" as prefix, and v2 using "net-nextt"
diff --git a/net/core/sock.c b/net/core/sock.c index 0ed98f20448a..cc31b601ae10 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -3440,6 +3440,32 @@ static void tw_prot_cleanup(struct timewait_sock_ops *twsk_prot) twsk_prot->twsk_slab = NULL; } +static int tw_prot_init(const struct proto *prot) +{ + struct timewait_sock_ops *twsk_prot = prot->twsk_prot; + + if (!twsk_prot) + return 0; + + twsk_prot->twsk_slab_name = kasprintf(GFP_KERNEL, "tw_sock_%s", + prot->name); + if (!twsk_prot->twsk_slab_name) + return -ENOMEM; + + twsk_prot->twsk_slab = + kmem_cache_create(twsk_prot->twsk_slab_name, + twsk_prot->twsk_obj_size, 0, + SLAB_ACCOUNT | prot->slab_flags, + NULL); + if (!twsk_prot->twsk_slab) { + pr_crit("%s: Can't create timewait sock SLAB cache!\n", + prot->name); + return -ENOMEM; + } + + return 0; +} + static void req_prot_cleanup(struct request_sock_ops *rsk_prot) { if (!rsk_prot) @@ -3496,22 +3522,8 @@ int proto_register(struct proto *prot, int alloc_slab) if (req_prot_init(prot)) goto out_free_request_sock_slab; - if (prot->twsk_prot != NULL) { - prot->twsk_prot->twsk_slab_name = kasprintf(GFP_KERNEL, "tw_sock_%s", prot->name); - - if (prot->twsk_prot->twsk_slab_name == NULL) - goto out_free_request_sock_slab; - - prot->twsk_prot->twsk_slab = - kmem_cache_create(prot->twsk_prot->twsk_slab_name, - prot->twsk_prot->twsk_obj_size, - 0, - SLAB_ACCOUNT | - prot->slab_flags, - NULL); - if (prot->twsk_prot->twsk_slab == NULL) - goto out_free_timewait_sock_slab; - } + if (tw_prot_init(prot)) + goto out_free_timewait_sock_slab; } mutex_lock(&proto_list_mutex);