patchpanel: Add GetTrafficCounters in patchpanel client
BUG=b:160112867
TEST=unit_tests and fuzzer test;
TEST=wrote experiment code in shill::Manager to invoke this method, it
seems to be working well.
Change-Id: Iae0c4aca2278a80917dc3f593e2142c005e0f761
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/2319439
Tested-by: Jie Jiang <jiejiang@chromium.org>
Commit-Queue: Jie Jiang <jiejiang@chromium.org>
Reviewed-by: Garrick Evans <garrick@chromium.org>
Reviewed-by: Hugo Benichi <hugobenichi@google.com>
Reviewed-by: Matthew Wang <matthewmwang@chromium.org>
diff --git a/patchpanel/client_fuzzer.cc b/patchpanel/client_fuzzer.cc
index d15f9a4..ae811e4 100644
--- a/patchpanel/client_fuzzer.cc
+++ b/patchpanel/client_fuzzer.cc
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <net/if.h>
+
#include <base/logging.h>
#include <dbus/message.h>
#include <fuzzer/FuzzedDataProvider.h>
@@ -71,7 +73,7 @@
client.NotifyArcVmStartup(provider.ConsumeIntegral<uint32_t>());
client.NotifyArcVmShutdown(provider.ConsumeIntegral<uint32_t>());
NetworkDevice device;
- device.set_ifname(provider.ConsumeRandomLengthString(100));
+ device.set_ifname(provider.ConsumeRandomLengthString(IFNAMSIZ * 2));
device.set_ipv4_addr(provider.ConsumeIntegral<uint32_t>());
device.mutable_ipv4_subnet()->set_base_addr(
provider.ConsumeIntegral<uint32_t>());
@@ -94,6 +96,14 @@
client.ConnectNamespace(provider.ConsumeIntegral<pid_t>(),
provider.ConsumeRandomLengthString(100),
provider.ConsumeBool());
+ std::set<std::string> devices_for_counters;
+ for (int i = 0; i < 10; i++) {
+ if (provider.ConsumeBool()) {
+ devices_for_counters.insert(
+ provider.ConsumeRandomLengthString(IFNAMSIZ * 2));
+ }
+ }
+ client.GetTrafficCounters(devices_for_counters);
}
bus->ShutdownAndBlock();
return 0;