Netdev List
 help / color / mirror / Atom feed
* Re: bug: 'ethtool -m' reports spurious alarm & warning threshold values for QSFP28 transceivers
From: Andrew Lunn @ 2018-09-26 21:46 UTC (permalink / raw)
  To: Chris Preimesberger; +Cc: linville@tuxdriver.com, netdev@vger.kernel.org
In-Reply-To: <82CEAF9FFBA4DD428B132074FB91DF7D5F64838C@CSI-MAILSRV.csicompanies.internal>

On Wed, Sep 26, 2018 at 08:47:34PM +0000, Chris Preimesberger wrote:
> Hello Andrew,
> 
> Thank you for the quick response!!
> Apologies in advance for my use of outlook and top-posting, etc...
> 
> I've run the raw option and the hex option, and pasted the results below.
> Since the raw option printed strange characters on the CLI, I re-ran it,
> Sending the output to a file (raw.txt) and attached that file as well.
> 
> Pasted from Ubuntu CLI:
> 
> tech1@D7:~$ 
> tech1@D7:~$ 
> tech1@D7:~$ 
> tech1@D7:~$ 
> tech1@D7:~$ sudo ethtool -m enp1s0 raw on
> \x11UU$��pA`?�@�G\x10#
>                  �\x12v\x01\x11��\x03�\x02@TRANSITION      ��TNQSFP100GCWDM4 1AfX%\x1cF?\x06?�TN02000301      180919  
>     h�\x02I��_��'\x16��Ri=\x02`��Zntech1@D7:~$ 
> tech1@D7:~$ 
> tech1@D7:~$ 
> tech1@D7:~$ 
> tech1@D7:~$ sudo ethtool -m enp1s0 hex on
> Offset		Values
> ------		------
> 0x0000:		11 00 00 0f 00 00 00 00 00 55 55 00 00 00 00 00 
> 0x0010:		00 00 00 00 00 00 24 e2 00 00 81 68 00 00 00 00 
> 0x0020:		00 00 00 00 00 00 00 00 00 00 41 60 3f e0 40 e0 
> 0x0030:		47 00 1f 10 0e 1e 0b f7 12 76 00 00 00 00 00 00 
> 0x0040:		00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
> 0x0050:		00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 
> 0x0060:		00 00 00 00 00 00 00 00 00 00 1f 00 00 00 00 00 
> 0x0070:		00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
> 0x0080:		11 fc 07 80 00 00 00 00 00 00 00 03 ff 00 02 00 
> 0x0090:		00 00 00 40 54 52 41 4e 53 49 54 49 4f 4e 20 20 
> 0x00a0:		20 20 20 20 00 00 c0 f2 54 4e 51 53 46 50 31 30 
> 0x00b0:		30 47 43 57 44 4d 34 20 31 41 66 58 25 1c 46 3f 
> 0x00c0:		06 00 3f d6 54 4e 30 32 30 30 30 33 30 31 20 20 
> 0x00d0:		20 20 20 20 31 38 30 39 31 39 20 20 0c 00 68 f3 
> 0x00e0:		00 00 02 49 80 a0 5f 1f de c9 27 16 f8 ae 52 69 
> 0x00f0:		3d 02 60 00 00 00 00 00 00 00 00 00 83 f4 5a 6e 

Hi Chris

I've only recently got involved with SFP modules. ethtool says this is
a SFF-8636 SFP. So a QSFP. It has multiple pages, each 128 bytes in
length, which should be returned in a concatenated form. Here we see
256 bytes, meaning there are two pages. There can be up to 5 pages.

ethtool is looking for the temperature alarms at offset 0x200. So that
does not exist in this hex dump. But the raw dump you provided has
more bytes, 0x400 of them.

So i would say the first bug is that ethtool dumps different amounts
of data in hex than raw.

The fact you get different alarm thresholds on different runs suggests
to me we might only be getting two pages from the kernel?

Can you build ethtool from source and run it inside a debugger?
ethtool makes two IOCTL calls. The first is ETHTOOL_GMODULEINFO.
Could you print out the modinfo which is returned. It then does a
ETHTOOL_GMODULEEEPROM. Can you print out eeprom after the second
IOCTL.

Thanks
	Andrew

^ permalink raw reply

* Re: bug: 'ethtool -m' reports spurious alarm & warning threshold values for QSFP28 transceivers
From: Neil Horman @ 2018-09-26 21:34 UTC (permalink / raw)
  To: Chris Preimesberger; +Cc: linville@tuxdriver.com, netdev@vger.kernel.org
In-Reply-To: <82CEAF9FFBA4DD428B132074FB91DF7D5F6481EA@CSI-MAILSRV.csicompanies.internal>

On Wed, Sep 26, 2018 at 07:29:23PM +0000, Chris Preimesberger wrote:
> Hello,
> 
> I'm re-sending in plain text per the auto-reply from a spam filter.  I have attached some text files this time, which explain the situation below, in case the below email's font & formatting is now too messed up for easy comprehension.
> 
> Thank you and best regards.
> 
> 
> Chris Preimesberger | Test & Validation Engineer
> Transition Networks, Inc.
> 
> chrisp@transition.com
> direct: +1.952.996.1509 | fax: +1.952.941.2322 | www.transition.com
> ________________________________________
> 
> 
> 
This is just a drive by guess, but I think this is a driver issue.  


Issue 1 seems like a red herring, cat doesn't modify output, nor does ethtool
know if its output is going to a console or a pipe, its all the same.  And given
issue 2 (that the output of the thresholds, etc are spurriously changing and
wrong), suggests that they are spurriously changing and wrong regardless of what
cat does.

That said, I think issue two is a problem with the mlx4 driver.  Specifically
that the driver is copying garbage data.

The three ethtool functions at work here are:
mlx4_en_get_module_info
mlx4_en_get_module_eeprom
mlx4_get_module_info

When you run ethtool -m on this driver, the kernel calls mlx4_en_get_module_info
to determine the length of the eeprom, and that value will be either 256 or 512
bytes.  Lets assume that the value is 256 for the sake of argument

Next it calls mlx4_en_get_module_eeprom, passing in that size 256 to actually
read the eeprom data, which in turn calls mlx4_get_module_info to fetch the data
from hardware, again, passing in 256 as the size for the first call (theres a
loop, but it will only get executed once in this scenario)

mlx4_get_module_info then issues the appropriate mailbox commands to dump the
eeprom.  Here it starts to go sideways.  The mailbox buffer allocated for the
return data is of type mlx4_mad_ifc, which has some front matter information and
a data buffer that is 192 bytes long!

A little further down in the function, size gets restricted if the buffer
crosses a page boundary, but given that the size is 256 on the first call here,
and offset is zero on the first call, we're not crossing anything, so size
remains unchanged.

The output mailbox buffer outmad->data (a 192 byte array), then gets cast to a
sturt mlx4_cable_info structure, which has its own internal data buffer that is
only 48 bytes long.

The memcpy in this functionthen copies cable_info->data to the buffer that gets
returned to ethtool, but it copies size bytes (256), even though the source data
buffer is only 48 bytes long.  That 48 byte array is embedded in the larger 192
byte structure, so there won't be a panic on the overrun, but theres no telling
what garbage is in the buffer beyond those first 48 bytes.  Even if the
remaining 144 bytes have valid eeprom data, its less than the required 256
bytes.  The additional copy may cause a panic, but if the buffer commonly bumps
up against other allocated memory, that will go unnoticed.

after the memcpy, mlx4_get_module_info just returns the size of the passed in
buffer (256), and so the calling function thinks its work is done, and lets  the
kernel send back the buffer with garbage data to ethtool.

I think the mlx4 guys have some work to do here.

My $0.02
Neil

> 
> 
> From: Chris Preimesberger 
> Sent: Wednesday, September 26, 2018 2:14 PM
> To: 'linville@tuxdriver.com'; 'netdev@vger.kernel.org'
> Subject: bug: 'ethtool -m' reports spurious alarm & warning threshold values for QSFP28 transceivers
> 
> Hello John, All,
> 
> 
> I think I may have found a bug or two in ethtool, with respect to its reporting of a QSFP28 transceiver's diagnostic information.  Ethtool seems to correctly report all diagnostic information about QSFP28 transceivers, except for the transceiver's warning and alarm thresholds.  I'm not sure whether the spurious warning and alarm values that get reported are the fault of ethtool or my NIC/driver, and I have no other models of 100GbE NICs to test with.  I've contacted Mellanox support about this, and they point the finger at ethtool.  Can these issues be investigated by ethtool developers?  Here is some background information about the equipment and software used when I observe these issues:
> 
> Equipment used:
> NIC: Mellanox ConnectX-4 100GbE, part number MCX415A-CCAT
> Transceiver: Any 40Gb or 100Gb QSFP28 transceiver installed in the NIC (Intel, Mellanox, Transition Networks, etc..)
> 
> Software used:
> Ubuntu 18.04 with the distro's packaged NIC driver and ethtool v4.15
> also tested were ethtool v4.18 compiled from source and the current Mellanox OFED driver.
> 
> All test scenarios produced the same bugs.
> 
> 
> Bug #1.  Ethtool's reporting of the installed transceiver's alarm and warning thresholds will differ, depending on whether or not ethtool is piped to another command.  Example commands are below, with their respective differing output values highlighted:
> 
> 
> tech1@D8:~$ sudo ethtool -m enp1s0
>         Identifier                                : 0x11 (QSFP28)
>         Extended identifier                       : 0xfc
>         Extended identifier description           : 3.5W max. Power consumption
>         Extended identifier description           : CDR present in TX, CDR present in RX
>         Extended identifier description           : High Power Class (> 3.5 W) not enabled
>         Connector                                 : 0x07 (LC)
>         Transceiver codes                         : 0x80 0x00 0x00 0x00 0x00 0x00 0x00 0x00
>         Transceiver type                          : 100G Ethernet: 100G CWDM4 MSA with FEC
>         Encoding                                  : 0x03 (NRZ)
>         BR, Nominal                               : 25500Mbps
>         Rate identifier                           : 0x00
>         Length (SMF,km)                           : 2km
>         Length (OM3 50um)                         : 0m
>         Length (OM2 50um)                         : 0m
>         Length (OM1 62.5um)                       : 0m
>         Length (Copper or Active cable)           : 0m
>         Transmitter technology                    : 0x40 (1310 nm DFB)
>         Laser wavelength                          : 1310.000nm
>         Laser wavelength tolerance                : 47.500nm
>         Vendor name                               : TRANSITION
>         Vendor OUI                                : 00:c0:f2
>         Vendor PN                                 : TNQSFP100GCWDM4
>         Vendor rev                                : 1A
>         Vendor SN                                 : TN02000302
>         Date code                                 : 180919
>         Revision Compliance                       : SFF-8636 Rev 2.5/2.6/2.7
>         Module temperature                        : 39.53 degrees C / 103.15 degrees F
>         Module voltage                            : 3.3241 V
>         Alarm/warning flags implemented           : Yes
>         Laser tx bias current (Channel 1)         : 34.432 mA
>         Laser tx bias current (Channel 2)         : 34.432 mA
>         Laser tx bias current (Channel 3)         : 33.408 mA
>         Laser tx bias current (Channel 4)         : 33.920 mA
>         Transmit avg optical power (Channel 1)    : 0.9048 mW / -0.43 dBm
>         Transmit avg optical power (Channel 2)    : 0.7832 mW / -1.06 dBm
>         Transmit avg optical power (Channel 3)    : 0.8057 mW / -0.94 dBm
>         Transmit avg optical power (Channel 4)    : 0.7014 mW / -1.54 dBm
>         Rcvr signal avg optical power(Channel 1)  : 0.7378 mW / -1.32 dBm
>         Rcvr signal avg optical power(Channel 2)  : 0.7553 mW / -1.22 dBm
>         Rcvr signal avg optical power(Channel 3)  : 0.6529 mW / -1.85 dBm
>         Rcvr signal avg optical power(Channel 4)  : 0.6847 mW / -1.64 dBm
>         Laser bias current high alarm   (Chan 1)  : Off
>         Laser bias current low alarm    (Chan 1)  : Off
>         Laser bias current high warning (Chan 1)  : Off
>         Laser bias current low warning  (Chan 1)  : Off
>         Laser bias current high alarm   (Chan 2)  : Off
>         Laser bias current low alarm    (Chan 2)  : Off
>         Laser bias current high warning (Chan 2)  : Off
>         Laser bias current low warning  (Chan 2)  : Off
>         Laser bias current high alarm   (Chan 3)  : Off
>         Laser bias current low alarm    (Chan 3)  : Off
>         Laser bias current high warning (Chan 3)  : Off
>         Laser bias current low warning  (Chan 3)  : Off
>         Laser bias current high alarm   (Chan 4)  : Off
>         Laser bias current low alarm    (Chan 4)  : Off
>         Laser bias current high warning (Chan 4)  : Off
>         Laser bias current low warning  (Chan 4)  : Off
>         Module temperature high alarm             : Off
>         Module temperature low alarm              : Off
>         Module temperature high warning           : Off
>         Module temperature low warning            : Off
>         Module voltage high alarm                 : Off
>         Module voltage low alarm                  : Off
>         Module voltage high warning               : Off
>         Module voltage low warning                : Off
>         Laser tx power high alarm   (Channel 1)   : Off
>         Laser tx power low alarm    (Channel 1)   : Off
>         Laser tx power high warning (Channel 1)   : Off
>         Laser tx power low warning  (Channel 1)   : Off
>         Laser tx power high alarm   (Channel 2)   : Off
>         Laser tx power low alarm    (Channel 2)   : Off
>         Laser tx power high warning (Channel 2)   : Off
>         Laser tx power low warning  (Channel 2)   : Off
>         Laser tx power high alarm   (Channel 3)   : Off
>         Laser tx power low alarm    (Channel 3)   : Off
>         Laser tx power high warning (Channel 3)   : Off
>         Laser tx power low warning  (Channel 3)   : Off
>         Laser tx power high alarm   (Channel 4)   : Off
>         Laser tx power low alarm    (Channel 4)   : Off
>         Laser tx power high warning (Channel 4)   : Off
>         Laser tx power low warning  (Channel 4)   : Off
>         Laser rx power high alarm   (Channel 1)   : Off
>         Laser rx power low alarm    (Channel 1)   : Off
>         Laser rx power high warning (Channel 1)   : Off
>         Laser rx power low warning  (Channel 1)   : Off
>         Laser rx power high alarm   (Channel 2)   : Off
>         Laser rx power low alarm    (Channel 2)   : Off
>         Laser rx power high warning (Channel 2)   : Off
>         Laser rx power low warning  (Channel 2)   : Off
>         Laser rx power high alarm   (Channel 3)   : Off
>         Laser rx power low alarm    (Channel 3)   : Off
>         Laser rx power high warning (Channel 3)   : Off
>         Laser rx power low warning  (Channel 3)   : Off
>         Laser rx power high alarm   (Channel 4)   : Off
>         Laser rx power low alarm    (Channel 4)   : Off
>         Laser rx power high warning (Channel 4)   : Off
>         Laser rx power low warning  (Channel 4)   : Off
>         Laser bias current high alarm threshold   : 0.000 mA
>         Laser bias current low alarm threshold    : 0.000 mA
>         Laser bias current high warning threshold : 0.000 mA
>         Laser bias current low warning threshold  : 0.000 mA
>         Laser output power high alarm threshold   : 0.0000 mW / -inf dBm
>         Laser output power low alarm threshold    : 0.0000 mW / -inf dBm
>         Laser output power high warning threshold : 0.0000 mW / -inf dBm
>         Laser output power low warning threshold  : 0.0000 mW / -inf dBm
>         Module temperature high alarm threshold   : 0.00 degrees C / 32.00 degrees F
>         Module temperature low alarm threshold    : 0.00 degrees C / 32.00 degrees F
>         Module temperature high warning threshold : 0.00 degrees C / 32.00 degrees F
>         Module temperature low warning threshold  : 0.00 degrees C / 32.00 degrees F
>         Module voltage high alarm threshold       : 0.0000 V
>         Module voltage low alarm threshold        : 0.0000 V
>         Module voltage high warning threshold     : 0.0000 V
>         Module voltage low warning threshold      : 0.0000 V
>         Laser rx power high alarm threshold       : 0.0000 mW / -inf dBm
>         Laser rx power low alarm threshold        : 0.0000 mW / -inf dBm
>         Laser rx power high warning threshold     : 0.0000 mW / -inf dBm
>         Laser rx power low warning threshold      : 0.0000 mW / -inf dBm
> 
> 
> tech1@D8:~$ sudo ethtool -m enp1s0 | cat
>         Identifier                                : 0x11 (QSFP28)
>         Extended identifier                       : 0xfc
>         Extended identifier description           : 3.5W max. Power consumption
>         Extended identifier description           : CDR present in TX, CDR present in RX
>         Extended identifier description           : High Power Class (> 3.5 W) not enabled
>         Connector                                 : 0x07 (LC)
>         Transceiver codes                         : 0x80 0x00 0x00 0x00 0x00 0x00 0x00 0x00
>         Transceiver type                          : 100G Ethernet: 100G CWDM4 MSA with FEC
>         Encoding                                  : 0x03 (NRZ)
>         BR, Nominal                               : 25500Mbps
>         Rate identifier                           : 0x00
>         Length (SMF,km)                           : 2km
>         Length (OM3 50um)                         : 0m
>         Length (OM2 50um)                         : 0m
>         Length (OM1 62.5um)                       : 0m
>         Length (Copper or Active cable)           : 0m
>         Transmitter technology                    : 0x40 (1310 nm DFB)
>         Laser wavelength                          : 1310.000nm
>         Laser wavelength tolerance                : 47.500nm
>         Vendor name                               : TRANSITION
>         Vendor OUI                                : 00:c0:f2
>         Vendor PN                                 : TNQSFP100GCWDM4
>         Vendor rev                                : 1A
>         Vendor SN                                 : TN02000302
>         Date code                                 : 180919
>         Revision Compliance                       : SFF-8636 Rev 2.5/2.6/2.7
>         Module temperature                        : 39.53 degrees C / 103.15 degrees F
>         Module voltage                            : 3.3249 V
>         Alarm/warning flags implemented           : Yes
>         Laser tx bias current (Channel 1)         : 34.432 mA
>         Laser tx bias current (Channel 2)         : 34.432 mA
>         Laser tx bias current (Channel 3)         : 33.408 mA
>         Laser tx bias current (Channel 4)         : 33.920 mA
>         Transmit avg optical power (Channel 1)    : 0.9043 mW / -0.44 dBm
>         Transmit avg optical power (Channel 2)    : 0.7832 mW / -1.06 dBm
>         Transmit avg optical power (Channel 3)    : 0.8057 mW / -0.94 dBm
>         Transmit avg optical power (Channel 4)    : 0.7009 mW / -1.54 dBm
>         Rcvr signal avg optical power(Channel 1)  : 0.7378 mW / -1.32 dBm
>         Rcvr signal avg optical power(Channel 2)  : 0.7553 mW / -1.22 dBm
>         Rcvr signal avg optical power(Channel 3)  : 0.6529 mW / -1.85 dBm
>         Rcvr signal avg optical power(Channel 4)  : 0.6847 mW / -1.64 dBm
>         Laser bias current high alarm   (Chan 1)  : Off
>         Laser bias current low alarm    (Chan 1)  : Off
>         Laser bias current high warning (Chan 1)  : Off
>         Laser bias current low warning  (Chan 1)  : Off
>         Laser bias current high alarm   (Chan 2)  : Off
>         Laser bias current low alarm    (Chan 2)  : Off
>         Laser bias current high warning (Chan 2)  : Off
>         Laser bias current low warning  (Chan 2)  : Off
>         Laser bias current high alarm   (Chan 3)  : Off
>         Laser bias current low alarm    (Chan 3)  : Off
>         Laser bias current high warning (Chan 3)  : Off
>         Laser bias current low warning  (Chan 3)  : Off
>         Laser bias current high alarm   (Chan 4)  : Off
>         Laser bias current low alarm    (Chan 4)  : Off
>         Laser bias current high warning (Chan 4)  : Off
>         Laser bias current low warning  (Chan 4)  : Off
>         Module temperature high alarm             : Off
>         Module temperature low alarm              : Off
>         Module temperature high warning           : Off
>         Module temperature low warning            : Off
>         Module voltage high alarm                 : Off
>         Module voltage low alarm                  : Off
>         Module voltage high warning               : Off
>         Module voltage low warning                : Off
>         Laser tx power high alarm   (Channel 1)   : Off
>         Laser tx power low alarm    (Channel 1)   : Off
>         Laser tx power high warning (Channel 1)   : Off
>         Laser tx power low warning  (Channel 1)   : Off
>         Laser tx power high alarm   (Channel 2)   : Off
>         Laser tx power low alarm    (Channel 2)   : Off
>         Laser tx power high warning (Channel 2)   : Off
>         Laser tx power low warning  (Channel 2)   : Off
>         Laser tx power high alarm   (Channel 3)   : Off
>         Laser tx power low alarm    (Channel 3)   : Off
>         Laser tx power high warning (Channel 3)   : Off
>         Laser tx power low warning  (Channel 3)   : Off
>         Laser tx power high alarm   (Channel 4)   : Off
>         Laser tx power low alarm    (Channel 4)   : Off
>         Laser tx power high warning (Channel 4)   : Off
>         Laser tx power low warning  (Channel 4)   : Off
>         Laser rx power high alarm   (Channel 1)   : Off
>         Laser rx power low alarm    (Channel 1)   : Off
>         Laser rx power high warning (Channel 1)   : Off
>         Laser rx power low warning  (Channel 1)   : Off
>         Laser rx power high alarm   (Channel 2)   : Off
>         Laser rx power low alarm    (Channel 2)   : Off
>         Laser rx power high warning (Channel 2)   : Off
>         Laser rx power low warning  (Channel 2)   : Off
>         Laser rx power high alarm   (Channel 3)   : Off
>         Laser rx power low alarm    (Channel 3)   : Off
>         Laser rx power high warning (Channel 3)   : Off
>         Laser rx power low warning  (Channel 3)   : Off
>         Laser rx power high alarm   (Channel 4)   : Off
>         Laser rx power low alarm    (Channel 4)   : Off
>         Laser rx power high warning (Channel 4)   : Off
>         Laser rx power low warning  (Channel 4)   : Off
>         Laser bias current high alarm threshold   : 16.448 mA
>         Laser bias current low alarm threshold    : 16.448 mA
>         Laser bias current high warning threshold : 16.448 mA
>         Laser bias current low warning threshold  : 16.448 mA
>         Laser output power high alarm threshold   : 0.8224 mW / -0.85 dBm
>         Laser output power low alarm threshold    : 0.8250 mW / -0.84 dBm
>         Laser output power high warning threshold : 0.8264 mW / -0.83 dBm
>         Laser output power low warning threshold  : 2.6983 mW / 4.31 dBm
>         Module temperature high alarm threshold   : 110.12 degrees C / 230.22 degrees F
>         Module temperature low alarm threshold    : 84.34 degrees C / 183.82 degrees F
>         Module temperature high warning threshold : 44.12 degrees C / 111.42 degrees F
>         Module temperature low warning threshold  : 67.27 degrees C / 153.08 degrees F
>         Module voltage high alarm threshold       : 2.9728 V
>         Module voltage low alarm threshold        : 2.6990 V
>         Module voltage high warning threshold     : 0.8274 V
>         Module voltage low warning threshold      : 2.2538 V
>         Laser rx power high alarm threshold       : 2.5458 mW / 4.06 dBm
>         Laser rx power low alarm threshold        : 2.6992 mW / 4.31 dBm
>         Laser rx power high warning threshold     : 2.9801 mW / 4.74 dBm
>         Laser rx power low warning threshold      : 2.8526 mW / 4.55 dBm
> 
> 
> Bug # 2. All of the alarm and warning threshold values reported in the above commands are spurious.
> At first glance, one would assume that the threshold values reported by the piped ethtool command are correct, but they're not.  I know the programmed values for the above transceiver, so that makes it easy for me to spot the spurious values, but even without knowing the programmed values of a given transceiver, one can use logic to detect when the ethtool displayed values don't make sense.
> For example, lets scrutinize the values for voltage warnings and alarms reported by ethtool on this transceiver.  We will look at each voltage threshold, and scrutinize that value relative to the other voltage thresholds, and look for contradictions to determine whether the reported values seem legit.  
>                                 Known           ethtool
>                                 Actual          Reported
>          Values          Values
> High Voltage Alarm              3.70V           2.9728 V
> High Voltage Warning            3.59V           0.8274 V
> (Operating spec = 3.30V)        
> Low Voltage Warning             3.00V           2.2538 V
> Low Voltage Alarm               2.90V           2.6990 V
> 
> Contradictions for the ethtool reported voltage warning and alarm thresholds:
> 1. The high voltage alarm should occur at higher voltage than the operating voltage, but ethtool didn't report that.
> 2. The high voltage warning should occur at higher voltage than the low voltage warning and alarm, but ethtool didn't report that.
> 3. The low voltage warning should occur at higher voltage than the low voltage alarm, but ethtool didn't report that.
> 4. The low voltage alarm should occur at a lower voltage than any of the other voltage warnings and alarms, but ethtool didn't report that.
> 5. The current voltage value was reported as 3.3249V, which should trigger high voltage warning and alarm, according to the reported thresholds, but no warnings or alarms are indicated.  
>  
> Each of the 4 voltage thresholds reported by ethtool have contradictions, so we know something is not right.  This same kind of logic can be applied to the thresholds for temperature, laser TX power, etc.. to find that those values are also spurious.
> 
> 
> Installing the above transceiver in a Cisco switch reveals that the Cisco correctly retrieves the true warning and alarm threshold values from the transceiver's EEPROM, so we trust that the transceiver has been correctly programmed.  Cisco CLI output for that transceiver shown here:
> 
> switch# show interface ethernet 1/3 transceiver details 
> Ethernet1/3
>     transceiver is present
>     type is QSFP-100G-CWDM4-MSA-FEC
>     name is TRANSITION
>     part number is TNQSFP100GCWDM4
>     revision is 1A
>     serial number is TN02000302
>     nominal bitrate is 25500 MBit/sec per channel
>     Link length supported for 9/125um fiber is 2 km
>     cisco id is 17
>     cisco extended id number is 252
> 
> Lane Number:1 Network Lane
>            SFP Detail Diagnostics Information (internal calibration)
>   ----------------------------------------------------------------------------
>                 Current              Alarms                  Warnings
>                 Measurement     High        Low         High          Low
>   ----------------------------------------------------------------------------
>   Temperature   38.08 C        80.00 C    -10.00 C     75.00 C       -5.00 C
>   Voltage        3.34 V         3.70 V      2.90 V      3.59 V        3.00 V
>   Current       34.24 mA       75.00 mA    10.00 mA    70.00 mA      15.00 mA
>   Tx Power      -0.44 dBm       4.49 dBm   -8.50 dBm    3.49 dBm     -7.52 dBm
>   Rx Power          N/A         4.49 dBm  -14.55 dBm    3.49 dBm    -12.51 dBm
>   Transmit Fault Count = 0
>   ----------------------------------------------------------------------------
>   Note: ++  high-alarm; +  high-warning; --  low-alarm; -  low-warning
> 
> Lane Number:2 Network Lane
>            SFP Detail Diagnostics Information (internal calibration)
>   ----------------------------------------------------------------------------
>                 Current              Alarms                  Warnings
>                 Measurement     High        Low         High          Low
>   ----------------------------------------------------------------------------
>   Temperature   38.08 C        80.00 C    -10.00 C     75.00 C       -5.00 C
>   Voltage        3.34 V         3.70 V      2.90 V      3.59 V        3.00 V
>   Current       34.24 mA       75.00 mA    10.00 mA    70.00 mA      15.00 mA
>   Tx Power      -1.20 dBm       4.49 dBm   -8.50 dBm    3.49 dBm     -7.52 dBm
>   Rx Power          N/A         4.49 dBm  -14.55 dBm    3.49 dBm    -12.51 dBm
>   Transmit Fault Count = 0
>   ----------------------------------------------------------------------------
>   Note: ++  high-alarm; +  high-warning; --  low-alarm; -  low-warning
> 
> Lane Number:3 Network Lane
>            SFP Detail Diagnostics Information (internal calibration)
>   ----------------------------------------------------------------------------
>                 Current              Alarms                  Warnings
>                 Measurement     High        Low         High          Low
>   ----------------------------------------------------------------------------
>   Temperature   38.08 C        80.00 C    -10.00 C     75.00 C       -5.00 C
>   Voltage        3.34 V         3.70 V      2.90 V      3.59 V        3.00 V
>   Current       33.21 mA       75.00 mA    10.00 mA    70.00 mA      15.00 mA
>   Tx Power      -0.96 dBm       4.49 dBm   -8.50 dBm    3.49 dBm     -7.52 dBm
>   Rx Power          N/A         4.49 dBm  -14.55 dBm    3.49 dBm    -12.51 dBm
>  Transmit Fault Count = 0
>   ----------------------------------------------------------------------------
>   Note: ++  high-alarm; +  high-warning; --  low-alarm; -  low-warning
> 
> Lane Number:4 Network Lane
>            SFP Detail Diagnostics Information (internal calibration)
>   ----------------------------------------------------------------------------
>                 Current              Alarms                  Warnings
>                 Measurement     High        Low         High          Low
>   ----------------------------------------------------------------------------
>   Temperature   38.08 C        80.00 C    -10.00 C     75.00 C       -5.00 C
>   Voltage        3.34 V         3.70 V      2.90 V      3.59 V        3.00 V
>   Current       33.72 mA       75.00 mA    10.00 mA    70.00 mA      15.00 mA
>   Tx Power      -1.59 dBm       4.49 dBm   -8.50 dBm    3.49 dBm     -7.52 dBm
>   Rx Power          N/A         4.49 dBm  -14.55 dBm    3.49 dBm    -12.51 dBm
>   Transmit Fault Count = 0
>   ----------------------------------------------------------------------------
>   Note: ++  high-alarm; +  high-warning; --  low-alarm; -  low-warning
> 
> switch#
> 
> 
> Any help with these issues is greatly appreciated.  If you have any questions or advice, please let me know.  I'll be glad to continue troubleshooting this until it's resolved.  Thank you.    
> 
> 
> Chris Preimesberger | Test & Validation Engineer
> Transition Networks, Inc.
> 
> chrisp@transition.com
> direct: +1.952.996.1509 | fax: +1.952.941.2322 | www.transition.com
> ________________________________________
> 
> 
> 
> 
> 
> 
> 

