netd: BandwidthController: return extra info on gettetherstats failure
Use the error message string to report the raw parsed data in case of
failure.
Bug:5543131
Change-Id: If9f3bcea09fd3ab8a506955d8153b3430bfd239c
diff --git a/BandwidthController.cpp b/BandwidthController.cpp
index bb088a9..09601af 100644
--- a/BandwidthController.cpp
+++ b/BandwidthController.cpp
@@ -920,7 +920,8 @@
* 0 0 ACCEPT all -- wlan0 rmnet0 0.0.0.0/0 0.0.0.0/0
*
*/
-int BandwidthController::parseForwardChainStats(TetherStats &stats, FILE *fp) {
+int BandwidthController::parseForwardChainStats(TetherStats &stats, FILE *fp,
+ std::string &extraProcessingInfo) {
int res;
char lineBuffer[MAX_IPT_OUTPUT_LINE_LEN];
char iface0[MAX_IPT_OUTPUT_LINE_LEN];
@@ -937,6 +938,8 @@
&packets, &bytes, iface0, iface1, rest);
ALOGV("parse res=%d iface0=<%s> iface1=<%s> pkts=%lld bytes=%lld rest=<%s> orig line=<%s>", res,
iface0, iface1, packets, bytes, rest, buffPtr);
+ extraProcessingInfo += buffPtr;
+
if (res != 5) {
continue;
}
@@ -962,7 +965,7 @@
return msg;
}
-int BandwidthController::getTetherStats(TetherStats &stats) {
+int BandwidthController::getTetherStats(TetherStats &stats, std::string &extraProcessingInfo) {
int res;
std::string fullCmd;
FILE *iptOutput;
@@ -985,9 +988,10 @@
iptOutput = popen(fullCmd.c_str(), "r");
if (!iptOutput) {
LOGE("Failed to run %s err=%s", fullCmd.c_str(), strerror(errno));
+ extraProcessingInfo += "Failed to run iptables.";
return -1;
}
- res = parseForwardChainStats(stats, iptOutput);
+ res = parseForwardChainStats(stats, iptOutput, extraProcessingInfo);
pclose(iptOutput);
/* Currently NatController doesn't do ipv6 tethering, so we are done. */