mirror of
https://github.com/openvswitch/ovs
synced 2025-10-11 13:57:52 +00:00
bridge: Correctly omit unsupported interface statistics from database.
The database documentation says: If an interface does not support a given statistic, then that pair is omitted. but in fact the implementation included the key-value pair for an unsupported statistic with -1 as the value. Found by inspection. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
This commit is contained in:
@@ -1898,11 +1898,12 @@ iface_refresh_stats(struct iface *iface)
|
|||||||
IFACE_STAT(rx_crc_errors, "rx_crc_err") \
|
IFACE_STAT(rx_crc_errors, "rx_crc_err") \
|
||||||
IFACE_STAT(collisions, "collisions")
|
IFACE_STAT(collisions, "collisions")
|
||||||
|
|
||||||
#define IFACE_STAT(MEMBER, NAME) NAME,
|
#define IFACE_STAT(MEMBER, NAME) + 1
|
||||||
static char *keys[] = { IFACE_STATS };
|
enum { N_IFACE_STATS = IFACE_STATS };
|
||||||
#undef IFACE_STAT
|
#undef IFACE_STAT
|
||||||
int64_t values[ARRAY_SIZE(keys)];
|
int64_t values[N_IFACE_STATS];
|
||||||
int i;
|
char *keys[N_IFACE_STATS];
|
||||||
|
int n;
|
||||||
|
|
||||||
struct netdev_stats stats;
|
struct netdev_stats stats;
|
||||||
|
|
||||||
@@ -1914,15 +1915,19 @@ iface_refresh_stats(struct iface *iface)
|
|||||||
* all-1s, and we will deal with that correctly below. */
|
* all-1s, and we will deal with that correctly below. */
|
||||||
netdev_get_stats(iface->netdev, &stats);
|
netdev_get_stats(iface->netdev, &stats);
|
||||||
|
|
||||||
/* Copy statistics into values[] array. */
|
/* Copy statistics into keys[] and values[]. */
|
||||||
i = 0;
|
n = 0;
|
||||||
#define IFACE_STAT(MEMBER, NAME) values[i++] = stats.MEMBER;
|
#define IFACE_STAT(MEMBER, NAME) \
|
||||||
|
if (stats.MEMBER != UINT64_MAX) { \
|
||||||
|
keys[n] = NAME; \
|
||||||
|
values[n] = stats.MEMBER; \
|
||||||
|
n++; \
|
||||||
|
}
|
||||||
IFACE_STATS;
|
IFACE_STATS;
|
||||||
#undef IFACE_STAT
|
#undef IFACE_STAT
|
||||||
ovs_assert(i == ARRAY_SIZE(keys));
|
ovs_assert(n <= N_IFACE_STATS);
|
||||||
|
|
||||||
ovsrec_interface_set_statistics(iface->cfg, keys, values,
|
ovsrec_interface_set_statistics(iface->cfg, keys, values, n);
|
||||||
ARRAY_SIZE(keys));
|
|
||||||
#undef IFACE_STATS
|
#undef IFACE_STATS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user