> For comparison to ethtool's output that shows incorrect threshold values, when installing the same transceiver in a Cisco Nexus switch, and issuing the Cisco command "show interface ethernet 1/3 transceiver details", the switch correctly correctly reads/displays the transceiver's Alarm and Warning thresholds, as shown below:
> 
> 
> switch# show interface ethernet 1/3 transceiver details 
> Ethernet1/3
>     transceiver is present
>     type is QSFP-100G-CWDM4-MSA-FEC
>     name is TRANSITION
>     part number is TNQSFP100GCWDM4
>     revision is 1A
>     serial number is TN02000302
>     nominal bitrate is 25500 MBit/sec per channel
>     Link length supported for 9/125um fiber is 2 km
>     cisco id is 17
>     cisco extended id number is 252
> 
> Lane Number:1 Network Lane
>            SFP Detail Diagnostics Information (internal calibration)
>   ----------------------------------------------------------------------------
>                 Current              Alarms                  Warnings
>                 Measurement     High        Low         High          Low
>   ----------------------------------------------------------------------------
>   Temperature   38.08 C        80.00 C    -10.00 C     75.00 C       -5.00 C
>   Voltage        3.34 V         3.70 V      2.90 V      3.59 V        3.00 V
>   Current       34.24 mA       75.00 mA    10.00 mA    70.00 mA      15.00 mA
>   Tx Power      -0.44 dBm       4.49 dBm   -8.50 dBm    3.49 dBm     -7.52 dBm
>   Rx Power          N/A         4.49 dBm  -14.55 dBm    3.49 dBm    -12.51 dBm
>   Transmit Fault Count = 0
>   ----------------------------------------------------------------------------
>   Note: ++  high-alarm; +  high-warning; --  low-alarm; -  low-warning
> 
> Lane Number:2 Network Lane
>            SFP Detail Diagnostics Information (internal calibration)
>   ----------------------------------------------------------------------------
>                 Current              Alarms                  Warnings
>                 Measurement     High        Low         High          Low
>   ----------------------------------------------------------------------------
>   Temperature   38.08 C        80.00 C    -10.00 C     75.00 C       -5.00 C
>   Voltage        3.34 V         3.70 V      2.90 V      3.59 V        3.00 V
>   Current       34.24 mA       75.00 mA    10.00 mA    70.00 mA      15.00 mA
>   Tx Power      -1.20 dBm       4.49 dBm   -8.50 dBm    3.49 dBm     -7.52 dBm
>   Rx Power          N/A         4.49 dBm  -14.55 dBm    3.49 dBm    -12.51 dBm
>   Transmit Fault Count = 0
>   ----------------------------------------------------------------------------
>   Note: ++  high-alarm; +  high-warning; --  low-alarm; -  low-warning
> 
> Lane Number:3 Network Lane
>            SFP Detail Diagnostics Information (internal calibration)
>   ----------------------------------------------------------------------------
>                 Current              Alarms                  Warnings
>                 Measurement     High        Low         High          Low
>   ----------------------------------------------------------------------------
>   Temperature   38.08 C        80.00 C    -10.00 C     75.00 C       -5.00 C
>   Voltage        3.34 V         3.70 V      2.90 V      3.59 V        3.00 V
>   Current       33.21 mA       75.00 mA    10.00 mA    70.00 mA      15.00 mA
>   Tx Power      -0.96 dBm       4.49 dBm   -8.50 dBm    3.49 dBm     -7.52 dBm
>   Rx Power          N/A         4.49 dBm  -14.55 dBm    3.49 dBm    -12.51 dBm
>   Transmit Fault Count = 0
>   ----------------------------------------------------------------------------
>   Note: ++  high-alarm; +  high-warning; --  low-alarm; -  low-warning
> 
> Lane Number:4 Network Lane
>            SFP Detail Diagnostics Information (internal calibration)
>   ----------------------------------------------------------------------------
>                 Current              Alarms                  Warnings
>                 Measurement     High        Low         High          Low
>   ----------------------------------------------------------------------------
>   Temperature   38.08 C        80.00 C    -10.00 C     75.00 C       -5.00 C
>   Voltage        3.34 V         3.70 V      2.90 V      3.59 V        3.00 V
>   Current       33.72 mA       75.00 mA    10.00 mA    70.00 mA      15.00 mA
>   Tx Power      -1.59 dBm       4.49 dBm   -8.50 dBm    3.49 dBm     -7.52 dBm
>   Rx Power          N/A         4.49 dBm  -14.55 dBm    3.49 dBm    -12.51 dBm
>   Transmit Fault Count = 0
>   ----------------------------------------------------------------------------
>   Note: ++  high-alarm; +  high-warning; --  low-alarm; -  low-warning
> 
> switch# 
> 

