* [PATCH 1/3] ipv4: icmp: use icmp_sk_exit()
@ 2019-02-22 1:57 Kefeng Wang
2019-02-22 1:57 ` [PATCH 2/3] ipv6: icmp: use icmpv6_sk_exit() Kefeng Wang
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Kefeng Wang @ 2019-02-22 1:57 UTC (permalink / raw)
To: davem, netdev; +Cc: Kefeng Wang
Simply use icmp_sk_exit() when inet_ctl_sock_create() fail in icmp_sk_init().
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
net/ipv4/icmp.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index 065997f414e6..364cfe5e414b 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -1245,9 +1245,7 @@ static int __net_init icmp_sk_init(struct net *net)
return 0;
fail:
- for_each_possible_cpu(i)
- inet_ctl_sock_destroy(*per_cpu_ptr(net->ipv4.icmp_sk, i));
- free_percpu(net->ipv4.icmp_sk);
+ icmp_sk_exit(net);
return err;
}
--
2.20.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] ipv6: icmp: use icmpv6_sk_exit()
2019-02-22 1:57 [PATCH 1/3] ipv4: icmp: use icmp_sk_exit() Kefeng Wang
@ 2019-02-22 1:57 ` Kefeng Wang
2019-02-22 1:58 ` [PATCH 3/3] ipv6: icmp: use percpu allocation Kefeng Wang
2019-02-22 17:11 ` [PATCH 1/3] ipv4: icmp: use icmp_sk_exit() Eric Dumazet
2 siblings, 0 replies; 5+ messages in thread
From: Kefeng Wang @ 2019-02-22 1:57 UTC (permalink / raw)
To: davem, netdev; +Cc: Kefeng Wang
Simply use icmpv6_sk_exit() when inet_ctl_sock_create() fail
in icmpv6_sk_init().
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
net/ipv6/icmp.c | 25 +++++++++++--------------
1 file changed, 11 insertions(+), 14 deletions(-)
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
index bbcdfd299692..af520014def5 100644
--- a/net/ipv6/icmp.c
+++ b/net/ipv6/icmp.c
@@ -953,10 +953,19 @@ void icmpv6_flow_init(struct sock *sk, struct flowi6 *fl6,
security_sk_classify_flow(sk, flowi6_to_flowi(fl6));
}
+static void __net_exit icmpv6_sk_exit(struct net *net)
+{
+ int i;
+
+ for_each_possible_cpu(i)
+ inet_ctl_sock_destroy(net->ipv6.icmp_sk[i]);
+ kfree(net->ipv6.icmp_sk);
+}
+
static int __net_init icmpv6_sk_init(struct net *net)
{
struct sock *sk;
- int err, i, j;
+ int err, i;
net->ipv6.icmp_sk =
kcalloc(nr_cpu_ids, sizeof(struct sock *), GFP_KERNEL);
@@ -982,22 +991,10 @@ static int __net_init icmpv6_sk_init(struct net *net)
return 0;
fail:
- for (j = 0; j < i; j++)
- inet_ctl_sock_destroy(net->ipv6.icmp_sk[j]);
- kfree(net->ipv6.icmp_sk);
+ icmpv6_sk_exit(net);
return err;
}
-static void __net_exit icmpv6_sk_exit(struct net *net)
-{
- int i;
-
- for_each_possible_cpu(i) {
- inet_ctl_sock_destroy(net->ipv6.icmp_sk[i]);
- }
- kfree(net->ipv6.icmp_sk);
-}
-
static struct pernet_operations icmpv6_sk_ops = {
.init = icmpv6_sk_init,
.exit = icmpv6_sk_exit,
--
2.20.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] ipv6: icmp: use percpu allocation
2019-02-22 1:57 [PATCH 1/3] ipv4: icmp: use icmp_sk_exit() Kefeng Wang
2019-02-22 1:57 ` [PATCH 2/3] ipv6: icmp: use icmpv6_sk_exit() Kefeng Wang
@ 2019-02-22 1:58 ` Kefeng Wang
2019-02-22 17:11 ` [PATCH 1/3] ipv4: icmp: use icmp_sk_exit() Eric Dumazet
2 siblings, 0 replies; 5+ messages in thread
From: Kefeng Wang @ 2019-02-22 1:58 UTC (permalink / raw)
To: davem, netdev; +Cc: Kefeng Wang
Use percpu allocations for the ipv6.icmp_sk.
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
include/net/netns/ipv6.h | 2 +-
net/ipv6/icmp.c | 11 +++++------
2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
index ef1ed529f33c..b028a1dc150d 100644
--- a/include/net/netns/ipv6.h
+++ b/include/net/netns/ipv6.h
@@ -83,7 +83,7 @@ struct netns_ipv6 {
struct fib6_table *fib6_local_tbl;
struct fib_rules_ops *fib6_rules_ops;
#endif
- struct sock **icmp_sk;
+ struct sock * __percpu *icmp_sk;
struct sock *ndisc_sk;
struct sock *tcp_sk;
struct sock *igmp_sk;
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
index af520014def5..802faa2fcc0e 100644
--- a/net/ipv6/icmp.c
+++ b/net/ipv6/icmp.c
@@ -81,7 +81,7 @@
*/
static inline struct sock *icmpv6_sk(struct net *net)
{
- return net->ipv6.icmp_sk[smp_processor_id()];
+ return *this_cpu_ptr(net->ipv6.icmp_sk);
}
static int icmpv6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
@@ -958,8 +958,8 @@ static void __net_exit icmpv6_sk_exit(struct net *net)
int i;
for_each_possible_cpu(i)
- inet_ctl_sock_destroy(net->ipv6.icmp_sk[i]);
- kfree(net->ipv6.icmp_sk);
+ inet_ctl_sock_destroy(*per_cpu_ptr(net->ipv6.icmp_sk, i));
+ free_percpu(net->ipv6.icmp_sk);
}
static int __net_init icmpv6_sk_init(struct net *net)
@@ -967,8 +967,7 @@ static int __net_init icmpv6_sk_init(struct net *net)
struct sock *sk;
int err, i;
- net->ipv6.icmp_sk =
- kcalloc(nr_cpu_ids, sizeof(struct sock *), GFP_KERNEL);
+ net->ipv6.icmp_sk = alloc_percpu(struct sock *);
if (!net->ipv6.icmp_sk)
return -ENOMEM;
@@ -981,7 +980,7 @@ static int __net_init icmpv6_sk_init(struct net *net)
goto fail;
}
- net->ipv6.icmp_sk[i] = sk;
+ *per_cpu_ptr(net->ipv6.icmp_sk, i) = sk;
/* Enough space for 2 64K ICMP packets, including
* sk_buff struct overhead.
--
2.20.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/3] ipv4: icmp: use icmp_sk_exit()
2019-02-22 1:57 [PATCH 1/3] ipv4: icmp: use icmp_sk_exit() Kefeng Wang
2019-02-22 1:57 ` [PATCH 2/3] ipv6: icmp: use icmpv6_sk_exit() Kefeng Wang
2019-02-22 1:58 ` [PATCH 3/3] ipv6: icmp: use percpu allocation Kefeng Wang
@ 2019-02-22 17:11 ` Eric Dumazet
2019-02-22 17:16 ` Eric Dumazet
2 siblings, 1 reply; 5+ messages in thread
From: Eric Dumazet @ 2019-02-22 17:11 UTC (permalink / raw)
To: Kefeng Wang, davem, netdev
On 02/21/2019 05:57 PM, Kefeng Wang wrote:
> Simply use icmp_sk_exit() when inet_ctl_sock_create() fail in icmp_sk_init().
>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
> net/ipv4/icmp.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
> index 065997f414e6..364cfe5e414b 100644
> --- a/net/ipv4/icmp.c
> +++ b/net/ipv4/icmp.c
> @@ -1245,9 +1245,7 @@ static int __net_init icmp_sk_init(struct net *net)
> return 0;
>
> fail:
> - for_each_possible_cpu(i)
> - inet_ctl_sock_destroy(*per_cpu_ptr(net->ipv4.icmp_sk, i));
> - free_percpu(net->ipv4.icmp_sk);
> + icmp_sk_exit(net);
> return err;
> }
>
>
I do not like this. Future changes in icmp_sk_exit() might trigger a bug in this seldom tested path.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/3] ipv4: icmp: use icmp_sk_exit()
2019-02-22 17:11 ` [PATCH 1/3] ipv4: icmp: use icmp_sk_exit() Eric Dumazet
@ 2019-02-22 17:16 ` Eric Dumazet
0 siblings, 0 replies; 5+ messages in thread
From: Eric Dumazet @ 2019-02-22 17:16 UTC (permalink / raw)
To: Kefeng Wang, davem, netdev
On 02/22/2019 09:11 AM, Eric Dumazet wrote:
>
>
> On 02/21/2019 05:57 PM, Kefeng Wang wrote:
>> Simply use icmp_sk_exit() when inet_ctl_sock_create() fail in icmp_sk_init().
>>
>> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
>> ---
>> net/ipv4/icmp.c | 4 +---
>> 1 file changed, 1 insertion(+), 3 deletions(-)
>>
>> diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
>> index 065997f414e6..364cfe5e414b 100644
>> --- a/net/ipv4/icmp.c
>> +++ b/net/ipv4/icmp.c
>> @@ -1245,9 +1245,7 @@ static int __net_init icmp_sk_init(struct net *net)
>> return 0;
>>
>> fail:
>> - for_each_possible_cpu(i)
>> - inet_ctl_sock_destroy(*per_cpu_ptr(net->ipv4.icmp_sk, i));
>> - free_percpu(net->ipv4.icmp_sk);
>> + icmp_sk_exit(net);
>> return err;
>> }
>>
>>
>
>
> I do not like this. Future changes in icmp_sk_exit() might trigger a bug in this seldom tested path.
>
Oh I see the next patches, now it makes sense.
Please send a proper patch series, with a cover letter, so that it is obvious.
Also you need to include "net-next" instead of plain [PATCH] to express this targets net-next tree.
Carefully read Documentation/networking/netdev-FAQ.rst
Thank you.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-02-22 17:16 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-22 1:57 [PATCH 1/3] ipv4: icmp: use icmp_sk_exit() Kefeng Wang
2019-02-22 1:57 ` [PATCH 2/3] ipv6: icmp: use icmpv6_sk_exit() Kefeng Wang
2019-02-22 1:58 ` [PATCH 3/3] ipv6: icmp: use percpu allocation Kefeng Wang
2019-02-22 17:11 ` [PATCH 1/3] ipv4: icmp: use icmp_sk_exit() Eric Dumazet
2019-02-22 17:16 ` Eric Dumazet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).