virtio_net: validate ethtool port setting and explain the user validation
authorNikolay Aleksandrov <nikolay@cumulusnetworks.com>
Sun, 7 Feb 2016 20:52:24 +0000 (21:52 +0100)
committerDavid S. Miller <davem@davemloft.net>
Thu, 11 Feb 2016 16:55:38 +0000 (11:55 -0500)
We should validate the port setting that we got from the user and check
if it's what we've set it to (PORT_OTHER), also add explanation that
ignoring advertising is good as long as we don't have autonegotiation.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/virtio_net.c

index c9fd52a8e6ec5f05d3459ba26994a449df764ec6..fb0eae42bf398c977fec8f2c4f59d74e5d9b4394 100644 (file)
@@ -1386,11 +1386,13 @@ 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 */
+       /* cmd is always set so we need to clear it, validate the port type
+        * and also without autonegotiation we can ignore advertising
+        */
        ethtool_cmd_speed_set(&diff1, 0);
+       diff2.port = PORT_OTHER;
        diff1.advertising = 0;
        diff1.duplex = 0;
-       diff1.port = 0;
        diff1.cmd = 0;
 
        return !memcmp(&diff1, &diff2, sizeof(diff1));