> 
> Look at each line in the ethtool output below that includes the word "threshold".  This file has been hand-edited to show the threshold values that have been programmed into the transceiver, which should be displayed by ethtool.  The threshold values shown below are copied and pasted from the output of the Cisco NX-OS command "show interface ethernet 1/3 transceiver details", while the transceiver was installed in a Cisco Nexus switch.
> 
> Note - I only copied the threshold values in the units that were displayed by the Cisco switch.  The "?" symbols are just a placeholder for the converted values; I was too lazy to do conversions between dBm and mW, or between degrees C and degrees F.  Ethtool would be expected to report the true / converted values.
> 
> 
> 
> 
> tech1@D8:~$ sudo ethtool -m enp1s0
> 	Identifier                                : 0x11 (QSFP28)
> 	Extended identifier                       : 0xfc
> 	Extended identifier description           : 3.5W max. Power consumption
> 	Extended identifier description           : CDR present in TX, CDR present in RX
> 	Extended identifier description           : High Power Class (> 3.5 W) not enabled
> 	Connector                                 : 0x07 (LC)
> 	Transceiver codes                         : 0x80 0x00 0x00 0x00 0x00 0x00 0x00 0x00
> 	Transceiver type                          : 100G Ethernet: 100G CWDM4 MSA with FEC
> 	Encoding                                  : 0x03 (NRZ)
> 	BR, Nominal                               : 25500Mbps
> 	Rate identifier                           : 0x00
> 	Length (SMF,km)                           : 2km
> 	Length (OM3 50um)                         : 0m
> 	Length (OM2 50um)                         : 0m
> 	Length (OM1 62.5um)                       : 0m
> 	Length (Copper or Active cable)           : 0m
> 	Transmitter technology                    : 0x40 (1310 nm DFB)
> 	Laser wavelength                          : 1310.000nm
> 	Laser wavelength tolerance                : 47.500nm
> 	Vendor name                               : TRANSITION
> 	Vendor OUI                                : 00:c0:f2
> 	Vendor PN                                 : TNQSFP100GCWDM4
> 	Vendor rev                                : 1A
> 	Vendor SN                                 : TN02000302
> 	Date code                                 : 180919
> 	Revision Compliance                       : SFF-8636 Rev 2.5/2.6/2.7
> 	Module temperature                        : 39.53 degrees C / 103.15 degrees F
> 	Module voltage                            : 3.3233 V
> 	Alarm/warning flags implemented           : Yes
> 	Laser tx bias current (Channel 1)         : 34.432 mA
> 	Laser tx bias current (Channel 2)         : 34.432 mA
> 	Laser tx bias current (Channel 3)         : 33.408 mA
> 	Laser tx bias current (Channel 4)         : 33.920 mA
> 	Transmit avg optical power (Channel 1)    : 0.9052 mW / -0.43 dBm
> 	Transmit avg optical power (Channel 2)    : 0.7832 mW / -1.06 dBm
> 	Transmit avg optical power (Channel 3)    : 0.8057 mW / -0.94 dBm
> 	Transmit avg optical power (Channel 4)    : 0.7009 mW / -1.54 dBm
> 	Rcvr signal avg optical power(Channel 1)  : 0.7378 mW / -1.32 dBm
> 	Rcvr signal avg optical power(Channel 2)  : 0.7553 mW / -1.22 dBm
> 	Rcvr signal avg optical power(Channel 3)  : 0.6529 mW / -1.85 dBm
> 	Rcvr signal avg optical power(Channel 4)  : 0.6948 mW / -1.58 dBm
> 	Laser bias current high alarm   (Chan 1)  : Off
> 	Laser bias current low alarm    (Chan 1)  : Off
> 	Laser bias current high warning (Chan 1)  : Off
> 	Laser bias current low warning  (Chan 1)  : Off
> 	Laser bias current high alarm   (Chan 2)  : Off
> 	Laser bias current low alarm    (Chan 2)  : Off
> 	Laser bias current high warning (Chan 2)  : Off
> 	Laser bias current low warning  (Chan 2)  : Off
> 	Laser bias current high alarm   (Chan 3)  : Off
> 	Laser bias current low alarm    (Chan 3)  : Off
> 	Laser bias current high warning (Chan 3)  : Off
> 	Laser bias current low warning  (Chan 3)  : Off
> 	Laser bias current high alarm   (Chan 4)  : Off
> 	Laser bias current low alarm    (Chan 4)  : Off
> 	Laser bias current high warning (Chan 4)  : Off
> 	Laser bias current low warning  (Chan 4)  : Off
> 	Module temperature high alarm             : Off
> 	Module temperature low alarm              : Off
> 	Module temperature high warning           : Off
> 	Module temperature low warning            : Off
> 	Module voltage high alarm                 : Off
> 	Module voltage low alarm                  : Off
> 	Module voltage high warning               : Off
> 	Module voltage low warning                : Off
> 	Laser tx power high alarm   (Channel 1)   : Off
> 	Laser tx power low alarm    (Channel 1)   : Off
> 	Laser tx power high warning (Channel 1)   : Off
> 	Laser tx power low warning  (Channel 1)   : Off
> 	Laser tx power high alarm   (Channel 2)   : Off
> 	Laser tx power low alarm    (Channel 2)   : Off
> 	Laser tx power high warning (Channel 2)   : Off
> 	Laser tx power low warning  (Channel 2)   : Off
> 	Laser tx power high alarm   (Channel 3)   : Off
> 	Laser tx power low alarm    (Channel 3)   : Off
> 	Laser tx power high warning (Channel 3)   : Off
> 	Laser tx power low warning  (Channel 3)   : Off
> 	Laser tx power high alarm   (Channel 4)   : Off
> 	Laser tx power low alarm    (Channel 4)   : Off
> 	Laser tx power high warning (Channel 4)   : Off
> 	Laser tx power low warning  (Channel 4)   : Off
> 	Laser rx power high alarm   (Channel 1)   : Off
> 	Laser rx power low alarm    (Channel 1)   : Off
> 	Laser rx power high warning (Channel 1)   : Off
> 	Laser rx power low warning  (Channel 1)   : Off
> 	Laser rx power high alarm   (Channel 2)   : Off
> 	Laser rx power low alarm    (Channel 2)   : Off
> 	Laser rx power high warning (Channel 2)   : Off
> 	Laser rx power low warning  (Channel 2)   : Off
> 	Laser rx power high alarm   (Channel 3)   : Off
> 	Laser rx power low alarm    (Channel 3)   : Off
> 	Laser rx power high warning (Channel 3)   : Off
> 	Laser rx power low warning  (Channel 3)   : Off
> 	Laser rx power high alarm   (Channel 4)   : Off
> 	Laser rx power low alarm    (Channel 4)   : Off
> 	Laser rx power high warning (Channel 4)   : Off
> 	Laser rx power low warning  (Channel 4)   : Off
> 	Laser bias current high alarm threshold   : 75.000 mA
> 	Laser bias current low alarm threshold    : 10.000 mA
> 	Laser bias current high warning threshold : 70.000 mA
> 	Laser bias current low warning threshold  : 15.000 mA
> 	Laser output power high alarm threshold   : ? mW / 4.49 dBm
> 	Laser output power low alarm threshold    : ? mW / -8.50 dBm
> 	Laser output power high warning threshold : ? mW / 3.49 dBm
> 	Laser output power low warning threshold  : ? mW / -7.52 dBm
> 	Module temperature high alarm threshold   : 80.00 degrees C / ? degrees F
> 	Module temperature low alarm threshold    : -10.00 degrees C / ? degrees F
> 	Module temperature high warning threshold : 75.00 degrees C / ? degrees F
> 	Module temperature low warning threshold  : -5.00 degrees C / ? degrees F
> 	Module voltage high alarm threshold       : 3.7000 V
> 	Module voltage low alarm threshold        : 2.9000 V
> 	Module voltage high warning threshold     : 3.5900 V
> 	Module voltage low warning threshold      : 3.0000 V
> 	Laser rx power high alarm threshold       : ? mW / 4.49 dBm
> 	Laser rx power low alarm threshold        : ? mW / -14.55 dBm
> 	Laser rx power high warning threshold     : ? mW / 3.49 dBm
> 	Laser rx power low warning threshold      : ? mW / -12.51 dBm
> 

> 
> Look at each line in the ethtool output below that includes the word "threshold".  This file shows the actual output from ethtool v4.18, when the output is not piped to another command.  Notice that all of the displayed threshold values are 0 (which is incorrect), while other values report as expected.
> 
> tech1@D8:~$ sudo ethtool -m enp1s0
> 	Identifier                                : 0x11 (QSFP28)
> 	Extended identifier                       : 0xfc
> 	Extended identifier description           : 3.5W max. Power consumption
> 	Extended identifier description           : CDR present in TX, CDR present in RX
> 	Extended identifier description           : High Power Class (> 3.5 W) not enabled
> 	Connector                                 : 0x07 (LC)
> 	Transceiver codes                         : 0x80 0x00 0x00 0x00 0x00 0x00 0x00 0x00
> 	Transceiver type                          : 100G Ethernet: 100G CWDM4 MSA with FEC
> 	Encoding                                  : 0x03 (NRZ)
> 	BR, Nominal                               : 25500Mbps
> 	Rate identifier                           : 0x00
> 	Length (SMF,km)                           : 2km
> 	Length (OM3 50um)                         : 0m
> 	Length (OM2 50um)                         : 0m
> 	Length (OM1 62.5um)                       : 0m
> 	Length (Copper or Active cable)           : 0m
> 	Transmitter technology                    : 0x40 (1310 nm DFB)
> 	Laser wavelength                          : 1310.000nm
> 	Laser wavelength tolerance                : 47.500nm
> 	Vendor name                               : TRANSITION
> 	Vendor OUI                                : 00:c0:f2
> 	Vendor PN                                 : TNQSFP100GCWDM4
> 	Vendor rev                                : 1A
> 	Vendor SN                                 : TN02000302
> 	Date code                                 : 180919
> 	Revision Compliance                       : SFF-8636 Rev 2.5/2.6/2.7
> 	Module temperature                        : 39.53 degrees C / 103.15 degrees F
> 	Module voltage                            : 3.3241 V
> 	Alarm/warning flags implemented           : Yes
> 	Laser tx bias current (Channel 1)         : 34.432 mA
> 	Laser tx bias current (Channel 2)         : 34.432 mA
> 	Laser tx bias current (Channel 3)         : 33.408 mA
> 	Laser tx bias current (Channel 4)         : 33.920 mA
> 	Transmit avg optical power (Channel 1)    : 0.9048 mW / -0.43 dBm
> 	Transmit avg optical power (Channel 2)    : 0.7832 mW / -1.06 dBm
> 	Transmit avg optical power (Channel 3)    : 0.8057 mW / -0.94 dBm
> 	Transmit avg optical power (Channel 4)    : 0.7014 mW / -1.54 dBm
> 	Rcvr signal avg optical power(Channel 1)  : 0.7378 mW / -1.32 dBm
> 	Rcvr signal avg optical power(Channel 2)  : 0.7553 mW / -1.22 dBm
> 	Rcvr signal avg optical power(Channel 3)  : 0.6529 mW / -1.85 dBm
> 	Rcvr signal avg optical power(Channel 4)  : 0.6847 mW / -1.64 dBm
> 	Laser bias current high alarm   (Chan 1)  : Off
> 	Laser bias current low alarm    (Chan 1)  : Off
> 	Laser bias current high warning (Chan 1)  : Off
> 	Laser bias current low warning  (Chan 1)  : Off
> 	Laser bias current high alarm   (Chan 2)  : Off
> 	Laser bias current low alarm    (Chan 2)  : Off
> 	Laser bias current high warning (Chan 2)  : Off
> 	Laser bias current low warning  (Chan 2)  : Off
> 	Laser bias current high alarm   (Chan 3)  : Off
> 	Laser bias current low alarm    (Chan 3)  : Off
> 	Laser bias current high warning (Chan 3)  : Off
> 	Laser bias current low warning  (Chan 3)  : Off
> 	Laser bias current high alarm   (Chan 4)  : Off
> 	Laser bias current low alarm    (Chan 4)  : Off
> 	Laser bias current high warning (Chan 4)  : Off
> 	Laser bias current low warning  (Chan 4)  : Off
> 	Module temperature high alarm             : Off
> 	Module temperature low alarm              : Off
> 	Module temperature high warning           : Off
> 	Module temperature low warning            : Off
> 	Module voltage high alarm                 : Off
> 	Module voltage low alarm                  : Off
> 	Module voltage high warning               : Off
> 	Module voltage low warning                : Off
> 	Laser tx power high alarm   (Channel 1)   : Off
> 	Laser tx power low alarm    (Channel 1)   : Off
> 	Laser tx power high warning (Channel 1)   : Off
> 	Laser tx power low warning  (Channel 1)   : Off
> 	Laser tx power high alarm   (Channel 2)   : Off
> 	Laser tx power low alarm    (Channel 2)   : Off
> 	Laser tx power high warning (Channel 2)   : Off
> 	Laser tx power low warning  (Channel 2)   : Off
> 	Laser tx power high alarm   (Channel 3)   : Off
> 	Laser tx power low alarm    (Channel 3)   : Off
> 	Laser tx power high warning (Channel 3)   : Off
> 	Laser tx power low warning  (Channel 3)   : Off
> 	Laser tx power high alarm   (Channel 4)   : Off
> 	Laser tx power low alarm    (Channel 4)   : Off
> 	Laser tx power high warning (Channel 4)   : Off
> 	Laser tx power low warning  (Channel 4)   : Off
> 	Laser rx power high alarm   (Channel 1)   : Off
> 	Laser rx power low alarm    (Channel 1)   : Off
> 	Laser rx power high warning (Channel 1)   : Off
> 	Laser rx power low warning  (Channel 1)   : Off
> 	Laser rx power high alarm   (Channel 2)   : Off
> 	Laser rx power low alarm    (Channel 2)   : Off
> 	Laser rx power high warning (Channel 2)   : Off
> 	Laser rx power low warning  (Channel 2)   : Off
> 	Laser rx power high alarm   (Channel 3)   : Off
> 	Laser rx power low alarm    (Channel 3)   : Off
> 	Laser rx power high warning (Channel 3)   : Off
> 	Laser rx power low warning  (Channel 3)   : Off
> 	Laser rx power high alarm   (Channel 4)   : Off
> 	Laser rx power low alarm    (Channel 4)   : Off
> 	Laser rx power high warning (Channel 4)   : Off
> 	Laser rx power low warning  (Channel 4)   : Off
> 	Laser bias current high alarm threshold   : 0.000 mA
> 	Laser bias current low alarm threshold    : 0.000 mA
> 	Laser bias current high warning threshold : 0.000 mA
> 	Laser bias current low warning threshold  : 0.000 mA
> 	Laser output power high alarm threshold   : 0.0000 mW / -inf dBm
> 	Laser output power low alarm threshold    : 0.0000 mW / -inf dBm
> 	Laser output power high warning threshold : 0.0000 mW / -inf dBm
> 	Laser output power low warning threshold  : 0.0000 mW / -inf dBm
> 	Module temperature high alarm threshold   : 0.00 degrees C / 32.00 degrees F
> 	Module temperature low alarm threshold    : 0.00 degrees C / 32.00 degrees F
> 	Module temperature high warning threshold : 0.00 degrees C / 32.00 degrees F
> 	Module temperature low warning threshold  : 0.00 degrees C / 32.00 degrees F
> 	Module voltage high alarm threshold       : 0.0000 V
> 	Module voltage low alarm threshold        : 0.0000 V
> 	Module voltage high warning threshold     : 0.0000 V
> 	Module voltage low warning threshold      : 0.0000 V
> 	Laser rx power high alarm threshold       : 0.0000 mW / -inf dBm
> 	Laser rx power low alarm threshold        : 0.0000 mW / -inf dBm
> 	Laser rx power high warning threshold     : 0.0000 mW / -inf dBm
> 	Laser rx power low warning threshold      : 0.0000 mW / -inf dBm
> 
> 

> 
> Look at each line in the ethtool output below that includes the word "threshold".  This file shows the actual output from ethtool v4.18, when the ethtool output is piped to another command.  Notice that all of the displayed threshold values are spurious while other values report as expected.
> 
> tech1@D8:~$ sudo ethtool -m enp1s0 | cat
> 	Identifier                                : 0x11 (QSFP28)
> 	Extended identifier                       : 0xfc
> 	Extended identifier description           : 3.5W max. Power consumption
> 	Extended identifier description           : CDR present in TX, CDR present in RX
> 	Extended identifier description           : High Power Class (> 3.5 W) not enabled
> 	Connector                                 : 0x07 (LC)
> 	Transceiver codes                         : 0x80 0x00 0x00 0x00 0x00 0x00 0x00 0x00
> 	Transceiver type                          : 100G Ethernet: 100G CWDM4 MSA with FEC
> 	Encoding                                  : 0x03 (NRZ)
> 	BR, Nominal                               : 25500Mbps
> 	Rate identifier                           : 0x00
> 	Length (SMF,km)                           : 2km
> 	Length (OM3 50um)                         : 0m
> 	Length (OM2 50um)                         : 0m
> 	Length (OM1 62.5um)                       : 0m
> 	Length (Copper or Active cable)           : 0m
> 	Transmitter technology                    : 0x40 (1310 nm DFB)
> 	Laser wavelength                          : 1310.000nm
> 	Laser wavelength tolerance                : 47.500nm
> 	Vendor name                               : TRANSITION
> 	Vendor OUI                                : 00:c0:f2
> 	Vendor PN                                 : TNQSFP100GCWDM4
> 	Vendor rev                                : 1A
> 	Vendor SN                                 : TN02000302
> 	Date code                                 : 180919
> 	Revision Compliance                       : SFF-8636 Rev 2.5/2.6/2.7
> 	Module temperature                        : 39.53 degrees C / 103.15 degrees F
> 	Module voltage                            : 3.3249 V
> 	Alarm/warning flags implemented           : Yes
> 	Laser tx bias current (Channel 1)         : 34.432 mA
> 	Laser tx bias current (Channel 2)         : 34.432 mA
> 	Laser tx bias current (Channel 3)         : 33.408 mA
> 	Laser tx bias current (Channel 4)         : 33.920 mA
> 	Transmit avg optical power (Channel 1)    : 0.9043 mW / -0.44 dBm
> 	Transmit avg optical power (Channel 2)    : 0.7832 mW / -1.06 dBm
> 	Transmit avg optical power (Channel 3)    : 0.8057 mW / -0.94 dBm
> 	Transmit avg optical power (Channel 4)    : 0.7009 mW / -1.54 dBm
> 	Rcvr signal avg optical power(Channel 1)  : 0.7378 mW / -1.32 dBm
> 	Rcvr signal avg optical power(Channel 2)  : 0.7553 mW / -1.22 dBm
> 	Rcvr signal avg optical power(Channel 3)  : 0.6529 mW / -1.85 dBm
> 	Rcvr signal avg optical power(Channel 4)  : 0.6847 mW / -1.64 dBm
> 	Laser bias current high alarm   (Chan 1)  : Off
> 	Laser bias current low alarm    (Chan 1)  : Off
> 	Laser bias current high warning (Chan 1)  : Off
> 	Laser bias current low warning  (Chan 1)  : Off
> 	Laser bias current high alarm   (Chan 2)  : Off
> 	Laser bias current low alarm    (Chan 2)  : Off
> 	Laser bias current high warning (Chan 2)  : Off
> 	Laser bias current low warning  (Chan 2)  : Off
> 	Laser bias current high alarm   (Chan 3)  : Off
> 	Laser bias current low alarm    (Chan 3)  : Off
> 	Laser bias current high warning (Chan 3)  : Off
> 	Laser bias current low warning  (Chan 3)  : Off
> 	Laser bias current high alarm   (Chan 4)  : Off
> 	Laser bias current low alarm    (Chan 4)  : Off
> 	Laser bias current high warning (Chan 4)  : Off
> 	Laser bias current low warning  (Chan 4)  : Off
> 	Module temperature high alarm             : Off
> 	Module temperature low alarm              : Off
> 	Module temperature high warning           : Off
> 	Module temperature low warning            : Off
> 	Module voltage high alarm                 : Off
> 	Module voltage low alarm                  : Off
> 	Module voltage high warning               : Off
> 	Module voltage low warning                : Off
> 	Laser tx power high alarm   (Channel 1)   : Off
> 	Laser tx power low alarm    (Channel 1)   : Off
> 	Laser tx power high warning (Channel 1)   : Off
> 	Laser tx power low warning  (Channel 1)   : Off
> 	Laser tx power high alarm   (Channel 2)   : Off
> 	Laser tx power low alarm    (Channel 2)   : Off
> 	Laser tx power high warning (Channel 2)   : Off
> 	Laser tx power low warning  (Channel 2)   : Off
> 	Laser tx power high alarm   (Channel 3)   : Off
> 	Laser tx power low alarm    (Channel 3)   : Off
> 	Laser tx power high warning (Channel 3)   : Off
> 	Laser tx power low warning  (Channel 3)   : Off
> 	Laser tx power high alarm   (Channel 4)   : Off
> 	Laser tx power low alarm    (Channel 4)   : Off
> 	Laser tx power high warning (Channel 4)   : Off
> 	Laser tx power low warning  (Channel 4)   : Off
> 	Laser rx power high alarm   (Channel 1)   : Off
> 	Laser rx power low alarm    (Channel 1)   : Off
> 	Laser rx power high warning (Channel 1)   : Off
> 	Laser rx power low warning  (Channel 1)   : Off
> 	Laser rx power high alarm   (Channel 2)   : Off
> 	Laser rx power low alarm    (Channel 2)   : Off
> 	Laser rx power high warning (Channel 2)   : Off
> 	Laser rx power low warning  (Channel 2)   : Off
> 	Laser rx power high alarm   (Channel 3)   : Off
> 	Laser rx power low alarm    (Channel 3)   : Off
> 	Laser rx power high warning (Channel 3)   : Off
> 	Laser rx power low warning  (Channel 3)   : Off
> 	Laser rx power high alarm   (Channel 4)   : Off
> 	Laser rx power low alarm    (Channel 4)   : Off
> 	Laser rx power high warning (Channel 4)   : Off
> 	Laser rx power low warning  (Channel 4)   : Off
> 	Laser bias current high alarm threshold   : 16.448 mA
> 	Laser bias current low alarm threshold    : 16.448 mA
> 	Laser bias current high warning threshold : 16.448 mA
> 	Laser bias current low warning threshold  : 16.448 mA
> 	Laser output power high alarm threshold   : 0.8224 mW / -0.85 dBm
> 	Laser output power low alarm threshold    : 0.8250 mW / -0.84 dBm
> 	Laser output power high warning threshold : 0.8264 mW / -0.83 dBm
> 	Laser output power low warning threshold  : 2.6983 mW / 4.31 dBm
> 	Module temperature high alarm threshold   : 110.12 degrees C / 230.22 degrees F
> 	Module temperature low alarm threshold    : 84.34 degrees C / 183.82 degrees F
> 	Module temperature high warning threshold : 44.12 degrees C / 111.42 degrees F
> 	Module temperature low warning threshold  : 67.27 degrees C / 153.08 degrees F
> 	Module voltage high alarm threshold       : 2.9728 V
> 	Module voltage low alarm threshold        : 2.6990 V
> 	Module voltage high warning threshold     : 0.8274 V
> 	Module voltage low warning threshold      : 2.2538 V
> 	Laser rx power high alarm threshold       : 2.5458 mW / 4.06 dBm
> 	Laser rx power low alarm threshold        : 2.6992 mW / 4.31 dBm
> 	Laser rx power high warning threshold     : 2.9801 mW / 4.74 dBm
> 	Laser rx power low warning threshold      : 2.8526 mW / 4.55 dBm
> tech1@D8:~$ 
> 

