Merge "ClatCoordinator: Dump ClatdTracker information"

This commit is contained in:
Treehugger Robot
2022-07-05 15:01:11 +00:00
committed by Gerrit Code Review
2 changed files with 23 additions and 7 deletions

View File

@@ -347,6 +347,19 @@ public class ClatCoordinator {
&& this.pid == that.pid && this.pid == that.pid
&& this.cookie == that.cookie; && this.cookie == that.cookie;
} }
@Override
public String toString() {
return "iface: " + iface
+ " (" + ifIndex + ")"
+ ", v4iface: " + v4iface
+ " (" + v4ifIndex + ")"
+ ", v4: " + v4
+ ", v6: " + v6
+ ", pfx96: " + pfx96
+ ", pid: " + pid
+ ", cookie: " + cookie;
}
}; };
@VisibleForTesting @VisibleForTesting
@@ -819,9 +832,9 @@ public class ClatCoordinator {
* @param pw print writer. * @param pw print writer.
*/ */
public void dump(@NonNull IndentingPrintWriter pw) { 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 // TODO: move map dump to a global place to avoid duplicate dump while there are two or
// more IPv6 only networks. // more IPv6 only networks.
pw.println("CLAT tracker: " + mClatdTracker.toString());
pw.println("Forwarding rules:"); pw.println("Forwarding rules:");
pw.increaseIndent(); pw.increaseIndent();
dumpBpfIngress(pw); dumpBpfIngress(pw);

View File

@@ -525,16 +525,19 @@ public class ClatCoordinatorTest {
coordinator.dump(ipw); coordinator.dump(ipw);
final String[] dumpStrings = stringWriter.toString().split("\n"); final String[] dumpStrings = stringWriter.toString().split("\n");
assertEquals(5, dumpStrings.length); assertEquals(6, dumpStrings.length);
assertEquals("Forwarding rules:", dumpStrings[0].trim()); assertEquals("CLAT tracker: iface: test0 (1000), v4iface: v4-test0 (1001), "
+ "v4: /192.0.0.46, v6: /2001:db8:0:b11::464, pfx96: /64:ff9b::, "
+ "pid: 10483, cookie: 27149", dumpStrings[0].trim());
assertEquals("Forwarding rules:", dumpStrings[1].trim());
assertEquals("BPF ingress map: iif nat64Prefix v6Addr -> v4Addr oif", assertEquals("BPF ingress map: iif nat64Prefix v6Addr -> v4Addr oif",
dumpStrings[1].trim());
assertEquals("1000 /64:ff9b::/96 /2001:db8:0:b11::464 -> /192.0.0.46 1001",
dumpStrings[2].trim()); dumpStrings[2].trim());
assertEquals("BPF egress map: iif v4Addr -> v6Addr nat64Prefix oif", assertEquals("1000 /64:ff9b::/96 /2001:db8:0:b11::464 -> /192.0.0.46 1001",
dumpStrings[3].trim()); dumpStrings[3].trim());
assertEquals("1001 /192.0.0.46 -> /2001:db8:0:b11::464 /64:ff9b::/96 1000 ether", assertEquals("BPF egress map: iif v4Addr -> v6Addr nat64Prefix oif",
dumpStrings[4].trim()); dumpStrings[4].trim());
assertEquals("1001 /192.0.0.46 -> /2001:db8:0:b11::464 /64:ff9b::/96 1000 ether",
dumpStrings[5].trim());
} }
@Test @Test