Merge "ClatCoordinator: dump BPF forwarding rules" into tm-dev
This commit is contained in:
commit
b2db0b5119
4 changed files with 97 additions and 0 deletions
|
|
@ -3431,6 +3431,10 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||
pw.increaseIndent();
|
||||
nai.dumpInactivityTimers(pw);
|
||||
pw.decreaseIndent();
|
||||
pw.println("Nat464Xlat:");
|
||||
pw.increaseIndent();
|
||||
nai.dumpNat464Xlat(pw);
|
||||
pw.decreaseIndent();
|
||||
pw.decreaseIndent();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ import android.system.ErrnoException;
|
|||
import android.util.Log;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.util.IndentingPrintWriter;
|
||||
import com.android.modules.utils.build.SdkLevel;
|
||||
import com.android.net.module.util.BpfMap;
|
||||
import com.android.net.module.util.IBpfMap;
|
||||
|
|
@ -742,6 +743,69 @@ public class ClatCoordinator {
|
|||
mClatdTracker = null;
|
||||
}
|
||||
|
||||
private void dumpBpfIngress(@NonNull IndentingPrintWriter pw) {
|
||||
if (mIngressMap == null) {
|
||||
pw.println("No BPF ingress6 map");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (mIngressMap.isEmpty()) {
|
||||
pw.println("<empty>");
|
||||
}
|
||||
pw.println("BPF ingress map: iif nat64Prefix v6Addr -> v4Addr oif");
|
||||
pw.increaseIndent();
|
||||
mIngressMap.forEach((k, v) -> {
|
||||
// TODO: print interface name
|
||||
pw.println(String.format("%d %s/96 %s -> %s %d", k.iif, k.pfx96, k.local6,
|
||||
v.local4, v.oif));
|
||||
});
|
||||
pw.decreaseIndent();
|
||||
} catch (ErrnoException e) {
|
||||
pw.println("Error dumping BPF ingress6 map: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
private void dumpBpfEgress(@NonNull IndentingPrintWriter pw) {
|
||||
if (mEgressMap == null) {
|
||||
pw.println("No BPF egress4 map");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (mEgressMap.isEmpty()) {
|
||||
pw.println("<empty>");
|
||||
}
|
||||
pw.println("BPF egress map: iif v4Addr -> v6Addr nat64Prefix oif");
|
||||
pw.increaseIndent();
|
||||
mEgressMap.forEach((k, v) -> {
|
||||
// TODO: print interface name
|
||||
pw.println(String.format("%d %s -> %s %s/96 %d %s", k.iif, k.local4, v.local6,
|
||||
v.pfx96, v.oif, v.oifIsEthernet != 0 ? "ether" : "rawip"));
|
||||
});
|
||||
pw.decreaseIndent();
|
||||
} catch (ErrnoException e) {
|
||||
pw.println("Error dumping BPF egress4 map: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dump the cordinator information.
|
||||
*
|
||||
* @param pw print writer.
|
||||
*/
|
||||
public void dump(@NonNull IndentingPrintWriter pw) {
|
||||
// TODO: dump ClatdTracker
|
||||
// TODO: move map dump to a global place to avoid duplicate dump while there are two or
|
||||
// more IPv6 only networks.
|
||||
pw.println("Forwarding rules:");
|
||||
pw.increaseIndent();
|
||||
dumpBpfIngress(pw);
|
||||
dumpBpfEgress(pw);
|
||||
pw.decreaseIndent();
|
||||
pw.println();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get clatd tracker. For test only.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ import android.os.ServiceSpecificException;
|
|||
import android.util.Log;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.util.IndentingPrintWriter;
|
||||
import com.android.modules.utils.build.SdkLevel;
|
||||
import com.android.net.module.util.NetworkStackConstants;
|
||||
import com.android.server.ConnectivityService;
|
||||
|
|
@ -526,6 +527,24 @@ public class Nat464Xlat {
|
|||
mNetwork.handler().post(() -> handleInterfaceRemoved(iface));
|
||||
}
|
||||
|
||||
/**
|
||||
* Dump the NAT64 xlat information.
|
||||
*
|
||||
* @param pw print writer.
|
||||
*/
|
||||
public void dump(IndentingPrintWriter pw) {
|
||||
if (SdkLevel.isAtLeastT()) {
|
||||
if (isStarted()) {
|
||||
pw.println("ClatCoordinator:");
|
||||
pw.increaseIndent();
|
||||
mClatCoordinator.dump(pw);
|
||||
pw.decreaseIndent();
|
||||
} else {
|
||||
pw.println("<not start>");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "mBaseIface: " + mBaseIface + ", mIface: " + mIface + ", mState: " + mState;
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ import android.util.Log;
|
|||
import android.util.Pair;
|
||||
import android.util.SparseArray;
|
||||
|
||||
import com.android.internal.util.IndentingPrintWriter;
|
||||
import com.android.internal.util.WakeupMessage;
|
||||
import com.android.modules.utils.build.SdkLevel;
|
||||
import com.android.server.ConnectivityService;
|
||||
|
|
@ -1185,6 +1186,15 @@ public class NetworkAgentInfo implements Comparable<NetworkAgentInfo>, NetworkRa
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dump the NAT64 xlat information.
|
||||
*
|
||||
* @param pw print writer.
|
||||
*/
|
||||
public void dumpNat464Xlat(IndentingPrintWriter pw) {
|
||||
clatd.dump(pw);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the most recent ConnectivityReport for this network.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in a new issue