^ permalink raw reply

* Re: bpf: Massive skbuff_head_cache memory leak?
From: Daniel Borkmann @ 2018-09-26 21:22 UTC (permalink / raw)
  To: Tetsuo Handa, Alexei Starovoitov
  Cc: Network Development, David S. Miller, Dmitry Vyukov,
	Andrew Morton, Michal Hocko, John Johansen
In-Reply-To: <c33e8c78-6112-7c0d-c816-98aab90575cc@I-love.SAKURA.ne.jp>

On 09/26/2018 11:09 PM, Tetsuo Handa wrote:
> Hello, Alexei and Daniel.
> 
> Can you show us how to run testcases you are testing?

Sorry for the delay; currently quite backlogged but will definitely take a look
at these reports. Regarding your question: majority of test cases are in the
kernel tree under selftests, see tools/testing/selftests/bpf/ .

> On 2018/09/22 22:25, Tetsuo Handa wrote:
>> Hello.
>>
>> syzbot is reporting many lockup problems on bpf.git / bpf-next.git / net.git / net-next.git trees.
>>
>>   INFO: rcu detected stall in br_multicast_port_group_expired (2)
>>   https://syzkaller.appspot.com/bug?id=15c7ad8cf35a07059e8a697a22527e11d294bc94
>>
>>   INFO: rcu detected stall in tun_chr_close
>>   https://syzkaller.appspot.com/bug?id=6c50618bde03e5a2eefdd0269cf9739c5ebb8270
>>
>>   INFO: rcu detected stall in discover_timer
>>   https://syzkaller.appspot.com/bug?id=55da031ddb910e58ab9c6853a5784efd94f03b54
>>
>>   INFO: rcu detected stall in ret_from_fork (2)
>>   https://syzkaller.appspot.com/bug?id=c83129a6683b44b39f5b8864a1325893c9218363
>>
>>   INFO: rcu detected stall in addrconf_rs_timer
>>   https://syzkaller.appspot.com/bug?id=21c029af65f81488edbc07a10ed20792444711b6
>>
>>   INFO: rcu detected stall in kthread (2)
>>   https://syzkaller.appspot.com/bug?id=6accd1ed11c31110fed1982f6ad38cc9676477d2
>>
>>   INFO: rcu detected stall in ext4_filemap_fault
>>   https://syzkaller.appspot.com/bug?id=817e38d20e9ee53390ac361bf0fd2007eaf188af
>>
>>   INFO: rcu detected stall in run_timer_softirq (2)
>>   https://syzkaller.appspot.com/bug?id=f5a230a3ff7822f8d39fddf8485931bd06ae47fe
>>
>>   INFO: rcu detected stall in bpf_prog_ADDR
>>   https://syzkaller.appspot.com/bug?id=fb4911fd0e861171cc55124e209f810a0dd68744
>>
>>   INFO: rcu detected stall in __run_timers (2)
>>   https://syzkaller.appspot.com/bug?id=65416569ddc8d2feb8f19066aa761f5a47f7451a
>>
>> The cause of lockup seems to be flood of printk() messages from memory allocation
>> failures, and one of out_of_memory() messages indicates that skbuff_head_cache
>> usage is huge enough to suspect in-kernel memory leaks.
>>
>>   [ 1554.547011] skbuff_head_cache    1847887KB    1847887KB
>>
>> Unfortunately, we cannot find from logs what syzbot is trying to do
>> because constant printk() messages is flooding away syzkaller messages.
>> Can you try running your testcases with kmemleak enabled?
>>
> 
> On 2018/09/27 2:35, Dmitry Vyukov wrote:
>> I also started suspecting Apparmor. We switched to Apparmor on Aug 30:
>> https://groups.google.com/d/msg/syzkaller-bugs/o73lO4KGh0w/j9pcH2tSBAAJ
>> Now the instances that use SELinux and Smack explicitly contain that
>> in the name, but the rest are Apparmor.
>> Aug 30 roughly matches these assorted "task hung" reports. Perhaps
>> some Apparmor hook leaks a reference to skbs?
> 
> Maybe. They have CONFIG_DEFAULT_SECURITY="apparmor". But I'm wondering why
> this problem is not occurring on linux-next.git when this problem is occurring
> on bpf.git / bpf-next.git / net.git / net-next.git trees. Is syzbot running
> different testcases depending on which git tree is targeted?
> 

^ permalink raw reply

* Re: [PATCH] Documentation: Add HOWTO Korean translation into BPF and XDP Reference Guide.
From: Daniel Borkmann @ 2018-09-26 21:19 UTC (permalink / raw)
  To: Jonathan Corbet, Chang-an Song; +Cc: tj, netdev, davem
In-Reply-To: <20180926134441.5e731b8b@lwn.net>

On 09/26/2018 09:44 PM, Jonathan Corbet wrote:
> On Wed, 26 Sep 2018 18:11:42 +0900
> Chang-an Song <csongxdp@gmail.com> wrote:
> 
>>>  - The original document has a copyright assertion but no associated
>>>    license.  Do we know what the license is?  I assume it's something
>>>    that is free and GPL-compatible, but that would be good to know for
>>>    sure.  
>>
>> 3. I asked to main author Daniel that apache 2.0 license for this document.
> 
> That is a bit of a problem, since Apache v2 is not compatible with GPLv2.
> If the license of the document cannot be changed, I don't think we can
> accept it into the kernel tree.

Alternative option could also be to integrate it into Cilium's doc given the
original document is present there as well, so it could link to the Korean
version from there.

^ permalink raw reply

* Re: [PATCH net-next] net: mvneta: Add support for 2500Mbps SGMII
From: David Miller @ 2018-09-27  3:27 UTC (permalink / raw)
  To: maxime.chevallier
  Cc: netdev, linux-kernel, antoine.tenart, thomas.petazzoni,
	gregory.clement, miquel.raynal, nadavh, stefanc, mw, yelena,
	linux-arm-kernel
In-Reply-To: <20180925135939.4816-1-maxime.chevallier@bootlin.com>

From: Maxime Chevallier <maxime.chevallier@bootlin.com>
Date: Tue, 25 Sep 2018 15:59:39 +0200

> The mvneta controller can handle speeds up to 2500Mbps on the SGMII
> interface. This relies on serdes configuration, the lane must be
> configured at 3.125Gbps and we can't use in-band autoneg at that speed.
> 
> The main issue when supporting that speed on this particular controller
> is that the link partner can send ethernet frames with a shortened
> preamble, which if not explicitly enabled in the controller will cause
> unexpected behaviours.
> 
> This was tested on Armada 385, with the comphy configuration done in
> bootloader.
> 
> Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>

Applied.

^ permalink raw reply

* Re: bpf: Massive skbuff_head_cache memory leak?
From: Tetsuo Handa @ 2018-09-26 21:09 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann
  Cc: Network Development, David S. Miller, Dmitry Vyukov,
	Andrew Morton, Michal Hocko, John Johansen
In-Reply-To: <b11ff285-1e8a-2729-d065-ac263572c511@I-love.SAKURA.ne.jp>

Hello, Alexei and Daniel.

Can you show us how to run testcases you are testing?

On 2018/09/22 22:25, Tetsuo Handa wrote:
> Hello.
> 
> syzbot is reporting many lockup problems on bpf.git / bpf-next.git / net.git / net-next.git trees.
> 
>   INFO: rcu detected stall in br_multicast_port_group_expired (2)
>   https://syzkaller.appspot.com/bug?id=15c7ad8cf35a07059e8a697a22527e11d294bc94
> 
>   INFO: rcu detected stall in tun_chr_close
>   https://syzkaller.appspot.com/bug?id=6c50618bde03e5a2eefdd0269cf9739c5ebb8270
> 
>   INFO: rcu detected stall in discover_timer
>   https://syzkaller.appspot.com/bug?id=55da031ddb910e58ab9c6853a5784efd94f03b54
> 
>   INFO: rcu detected stall in ret_from_fork (2)
>   https://syzkaller.appspot.com/bug?id=c83129a6683b44b39f5b8864a1325893c9218363
> 
>   INFO: rcu detected stall in addrconf_rs_timer
>   https://syzkaller.appspot.com/bug?id=21c029af65f81488edbc07a10ed20792444711b6
> 
>   INFO: rcu detected stall in kthread (2)
>   https://syzkaller.appspot.com/bug?id=6accd1ed11c31110fed1982f6ad38cc9676477d2
> 
>   INFO: rcu detected stall in ext4_filemap_fault
>   https://syzkaller.appspot.com/bug?id=817e38d20e9ee53390ac361bf0fd2007eaf188af
> 
>   INFO: rcu detected stall in run_timer_softirq (2)
>   https://syzkaller.appspot.com/bug?id=f5a230a3ff7822f8d39fddf8485931bd06ae47fe
> 
>   INFO: rcu detected stall in bpf_prog_ADDR
>   https://syzkaller.appspot.com/bug?id=fb4911fd0e861171cc55124e209f810a0dd68744
> 
>   INFO: rcu detected stall in __run_timers (2)
>   https://syzkaller.appspot.com/bug?id=65416569ddc8d2feb8f19066aa761f5a47f7451a
> 
> The cause of lockup seems to be flood of printk() messages from memory allocation
> failures, and one of out_of_memory() messages indicates that skbuff_head_cache
> usage is huge enough to suspect in-kernel memory leaks.
> 
>   [ 1554.547011] skbuff_head_cache    1847887KB    1847887KB
> 
> Unfortunately, we cannot find from logs what syzbot is trying to do
> because constant printk() messages is flooding away syzkaller messages.
> Can you try running your testcases with kmemleak enabled?
> 

On 2018/09/27 2:35, Dmitry Vyukov wrote:
> I also started suspecting Apparmor. We switched to Apparmor on Aug 30:
> https://groups.google.com/d/msg/syzkaller-bugs/o73lO4KGh0w/j9pcH2tSBAAJ
> Now the instances that use SELinux and Smack explicitly contain that
> in the name, but the rest are Apparmor.
> Aug 30 roughly matches these assorted "task hung" reports. Perhaps
> some Apparmor hook leaks a reference to skbs?

Maybe. They have CONFIG_DEFAULT_SECURITY="apparmor". But I'm wondering why
this problem is not occurring on linux-next.git when this problem is occurring
on bpf.git / bpf-next.git / net.git / net-next.git trees. Is syzbot running
different testcases depending on which git tree is targeted?

^ permalink raw reply

* Re: [PATCH] 9p: potential NULL dereference
From: Dominique Martinet @ 2018-09-26 21:07 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Eric Van Hensbergen, Matthew Wilcox, Latchesar Ionkov,
	David S. Miller, v9fs-developer, netdev, kernel-janitors
In-Reply-To: <20180926103934.GA14535@mwanda>

Dan Carpenter wrote on Wed, Sep 26, 2018:
> p9_tag_alloc() is supposed to return error pointers, but we accidentally
> return a NULL here.  It would cause a NULL dereference in the caller.
> 
> Fixes: 996d5b4db4b1 ("9p: Use a slab for allocating requests")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Good catch, the culprit commit is only in -next so just adding this to
the queue right away.

Thanks!
-- 
Dominique

^ permalink raw reply

* Re: [PATCH v2] qed: Avoid implicit enum conversion in qed_roce_mode_to_flavor
From: David Miller @ 2018-09-27  3:19 UTC (permalink / raw)
  To: natechancellor; +Cc: Ariel.Elior, everest-linux-l2, netdev, linux-kernel
In-Reply-To: <20180924213452.19334-1-natechancellor@gmail.com>

From: Nathan Chancellor <natechancellor@gmail.com>
Date: Mon, 24 Sep 2018 14:34:53 -0700

> Clang warns when one enumerated type is implicitly converted to another.
> 
> drivers/net/ethernet/qlogic/qed/qed_roce.c:153:12: warning: implicit
> conversion from enumeration type 'enum roce_mode' to different
> enumeration type 'enum roce_flavor' [-Wenum-conversion]
>                 flavor = ROCE_V2_IPV6;
>                        ~ ^~~~~~~~~~~~
> drivers/net/ethernet/qlogic/qed/qed_roce.c:156:12: warning: implicit
> conversion from enumeration type 'enum roce_mode' to different
> enumeration type 'enum roce_flavor' [-Wenum-conversion]
>                 flavor = MAX_ROCE_MODE;
>                        ~ ^~~~~~~~~~~~~
> 2 warnings generated.
> 
> Use the appropriate values from the expected type, roce_flavor:
> 
> ROCE_V2_IPV6 = RROCE_IPV6 = 2
> MAX_ROCE_MODE = MAX_ROCE_FLAVOR = 3
> 
> While we're add it, ditch the local variable flavor, we can just return
> the value directly from the switch statement.
> 
> Link: https://github.com/ClangBuiltLinux/linux/issues/125
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
> 
> v1 -> v2:
> 
> * s/if statement/switch statement/ in commit message

Applied.

^ permalink raw reply

* Re: [PATCH] qed: Fix mask parameter in qed_vf_prep_tunn_req_tlv
From: David Miller @ 2018-09-27  3:19 UTC (permalink / raw)
  To: natechancellor; +Cc: Ariel.Elior, everest-linux-l2, netdev, linux-kernel
In-Reply-To: <20180924210527.11996-1-natechancellor@gmail.com>

From: Nathan Chancellor <natechancellor@gmail.com>
Date: Mon, 24 Sep 2018 14:05:27 -0700

> Clang complains when one enumerated type is implicitly converted to
> another.
> 
> drivers/net/ethernet/qlogic/qed/qed_vf.c:686:6: warning: implicit
> conversion from enumeration type 'enum qed_tunn_mode' to different
> enumeration type 'enum qed_tunn_clss' [-Wenum-conversion]
>                                  QED_MODE_L2GENEVE_TUNN,
>                                  ^~~~~~~~~~~~~~~~~~~~~~
> 
> Update mask's parameter to expect qed_tunn_mode, which is what was
> intended.
> 
> Link: https://github.com/ClangBuiltLinux/linux/issues/125
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>

Applied

^ permalink raw reply

* Re: [PATCH] qed: Avoid implicit enum conversion in qed_set_tunn_cls_info
From: David Miller @ 2018-09-27  3:16 UTC (permalink / raw)
  To: natechancellor; +Cc: Ariel.Elior, everest-linux-l2, netdev, linux-kernel
In-Reply-To: <20180924205334.7337-1-natechancellor@gmail.com>

From: Nathan Chancellor <natechancellor@gmail.com>
Date: Mon, 24 Sep 2018 13:53:34 -0700

> Clang warns when one enumerated type is implicitly converted to another.
 ...
> Link: https://github.com/ClangBuiltLinux/linux/issues/125
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>

Applied.

^ permalink raw reply

* [RFC] netlink: add policy validation function for binary attributes
From: Johannes Berg @ 2018-09-26 20:57 UTC (permalink / raw)
  To: linux-wireless, netdev; +Cc: Johannes Berg

From: Johannes Berg <johannes.berg@intel.com>

Add the ability to have an arbitrary validation function attached
to NLA_BINARY.

NOTE: obviously, the nl80211 part should be split off, that's just
      to show how it might be used - saves ~1.2KiB there (x86-64)

NOTE: should probably allow this for the exact length fields, and
      perhaps even provide a general NLA_POLICY_VALID_ETH_ADDR define
      and similar?
---
 include/net/netlink.h  |  6 +++++
 lib/nlattr.c           |  6 +++++
 net/wireless/nl80211.c | 67 ++++++++++++++------------------------------------
 3 files changed, 31 insertions(+), 48 deletions(-)

