summaryrefslogtreecommitdiff
path: root/lib/netdev-linux.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2010-02-11 10:34:45 -0800
committerBen Pfaff <blp@nicira.com>2010-02-11 10:34:45 -0800
commitb62aeed2ab06ecb9a3b3a82dc42ebfc2703ef52f (patch)
treef5d15a0d3fece1116b4299938ca3e571e1d229cb /lib/netdev-linux.c
parent413f274f20bd7e614e144b512b38984d1e9f28b3 (diff)
downloadopenvswitch-b62aeed2ab06ecb9a3b3a82dc42ebfc2703ef52f.tar.gz
netdev-linux: Avoid fiddling with indeterminate data.
If we are using netlink to get stats and get_ifindex() fails, then for an internal network device we will then swap around a bunch of indeterminate (uninitialized) data values. That won't hurt anything--the caller will still set them to all-1-bits due to the error--but it still seems wrong. So this commit avoid it. Found using Clang (http://clang-analyzer.llvm.org/).
Diffstat (limited to 'lib/netdev-linux.c')
-rw-r--r--lib/netdev-linux.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c
index ccc3f845c..6d46b09e9 100644
--- a/lib/netdev-linux.c
+++ b/lib/netdev-linux.c
@@ -1223,9 +1223,7 @@ netdev_linux_get_stats(const struct netdev *netdev_,
COVERAGE_INC(netdev_get_stats);
if (!(netdev_dev->cache_valid & VALID_IS_INTERNAL)) {
- netdev_dev->is_internal = !strcmp(netdev_get_type(netdev_),
- "tap");
-
+ netdev_dev->is_internal = !strcmp(netdev_get_type(netdev_), "tap");
if (!netdev_dev->is_internal) {
struct ethtool_drvinfo drvinfo;
@@ -1266,7 +1264,7 @@ netdev_linux_get_stats(const struct netdev *netdev_,
* will appear to be swapped relative to the other ports since we are the
* one sending the data, not a remote computer. For consistency, we swap
* them back here. */
- if (netdev_dev->is_internal) {
+ if (!error && netdev_dev->is_internal) {
stats->rx_packets = raw_stats.tx_packets;
stats->tx_packets = raw_stats.rx_packets;
stats->rx_bytes = raw_stats.tx_bytes;