[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <87a5nemahr.fsf@nvidia.com>
Date: Mon, 4 Mar 2024 12:09:41 +0100
From: Petr Machata <petrm@...dia.com>
To: Eric Dumazet <edumazet@...gle.com>
CC: Petr Machata <petrm@...dia.com>, "David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
<netdev@...r.kernel.org>, Ido Schimmel <idosch@...dia.com>, David Ahern
<dsahern@...nel.org>, Simon Horman <horms@...nel.org>, <mlxsw@...dia.com>
Subject: Re: [PATCH net-next v2 4/7] net: nexthop: Expose nexthop group
stats to user space
Eric Dumazet <edumazet@...gle.com> writes:
> On Thu, Feb 29, 2024 at 7:20 PM Petr Machata <petrm@...dia.com> wrote:
>> @@ -661,8 +663,77 @@ static int nla_put_nh_group_res(struct sk_buff *skb, struct nh_group *nhg)
>> return -EMSGSIZE;
>> }
>>
>> -static int nla_put_nh_group(struct sk_buff *skb, struct nh_group *nhg)
>> +static void nh_grp_entry_stats_read(struct nh_grp_entry *nhge,
>> + struct nh_grp_entry_stats *stats)
>> {
>> + int i;
>> +
>> + memset(stats, 0, sizeof(*stats));
>> + for_each_possible_cpu(i) {
>> + struct nh_grp_entry_stats *cpu_stats;
>> + unsigned int start;
>> + u64 packets;
>> +
>> + cpu_stats = per_cpu_ptr(nhge->stats, i);
>> + do {
>> + start = u64_stats_fetch_begin(&cpu_stats->syncp);
>> + packets = cpu_stats->packets;
>
> This is not safe, even on 64bit arches.
>
> You should use u64_stats_t, u64_stats_read(), u64_stats_add() ...
OK.
Powered by blists - more mailing lists