BpfNetworkStats: fallback to if_indextoname() on index->name map lookup failure
(this should fix the 4 ipsec tests which don't call the right higher APIs that would eventually call into bpfRegisterIface) Test: TreeHugger, atest libnetworkstats_test Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I3069f3a2f809948cd2e7755745586b78ff3362c9
This commit is contained in:
parent
6db149aa7d
commit
d3d144f54d
1 changed files with 6 additions and 1 deletions
|
|
@ -51,7 +51,12 @@ const BpfMapRO<uint32_t, StatsValue>& getIfaceStatsMap() {
|
|||
}
|
||||
|
||||
Result<IfaceValue> ifindex2name(const uint32_t ifindex) {
|
||||
return getIfaceIndexNameMap().readValue(ifindex);
|
||||
Result<IfaceValue> v = getIfaceIndexNameMap().readValue(ifindex);
|
||||
if (v.ok()) return v;
|
||||
IfaceValue iv = {};
|
||||
if (!if_indextoname(ifindex, iv.name)) return v;
|
||||
getIfaceIndexNameMap().writeValue(ifindex, iv, BPF_ANY);
|
||||
return iv;
|
||||
}
|
||||
|
||||
void bpfRegisterIface(const char* iface) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue