Based on reading current implementations of {GS}CHANNELS, most drivers
either support only combined counts or only separate counts. At least
one driver supported setting combined or separate channels. No driver
supported combined and separate channels setting at the same time, and
this patch adds a sanity check to prevent such requests. I am not 100%
sure if this is correct as I was not able to find documentation and
I think it currently depended on driver implementation.

Signed-off-by: Jacob Keller <jacob.e.kel...@intel.com>
---
 net/core/ethtool.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 71aff99157c3..7d4cef7b7176 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -1297,6 +1297,11 @@ static noinline_for_stack int 
ethtool_set_channels(struct net_device *dev,
            (channels.other_count > max.max_other))
                return -EINVAL;
 
+       /* can't set combined and separate channels at the same time */
+       if ((channels.combined_count &&
+            (channels.rx_count || channels.tx_count))
+           return -EINVAL;
+
        /* ensure the new Rx count fits within the configured Rx flow
         * indirection table settings */
        if (netif_is_rxfh_configured(dev) &&
-- 
2.7.0.236.gda096a0.dirty

Reply via email to