Skip to content
Snippets Groups Projects
Commit 376e7710 authored by Kevin Jeon's avatar Kevin Jeon
Browse files

Update mBpfMap name for clarity

This change updates 'mBpfMap' to 'mIndexToIfaceBpfMap' to
better-describe what the bpf map contains. This is done as a
prerequisite change for adding a name->indices map.

Test: Build
Bug: 241098920
Change-Id: Idaab7072a14ea3c88e9a5df808e768f355d83782
parent 87d66ebd
No related branches found
No related tags found
No related merge requests found
...@@ -41,7 +41,7 @@ public class BpfInterfaceMapUpdater { ...@@ -41,7 +41,7 @@ public class BpfInterfaceMapUpdater {
// This is current path but may be changed soon. // This is current path but may be changed soon.
private static final String IFACE_INDEX_NAME_MAP_PATH = private static final String IFACE_INDEX_NAME_MAP_PATH =
"/sys/fs/bpf/netd_shared/map_netd_iface_index_name_map"; "/sys/fs/bpf/netd_shared/map_netd_iface_index_name_map";
private final IBpfMap<S32, InterfaceMapValue> mBpfMap; private final IBpfMap<S32, InterfaceMapValue> mIndexToIfaceBpfMap;
private final INetd mNetd; private final INetd mNetd;
private final Handler mHandler; private final Handler mHandler;
private final Dependencies mDeps; private final Dependencies mDeps;
...@@ -53,7 +53,7 @@ public class BpfInterfaceMapUpdater { ...@@ -53,7 +53,7 @@ public class BpfInterfaceMapUpdater {
@VisibleForTesting @VisibleForTesting
public BpfInterfaceMapUpdater(Context ctx, Handler handler, Dependencies deps) { public BpfInterfaceMapUpdater(Context ctx, Handler handler, Dependencies deps) {
mDeps = deps; mDeps = deps;
mBpfMap = deps.getInterfaceMap(); mIndexToIfaceBpfMap = deps.getInterfaceMap();
mNetd = deps.getINetd(ctx); mNetd = deps.getINetd(ctx);
mHandler = handler; mHandler = handler;
} }
...@@ -91,7 +91,7 @@ public class BpfInterfaceMapUpdater { ...@@ -91,7 +91,7 @@ public class BpfInterfaceMapUpdater {
*/ */
public void start() { public void start() {
mHandler.post(() -> { mHandler.post(() -> {
if (mBpfMap == null) { if (mIndexToIfaceBpfMap == null) {
Log.wtf(TAG, "Fail to start: Null bpf map"); Log.wtf(TAG, "Fail to start: Null bpf map");
return; return;
} }
...@@ -126,7 +126,7 @@ public class BpfInterfaceMapUpdater { ...@@ -126,7 +126,7 @@ public class BpfInterfaceMapUpdater {
} }
try { try {
mBpfMap.updateEntry(new S32(iface.index), new InterfaceMapValue(ifaceName)); mIndexToIfaceBpfMap.updateEntry(new S32(iface.index), new InterfaceMapValue(ifaceName));
} catch (ErrnoException e) { } catch (ErrnoException e) {
Log.e(TAG, "Unable to update entry for " + ifaceName + ", " + e); Log.e(TAG, "Unable to update entry for " + ifaceName + ", " + e);
} }
...@@ -142,7 +142,7 @@ public class BpfInterfaceMapUpdater { ...@@ -142,7 +142,7 @@ public class BpfInterfaceMapUpdater {
/** get interface name by interface index from bpf map */ /** get interface name by interface index from bpf map */
public String getIfNameByIndex(final int index) { public String getIfNameByIndex(final int index) {
try { try {
final InterfaceMapValue value = mBpfMap.getValue(new S32(index)); final InterfaceMapValue value = mIndexToIfaceBpfMap.getValue(new S32(index));
if (value == null) { if (value == null) {
Log.e(TAG, "No if name entry for index " + index); Log.e(TAG, "No if name entry for index " + index);
return null; return null;
...@@ -162,11 +162,12 @@ public class BpfInterfaceMapUpdater { ...@@ -162,11 +162,12 @@ public class BpfInterfaceMapUpdater {
public void dump(final IndentingPrintWriter pw) { public void dump(final IndentingPrintWriter pw) {
pw.println("BPF map status:"); pw.println("BPF map status:");
pw.increaseIndent(); pw.increaseIndent();
BpfDump.dumpMapStatus(mBpfMap, pw, "IfaceIndexNameMap", IFACE_INDEX_NAME_MAP_PATH); BpfDump.dumpMapStatus(mIndexToIfaceBpfMap, pw, "IfaceIndexNameMap",
IFACE_INDEX_NAME_MAP_PATH);
pw.decreaseIndent(); pw.decreaseIndent();
pw.println("BPF map content:"); pw.println("BPF map content:");
pw.increaseIndent(); pw.increaseIndent();
BpfDump.dumpMap(mBpfMap, pw, "IfaceIndexNameMap", BpfDump.dumpMap(mIndexToIfaceBpfMap, pw, "IfaceIndexNameMap",
(key, value) -> "ifaceIndex=" + key.val (key, value) -> "ifaceIndex=" + key.val
+ " ifaceName=" + value.getInterfaceNameString()); + " ifaceName=" + value.getInterfaceNameString());
pw.decreaseIndent(); pw.decreaseIndent();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment