Search Linux Wireless

Re: [PATCH 1/2] wireless: expand per-station byte counters to 64bit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 2013-02-04 at 16:36 +0100, Johannes Berg wrote:

> > +	if ((sinfo->filled & STATION_INFO_RX_BYTES64) &&
> > +	    nla_put_u64(msg, NL80211_STA_INFO_RX_BYTES64,
> > +			sinfo->rx_bytes))
> > +		goto nla_put_failure;
> >[...]
> 
> +       if (sinfo->filled & STATION_INFO_RX_BYTES64) {
> +               if (nla_put_u64(msg, NL80211_STA_INFO_RX_BYTES64,
> +                               sinfo->rx_bytes))
> +                       goto nla_put_failure;
> +               if (sinfo->rx_bytes <= UINT_MAX &&
> +                   nla_put_u32(msg, NL80211_STA_INFO_RX_BYTES,
> +                               (u32)sinfo->rx_bytes))
> +                       goto nla_put_failure;
> +       }
> +       if (sinfo->filled & STATION_INFO_TX_BYTES64) {
> +               if (nla_put_u64(msg, NL80211_STA_INFO_TX_BYTES64,
> +                               sinfo->tx_bytes))
> +                       goto nla_put_failure;
> +               if (sinfo->tx_bytes <= UINT_MAX &&
> +                   nla_put_u32(msg, NL80211_STA_INFO_TX_BYTES,
> +                               (u32)sinfo->tx_bytes))
> +                       goto nla_put_failure;
> +       }

Ok Vladimir convinced me this was stupid because it breaks the current
userspace API in a subtle way: right now, if it rolls over, we will get
wrapped values in userspace, afterwards with a 64-bit compatible driver
we won't get any 32-bit value ...

I'll change it to this though, so drivers don't get this choice:


-       if ((sinfo->filled & STATION_INFO_RX_BYTES) &&
+       if ((sinfo->filled & (STATION_INFO_RX_BYTES |
+                             STATION_INFO_RX_BYTES64)) &&
            nla_put_u32(msg, NL80211_STA_INFO_RX_BYTES,
-                       sinfo->rx_bytes))
+                       (u32)sinfo->rx_bytes))
                goto nla_put_failure;
-       if ((sinfo->filled & STATION_INFO_TX_BYTES) &&
+       if ((sinfo->filled & (STATION_INFO_TX_BYTES |
+                             NL80211_STA_INFO_TX_BYTES64)) &&
            nla_put_u32(msg, NL80211_STA_INFO_TX_BYTES,
+                       (u32)sinfo->tx_bytes))
+               goto nla_put_failure;
+       if ((sinfo->filled & STATION_INFO_RX_BYTES64) &&
+           nla_put_u64(msg, NL80211_STA_INFO_RX_BYTES64,
+                       sinfo->rx_bytes))
+               goto nla_put_failure;
+       if ((sinfo->filled & STATION_INFO_TX_BYTES64) &&
+           nla_put_u64(msg, NL80211_STA_INFO_TX_BYTES64,
                        sinfo->tx_bytes))
                goto nla_put_failure;


IOW, always put the 32-bit value even if the driver said it had 64-bit,
but then also give the 64-bit value to userspace.

johannes

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux