lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3375fb21-c921-4245-a084-738a418f084c@redhat.com>
Date: Tue, 4 Feb 2025 14:02:42 +0100
From: Paolo Abeni <pabeni@...hat.com>
To: Eric Dumazet <edumazet@...gle.com>, Joe Damato <jdamato@...tly.com>
Cc: netdev@...r.kernel.org, kuba@...nel.org,
 "David S. Miller" <davem@...emloft.net>, Simon Horman <horms@...nel.org>,
 Amritha Nambiar <amritha.nambiar@...el.com>,
 Mina Almasry <almasrymina@...gle.com>,
 open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH net-next v2] netdev-genl: Elide napi_id when not present

On 2/4/25 6:41 AM, Eric Dumazet wrote:
> On Mon, Feb 3, 2025 at 8:17 PM Joe Damato <jdamato@...tly.com> wrote:
>>
>> There are at least two cases where napi_id may not present and the
>> napi_id should be elided:
>>
>> 1. Queues could be created, but napi_enable may not have been called
>>    yet. In this case, there may be a NAPI but it may not have an ID and
>>    output of a napi_id should be elided.
>>
>> 2. TX-only NAPIs currently do not have NAPI IDs. If a TX queue happens
>>    to be linked with a TX-only NAPI, elide the NAPI ID from the netlink
>>    output as a NAPI ID of 0 is not useful for users.
>>
>> Signed-off-by: Joe Damato <jdamato@...tly.com>
>> ---
>>  v2:
>>    - Updated to elide NAPI IDs for RX queues which may have not called
>>      napi_enable yet.
>>
>>  rfc: https://lore.kernel.org/lkml/20250128163038.429864-1-jdamato@fastly.com/
>>  net/core/netdev-genl.c | 14 ++++++++------
>>  1 file changed, 8 insertions(+), 6 deletions(-)
>>
>> diff --git a/net/core/netdev-genl.c b/net/core/netdev-genl.c
>> index 715f85c6b62e..a97d3b99f6cd 100644
>> --- a/net/core/netdev-genl.c
>> +++ b/net/core/netdev-genl.c
>> @@ -385,9 +385,10 @@ netdev_nl_queue_fill_one(struct sk_buff *rsp, struct net_device *netdev,
>>         switch (q_type) {
>>         case NETDEV_QUEUE_TYPE_RX:
>>                 rxq = __netif_get_rx_queue(netdev, q_idx);
>> -               if (rxq->napi && nla_put_u32(rsp, NETDEV_A_QUEUE_NAPI_ID,
>> -                                            rxq->napi->napi_id))
>> -                       goto nla_put_failure;
>> +               if (rxq->napi && rxq->napi->napi_id >= MIN_NAPI_ID)
>> +                       if (nla_put_u32(rsp, NETDEV_A_QUEUE_NAPI_ID,
>> +                                       rxq->napi->napi_id))
>> +                               goto nla_put_failure;
>>
>>                 binding = rxq->mp_params.mp_priv;
>>                 if (binding &&
>> @@ -397,9 +398,10 @@ netdev_nl_queue_fill_one(struct sk_buff *rsp, struct net_device *netdev,
>>                 break;
>>         case NETDEV_QUEUE_TYPE_TX:
>>                 txq = netdev_get_tx_queue(netdev, q_idx);
>> -               if (txq->napi && nla_put_u32(rsp, NETDEV_A_QUEUE_NAPI_ID,
>> -                                            txq->napi->napi_id))
>> -                       goto nla_put_failure;
>> +               if (txq->napi && txq->napi->napi_id >= MIN_NAPI_ID)
>> +                       if (nla_put_u32(rsp, NETDEV_A_QUEUE_NAPI_ID,
>> +                                       txq->napi->napi_id))
>> +                               goto nla_put_failure;
>>         }
> 
> Hi Joe
> 
> This might be time to add helpers, we now have these checks about
> MIN_NAPI_ID all around the places.

+1.

IMHO a follow-up patch could additionally replace the existing
open-coded tests with the new helper.

/P


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