diff --git a/include/net/netlink.h b/include/net/netlink.h
index ddabc832febc..ff80ccbfc6b0 100644
--- a/include/net/netlink.h
+++ b/include/net/netlink.h
@@ -256,6 +256,10 @@ enum {
  *                         of s16 - do that as usual in the code instead.
  *    All other            Unused - but note that it's a union
  *
+ * Meaning of `validate' field:
+ *    NLA_BINARY           Validation function called for the binary attribute
+ *    All other            Unused - but note that it's a union
+ *
  * Example:
  * static const struct nla_policy my_policy[ATTR_MAX+1] = {
  * 	[ATTR_FOO] = { .type = NLA_U16 },
@@ -272,6 +276,8 @@ struct nla_policy {
 		struct {
 			s16 min, max;
 		};
+		int (*validate)(const struct nlattr *attr,
+				struct netlink_ext_ack *extack);
 	};
 };
 
diff --git a/lib/nlattr.c b/lib/nlattr.c
index dd8d34c1ae19..4f003da28918 100644
--- a/lib/nlattr.c
+++ b/lib/nlattr.c
@@ -175,6 +175,12 @@ static int validate_nla(const struct nlattr *nla, int maxtype,
 	case NLA_BINARY:
 		if (pt->len && attrlen > pt->len)
 			goto out_err;
+
+		if (pt->len && pt->validate) {
+			err = pt->validate(nla, extack);
+			if (err)
+				return err;
+		}
 		break;
 
 	case NLA_NESTED:
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 551310d5965e..a09066896f64 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -200,6 +200,9 @@ cfg80211_get_dev_from_info(struct net *netns, struct genl_info *info)
 	return __cfg80211_rdev_from_attrs(netns, info->attrs);
 }
 
+static int validate_ie_attr(const struct nlattr *attr,
+			    struct netlink_ext_ack *extack);
+
 /* policy for the attributes */
 static const struct nla_policy
 nl80211_pmsr_ftm_req_attr_policy[NL80211_PMSR_FTM_REQ_ATTR_MAX + 1] = {
@@ -311,7 +314,8 @@ const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {
 	[NL80211_ATTR_BEACON_HEAD] = { .type = NLA_BINARY,
 				       .len = IEEE80211_MAX_DATA_LEN },
 	[NL80211_ATTR_BEACON_TAIL] = { .type = NLA_BINARY,
-				       .len = IEEE80211_MAX_DATA_LEN },
+				       .len = IEEE80211_MAX_DATA_LEN,
+				       .validate = validate_ie_attr },
 	[NL80211_ATTR_STA_AID] = {
 		.type = NLA_U16,
 		.min = 1,
@@ -348,7 +352,8 @@ const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {
 
 	[NL80211_ATTR_MGMT_SUBTYPE] = { .type = NLA_U8 },
 	[NL80211_ATTR_IE] = { .type = NLA_BINARY,
-			      .len = IEEE80211_MAX_DATA_LEN },
+			      .len = IEEE80211_MAX_DATA_LEN,
+			      .validate = validate_ie_attr },
 	[NL80211_ATTR_SCAN_FREQUENCIES] = { .type = NLA_NESTED },
 	[NL80211_ATTR_SCAN_SSIDS] = { .type = NLA_NESTED },
 
@@ -417,9 +422,11 @@ const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {
 		.max = NL80211_HIDDEN_SSID_ZERO_CONTENTS,
 	},
 	[NL80211_ATTR_IE_PROBE_RESP] = { .type = NLA_BINARY,
-					 .len = IEEE80211_MAX_DATA_LEN },
+					 .len = IEEE80211_MAX_DATA_LEN,
+					 .validate = validate_ie_attr },
 	[NL80211_ATTR_IE_ASSOC_RESP] = { .type = NLA_BINARY,
-					 .len = IEEE80211_MAX_DATA_LEN },
+					 .len = IEEE80211_MAX_DATA_LEN,
+					 .validate = validate_ie_attr },
 	[NL80211_ATTR_ROAM_SUPPORT] = { .type = NLA_FLAG },
 	[NL80211_ATTR_SCHED_SCAN_MATCH] = { .type = NLA_NESTED },
 	[NL80211_ATTR_TX_NO_CCK_RATE] = { .type = NLA_FLAG },
@@ -738,14 +745,12 @@ static int nl80211_prepare_wdev_dump(struct sk_buff *skb,
 }
 
 /* IE validation */
-static bool is_valid_ie_attr(const struct nlattr *attr)
+static int validate_ie_attr(const struct nlattr *attr,
+			    struct netlink_ext_ack *extack)
 {
 	const u8 *pos;
 	int len;
 
-	if (!attr)
-		return true;
-
 	pos = nla_data(attr);
 	len = nla_len(attr);
 
@@ -753,18 +758,18 @@ static bool is_valid_ie_attr(const struct nlattr *attr)
 		u8 elemlen;
 
 		if (len < 2)
-			return false;
+			return -EINVAL;
 		len -= 2;
 
 		elemlen = pos[1];
 		if (elemlen > len)
-			return false;
+			return -EINVAL;
 
 		len -= elemlen;
 		pos += 2 + elemlen;
 	}
 
-	return true;
+	return 0;
 }
 
 /* message building helper */
@@ -4191,12 +4196,6 @@ static int nl80211_parse_beacon(struct nlattr *attrs[],
 {
 	bool haveinfo = false;
 
-	if (!is_valid_ie_attr(attrs[NL80211_ATTR_BEACON_TAIL]) ||
-	    !is_valid_ie_attr(attrs[NL80211_ATTR_IE]) ||
-	    !is_valid_ie_attr(attrs[NL80211_ATTR_IE_PROBE_RESP]) ||
-	    !is_valid_ie_attr(attrs[NL80211_ATTR_IE_ASSOC_RESP]))
-		return -EINVAL;
-
 	memset(bcn, 0, sizeof(*bcn));
 
 	if (attrs[NL80211_ATTR_BEACON_HEAD]) {
@@ -6326,7 +6325,8 @@ static const struct nla_policy
 	[NL80211_MESH_SETUP_AUTH_PROTOCOL] = { .type = NLA_U8 },
 	[NL80211_MESH_SETUP_USERSPACE_MPM] = { .type = NLA_FLAG },
 	[NL80211_MESH_SETUP_IE] = { .type = NLA_BINARY,
-				    .len = IEEE80211_MAX_DATA_LEN },
+				    .len = IEEE80211_MAX_DATA_LEN,
+				    .validate = validate_ie_attr },
 	[NL80211_MESH_SETUP_USERSPACE_AMPE] = { .type = NLA_FLAG },
 };
 
@@ -6527,8 +6527,6 @@ static int nl80211_parse_mesh_setup(struct genl_info *info,
 	if (tb[NL80211_MESH_SETUP_IE]) {
 		struct nlattr *ieattr =
 			tb[NL80211_MESH_SETUP_IE];
-		if (!is_valid_ie_attr(ieattr))
-			return -EINVAL;
 		setup->ie = nla_data(ieattr);
 		setup->ie_len = nla_len(ieattr);
 	}
@@ -7161,9 +7159,6 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info)
 	int err, tmp, n_ssids = 0, n_channels, i;
 	size_t ie_len;
 
-	if (!is_valid_ie_attr(info->attrs[NL80211_ATTR_IE]))
-		return -EINVAL;
-
 	wiphy = &rdev->wiphy;
 
 	if (wdev->iftype == NL80211_IFTYPE_NAN)
@@ -7517,9 +7512,6 @@ nl80211_parse_sched_scan(struct wiphy *wiphy, struct wireless_dev *wdev,
 	struct nlattr *tb[NL80211_SCHED_SCAN_MATCH_ATTR_MAX + 1];
 	s32 default_match_rssi = NL80211_SCAN_RSSI_THOLD_OFF;
 
-	if (!is_valid_ie_attr(attrs[NL80211_ATTR_IE]))
-		return ERR_PTR(-EINVAL);
-
 	if (attrs[NL80211_ATTR_SCAN_FREQUENCIES]) {
 		n_channels = validate_scan_freqs(
 				attrs[NL80211_ATTR_SCAN_FREQUENCIES]);
@@ -8487,9 +8479,6 @@ static int nl80211_authenticate(struct sk_buff *skb, struct genl_info *info)
 	struct key_parse key;
 	bool local_state_change;
 
-	if (!is_valid_ie_attr(info->attrs[NL80211_ATTR_IE]))
-		return -EINVAL;
-
 	if (!info->attrs[NL80211_ATTR_MAC])
 		return -EINVAL;
 
@@ -8728,9 +8717,6 @@ static int nl80211_associate(struct sk_buff *skb, struct genl_info *info)
 	    dev->ieee80211_ptr->conn_owner_nlportid != info->snd_portid)
 		return -EPERM;
 
-	if (!is_valid_ie_attr(info->attrs[NL80211_ATTR_IE]))
-		return -EINVAL;
-
 	if (!info->attrs[NL80211_ATTR_MAC] ||
 	    !info->attrs[NL80211_ATTR_SSID] ||
 	    !info->attrs[NL80211_ATTR_WIPHY_FREQ])
@@ -8854,9 +8840,6 @@ static int nl80211_deauthenticate(struct sk_buff *skb, struct genl_info *info)
 	    dev->ieee80211_ptr->conn_owner_nlportid != info->snd_portid)
 		return -EPERM;
 
-	if (!is_valid_ie_attr(info->attrs[NL80211_ATTR_IE]))
-		return -EINVAL;
-
 	if (!info->attrs[NL80211_ATTR_MAC])
 		return -EINVAL;
 
@@ -8905,9 +8888,6 @@ static int nl80211_disassociate(struct sk_buff *skb, struct genl_info *info)
 	    dev->ieee80211_ptr->conn_owner_nlportid != info->snd_portid)
 		return -EPERM;
 
-	if (!is_valid_ie_attr(info->attrs[NL80211_ATTR_IE]))
-		return -EINVAL;
-
 	if (!info->attrs[NL80211_ATTR_MAC])
 		return -EINVAL;
 
@@ -8982,9 +8962,6 @@ static int nl80211_join_ibss(struct sk_buff *skb, struct genl_info *info)
 
 	memset(&ibss, 0, sizeof(ibss));
 
-	if (!is_valid_ie_attr(info->attrs[NL80211_ATTR_IE]))
-		return -EINVAL;
-
 	if (!info->attrs[NL80211_ATTR_SSID] ||
 	    !nla_len(info->attrs[NL80211_ATTR_SSID]))
 		return -EINVAL;
@@ -9422,9 +9399,6 @@ static int nl80211_connect(struct sk_buff *skb, struct genl_info *info)
 
 	memset(&connect, 0, sizeof(connect));
 
-	if (!is_valid_ie_attr(info->attrs[NL80211_ATTR_IE]))
-		return -EINVAL;
-
 	if (!info->attrs[NL80211_ATTR_SSID] ||
 	    !nla_len(info->attrs[NL80211_ATTR_SSID]))
 		return -EINVAL;
@@ -9655,8 +9629,6 @@ static int nl80211_update_connect_params(struct sk_buff *skb,
 		return -EOPNOTSUPP;
 
 	if (info->attrs[NL80211_ATTR_IE]) {
-		if (!is_valid_ie_attr(info->attrs[NL80211_ATTR_IE]))
-			return -EINVAL;
 		connect.ie = nla_data(info->attrs[NL80211_ATTR_IE]);
 		connect.ie_len = nla_len(info->attrs[NL80211_ATTR_IE]);
 		changed |= UPDATE_ASSOC_IES;
@@ -12308,8 +12280,7 @@ static int nl80211_update_ft_ies(struct sk_buff *skb, struct genl_info *info)
 		return -EOPNOTSUPP;
 
 	if (!info->attrs[NL80211_ATTR_MDID] ||
-	    !info->attrs[NL80211_ATTR_IE] ||
-	    !is_valid_ie_attr(info->attrs[NL80211_ATTR_IE]))
+	    !info->attrs[NL80211_ATTR_IE])
 		return -EINVAL;
 
 	memset(&ft_params, 0, sizeof(ft_params));
-- 
2.14.4

^ permalink raw reply related

* [PATCH net-next 2/2] tcp: adjust rcv zerocopy hints based on frag sizes
From: Soheil Hassas Yeganeh @ 2018-09-26 20:57 UTC (permalink / raw)
  To: davem, netdev; +Cc: edumazet, Soheil Hassas Yeganeh
In-Reply-To: <20180926205704.42754-1-soheil.kdev@gmail.com>

From: Soheil Hassas Yeganeh <soheil@google.com>

When SKBs are coalesced, we can have SKBs with different
frag sizes. Some with PAGE_SIZE and some not with PAGE_SIZE.
Since recv_skip_hint is always set to the full SKB size,
it can overestimate the amount that should be read using
normal read for coalesced packets.

Change the recv_skip_hint so that it only includes the first
frags that are not of PAGE_SIZE.

Signed-off-by: Soheil Hassas Yeganeh <soheil@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 net/ipv4/tcp.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 3e17501fc1a1..cdbd423bdeb4 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -1805,8 +1805,17 @@ static int tcp_zerocopy_receive(struct sock *sk,
 				frags++;
 			}
 		}
-		if (frags->size != PAGE_SIZE || frags->page_offset)
+		if (frags->size != PAGE_SIZE || frags->page_offset) {
+			int remaining = zc->recv_skip_hint;
+
+			while (remaining && (frags->size != PAGE_SIZE ||
+					     frags->page_offset)) {
+				remaining -= frags->size;
+				frags++;
+			}
+			zc->recv_skip_hint -= remaining;
 			break;
+		}
 		ret = vm_insert_page(vma, address + length,
 				     skb_frag_page(frags));
 		if (ret)
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related

* [PATCH net-next 1/2] tcp: set recv_skip_hint when tcp_inq is less than PAGE_SIZE
From: Soheil Hassas Yeganeh @ 2018-09-26 20:57 UTC (permalink / raw)
  To: davem, netdev; +Cc: edumazet, Soheil Hassas Yeganeh

From: Soheil Hassas Yeganeh <soheil@google.com>

When we have less than PAGE_SIZE of data on receive queue,
we set recv_skip_hint to 0. Instead, set it to the actual
number of bytes available.

Signed-off-by: Soheil Hassas Yeganeh <soheil@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 net/ipv4/tcp.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 69c236943f56..3e17501fc1a1 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -1753,6 +1753,7 @@ static int tcp_zerocopy_receive(struct sock *sk,
 	struct vm_area_struct *vma;
 	struct sk_buff *skb = NULL;
 	struct tcp_sock *tp;
+	int inq;
 	int ret;
 
 	if (address & (PAGE_SIZE - 1) || address != zc->address)
@@ -1773,12 +1774,15 @@ static int tcp_zerocopy_receive(struct sock *sk,
 
 	tp = tcp_sk(sk);
 	seq = tp->copied_seq;
-	zc->length = min_t(u32, zc->length, tcp_inq(sk));
+	inq = tcp_inq(sk);
+	zc->length = min_t(u32, zc->length, inq);
 	zc->length &= ~(PAGE_SIZE - 1);
-
-	zap_page_range(vma, address, zc->length);
-
-	zc->recv_skip_hint = 0;
+	if (zc->length) {
+		zap_page_range(vma, address, zc->length);
+		zc->recv_skip_hint = 0;
+	} else {
+		zc->recv_skip_hint = inq;
+	}
 	ret = 0;
 	while (length + PAGE_SIZE <= zc->length) {
 		if (zc->recv_skip_hint < PAGE_SIZE) {
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related

* Re: [PATCH][V2] wimax/i2400m: fix spelling mistake "not unitialized" -> "uninitialized"
From: David Miller @ 2018-09-27  3:10 UTC (permalink / raw)
  To: colin.king
  Cc: inaky.perez-gonzalez, linux-wimax, netdev, kernel-janitors,
	linux-kernel
In-Reply-To: <20180924173951.3931-1-colin.king@canonical.com>

From: Colin King <colin.king@canonical.com>
Date: Mon, 24 Sep 2018 18:39:51 +0100

> From: Colin Ian King <colin.king@canonical.com>
> 
> Trivial fix to spelling mistake in ms_to_errno array of error messages
> and remove confusing "not" from the error text since the error code
> refers to an uninitialized error code.
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> 
> V2: remove "not" from text too. Thanks to Sergei Shtylyov for spotting that.

Applied.

^ permalink raw reply

* Re: [PATCH] qed: fix spelling mistake "toogle" -> "toggle"
From: David Miller @ 2018-09-27  3:09 UTC (permalink / raw)
  To: colin.king
  Cc: Ariel.Elior, everest-linux-l2, netdev, kernel-janitors,
	linux-kernel
In-Reply-To: <20180924155141.25125-1-colin.king@canonical.com>

From: Colin King <colin.king@canonical.com>
Date: Mon, 24 Sep 2018 16:51:41 +0100

> From: Colin Ian King <colin.king@canonical.com>
> 
> Trivial fix to spelling mistake in DP_VERBOSE message
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Applied.

^ permalink raw reply

* Re: [PATCH v2 net-next] tcp: expose sk_state in tcp_retransmit_skb tracepoint
From: David Miller @ 2018-09-27  3:07 UTC (permalink / raw)
  To: laoar.shao; +Cc: edumazet, netdev, linux-kernel
In-Reply-To: <1537793849-32396-1-git-send-email-laoar.shao@gmail.com>

From: Yafang Shao <laoar.shao@gmail.com>
Date: Mon, 24 Sep 2018 20:57:29 +0800

> After sk_state exposed, we can get in which state this retransmission
> occurs. That could give us more detail for dignostic.
> For example, if this retransmission occurs in SYN_SENT state, it may
> also indicates that the syn packet may be dropped on the remote peer due
> to syn backlog queue full and then we could check the remote peer.
> 
> BTW,SYNACK retransmission is traced in tcp_retransmit_synack tracepoint.
> 
> Signed-off-by: Yafang Shao <laoar.shao@gmail.com>

Applied.

^ permalink raw reply

* RE: bug: 'ethtool -m' reports spurious alarm & warning threshold values for QSFP28 transceivers
From: Chris Preimesberger @ 2018-09-26 20:47 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: linville@tuxdriver.com, netdev@vger.kernel.org
In-Reply-To: <20180926194436.GB1251@lunn.ch>

[-- Attachment #1: Type: text/plain, Size: 3140 bytes --]

Hello Andrew,

Thank you for the quick response!!
Apologies in advance for my use of outlook and top-posting, etc...

I've run the raw option and the hex option, and pasted the results below.
Since the raw option printed strange characters on the CLI, I re-ran it,
Sending the output to a file (raw.txt) and attached that file as well.

Pasted from Ubuntu CLI:

tech1@D7:~$ 
tech1@D7:~$ 
tech1@D7:~$ 
tech1@D7:~$ 
tech1@D7:~$ sudo ethtool -m enp1s0 raw on
\x11UU$��pA`?�@�G\x10#
                 �\x12v\x01\x11��\x03�\x02@TRANSITION      ��TNQSFP100GCWDM4 1AfX%\x1cF?\x06?�TN02000301      180919  
    h�\x02I��_��'\x16��Ri=\x02`��Zntech1@D7:~$ 
tech1@D7:~$ 
tech1@D7:~$ 
tech1@D7:~$ 
tech1@D7:~$ sudo ethtool -m enp1s0 hex on
Offset		Values
------		------
0x0000:		11 00 00 0f 00 00 00 00 00 55 55 00 00 00 00 00 
0x0010:		00 00 00 00 00 00 24 e2 00 00 81 68 00 00 00 00 
0x0020:		00 00 00 00 00 00 00 00 00 00 41 60 3f e0 40 e0 
0x0030:		47 00 1f 10 0e 1e 0b f7 12 76 00 00 00 00 00 00 
0x0040:		00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
0x0050:		00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 
0x0060:		00 00 00 00 00 00 00 00 00 00 1f 00 00 00 00 00 
0x0070:		00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
0x0080:		11 fc 07 80 00 00 00 00 00 00 00 03 ff 00 02 00 
0x0090:		00 00 00 40 54 52 41 4e 53 49 54 49 4f 4e 20 20 
0x00a0:		20 20 20 20 00 00 c0 f2 54 4e 51 53 46 50 31 30 
0x00b0:		30 47 43 57 44 4d 34 20 31 41 66 58 25 1c 46 3f 
0x00c0:		06 00 3f d6 54 4e 30 32 30 30 30 33 30 31 20 20 
0x00d0:		20 20 20 20 31 38 30 39 31 39 20 20 0c 00 68 f3 
0x00e0:		00 00 02 49 80 a0 5f 1f de c9 27 16 f8 ae 52 69 
0x00f0:		3d 02 60 00 00 00 00 00 00 00 00 00 83 f4 5a 6e 
tech1@D7:~$ 
tech1@D7:~$ 






Chris Preimesberger | Test & Validation Engineer
Transition Networks, Inc.

chrisp@transition.com
direct: +1.952.996.1509 | fax: +1.952.941.2322 | www.transition.com


-----Original Message-----
From: Andrew Lunn [mailto:andrew@lunn.ch] 
Sent: Wednesday, September 26, 2018 2:45 PM
To: Chris Preimesberger
Cc: linville@tuxdriver.com; netdev@vger.kernel.org
Subject: Re: bug: 'ethtool -m' reports spurious alarm & warning threshold values for QSFP28 transceivers

On Wed, Sep 26, 2018 at 07:29:23PM +0000, Chris Preimesberger wrote:
> Hello,
> 
> I'm re-sending in plain text per the auto-reply from a spam filter.

Yep. no html obfustication accepted here. Please ASCII only please :-)

Please can you also wrap your lines at about 75 characters.

>  I have attached some text files this time, which explain the situation below, in case the below email's font & formatting is now too messed up for easy comprehension.

> Bug #1.  Ethtool's reporting of the installed transceiver's alarm and warning thresholds will differ, depending on whether or not ethtool is piped to another command.  Example commands are below, with their respective differing output values highlighted:

Could you dump the raw values. That will make it easier for us to
reproduce this issue, assuming it is ethtool, and not the kernel
driver.

Thanks
	Andrew


