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: <20211102111023.6ed54026@kicinski-fedora-PC1C0HJN>
Date:   Tue, 2 Nov 2021 11:10:23 -0700
From:   Jakub Kicinski <kuba@...nel.org>
To:     Saeed Mahameed <saeedm@...dia.com>
Cc:     "davem@...emloft.net" <davem@...emloft.net>,
        "mkubecek@...e.cz" <mkubecek@...e.cz>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        "andrew@...n.ch" <andrew@...n.ch>
Subject: Re: [PATCH net] ethtool: fix ethtool msg len calculation for pause
 stats

On Tue, 2 Nov 2021 16:08:52 +0000 Saeed Mahameed wrote:
> > diff --git a/net/ethtool/pause.c b/net/ethtool/pause.c
> > index 9009f412151e..c9171234130b 100644
> > --- a/net/ethtool/pause.c
> > +++ b/net/ethtool/pause.c
> > @@ -57,7 +57,7 @@ static int pause_reply_size(const struct
> > ethnl_req_info *req_base,
> >         if (req_base->flags & ETHTOOL_FLAG_STATS)
> >                 n += nla_total_size(0) +        /* _PAUSE_STATS */
> >                         nla_total_size_64bit(sizeof(u64)) *
> > -                               (ETHTOOL_A_PAUSE_STAT_MAX - 2);
> > +                               (ETHTOOL_A_PAUSE_STAT_MAX - 1);  
> 
> Maybe for net-next we can improve readability here.
> Just by staring at these lines, you'd think that this should've been
> (ETHTOOL_A_PAUSE_STAT_MAX + 1), or even better, just
> (ETHTOOL_A_PAUSE_STAT_CNT) /* Count of only stats */
> 
> maybe we need to separate stats from non-stats, or define
> ETHTOOL_A_PAUSE_STAT_CNT where it needs to be defined.

Fair point, something like this?

+++ b/include/uapi/linux/ethtool_netlink.h
@@ -411,10 +411,14 @@ enum {
        ETHTOOL_A_PAUSE_STAT_TX_FRAMES,
        ETHTOOL_A_PAUSE_STAT_RX_FRAMES,
 
-       /* add new constants above here */
+       /* add new constants above here
+        * adjust ETHTOOL_PAUSE_STAT_CNT if adding non-stats!
+        */
        __ETHTOOL_A_PAUSE_STAT_CNT,
        ETHTOOL_A_PAUSE_STAT_MAX = (__ETHTOOL_A_PAUSE_STAT_CNT - 1)
 };
+#define ETHTOOL_PAUSE_STAT_CNT (__ETHTOOL_A_PAUSE_STAT_CNT -           \
+                                ETHTOOL_A_PAUSE_STAT_TX_FRAMES)
 
 /* EEE */
 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