diff options
-rw-r--r-- | lib/netdev-linux.c | 37 | ||||
-rw-r--r-- | lib/netdev-vport.c | 44 | ||||
-rw-r--r-- | lib/netdev-vport.h | 1 |
3 files changed, 37 insertions, 45 deletions
diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index d9a444b52..60f985e5f 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -1499,6 +1499,41 @@ netdev_internal_get_stats(const struct netdev *netdev_, return netdev_dev->vport_stats_error; } +static int +netdev_internal_set_stats(struct netdev *netdev, + const struct netdev_stats *stats) +{ + struct ovs_vport_stats vport_stats; + struct dpif_linux_vport vport; + int err; + + vport_stats.rx_packets = stats->rx_packets; + vport_stats.tx_packets = stats->tx_packets; + vport_stats.rx_bytes = stats->rx_bytes; + vport_stats.tx_bytes = stats->tx_bytes; + vport_stats.rx_errors = stats->rx_errors; + vport_stats.tx_errors = stats->tx_errors; + vport_stats.rx_dropped = stats->rx_dropped; + vport_stats.tx_dropped = stats->tx_dropped; + + dpif_linux_vport_init(&vport); + vport.cmd = OVS_VPORT_CMD_SET; + vport.name = netdev_get_name(netdev); + vport.stats = &vport_stats; + + err = dpif_linux_vport_transact(&vport, NULL, NULL); + + /* If the vport layer doesn't know about the device, that doesn't mean it + * doesn't exist (after all were able to open it when netdev_open() was + * called), it just means that it isn't attached and we'll be getting + * stats a different way. */ + if (err == ENODEV) { + err = EOPNOTSUPP; + } + + return err; +} + static void netdev_linux_read_features(struct netdev_dev_linux *netdev_dev) { @@ -2481,7 +2516,7 @@ const struct netdev_class netdev_internal_class = "internal", netdev_linux_create, netdev_internal_get_stats, - netdev_vport_set_stats, + netdev_internal_set_stats, NULL, /* get_features */ netdev_internal_get_drv_info); diff --git a/lib/netdev-vport.c b/lib/netdev-vport.c index ce4cea270..e50103b9f 100644 --- a/lib/netdev-vport.c +++ b/lib/netdev-vport.c @@ -377,21 +377,6 @@ netdev_stats_from_ovs_vport_stats(struct netdev_stats *dst, dst->tx_window_errors = 0; } -/* Copies 'src' into 'dst', performing format conversion in the process. */ -static void -netdev_stats_to_ovs_vport_stats(struct ovs_vport_stats *dst, - const struct netdev_stats *src) -{ - dst->rx_packets = src->rx_packets; - dst->tx_packets = src->tx_packets; - dst->rx_bytes = src->rx_bytes; - dst->tx_bytes = src->tx_bytes; - dst->rx_errors = src->rx_errors; - dst->tx_errors = src->tx_errors; - dst->rx_dropped = src->rx_dropped; - dst->tx_dropped = src->tx_dropped; -} - int netdev_vport_get_stats(const struct netdev *netdev, struct netdev_stats *stats) { @@ -414,33 +399,6 @@ netdev_vport_get_stats(const struct netdev *netdev, struct netdev_stats *stats) return 0; } -int -netdev_vport_set_stats(struct netdev *netdev, const struct netdev_stats *stats) -{ - struct ovs_vport_stats rtnl_stats; - struct dpif_linux_vport vport; - int err; - - netdev_stats_to_ovs_vport_stats(&rtnl_stats, stats); - - dpif_linux_vport_init(&vport); - vport.cmd = OVS_VPORT_CMD_SET; - vport.name = netdev_get_name(netdev); - vport.stats = &rtnl_stats; - - err = dpif_linux_vport_transact(&vport, NULL, NULL); - - /* If the vport layer doesn't know about the device, that doesn't mean it - * doesn't exist (after all were able to open it when netdev_open() was - * called), it just means that it isn't attached and we'll be getting - * stats a different way. */ - if (err == ENODEV) { - err = EOPNOTSUPP; - } - - return err; -} - static int netdev_vport_get_drv_info(const struct netdev *netdev, struct smap *smap) { @@ -932,7 +890,7 @@ unparse_patch_config(const char *name OVS_UNUSED, const char *type OVS_UNUSED, NULL, /* get_carrier_resets */ \ NULL, /* get_miimon */ \ netdev_vport_get_stats, \ - netdev_vport_set_stats, \ + NULL, /* set_stats */ \ \ NULL, /* get_features */ \ NULL, /* set_advertisements */ \ diff --git a/lib/netdev-vport.h b/lib/netdev-vport.h index d96a31865..b6bf5793b 100644 --- a/lib/netdev-vport.h +++ b/lib/netdev-vport.h @@ -29,6 +29,5 @@ enum ovs_vport_type netdev_vport_get_vport_type(const struct netdev *); const char *netdev_vport_get_netdev_type(const struct dpif_linux_vport *); int netdev_vport_get_stats(const struct netdev *, struct netdev_stats *); -int netdev_vport_set_stats(struct netdev *, const struct netdev_stats *); #endif /* netdev-vport.h */ |