patchpanel: Enable CountersService in Manager

This patch adds the glue code for enabling CountersService in
patchpanel, which includes:
- CountersService as a member in Manager;
- Dispatching TrafficCountersRequest to CountersService;
- Restricting caller of this dbus method to shill;
- Fix of a naming issue (kTrafficCountersMethod =>
  kGetTrafficCountersMethod).

BUG=b:160113423
BUG=crbug:733756
TEST=unit tests
TEST=manually tested with the following steps:
  1. deployed patchpanel on atlas;
  2. rebooted the DUT;
  3. observed that iptables rules are installed as expected.
  Note that the accounting rules are also tested in crrev.com/c/2291414
TEST=manually tested with: sudo -u shill dbus-send --system \
  --print-reply --type=method_call --dest=org.chromium.PatchPanel \
  /org/chromium/PatchPanel org.chromium.PatchPanel.GetTrafficCounters
  user shill is able to invoke this method and other users not.

Change-Id: Ic362f27e4527f9d3e7a464081fa62315a914e7e0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/2306855
Tested-by: Jie Jiang <jiejiang@chromium.org>
Commit-Queue: Jie Jiang <jiejiang@chromium.org>
Reviewed-by: Hugo Benichi <hugobenichi@google.com>
Reviewed-by: Matthew Wang <matthewmwang@chromium.org>
Reviewed-by: Garrick Evans <garrick@chromium.org>
Cr-Mirrored-From: https://chromium.googlesource.com/chromiumos/platform2
Cr-Mirrored-Commit: 493cde478a5211132bd1fe95880164ffa2b3291f
1 file changed
tree: 0e7ef3058c397c06249caa0c223a93054055b7a7
  1. constants/
  2. dbus/
  3. src/
  4. switches/
  5. .gitignore
  6. BUILD.gn
  7. build.rs
  8. Cargo.toml
  9. LICENSE
  10. OWNERS
  11. README.md
  12. system_api.pc
README.md

This directory (platform2/system_api) contains constants and definitions like D-Bus service names that are shared between Chromium and Chromium OS.

This directory is only for things like headers and .proto files. No implementation should be added.

When writting a .proto file make sure to use:

option optimize_for = LITE_RUNTIME;

This will force usage of a lite protobuf instead of a full/heavy weight protobuf. The browser only links against the light version, so you will get cryptic link errors about missing parts of Message if you define a protobuf here and then try to use it in Chrome. Currently CrOS links against the full protobuffer library, but that might change in the future.

When declaring a protobuf, avoid use of required unless it is exactly what you mean. “Required is Forever” and very rarely should actually be used. Consult Protocol Buffer Basics: C++ for a detailed of this issue.