OSDN Git Service

system/netd: bandwidth management initial support (uid+tag stats)
authorJP Abgrall <jpa@google.com>
Thu, 16 Jun 2011 01:37:39 +0000 (18:37 -0700)
committerJP Abgrall <jpa@google.com>
Thu, 16 Jun 2011 01:37:39 +0000 (18:37 -0700)
commit4a5f5ca3c9e07fc3e6feca2afde07f41a8a64f11
tree5a9e304d85c4c510c5a87e4027f2c198eed4eae4
parent4d0342ec22cc5ef0edc27033e2dcdacbb31d47f3
system/netd: bandwidth management initial support (uid+tag stats)

This is a minimalistic version to get accounting of data going
through tagged socket per uid.

When netd starts up the BandwidthController, it will look at the
properties for
   persist.bandwidth.enable=1
and enabled it.

It needs the kernel with the xt_qtaguid + iptables/netfilter goodness.
stlport is ok to use.

The "owner" netfilter module used is actually our xt_qtaguid that acts as it
(just until we get around to talking directly the to kernel).

Once
  "ndc bandwidth enable"
is invoked all traffic is counted against the UIDs receiving/sending it.
This allows BlockGuard.java to "tag" sockets and see stats for the tags.

Data shows up in
  /proc/net/xt_qtaguid/stats

  /proc/net/xt_qtaguid/iface_stat/<iface>/
     rx_packets_tcp
     rx_bytes_tcp
     ...
There is no <uid>/...

Supported commands:
 - "ndc bandwidth enable"
   will setup the needed iptable entries to track tag/uid.
 - "ndc bandwidth disable"
   will remove the iptable entries.
 - "ndc bandwidth setquota <iface> <value>"
   will set a quota on the iface.
   Once quota is reached, packets are rejected.
   With the correct kernel, rejects are turned in socket errors.

TODO
----
 * make bandwidth controller cooperate with tethering.
   - they both manipulate the iptables.

Change-Id: Ieb9e7c60ef8c974e99828f7833065d59b2922bf3
Android.mk
BandwidthController.cpp [new file with mode: 0644]
BandwidthController.h [new file with mode: 0644]
CommandListener.cpp
CommandListener.h