From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4E72FA0C4C; Tue, 30 Nov 2021 15:42:35 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A256341168; Tue, 30 Nov 2021 15:42:34 +0100 (CET) Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) by mails.dpdk.org (Postfix) with ESMTP id 230B741142 for ; Tue, 30 Nov 2021 15:42:33 +0100 (CET) Received: by mail-pj1-f52.google.com with SMTP id j5-20020a17090a318500b001a6c749e697so13975797pjb.1 for ; Tue, 30 Nov 2021 06:42:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:mime-version; bh=NOyWU3H1HExDRg+UHDrjt9v3YY2RbK5lg9U+ujtFmGs=; b=JO9ezwrW5vEFB1U/1XFuzpUQDuFfk6O/4V6uoXlA2ZPyxGEejiJC5J0H1gKa8FlAqV 53Q4eaV1nFxjbUYtkiYzpsSXTDAjX1vLC+IImuUZvNfsnRTu2VNkEnGs5kiCLNvb3rEi ipy3QupYLYniEsfrB1ymgYxgeF1rgGXcAQhVw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version; bh=NOyWU3H1HExDRg+UHDrjt9v3YY2RbK5lg9U+ujtFmGs=; b=MPLEhHsvNsqOr5t80xzeT9nl2fBx3Vq4upPhtXU0b19AFvsGznJe2zxSxJ+v3Rz3WO dK4YmgD2T5D00XCCb7tbhdA1YGgPUaF2vt4s4RkcPccz1f4Syt6qTc1VQbovrf+g0x+Z rJNC0gGCjEhEkqiwxijTEC5lWzzNII3WqOnHVXjBjNocvQXH0/rPqbqPw5ZpIgFzNYtV wQpiQ6Z3JPfrOfWWn2s1+t+UErl9KrZV7bOtXHYtrubvsNSWccD8lt5BKNykvVIrRiA6 e8HdCpX2jm0qjL18wgMicOP0e5VtOhVtDp/MyYEEjuBsYRVgPVWMw1Ziq+XQ9m/ceP9w GC9g== X-Gm-Message-State: AOAM5329jmRBgFRBA+7llsCcPQ1IGO2T9xiC49hJ9EqnXjriqR2E4q2l Bl62QEtJAC8lwHdCCS8Xrc40WQ== X-Google-Smtp-Source: ABdhPJz865OhfGLVdDc6zvoKiw0rct/xVigONjMYDHDcazlazqOCL2JCBOjiVHHcs5LGBgpf+sw9Gw== X-Received: by 2002:a17:902:a5c5:b0:143:c3cf:739b with SMTP id t5-20020a170902a5c500b00143c3cf739bmr68033929plq.9.1638283352127; Tue, 30 Nov 2021 06:42:32 -0800 (PST) Received: from localhost.localdomain ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id c3sm22397738pfv.67.2021.11.30.06.42.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Nov 2021 06:42:31 -0800 (PST) From: Lance Richardson To: Ajit Khaparde , Somnath Kotur Cc: dev@dpdk.org, stable@dpdk.org Subject: [PATCH] net/bnxt: fix xstats get names implementation Date: Tue, 30 Nov 2021 09:42:26 -0500 Message-Id: <20211130144226.40575-1-lance.richardson@broadcom.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg=sha-256; boundary="00000000000043c4db05d2029196" X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org --00000000000043c4db05d2029196 Content-Transfer-Encoding: 8bit When the xstats_names parameter to rte_eth_xstats_get_names() is non-NULL and the size parameter is less than the required number of entries, the driver must return the required size without modifying (and over-running) the caller's xstats_names array. Update bnxt_dev_xstats_get_names_op() in accordance with this requirement. Fixes: bfb9c2260be2 ("net/bnxt: support xstats get/reset") Cc: stable@dpdk.org Signed-off-by: Lance Richardson --- drivers/net/bnxt/bnxt_stats.c | 93 +++++++++++++++++------------------ 1 file changed, 46 insertions(+), 47 deletions(-) diff --git a/drivers/net/bnxt/bnxt_stats.c b/drivers/net/bnxt/bnxt_stats.c index 991eafc644..197fd7c02b 100644 --- a/drivers/net/bnxt/bnxt_stats.c +++ b/drivers/net/bnxt/bnxt_stats.c @@ -846,7 +846,7 @@ int bnxt_flow_stats_cnt(struct bnxt *bp) int bnxt_dev_xstats_get_names_op(struct rte_eth_dev *eth_dev, struct rte_eth_xstat_name *xstats_names, - __rte_unused unsigned int limit) + unsigned int size) { struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; const unsigned int stat_cnt = RTE_DIM(bnxt_rx_stats_strings) + @@ -862,63 +862,62 @@ int bnxt_dev_xstats_get_names_op(struct rte_eth_dev *eth_dev, if (rc) return rc; - if (xstats_names != NULL) { - count = 0; + if (xstats_names == NULL || size < stat_cnt) + return stat_cnt; - for (i = 0; i < RTE_DIM(bnxt_rx_stats_strings); i++) { - strlcpy(xstats_names[count].name, - bnxt_rx_stats_strings[i].name, - sizeof(xstats_names[count].name)); - count++; - } + for (i = 0; i < RTE_DIM(bnxt_rx_stats_strings); i++) { + strlcpy(xstats_names[count].name, + bnxt_rx_stats_strings[i].name, + sizeof(xstats_names[count].name)); + count++; + } - for (i = 0; i < RTE_DIM(bnxt_tx_stats_strings); i++) { - strlcpy(xstats_names[count].name, - bnxt_tx_stats_strings[i].name, - sizeof(xstats_names[count].name)); - count++; - } + for (i = 0; i < RTE_DIM(bnxt_tx_stats_strings); i++) { + strlcpy(xstats_names[count].name, + bnxt_tx_stats_strings[i].name, + sizeof(xstats_names[count].name)); + count++; + } - for (i = 0; i < RTE_DIM(bnxt_func_stats_strings); i++) { - strlcpy(xstats_names[count].name, - bnxt_func_stats_strings[i].name, - sizeof(xstats_names[count].name)); - count++; - } + for (i = 0; i < RTE_DIM(bnxt_func_stats_strings); i++) { + strlcpy(xstats_names[count].name, + bnxt_func_stats_strings[i].name, + sizeof(xstats_names[count].name)); + count++; + } - for (i = 0; i < RTE_DIM(bnxt_rx_ext_stats_strings); i++) { - strlcpy(xstats_names[count].name, - bnxt_rx_ext_stats_strings[i].name, - sizeof(xstats_names[count].name)); + for (i = 0; i < RTE_DIM(bnxt_rx_ext_stats_strings); i++) { + strlcpy(xstats_names[count].name, + bnxt_rx_ext_stats_strings[i].name, + sizeof(xstats_names[count].name)); - count++; - } + count++; + } - for (i = 0; i < RTE_DIM(bnxt_tx_ext_stats_strings); i++) { - strlcpy(xstats_names[count].name, - bnxt_tx_ext_stats_strings[i].name, - sizeof(xstats_names[count].name)); + for (i = 0; i < RTE_DIM(bnxt_tx_ext_stats_strings); i++) { + strlcpy(xstats_names[count].name, + bnxt_tx_ext_stats_strings[i].name, + sizeof(xstats_names[count].name)); - count++; - } + count++; + } - if (bp->fw_cap & BNXT_FW_CAP_ADV_FLOW_COUNTERS && - bp->fw_cap & BNXT_FW_CAP_ADV_FLOW_MGMT && - BNXT_FLOW_XSTATS_EN(bp)) { - for (i = 0; i < bp->max_l2_ctx; i++) { - char buf[RTE_ETH_XSTATS_NAME_SIZE]; + if (bp->fw_cap & BNXT_FW_CAP_ADV_FLOW_COUNTERS && + bp->fw_cap & BNXT_FW_CAP_ADV_FLOW_MGMT && + BNXT_FLOW_XSTATS_EN(bp)) { + for (i = 0; i < bp->max_l2_ctx; i++) { + char buf[RTE_ETH_XSTATS_NAME_SIZE]; - sprintf(buf, "flow_%d_bytes", i); - strlcpy(xstats_names[count].name, buf, - sizeof(xstats_names[count].name)); - count++; + sprintf(buf, "flow_%d_bytes", i); + strlcpy(xstats_names[count].name, buf, + sizeof(xstats_names[count].name)); + count++; - sprintf(buf, "flow_%d_packets", i); - strlcpy(xstats_names[count].name, buf, - sizeof(xstats_names[count].name)); + sprintf(buf, "flow_%d_packets", i); + strlcpy(xstats_names[count].name, buf, + sizeof(xstats_names[count].name)); - count++; - } + count++; } } -- 2.25.1 --00000000000043c4db05d2029196 Content-Type: application/pkcs7-signature; name="smime.p7s" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="smime.p7s" Content-Description: S/MIME Cryptographic Signature MIIQeQYJKoZIhvcNAQcCoIIQajCCEGYCAQExDzANBglghkgBZQMEAgEFADALBgkqhkiG9w0BBwGg gg3QMIIFDTCCA/WgAwIBAgIQeEqpED+lv77edQixNJMdADANBgkqhkiG9w0BAQsFADBMMSAwHgYD VQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMzETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UE AxMKR2xvYmFsU2lnbjAeFw0yMDA5MTYwMDAwMDBaFw0yODA5MTYwMDAwMDBaMFsxCzAJBgNVBAYT AkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMTEwLwYDVQQDEyhHbG9iYWxTaWduIEdDQyBS MyBQZXJzb25hbFNpZ24gMiBDQSAyMDIwMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA vbCmXCcsbZ/a0fRIQMBxp4gJnnyeneFYpEtNydrZZ+GeKSMdHiDgXD1UnRSIudKo+moQ6YlCOu4t rVWO/EiXfYnK7zeop26ry1RpKtogB7/O115zultAz64ydQYLe+a1e/czkALg3sgTcOOcFZTXk38e aqsXsipoX1vsNurqPtnC27TWsA7pk4uKXscFjkeUE8JZu9BDKaswZygxBOPBQBwrA5+20Wxlk6k1 e6EKaaNaNZUy30q3ArEf30ZDpXyfCtiXnupjSK8WU2cK4qsEtj09JS4+mhi0CTCrCnXAzum3tgcH cHRg0prcSzzEUDQWoFxyuqwiwhHu3sPQNmFOMwIDAQABo4IB2jCCAdYwDgYDVR0PAQH/BAQDAgGG MGAGA1UdJQRZMFcGCCsGAQUFBwMCBggrBgEFBQcDBAYKKwYBBAGCNxQCAgYKKwYBBAGCNwoDBAYJ KwYBBAGCNxUGBgorBgEEAYI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