[-- Attachment #2: raw.txt --]
[-- Type: text/plain, Size: 256 bytes --]

\x11\0\0\x0f\0\0\0\0\0UU\0\0\0\0\0\0\0\0\0\0\0$ò\0\0h\0\0\0\0\0\0\0\0\0\0\0\0\0\0A`?à@àG\0\x1f\x10\x0e\x1e\v÷\x12{\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\0\0\0\0\0\x1f\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x11ü\a€\0\0\0\0\0\0\0\x03ÿ\0\x02\0\0\0\0@TRANSITION      \0\0ÀòTNQSFP100GCWDM4 1AfX%\x1cF?\x06\0?ÖTN02000301      180919  \f\0hó\0\0\x02I€ _\x1fÞÉ'\x16ø®Ri=\x02`\0\0\0\0\0\0\0\0\0ƒôZn

^ permalink raw reply

* RE: [PATCH] net/ncsi: Add NCSI OEM command for FB Tiogapass
From: Justin.Lee1 @ 2018-09-26 20:39 UTC (permalink / raw)
  To: amithash, vijaykhemka, sam, joel; +Cc: linux-aspeed, openbmc, sdasari, netdev
In-Reply-To: <MWHPR15MB14861AED8F8AF652CE5E62B3B2150@MWHPR15MB1486.namprd15.prod.outlook.com>

> >  As I understand Justin's version adds a generic handler, using the NCSI
> >  Netlink interface to pass OEM commands and responses to and from
> >  userspace, which does the actual packet handling.
> Thanks for the direction Sam! Justin, if you don't mind, can you share the patches you have to add the support? This actually would solve a few other things we are trying to accomplish.


Basically, I add a new flag to indicate the request is coming from the Netlink interface to allow the command handler and response handler to react.
#define NCSI_REQ_FLAG_NETLINK_DRIVEN	2

The work flow is as below. 

Request:
User space application -> Netlink interface (msg) -> new Netlink handler - ncsi_send_cmd_nl() - ncsi_xmit_cmd()

Response:
Response received - ncsi_rcv_rsp() -> internal response handler - ncsi_rsp_handler_xxx() -> ncsi_send_netlink_rsp () -> Netlink interface (msg) -> user space application
Command timeout - ncsi_request_timeout() -> ncsi_send_netlink_timeout () -> Netlink interface (msg with zero data length) -> user space application

Error:
Detected error -> ncsi_send_netlink_err () -> Netlink interface (err msg) -> user space application

I will clean up some code and send out the patch. 

Thanks,
Justin

^ permalink raw reply

* [net  1/1] tipc: ignore STATE_MSG on wrong link session
From: Jon Maloy @ 2018-09-26 20:28 UTC (permalink / raw)
  To: davem, netdev
  Cc: gordan.mihaljevic, tung.q.nguyen, hoang.h.le, jon.maloy,
	canh.d.luu, ying.xue, tipc-discussion

From: LUU Duc Canh <canh.d.luu@dektech.com.au>

The initial session number when a link is created is based on a random
value, taken from struct tipc_net->random. It is then incremented for
each link reset to avoid mixing protocol messages from different link
sessions.

However, when a bearer is reset all its links are deleted, and will
later be re-created using the same random value as the first time.
This means that if the link never went down between creation and
deletion we will still sometimes have two subsequent sessions with
the same session number. In virtual environments with potentially
long transmission times this has turned out to be a real problem.

We now fix this by randomizing the session number each time a link
is created.

With a session number size of 16 bits this gives a risk of session
collision of 1/64k. To reduce this further, we also introduce a sanity
check on the very first STATE message arriving at a link. If this has
an acknowledge value differing from 0, which is logically impossible,
we ignore the message. The final risk for session collision is hence
reduced to 1/4G, which should be sufficient.

Signed-off-by: LUU Duc Canh <canh.d.luu@dektech.com.au>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
---
 net/tipc/link.c | 3 +++
 net/tipc/node.c | 5 +++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/net/tipc/link.c b/net/tipc/link.c
index 4ed650c..fb886b5 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -1516,6 +1516,9 @@ bool tipc_link_validate_msg(struct tipc_link *l, struct tipc_msg *hdr)
 			return false;
 		if (session != curr_session)
 			return false;
+		/* Extra sanity check */
+		if (!link_is_up(l) && msg_ack(hdr))
+			return false;
 		if (!(l->peer_caps & TIPC_LINK_PROTO_SEQNO))
 			return true;
 		/* Accept only STATE with new sequence number */
diff --git a/net/tipc/node.c b/net/tipc/node.c
index b0ee25f..2afc4f8 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -913,6 +913,7 @@ void tipc_node_check_dest(struct net *net, u32 addr,
 	bool reset = true;
 	char *if_name;
 	unsigned long intv;
+	u16 session;
 
 	*dupl_addr = false;
 	*respond = false;
@@ -999,9 +1000,10 @@ void tipc_node_check_dest(struct net *net, u32 addr,
 			goto exit;
 
 		if_name = strchr(b->name, ':') + 1;
+		get_random_bytes(&session, sizeof(u16));
 		if (!tipc_link_create(net, if_name, b->identity, b->tolerance,
 				      b->net_plane, b->mtu, b->priority,
-				      b->window, mod(tipc_net(net)->random),
+				      b->window, session,
 				      tipc_own_addr(net), addr, peer_id,
 				      n->capabilities,
 				      tipc_bc_sndlink(n->net), n->bc_entry.link,
@@ -1625,7 +1627,6 @@ static bool tipc_node_check_state(struct tipc_node *n, struct sk_buff *skb,
 			tipc_link_create_dummy_tnl_msg(l, xmitq);
 			n->failover_sent = true;
 		}
-
 		/* If pkts arrive out of order, use lowest calculated syncpt */
 		if (less(syncpt, n->sync_point))
 			n->sync_point = syncpt;
-- 
2.1.4

^ permalink raw reply related

* Re: [PATCH] netlink: add policy attribute range validation
From: Johannes Berg @ 2018-09-26 20:24 UTC (permalink / raw)
  To: linux-wireless, netdev
In-Reply-To: <20180926200630.23399-1-johannes@sipsolutions.net>

Another thing to note:

Given the union of validation_data pointer and min/max, we'll always get
into this:

> +	/* validate range */
> +	if (pt->min || pt->max) {

if validation_data is set, but of course end up taking the default case,
where nothing further happens:

> +		default:
> +			/* no further validation */
> +			validate = false;
> +			break;
> +		}
> +
> +		if (validate && (value < pt->min || value > pt->max)) {
> +			NL_SET_ERR_MSG_ATTR(extack, nla,
> +					    "integer out of range");
> +			return -ERANGE;
> +		}
> +	}
> +
>  	return 0;

I'm not *entirely* happy with this, but I haven't been able to come up
with a way that doesn't do this, doesn't duplicate the nla types list
(NLA_{U,S}{8,16,32,64}) in the code, and also loads the attribute value
only if validation is needed.

johannes

^ permalink raw reply

* [PATCH] netlink: fix typo in nla_parse_nested() comment
From: Johannes Berg @ 2018-09-26 20:19 UTC (permalink / raw)
  To: netdev; +Cc: Johannes Berg

From: Johannes Berg <johannes.berg@intel.com>

Fix a simple typo: attribuets -> attributes

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 include/net/netlink.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/net/netlink.h b/include/net/netlink.h
index ddabc832febc..69866f5a97f2 100644
--- a/include/net/netlink.h
+++ b/include/net/netlink.h
@@ -153,7 +153,7 @@
  *   nla_find()				find attribute in stream of attributes
  *   nla_find_nested()			find attribute in nested attributes
  *   nla_parse()			parse and validate stream of attrs
- *   nla_parse_nested()			parse nested attribuets
+ *   nla_parse_nested()			parse nested attributes
  *   nla_for_each_attr()		loop over all attributes
  *   nla_for_each_nested()		loop over the nested attributes
  *=========================================================================
-- 
2.14.4

^ permalink raw reply related

* Re: [PATCH] netlink: add policy attribute range validation
From: Johannes Berg @ 2018-09-26 20:17 UTC (permalink / raw)
  To: linux-wireless, netdev
In-Reply-To: <20180926200630.23399-1-johannes@sipsolutions.net>

On Wed, 2018-09-26 at 22:06 +0200, Johannes Berg wrote:
> From: Johannes Berg <johannes.berg@intel.com>
> 
> Without further bloating the policy structs, we can overload
> the `validation_data' pointer with a struct of s16 min, max
> and use those to validate ranges in NLA_{U,S}{8,16,32,64}
> attributes.
> 
> It may sound strange to validate NLA_U32 with a s16 max, but
> in many cases NLA_U32 is used for enums etc. since there's no
> size benefit in using a smaller attribute width anyway, due
> to netlink attribute alignment; in cases like that it's still
> useful, particularly when the attribute really transports an
> enum value.

That said, I did find a few places where we could benefit from a larger
type here - e.g. having a NLA_U16 that must be non-zero cannot be
represented in the policy as is, since you can't set max to 65535.

However, I don't think we want to push the policy struct to 12 bytes on
32-bit platforms? It's currently 16 bytes on 64-bit due to the pointer
(and alignment), but only 8 bytes on 32-bit.

Keeping the few places that needed this validation is unlikely to be a
larger win than the policy size increase due to the larger type.

johannes

^ permalink raw reply

* [PATCH] r8169: Disable clk during suspend / resume
From: Hans de Goede @ 2018-09-26 20:12 UTC (permalink / raw)
  To: David S . Miller, Realtek linux nic maintainers; +Cc: Hans de Goede, netdev

Disable the clk during suspend to save power. Note that tp->clk may be
NULL, the clk core functions handle this without problems.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Carlo Caione <carlo@endlessm.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/net/ethernet/realtek/r8169.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index 474229548731..c289350fb98f 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -6852,8 +6852,10 @@ static int rtl8169_suspend(struct device *device)
 {
 	struct pci_dev *pdev = to_pci_dev(device);
 	struct net_device *dev = pci_get_drvdata(pdev);
+	struct rtl8169_private *tp = netdev_priv(dev);
 
 	rtl8169_net_suspend(dev);
+	clk_disable_unprepare(tp->clk);
 
 	return 0;
 }
@@ -6881,6 +6883,9 @@ static int rtl8169_resume(struct device *device)
 {
 	struct pci_dev *pdev = to_pci_dev(device);
 	struct net_device *dev = pci_get_drvdata(pdev);
+	struct rtl8169_private *tp = netdev_priv(dev);
+
+	clk_prepare_enable(tp->clk);
 
 	if (netif_running(dev))
 		__rtl8169_resume(dev);
-- 
2.19.0

^ permalink raw reply related

* Re: [RFC] nl80211: use policy range validation where applicable
From: Johannes Berg @ 2018-09-26 20:09 UTC (permalink / raw)
  To: linux-wireless, netdev
In-Reply-To: <20180926200731.23491-1-johannes@sipsolutions.net>

On Wed, 2018-09-26 at 22:07 +0200, Johannes Berg wrote:
> From: Johannes Berg <johannes.berg@intel.com>
> 
> Many range checks can be done in the policy, move them
> there. A few in mesh are added in the code (taken out of
> the macros) because they don't fit into the s16 range in
> the policy validation.

Forgot to say - this saves 550 bytes of .text on x86-64 for me.

johannes

^ permalink raw reply

* [RFC] nl80211: use policy range validation where applicable
From: Johannes Berg @ 2018-09-26 20:07 UTC (permalink / raw)
  To: linux-wireless, netdev; +Cc: Johannes Berg
In-Reply-To: <20180926200630.23399-1-johannes@sipsolutions.net>

From: Johannes Berg <johannes.berg@intel.com>

Many range checks can be done in the policy, move them
there. A few in mesh are added in the code (taken out of
the macros) because they don't fit into the s16 range in
the policy validation.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 net/wireless/nl80211.c | 493 +++++++++++++++++++++----------------------------
 1 file changed, 211 insertions(+), 282 deletions(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index e9550c5f5871..e3923c1cb5a5 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -265,14 +265,14 @@ const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {
 	[NL80211_ATTR_CENTER_FREQ1] = { .type = NLA_U32 },
 	[NL80211_ATTR_CENTER_FREQ2] = { .type = NLA_U32 },
 
-	[NL80211_ATTR_WIPHY_RETRY_SHORT] = { .type = NLA_U8 },
-	[NL80211_ATTR_WIPHY_RETRY_LONG] = { .type = NLA_U8 },
+	[NL80211_ATTR_WIPHY_RETRY_SHORT] = { .type = NLA_U8, .min = 1 },
+	[NL80211_ATTR_WIPHY_RETRY_LONG] = { .type = NLA_U8, .min = 1 },
 	[NL80211_ATTR_WIPHY_FRAG_THRESHOLD] = { .type = NLA_U32 },
 	[NL80211_ATTR_WIPHY_RTS_THRESHOLD] = { .type = NLA_U32 },
 	[NL80211_ATTR_WIPHY_COVERAGE_CLASS] = { .type = NLA_U8 },
 	[NL80211_ATTR_WIPHY_DYN_ACK] = { .type = NLA_FLAG },
 
-	[NL80211_ATTR_IFTYPE] = { .type = NLA_U32 },
+	[NL80211_ATTR_IFTYPE] = { .type = NLA_U32, .max = NL80211_IFTYPE_MAX },
 	[NL80211_ATTR_IFINDEX] = { .type = NLA_U32 },
 	[NL80211_ATTR_IFNAME] = { .type = NLA_NUL_STRING, .len = IFNAMSIZ-1 },
 
@@ -282,11 +282,12 @@ const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {
 	[NL80211_ATTR_KEY] = { .type = NLA_NESTED, },
 	[NL80211_ATTR_KEY_DATA] = { .type = NLA_BINARY,
 				    .len = WLAN_MAX_KEY_LEN },
-	[NL80211_ATTR_KEY_IDX] = { .type = NLA_U8 },
+	[NL80211_ATTR_KEY_IDX] = { .type = NLA_U8, .max = 5 },
 	[NL80211_ATTR_KEY_CIPHER] = { .type = NLA_U32 },
 	[NL80211_ATTR_KEY_DEFAULT] = { .type = NLA_FLAG },
 	[NL80211_ATTR_KEY_SEQ] = { .type = NLA_BINARY, .len = 16 },
-	[NL80211_ATTR_KEY_TYPE] = { .type = NLA_U32 },
+	[NL80211_ATTR_KEY_TYPE] = { .type = NLA_U32,
+				    .max = NUM_NL80211_KEYTYPES - 1 },
 
 	[NL80211_ATTR_BEACON_INTERVAL] = { .type = NLA_U32 },
 	[NL80211_ATTR_DTIM_PERIOD] = { .type = NLA_U32 },
@@ -294,12 +295,19 @@ const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {
 				       .len = IEEE80211_MAX_DATA_LEN },
 	[NL80211_ATTR_BEACON_TAIL] = { .type = NLA_BINARY,
 				       .len = IEEE80211_MAX_DATA_LEN },
-	[NL80211_ATTR_STA_AID] = { .type = NLA_U16 },
+	[NL80211_ATTR_STA_AID] = {
+		.type = NLA_U16,
+		.min = 1,
+		.max = IEEE80211_MAX_AID,
+	},
 	[NL80211_ATTR_STA_FLAGS] = { .type = NLA_NESTED },
 	[NL80211_ATTR_STA_LISTEN_INTERVAL] = { .type = NLA_U16 },
 	[NL80211_ATTR_STA_SUPPORTED_RATES] = { .type = NLA_BINARY,
 					       .len = NL80211_MAX_SUPP_RATES },
-	[NL80211_ATTR_STA_PLINK_ACTION] = { .type = NLA_U8 },
+	[NL80211_ATTR_STA_PLINK_ACTION] = {
+		.type = NLA_U8,
+		.max = NUM_NL80211_PLINK_ACTIONS - 1
+	},
 	[NL80211_ATTR_STA_VLAN] = { .type = NLA_U32 },
 	[NL80211_ATTR_MNTR_FLAGS] = { /* NLA_NESTED can't be empty */ },
 	[NL80211_ATTR_MESH_ID] = { .type = NLA_BINARY,
@@ -333,7 +341,11 @@ const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {
 	[NL80211_ATTR_REASON_CODE] = { .type = NLA_U16 },
 	[NL80211_ATTR_FREQ_FIXED] = { .type = NLA_FLAG },
 	[NL80211_ATTR_TIMED_OUT] = { .type = NLA_FLAG },
-	[NL80211_ATTR_USE_MFP] = { .type = NLA_U32 },
+	[NL80211_ATTR_USE_MFP] = {
+		.type = NLA_U32,
+		.min = NL80211_MFP_NO,
+		.max = NL80211_MFP_OPTIONAL,
+	},
 	[NL80211_ATTR_STA_FLAGS2] = {
 		.len = sizeof(struct nl80211_sta_flag_update),
 	},
@@ -353,7 +365,11 @@ const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {
 	[NL80211_ATTR_FRAME] = { .type = NLA_BINARY,
 				 .len = IEEE80211_MAX_DATA_LEN },
 	[NL80211_ATTR_FRAME_MATCH] = { .type = NLA_BINARY, },
-	[NL80211_ATTR_PS_STATE] = { .type = NLA_U32 },
+	[NL80211_ATTR_PS_STATE] = {
+		.type = NLA_U32,
+		.min = NL80211_PS_DISABLED,
+		.max = NL80211_PS_ENABLED,
+	},
 	[NL80211_ATTR_CQM] = { .type = NLA_NESTED, },
 	[NL80211_ATTR_LOCAL_STATE_CHANGE] = { .type = NLA_FLAG },
 	[NL80211_ATTR_AP_ISOLATE] = { .type = NLA_U8 },
@@ -366,11 +382,23 @@ const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {
 	[NL80211_ATTR_OFFCHANNEL_TX_OK] = { .type = NLA_FLAG },
 	[NL80211_ATTR_KEY_DEFAULT_TYPES] = { .type = NLA_NESTED },
 	[NL80211_ATTR_WOWLAN_TRIGGERS] = { .type = NLA_NESTED },
-	[NL80211_ATTR_STA_PLINK_STATE] = { .type = NLA_U8 },
+	[NL80211_ATTR_STA_PLINK_STATE] = {
+		.type = NLA_U8,
+		.max = NUM_NL80211_PLINK_STATES - 1
+	},
+	[NL80211_ATTR_MESH_PEER_AID] = {
+		.type = NLA_U16,
+		.min = 1,
+		.max = IEEE80211_MAX_AID,
+	},
 	[NL80211_ATTR_SCHED_SCAN_INTERVAL] = { .type = NLA_U32 },
 	[NL80211_ATTR_REKEY_DATA] = { .type = NLA_NESTED },
 	[NL80211_ATTR_SCAN_SUPP_RATES] = { .type = NLA_NESTED },
-	[NL80211_ATTR_HIDDEN_SSID] = { .type = NLA_U32 },
+	[NL80211_ATTR_HIDDEN_SSID] = {
+		.type = NLA_U32,
+		.min = NL80211_HIDDEN_SSID_NOT_IN_USE,
+		.max = NL80211_HIDDEN_SSID_ZERO_CONTENTS,
+	},
 	[NL80211_ATTR_IE_PROBE_RESP] = { .type = NLA_BINARY,
 					 .len = IEEE80211_MAX_DATA_LEN },
 	[NL80211_ATTR_IE_ASSOC_RESP] = { .type = NLA_BINARY,
@@ -400,9 +428,13 @@ const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {
 	[NL80211_ATTR_AUTH_DATA] = { .type = NLA_BINARY, },
 	[NL80211_ATTR_VHT_CAPABILITY] = { .len = NL80211_VHT_CAPABILITY_LEN },
 	[NL80211_ATTR_SCAN_FLAGS] = { .type = NLA_U32 },
-	[NL80211_ATTR_P2P_CTWINDOW] = { .type = NLA_U8 },
-	[NL80211_ATTR_P2P_OPPPS] = { .type = NLA_U8 },
-	[NL80211_ATTR_LOCAL_MESH_POWER_MODE] = {. type = NLA_U32 },
+	[NL80211_ATTR_P2P_CTWINDOW] = { .type = NLA_U8, .max = 127 },
+	[NL80211_ATTR_P2P_OPPPS] = { .type = NLA_U8, .max = 1 },
+	[NL80211_ATTR_LOCAL_MESH_POWER_MODE] = {
+		.type = NLA_U32,
+		.min = NL80211_MESH_POWER_UNKNOWN + 1,
+		.max = NL80211_MESH_POWER_MAX,
+	},
 	[NL80211_ATTR_ACL_POLICY] = {. type = NLA_U32 },
 	[NL80211_ATTR_MAC_ADDRS] = { .type = NLA_NESTED },
 	[NL80211_ATTR_STA_CAPABILITY] = { .type = NLA_U16 },
@@ -415,7 +447,11 @@ const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {
 	[NL80211_ATTR_MDID] = { .type = NLA_U16 },
 	[NL80211_ATTR_IE_RIC] = { .type = NLA_BINARY,
 				  .len = IEEE80211_MAX_DATA_LEN },
-	[NL80211_ATTR_PEER_AID] = { .type = NLA_U16 },
+	[NL80211_ATTR_PEER_AID] = {
+		.type = NLA_U16,
+		.min = 1,
+		.max = IEEE80211_MAX_AID,
+	},
 	[NL80211_ATTR_CH_SWITCH_COUNT] = { .type = NLA_U32 },
 	[NL80211_ATTR_CH_SWITCH_BLOCK_TX] = { .type = NLA_FLAG },
 	[NL80211_ATTR_CSA_IES] = { .type = NLA_NESTED },
@@ -436,8 +472,11 @@ const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {
 	[NL80211_ATTR_SOCKET_OWNER] = { .type = NLA_FLAG },
 	[NL80211_ATTR_CSA_C_OFFSETS_TX] = { .type = NLA_BINARY },
 	[NL80211_ATTR_USE_RRM] = { .type = NLA_FLAG },
-	[NL80211_ATTR_TSID] = { .type = NLA_U8 },
-	[NL80211_ATTR_USER_PRIO] = { .type = NLA_U8 },
+	[NL80211_ATTR_TSID] = { .type = NLA_U8, .max = IEEE80211_NUM_TIDS - 1 },
+	[NL80211_ATTR_USER_PRIO] = {
+		.type = NLA_U8,
+		.max = IEEE80211_NUM_UPS - 1,
+	},
 	[NL80211_ATTR_ADMITTED_TIME] = { .type = NLA_U16 },
 	[NL80211_ATTR_SMPS_MODE] = { .type = NLA_U8 },
 	[NL80211_ATTR_MAC_MASK] = { .len = ETH_ALEN },
@@ -447,12 +486,15 @@ const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {
 	[NL80211_ATTR_REG_INDOOR] = { .type = NLA_FLAG },
 	[NL80211_ATTR_PBSS] = { .type = NLA_FLAG },
 	[NL80211_ATTR_BSS_SELECT] = { .type = NLA_NESTED },
-	[NL80211_ATTR_STA_SUPPORT_P2P_PS] = { .type = NLA_U8 },
+	[NL80211_ATTR_STA_SUPPORT_P2P_PS] = {
+		.type = NLA_U8,
+		.max = NUM_NL80211_P2P_PS_STATUS - 1
+	},
 	[NL80211_ATTR_MU_MIMO_GROUP_DATA] = {
 		.len = VHT_MUMIMO_GROUPS_DATA_LEN
 	},
 	[NL80211_ATTR_MU_MIMO_FOLLOW_MAC_ADDR] = { .len = ETH_ALEN },
-	[NL80211_ATTR_NAN_MASTER_PREF] = { .type = NLA_U8 },
+	[NL80211_ATTR_NAN_MASTER_PREF] = { .type = NLA_U8, .min = 1 },
 	[NL80211_ATTR_BANDS] = { .type = NLA_U32 },
 	[NL80211_ATTR_NAN_FUNC] = { .type = NLA_NESTED },
 	[NL80211_ATTR_FILS_KEK] = { .type = NLA_BINARY,
@@ -496,7 +538,7 @@ static const struct nla_policy nl80211_key_policy[NL80211_KEY_MAX + 1] = {
 	[NL80211_KEY_SEQ] = { .type = NLA_BINARY, .len = 16 },
 	[NL80211_KEY_DEFAULT] = { .type = NLA_FLAG },
 	[NL80211_KEY_DEFAULT_MGMT] = { .type = NLA_FLAG },
-	[NL80211_KEY_TYPE] = { .type = NLA_U32 },
+	[NL80211_KEY_TYPE] = { .type = NLA_U32, .max = NUM_NL80211_KEYTYPES - 1 },
 	[NL80211_KEY_DEFAULT_TYPES] = { .type = NLA_NESTED },
 };
 
@@ -547,7 +589,11 @@ nl80211_wowlan_tcp_policy[NUM_NL80211_WOWLAN_TCP] = {
 static const struct nla_policy
 nl80211_coalesce_policy[NUM_NL80211_ATTR_COALESCE_RULE] = {
 	[NL80211_ATTR_COALESCE_RULE_DELAY] = { .type = NLA_U32 },
-	[NL80211_ATTR_COALESCE_RULE_CONDITION] = { .type = NLA_U32 },
+	[NL80211_ATTR_COALESCE_RULE_CONDITION] = {
+		.type = NLA_U32,
+		.min = NL80211_COALESCE_CONDITION_MATCH,
+		.max = NL80211_COALESCE_CONDITION_NO_MATCH,
+	},
 	[NL80211_ATTR_COALESCE_RULE_PKT_PATTERN] = { .type = NLA_NESTED },
 };
 
@@ -914,12 +960,8 @@ static int nl80211_parse_key_new(struct genl_info *info, struct nlattr *key,
 	if (tb[NL80211_KEY_CIPHER])
 		k->p.cipher = nla_get_u32(tb[NL80211_KEY_CIPHER]);
 
-	if (tb[NL80211_KEY_TYPE]) {
+	if (tb[NL80211_KEY_TYPE])
 		k->type = nla_get_u32(tb[NL80211_KEY_TYPE]);
-		if (k->type < 0 || k->type >= NUM_NL80211_KEYTYPES)
-			return genl_err_attr(info, -EINVAL,
-					     tb[NL80211_KEY_TYPE]);
-	}
 
 	if (tb[NL80211_KEY_DEFAULT_TYPES]) {
 		struct nlattr *kdt[NUM_NL80211_KEY_DEFAULT_TYPES];
@@ -966,13 +1008,8 @@ static int nl80211_parse_key_old(struct genl_info *info, struct key_parse *k)
 	if (k->defmgmt)
 		k->def_multi = true;
 
-	if (info->attrs[NL80211_ATTR_KEY_TYPE]) {
+	if (info->attrs[NL80211_ATTR_KEY_TYPE])
 		k->type = nla_get_u32(info->attrs[NL80211_ATTR_KEY_TYPE]);
-		if (k->type < 0 || k->type >= NUM_NL80211_KEYTYPES) {
-			GENL_SET_ERR_MSG(info, "key type out of range");
-			return -EINVAL;
-		}
-	}
 
 	if (info->attrs[NL80211_ATTR_KEY_DEFAULT_TYPES]) {
 		struct nlattr *kdt[NUM_NL80211_KEY_DEFAULT_TYPES];
@@ -2770,8 +2807,6 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info)
 	if (info->attrs[NL80211_ATTR_WIPHY_RETRY_SHORT]) {
 		retry_short = nla_get_u8(
 			info->attrs[NL80211_ATTR_WIPHY_RETRY_SHORT]);
-		if (retry_short == 0)
-			return -EINVAL;
 
 		changed |= WIPHY_PARAM_RETRY_SHORT;
 	}
@@ -2779,8 +2814,6 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info)
 	if (info->attrs[NL80211_ATTR_WIPHY_RETRY_LONG]) {
 		retry_long = nla_get_u8(
 			info->attrs[NL80211_ATTR_WIPHY_RETRY_LONG]);
-		if (retry_long == 0)
-			return -EINVAL;
 
 		changed |= WIPHY_PARAM_RETRY_LONG;
 	}
@@ -3272,8 +3305,6 @@ static int nl80211_set_interface(struct sk_buff *skb, struct genl_info *info)
 		ntype = nla_get_u32(info->attrs[NL80211_ATTR_IFTYPE]);
 		if (otype != ntype)
 			change = true;
-		if (ntype > NL80211_IFTYPE_MAX)
-			return -EINVAL;
 	}
 
 	if (info->attrs[NL80211_ATTR_MESH_ID]) {
@@ -3338,11 +3369,8 @@ static int nl80211_new_interface(struct sk_buff *skb, struct genl_info *info)
 	if (!info->attrs[NL80211_ATTR_IFNAME])
 		return -EINVAL;
 
-	if (info->attrs[NL80211_ATTR_IFTYPE]) {
+	if (info->attrs[NL80211_ATTR_IFTYPE])
 		type = nla_get_u32(info->attrs[NL80211_ATTR_IFTYPE]);
-		if (type > NL80211_IFTYPE_MAX)
-			return -EINVAL;
-	}
 
 	if (!rdev->ops->add_virtual_intf ||
 	    !(rdev->wiphy.interface_modes & (1 << type)))
@@ -3531,9 +3559,6 @@ static int nl80211_get_key(struct sk_buff *skb, struct genl_info *info)
 	if (info->attrs[NL80211_ATTR_KEY_IDX])
 		key_idx = nla_get_u8(info->attrs[NL80211_ATTR_KEY_IDX]);
 
-	if (key_idx > 5)
-		return -EINVAL;
-
 	if (info->attrs[NL80211_ATTR_MAC])
 		mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
 
@@ -3541,8 +3566,6 @@ static int nl80211_get_key(struct sk_buff *skb, struct genl_info *info)
 	if (info->attrs[NL80211_ATTR_KEY_TYPE]) {
 		u32 kt = nla_get_u32(info->attrs[NL80211_ATTR_KEY_TYPE]);
 
-		if (kt >= NUM_NL80211_KEYTYPES)
-			return -EINVAL;
 		if (kt != NL80211_KEYTYPE_GROUP &&
 		    kt != NL80211_KEYTYPE_PAIRWISE)
 			return -EINVAL;
@@ -4372,14 +4395,9 @@ static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info)
 			return -EINVAL;
 	}
 
-	if (info->attrs[NL80211_ATTR_HIDDEN_SSID]) {
+	if (info->attrs[NL80211_ATTR_HIDDEN_SSID])
 		params.hidden_ssid = nla_get_u32(
 			info->attrs[NL80211_ATTR_HIDDEN_SSID]);
-		if (params.hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE &&
-		    params.hidden_ssid != NL80211_HIDDEN_SSID_ZERO_LEN &&
-		    params.hidden_ssid != NL80211_HIDDEN_SSID_ZERO_CONTENTS)
-			return -EINVAL;
-	}
 
 	params.privacy = !!info->attrs[NL80211_ATTR_PRIVACY];
 
@@ -4409,8 +4427,6 @@ static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info)
 			return -EINVAL;
 		params.p2p_ctwindow =
 			nla_get_u8(info->attrs[NL80211_ATTR_P2P_CTWINDOW]);
-		if (params.p2p_ctwindow > 127)
-			return -EINVAL;
 		if (params.p2p_ctwindow != 0 &&
 		    !(rdev->wiphy.features & NL80211_FEATURE_P2P_GO_CTWIN))
 			return -EINVAL;
@@ -4422,8 +4438,6 @@ static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info)
 		if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO)
 			return -EINVAL;
 		tmp = nla_get_u8(info->attrs[NL80211_ATTR_P2P_OPPPS]);
-		if (tmp > 1)
-			return -EINVAL;
 		params.p2p_opp_ps = tmp;
 		if (params.p2p_opp_ps != 0 &&
 		    !(rdev->wiphy.features & NL80211_FEATURE_P2P_GO_OPPPS))
@@ -5360,17 +5374,11 @@ static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info)
 	else
 		params.listen_interval = -1;
 
-	if (info->attrs[NL80211_ATTR_STA_SUPPORT_P2P_PS]) {
-		u8 tmp;
-
-		tmp = nla_get_u8(info->attrs[NL80211_ATTR_STA_SUPPORT_P2P_PS]);
-		if (tmp >= NUM_NL80211_P2P_PS_STATUS)
-			return -EINVAL;
-
-		params.support_p2p_ps = tmp;
-	} else {
+	if (info->attrs[NL80211_ATTR_STA_SUPPORT_P2P_PS])
+		params.support_p2p_ps =
+			nla_get_u8(info->attrs[NL80211_ATTR_STA_SUPPORT_P2P_PS]);
+	else
 		params.support_p2p_ps = -1;
-	}
 
 	if (!info->attrs[NL80211_ATTR_MAC])
 		return -EINVAL;
@@ -5400,38 +5408,23 @@ static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info)
 	if (parse_station_flags(info, dev->ieee80211_ptr->iftype, &params))
 		return -EINVAL;
 
-	if (info->attrs[NL80211_ATTR_STA_PLINK_ACTION]) {
+	if (info->attrs[NL80211_ATTR_STA_PLINK_ACTION])
 		params.plink_action =
 			nla_get_u8(info->attrs[NL80211_ATTR_STA_PLINK_ACTION]);
-		if (params.plink_action >= NUM_NL80211_PLINK_ACTIONS)
-			return -EINVAL;
-	}
 
 	if (info->attrs[NL80211_ATTR_STA_PLINK_STATE]) {
 		params.plink_state =
 			nla_get_u8(info->attrs[NL80211_ATTR_STA_PLINK_STATE]);
-		if (params.plink_state >= NUM_NL80211_PLINK_STATES)
-			return -EINVAL;
-		if (info->attrs[NL80211_ATTR_MESH_PEER_AID]) {
+		if (info->attrs[NL80211_ATTR_MESH_PEER_AID])
 			params.peer_aid = nla_get_u16(
 				info->attrs[NL80211_ATTR_MESH_PEER_AID]);
-			if (params.peer_aid > IEEE80211_MAX_AID)
-				return -EINVAL;
-		}
 		params.sta_modify_mask |= STATION_PARAM_APPLY_PLINK_STATE;
 	}
 
-	if (info->attrs[NL80211_ATTR_LOCAL_MESH_POWER_MODE]) {
-		enum nl80211_mesh_power_mode pm = nla_get_u32(
+	if (info->attrs[NL80211_ATTR_LOCAL_MESH_POWER_MODE])
+		params.local_pm = nla_get_u32(
 			info->attrs[NL80211_ATTR_LOCAL_MESH_POWER_MODE]);
 
-		if (pm <= NL80211_MESH_POWER_UNKNOWN ||
-		    pm > NL80211_MESH_POWER_MAX)
-			return -EINVAL;
-
-		params.local_pm = pm;
-	}
-
 	if (info->attrs[NL80211_ATTR_OPMODE_NOTIF]) {
 		params.opmode_notif_used = true;
 		params.opmode_notif =
@@ -5508,13 +5501,8 @@ static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info)
 		nla_get_u16(info->attrs[NL80211_ATTR_STA_LISTEN_INTERVAL]);
 
 	if (info->attrs[NL80211_ATTR_STA_SUPPORT_P2P_PS]) {
-		u8 tmp;
-
-		tmp = nla_get_u8(info->attrs[NL80211_ATTR_STA_SUPPORT_P2P_PS]);
-		if (tmp >= NUM_NL80211_P2P_PS_STATUS)
-			return -EINVAL;
-
-		params.support_p2p_ps = tmp;
+		params.support_p2p_ps =
+			nla_get_u8(info->attrs[NL80211_ATTR_STA_SUPPORT_P2P_PS]);
 	} else {
 		/*
 		 * if not specified, assume it's supported for P2P GO interface,
@@ -5528,8 +5516,6 @@ static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info)
 		params.aid = nla_get_u16(info->attrs[NL80211_ATTR_PEER_AID]);
 	else
 		params.aid = nla_get_u16(info->attrs[NL80211_ATTR_STA_AID]);
-	if (!params.aid || params.aid > IEEE80211_MAX_AID)
-		return -EINVAL;
 
 	if (info->attrs[NL80211_ATTR_STA_CAPABILITY]) {
 		params.capability =
@@ -5569,12 +5555,9 @@ static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info)
 			nla_get_u8(info->attrs[NL80211_ATTR_OPMODE_NOTIF]);
 	}
 
-	if (info->attrs[NL80211_ATTR_STA_PLINK_ACTION]) {
+	if (info->attrs[NL80211_ATTR_STA_PLINK_ACTION])
 		params.plink_action =
 			nla_get_u8(info->attrs[NL80211_ATTR_STA_PLINK_ACTION]);
-		if (params.plink_action >= NUM_NL80211_PLINK_ACTIONS)
-			return -EINVAL;
-	}
 
 	err = nl80211_parse_sta_channel_info(info, &params);
 	if (err)
@@ -6084,9 +6067,7 @@ static int nl80211_set_bss(struct sk_buff *skb, struct genl_info *info)
 		if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO)
 			return -EINVAL;
 		params.p2p_ctwindow =
-			nla_get_s8(info->attrs[NL80211_ATTR_P2P_CTWINDOW]);
-		if (params.p2p_ctwindow < 0)
-			return -EINVAL;
+			nla_get_u8(info->attrs[NL80211_ATTR_P2P_CTWINDOW]);
 		if (params.p2p_ctwindow != 0 &&
 		    !(rdev->wiphy.features & NL80211_FEATURE_P2P_GO_CTWIN))
 			return -EINVAL;
@@ -6098,8 +6079,6 @@ static int nl80211_set_bss(struct sk_buff *skb, struct genl_info *info)
 		if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO)
 			return -EINVAL;
 		tmp = nla_get_u8(info->attrs[NL80211_ATTR_P2P_OPPPS]);
-		if (tmp > 1)
-			return -EINVAL;
 		params.p2p_opp_ps = tmp;
 		if (params.p2p_opp_ps &&
 		    !(rdev->wiphy.features & NL80211_FEATURE_P2P_GO_OPPPS))
@@ -6278,16 +6257,22 @@ static int nl80211_get_mesh_config(struct sk_buff *skb,
 	return -ENOBUFS;
 }
 
-static const struct nla_policy nl80211_meshconf_params_policy[NL80211_MESHCONF_ATTR_MAX+1] = {
-	[NL80211_MESHCONF_RETRY_TIMEOUT] = { .type = NLA_U16 },
-	[NL80211_MESHCONF_CONFIRM_TIMEOUT] = { .type = NLA_U16 },
-	[NL80211_MESHCONF_HOLDING_TIMEOUT] = { .type = NLA_U16 },
-	[NL80211_MESHCONF_MAX_PEER_LINKS] = { .type = NLA_U16 },
-	[NL80211_MESHCONF_MAX_RETRIES] = { .type = NLA_U8 },
-	[NL80211_MESHCONF_TTL] = { .type = NLA_U8 },
-	[NL80211_MESHCONF_ELEMENT_TTL] = { .type = NLA_U8 },
-	[NL80211_MESHCONF_AUTO_OPEN_PLINKS] = { .type = NLA_U8 },
-	[NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR] = { .type = NLA_U32 },
+static const struct nla_policy
+nl80211_meshconf_params_policy[NL80211_MESHCONF_ATTR_MAX+1] = {
+	[NL80211_MESHCONF_RETRY_TIMEOUT] = { .type = NLA_U16,
+					     .min = 1, .max = 255 },
+	[NL80211_MESHCONF_CONFIRM_TIMEOUT] = { .type = NLA_U16,
+					       .min = 1, .max = 255 },
+	[NL80211_MESHCONF_HOLDING_TIMEOUT] = { .type = NLA_U16,
+					       .min = 1, .max = 255 },
+	[NL80211_MESHCONF_MAX_PEER_LINKS] = { .type = NLA_U16, .max = 255 },
+	[NL80211_MESHCONF_MAX_RETRIES] = { .type = NLA_U8, .max = 16 },
+	[NL80211_MESHCONF_TTL] = { .type = NLA_U8, .min = 1, .max = 255 },
+	[NL80211_MESHCONF_ELEMENT_TTL] = { .type = NLA_U8,
+					   .min = 1, .max = 255 },
+	[NL80211_MESHCONF_AUTO_OPEN_PLINKS] = { .type = NLA_U8, .max = 1 },
+	[NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR] = { .type = NLA_U32,
+							.min = 1, .max = 255 },
 	[NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES] = { .type = NLA_U8 },
 	[NL80211_MESHCONF_PATH_REFRESH_TIME] = { .type = NLA_U32 },
 	[NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT] = { .type = NLA_U16 },
@@ -6295,16 +6280,19 @@ static const struct nla_policy nl80211_meshconf_params_policy[NL80211_MESHCONF_A
 	[NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL] = { .type = NLA_U16 },
 	[NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL] = { .type = NLA_U16 },
 	[NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME] = { .type = NLA_U16 },
-	[NL80211_MESHCONF_HWMP_ROOTMODE] = { .type = NLA_U8 },
+	[NL80211_MESHCONF_HWMP_ROOTMODE] = { .type = NLA_U8, .max = 4 },
 	[NL80211_MESHCONF_HWMP_RANN_INTERVAL] = { .type = NLA_U16 },
-	[NL80211_MESHCONF_GATE_ANNOUNCEMENTS] = { .type = NLA_U8 },
-	[NL80211_MESHCONF_FORWARDING] = { .type = NLA_U8 },
-	[NL80211_MESHCONF_RSSI_THRESHOLD] = { .type = NLA_U32 },
+	[NL80211_MESHCONF_GATE_ANNOUNCEMENTS] = { .type = NLA_U8, .max = 1 },
+	[NL80211_MESHCONF_FORWARDING] = { .type = NLA_U8, .max = 1 },
+	[NL80211_MESHCONF_RSSI_THRESHOLD] = { .type = NLA_U32,
+					      .min = -255, .max = 0 },
 	[NL80211_MESHCONF_HT_OPMODE] = { .type = NLA_U16 },
 	[NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT] = { .type = NLA_U32 },
 	[NL80211_MESHCONF_HWMP_ROOT_INTERVAL] = { .type = NLA_U16 },
 	[NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL] = { .type = NLA_U16 },
-	[NL80211_MESHCONF_POWER_MODE] = { .type = NLA_U32 },
+	[NL80211_MESHCONF_POWER_MODE] = { .type = NLA_U32,
+					  .min = NL80211_MESH_POWER_ACTIVE,
+					  .max = NL80211_MESH_POWER_MAX },
 	[NL80211_MESHCONF_AWAKE_WINDOW] = { .type = NLA_U16 },
 	[NL80211_MESHCONF_PLINK_TIMEOUT] = { .type = NLA_U32 },
 };
@@ -6322,63 +6310,6 @@ static const struct nla_policy
 	[NL80211_MESH_SETUP_USERSPACE_AMPE] = { .type = NLA_FLAG },
 };
 
-static int nl80211_check_bool(const struct nlattr *nla, u8 min, u8 max, bool *out)
-{
-	u8 val = nla_get_u8(nla);
-	if (val < min || val > max)
-		return -EINVAL;
-	*out = val;
-	return 0;
-}
-
-static int nl80211_check_u8(const struct nlattr *nla, u8 min, u8 max, u8 *out)
-{
-	u8 val = nla_get_u8(nla);
-	if (val < min || val > max)
-		return -EINVAL;
-	*out = val;
-	return 0;
-}
-
-static int nl80211_check_u16(const struct nlattr *nla, u16 min, u16 max, u16 *out)
-{
-	u16 val = nla_get_u16(nla);
-	if (val < min || val > max)
-		return -EINVAL;
-	*out = val;
-	return 0;
-}
-
-static int nl80211_check_u32(const struct nlattr *nla, u32 min, u32 max, u32 *out)
-{
-	u32 val = nla_get_u32(nla);
-	if (val < min || val > max)
-		return -EINVAL;
-	*out = val;
-	return 0;
-}
-
-static int nl80211_check_s32(const struct nlattr *nla, s32 min, s32 max, s32 *out)
-{
-	s32 val = nla_get_s32(nla);
-	if (val < min || val > max)
-		return -EINVAL;
-	*out = val;
-	return 0;
-}
-
-static int nl80211_check_power_mode(const struct nlattr *nla,
-				    enum nl80211_mesh_power_mode min,
-				    enum nl80211_mesh_power_mode max,
-				    enum nl80211_mesh_power_mode *out)
-{
-	u32 val = nla_get_u32(nla);
-	if (val < min || val > max)
-		return -EINVAL;
-	*out = val;
-	return 0;
-}
-
 static int nl80211_parse_mesh_config(struct genl_info *info,
 				     struct mesh_config *cfg,
 				     u32 *mask_out)
@@ -6387,13 +6318,12 @@ static int nl80211_parse_mesh_config(struct genl_info *info,
 	u32 mask = 0;
 	u16 ht_opmode;
 
-#define FILL_IN_MESH_PARAM_IF_SET(tb, cfg, param, min, max, mask, attr, fn) \
-do {									    \
-	if (tb[attr]) {							    \
-		if (fn(tb[attr], min, max, &cfg->param))		    \
-			return -EINVAL;					    \
-		mask |= (1 << (attr - 1));				    \
-	}								    \
+#define FILL_IN_MESH_PARAM_IF_SET(tb, cfg, param, mask, attr, fn)	\
+do {									\
+	if (tb[attr]) {							\
+		cfg->param = fn(tb[attr]);				\
+		mask |= BIT((attr) - 1);				\
+	}								\
 } while (0)
 
 	if (!info->attrs[NL80211_ATTR_MESH_CONFIG])
@@ -6408,75 +6338,88 @@ do {									    \
 	BUILD_BUG_ON(NL80211_MESHCONF_ATTR_MAX > 32);
 
 	/* Fill in the params struct */
-	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshRetryTimeout, 1, 255,
-				  mask, NL80211_MESHCONF_RETRY_TIMEOUT,
-				  nl80211_check_u16);
-	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshConfirmTimeout, 1, 255,
-				  mask, NL80211_MESHCONF_CONFIRM_TIMEOUT,
-				  nl80211_check_u16);
-	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHoldingTimeout, 1, 255,
-				  mask, NL80211_MESHCONF_HOLDING_TIMEOUT,
-				  nl80211_check_u16);
-	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshMaxPeerLinks, 0, 255,
-				  mask, NL80211_MESHCONF_MAX_PEER_LINKS,
-				  nl80211_check_u16);
-	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshMaxRetries, 0, 16,
-				  mask, NL80211_MESHCONF_MAX_RETRIES,
-				  nl80211_check_u8);
-	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshTTL, 1, 255,
-				  mask, NL80211_MESHCONF_TTL, nl80211_check_u8);
-	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, element_ttl, 1, 255,
-				  mask, NL80211_MESHCONF_ELEMENT_TTL,
-				  nl80211_check_u8);
-	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, auto_open_plinks, 0, 1,
-				  mask, NL80211_MESHCONF_AUTO_OPEN_PLINKS,
-				  nl80211_check_bool);
+	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshRetryTimeout, mask,
+				  NL80211_MESHCONF_RETRY_TIMEOUT, nla_get_u16);
+	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshConfirmTimeout, mask,
+				  NL80211_MESHCONF_CONFIRM_TIMEOUT,
+				  nla_get_u16);
+	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHoldingTimeout, mask,
+				  NL80211_MESHCONF_HOLDING_TIMEOUT,
+				  nla_get_u16);
+	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshMaxPeerLinks, mask,
+				  NL80211_MESHCONF_MAX_PEER_LINKS,
+				  nla_get_u16);
+	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshMaxRetries, mask,
+				  NL80211_MESHCONF_MAX_RETRIES, nla_get_u8);
+	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshTTL, mask,
+				  NL80211_MESHCONF_TTL, nla_get_u8);
+	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, element_ttl, mask,
+				  NL80211_MESHCONF_ELEMENT_TTL, nla_get_u8);
+	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, auto_open_plinks, mask,
+				  NL80211_MESHCONF_AUTO_OPEN_PLINKS,
+				  nla_get_u8);
 	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshNbrOffsetMaxNeighbor,
-				  1, 255, mask,
+				  mask,
 				  NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR,
-				  nl80211_check_u32);
-	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPmaxPREQretries, 0, 255,
-				  mask, NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES,
-				  nl80211_check_u8);
-	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, path_refresh_time, 1, 65535,
-				  mask, NL80211_MESHCONF_PATH_REFRESH_TIME,
-				  nl80211_check_u32);
-	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, min_discovery_timeout, 1, 65535,
-				  mask, NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT,
-				  nl80211_check_u16);
+				  nla_get_u32);
+	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPmaxPREQretries, mask,
+				  NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES,
+				  nla_get_u8);
+	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, path_refresh_time, mask,
+				  NL80211_MESHCONF_PATH_REFRESH_TIME,
+				  nla_get_u32);
+	if (mask & BIT(NL80211_MESHCONF_PATH_REFRESH_TIME) &&
+	    (cfg->path_refresh_time < 1 || cfg->path_refresh_time > 65535))
+		return -EINVAL;
+	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, min_discovery_timeout, mask,
+				  NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT,
+				  nla_get_u16);
+	if (mask & BIT(NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT) &&
+	    cfg->min_discovery_timeout < 1)
+		return -EINVAL;
 	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPactivePathTimeout,
-				  1, 65535, mask,
+				  mask,
 				  NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT,
-				  nl80211_check_u32);
-	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPpreqMinInterval,
-				  1, 65535, mask,
+				  nla_get_u32);
+	if (mask & BIT(NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT) &&
+	    (cfg->dot11MeshHWMPactivePathTimeout < 1 ||
+	     cfg->dot11MeshHWMPactivePathTimeout > 65535))
+		return -EINVAL;
+	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPpreqMinInterval, mask,
 				  NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL,
-				  nl80211_check_u16);
-	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPperrMinInterval,
-				  1, 65535, mask,
+				  nla_get_u16);
+	if (mask & BIT(NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL) &&
+	    cfg->dot11MeshHWMPpreqMinInterval < 1)
+		return -EINVAL;
+	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPperrMinInterval, mask,
 				  NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL,
-				  nl80211_check_u16);
+				  nla_get_u16);
+	if (mask & BIT(NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL) &&
+	    cfg->dot11MeshHWMPperrMinInterval < 1)
+		return -EINVAL;
 	FILL_IN_MESH_PARAM_IF_SET(tb, cfg,
-				  dot11MeshHWMPnetDiameterTraversalTime,
-				  1, 65535, mask,
+				  dot11MeshHWMPnetDiameterTraversalTime, mask,
 				  NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME,
-				  nl80211_check_u16);
-	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPRootMode, 0, 4,
-				  mask, NL80211_MESHCONF_HWMP_ROOTMODE,
-				  nl80211_check_u8);
-	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPRannInterval, 1, 65535,
-				  mask, NL80211_MESHCONF_HWMP_RANN_INTERVAL,
-				  nl80211_check_u16);
-	FILL_IN_MESH_PARAM_IF_SET(tb, cfg,
-				  dot11MeshGateAnnouncementProtocol, 0, 1,
+				  nla_get_u16);
+	if (mask & BIT(NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME) &&
+	    cfg->dot11MeshHWMPnetDiameterTraversalTime < 1)
+		return -EINVAL;
+	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPRootMode, mask,
+				  NL80211_MESHCONF_HWMP_ROOTMODE, nla_get_u8);
+	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPRannInterval, mask,
+				  NL80211_MESHCONF_HWMP_RANN_INTERVAL,
+				  nla_get_u16);
+	if (mask & BIT(NL80211_MESHCONF_HWMP_RANN_INTERVAL) &&
+	    cfg->dot11MeshHWMPRannInterval < 1)
+		return -EINVAL;
+	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshGateAnnouncementProtocol,
 				  mask, NL80211_MESHCONF_GATE_ANNOUNCEMENTS,
-				  nl80211_check_bool);
-	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshForwarding, 0, 1,
-				  mask, NL80211_MESHCONF_FORWARDING,
-				  nl80211_check_bool);
-	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, rssi_threshold, -255, 0,
-				  mask, NL80211_MESHCONF_RSSI_THRESHOLD,
-				  nl80211_check_s32);
+				  nla_get_u8);
+	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshForwarding, mask,
+				  NL80211_MESHCONF_FORWARDING, nla_get_u8);
+	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, rssi_threshold, mask,
+				  NL80211_MESHCONF_RSSI_THRESHOLD,
+				  nla_get_s32);
 	/*
 	 * Check HT operation mode based on
 	 * IEEE 802.11-2016 9.4.2.57 HT Operation element.
@@ -6495,29 +6438,33 @@ do {									    \
 		cfg->ht_opmode = ht_opmode;
 		mask |= (1 << (NL80211_MESHCONF_HT_OPMODE - 1));
 	}
-	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPactivePathToRootTimeout,
-				  1, 65535, mask,
-				  NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT,
-				  nl80211_check_u32);
-	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMProotInterval, 1, 65535,
-				  mask, NL80211_MESHCONF_HWMP_ROOT_INTERVAL,
-				  nl80211_check_u16);
 	FILL_IN_MESH_PARAM_IF_SET(tb, cfg,
-				  dot11MeshHWMPconfirmationInterval,
-				  1, 65535, mask,
+				  dot11MeshHWMPactivePathToRootTimeout, mask,
+				  NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT,
+				  nla_get_u32);
+	if (mask & BIT(NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT) &&
+	    (cfg->dot11MeshHWMPactivePathToRootTimeout < 1 ||
+	     cfg->dot11MeshHWMPactivePathToRootTimeout > 65535))
+		return -EINVAL;
+	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMProotInterval, mask,
+				  NL80211_MESHCONF_HWMP_ROOT_INTERVAL,
+				  nla_get_u16);
+	if (mask & BIT(NL80211_MESHCONF_HWMP_ROOT_INTERVAL) &&
+	    cfg->dot11MeshHWMProotInterval < 1)
+		return -EINVAL;
+	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPconfirmationInterval,
+				  mask,
 				  NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL,
-				  nl80211_check_u16);
-	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, power_mode,
-				  NL80211_MESH_POWER_ACTIVE,
-				  NL80211_MESH_POWER_MAX,
-				  mask, NL80211_MESHCONF_POWER_MODE,
-				  nl80211_check_power_mode);
-	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshAwakeWindowDuration,
-				  0, 65535, mask,
-				  NL80211_MESHCONF_AWAKE_WINDOW, nl80211_check_u16);
-	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, plink_timeout, 0, 0xffffffff,
-				  mask, NL80211_MESHCONF_PLINK_TIMEOUT,
-				  nl80211_check_u32);
+				  nla_get_u16);
+	if (mask & BIT(NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL) &&
+	    cfg->dot11MeshHWMPconfirmationInterval < 1)
+		return -EINVAL;
+	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, power_mode, mask,
+				  NL80211_MESHCONF_POWER_MODE, nla_get_u32);
+	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshAwakeWindowDuration, mask,
+				  NL80211_MESHCONF_AWAKE_WINDOW, nla_get_u16);
+	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, plink_timeout, mask,
+				  NL80211_MESHCONF_PLINK_TIMEOUT, nla_get_u32);
 	if (mask_out)
 		*mask_out = mask;
 
@@ -9516,11 +9463,6 @@ static int nl80211_connect(struct sk_buff *skb, struct genl_info *info)
 		    !wiphy_ext_feature_isset(&rdev->wiphy,
 					     NL80211_EXT_FEATURE_MFP_OPTIONAL))
 			return -EOPNOTSUPP;
-
-		if (connect.mfp != NL80211_MFP_REQUIRED &&
-		    connect.mfp != NL80211_MFP_NO &&
-		    connect.mfp != NL80211_MFP_OPTIONAL)
-			return -EINVAL;
 	} else {
 		connect.mfp = NL80211_MFP_NO;
 	}
@@ -10279,9 +10221,6 @@ static int nl80211_set_power_save(struct sk_buff *skb, struct genl_info *info)
 
 	ps_state = nla_get_u32(info->attrs[NL80211_ATTR_PS_STATE]);
 
-	if (ps_state != NL80211_PS_DISABLED && ps_state != NL80211_PS_ENABLED)
-		return -EINVAL;
-
 	wdev = dev->ieee80211_ptr;
 
 	if (!rdev->ops->set_power_mgmt)
@@ -11434,9 +11373,6 @@ static int nl80211_parse_coalesce_rule(struct cfg80211_registered_device *rdev,
 	if (tb[NL80211_ATTR_COALESCE_RULE_CONDITION])
 		new_rule->condition =
 			nla_get_u32(tb[NL80211_ATTR_COALESCE_RULE_CONDITION]);
-	if (new_rule->condition != NL80211_COALESCE_CONDITION_MATCH &&
-	    new_rule->condition != NL80211_COALESCE_CONDITION_NO_MATCH)
-		return -EINVAL;
 
 	if (!tb[NL80211_ATTR_COALESCE_RULE_PKT_PATTERN])
 		return -EINVAL;
@@ -11789,8 +11725,6 @@ static int nl80211_start_nan(struct sk_buff *skb, struct genl_info *info)
 
 	conf.master_pref =
 		nla_get_u8(info->attrs[NL80211_ATTR_NAN_MASTER_PREF]);
-	if (!conf.master_pref)
-		return -EINVAL;
 
 	if (info->attrs[NL80211_ATTR_BANDS]) {
 		u32 bands = nla_get_u32(info->attrs[NL80211_ATTR_BANDS]);
@@ -12775,12 +12709,7 @@ static int nl80211_add_tx_ts(struct sk_buff *skb, struct genl_info *info)
 		return -EINVAL;
 
 	tsid = nla_get_u8(info->attrs[NL80211_ATTR_TSID]);
-	if (tsid >= IEEE80211_NUM_TIDS)
-		return -EINVAL;
-
 	up = nla_get_u8(info->attrs[NL80211_ATTR_USER_PRIO]);
-	if (up >= IEEE80211_NUM_UPS)
-		return -EINVAL;
 
 	/* WMM uses TIDs 0-7 even for TSPEC */
 	if (tsid >= IEEE80211_FIRST_TSPEC_TSID) {
-- 
2.14.4

^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox