Thread (15 messages) flat view 15 messages, 6 authors, 2016-02-07

Re: [PATCH net-next v5 2/2] virtio_net: add ethtool support for set and get of settings

From: Nikolay Aleksandrov <hidden>
Date: 2016-02-04 12:26:30

On 02/04/2016 01:21 PM, Michael S. Tsirkin wrote:
On Wed, Feb 03, 2016 at 04:04:37AM +0100, Nikolay Aleksandrov wrote:
quoted
From: Nikolay Aleksandrov <redacted>
[snip]
quoted
 struct padded_vnet_hdr {
@@ -1376,6 +1380,58 @@ static void virtnet_get_channels(struct net_device *dev,
 	channels->other_count = 0;
 }
 
+/* Check if the user is trying to change anything besides speed/duplex */
+static bool virtnet_validate_ethtool_cmd(const struct ethtool_cmd *cmd)
+{
+	struct ethtool_cmd diff1 = *cmd;
+	struct ethtool_cmd diff2 = {};
+
+	/* advertising and cmd are usually set, ignore port because we set it */
We set it where?
If you're asking about advertising - ethtool sets it automatically when the
user tries to set both speed and duplex together.
Instead of this, should not we set diff2.port to PORT_OTHER?
Yes, that will validate it too.
quoted
+	ethtool_cmd_speed_set(&diff1, 0);
+	diff1.advertising = 0;
+	diff1.duplex = 0;
+	diff1.port = 0;
+	diff1.cmd = 0;
+
+	return !memcmp(&diff1, &diff2, sizeof(diff1));
+}
+
[snip]
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help