[ovs-dev] [PATCH v2 1/2] netdev-dummy: Correctly maintain port statistics.

Ben Pfaff blp at nicira.com
Fri Feb 1 00:28:44 UTC 2013


Signed-off-by: Ben Pfaff <blp at nicira.com>
---
 lib/netdev-dummy.c |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/lib/netdev-dummy.c b/lib/netdev-dummy.c
index f81b68e..234d7bc 100644
--- a/lib/netdev-dummy.c
+++ b/lib/netdev-dummy.c
@@ -205,6 +205,19 @@ netdev_dummy_drain(struct netdev *netdev_)
 }
 
 static int
+netdev_dummy_send(struct netdev *netdev, const void *buffer OVS_UNUSED,
+                  size_t size)
+{
+    struct netdev_dev_dummy *dev =
+        netdev_dev_dummy_cast(netdev_get_dev(netdev));
+
+    dev->stats.tx_packets++;
+    dev->stats.tx_bytes += size;
+
+    return 0;
+}
+
+static int
 netdev_dummy_set_etheraddr(struct netdev *netdev,
                            const uint8_t mac[ETH_ADDR_LEN])
 {
@@ -336,7 +349,7 @@ static const struct netdev_class dummy_class = {
     netdev_dummy_recv_wait,
     netdev_dummy_drain,
 
-    NULL,                       /* send */
+    netdev_dummy_send,          /* send */
     NULL,                       /* send_wait */
 
     netdev_dummy_set_etheraddr,
@@ -443,6 +456,9 @@ netdev_dummy_receive(struct unixctl_conn *conn,
             return;
         }
 
+        dummy_dev->stats.rx_packets++;
+        dummy_dev->stats.rx_bytes += packet->size;
+
         n_listeners = 0;
         LIST_FOR_EACH (dev, node, &dummy_dev->devs) {
             if (dev->listening) {
-- 
1.7.2.5




More information about the dev mailing list