Dump the input destination MAC address for IPv4 flows.

This is needed for forwarding to work, so it should be dumped.

New output:

  Forwarding rules:
    29(29) -> 14(rmnet2) 86dd 00:00:00:00:00:00 00:00:00:00:00:00
    [ap_br_wlan2]: iif(iface) oif(iface) v6addr srcmac dstmac
      14(rmnet2) 29(ap_br_wlan2) 2001:240:2423:13fa:3c21:e35a:6a59:ff8a da:17:fd:70:3d:14 26:5b:b2:ee:bc:ba
    IPv4: [inDstMac] iif(iface) src -> nat -> dst
      [da:17:fd:70:3d:14] 29(29) 192.168.222.151:39208 -> 14(rmnet2) 100.102.14.231:39208 -> 172.217.175.3:80
      [da:17:fd:70:3d:14] 29(29) 192.168.222.151:47386 -> 14(rmnet2) 100.102.14.231:47386 -> 216.58.197.196:443

Also add a call to getHostAddress() to remove the / on IPv6
forwarding rules.

Test: manual
Change-Id: I347ea5a3fd88c51f1fae0c76c75dfa30c68a55ad
This commit is contained in:
Lorenzo Colitti
2021-04-02 14:25:34 +09:00
committed by Maciej Żenczykowski
parent 5316e1ff18
commit e9bc8c9db7

View File

@@ -814,7 +814,7 @@ public class BpfCoordinator {
final int upstreamIfindex = rule.upstreamIfindex;
pw.println(String.format("%d(%s) %d(%s) %s %s %s", upstreamIfindex,
mInterfaceNames.get(upstreamIfindex), rule.downstreamIfindex,
downstreamIface, rule.address, rule.srcMac, rule.dstMac));
downstreamIface, rule.address.getHostAddress(), rule.srcMac, rule.dstMac));
}
pw.decreaseIndent();
}
@@ -851,9 +851,10 @@ public class BpfCoordinator {
} catch (UnknownHostException impossible) {
throw new AssertionError("4-byte array not valid IPv4 address!");
}
return String.format("%d(%s) %d(%s) %s:%d -> %s:%d -> %s:%d",
key.iif, getIfName(key.iif), value.oif, getIfName(value.oif),
private4, key.srcPort, public4, value.srcPort, dst4, key.dstPort);
return String.format("[%s] %d(%s) %s:%d -> %d(%s) %s:%d -> %s:%d",
key.dstMac, key.iif, getIfName(key.iif), private4, key.srcPort,
value.oif, getIfName(value.oif),
public4, value.srcPort, dst4, key.dstPort);
}
private void dumpIpv4ForwardingRules(IndentingPrintWriter pw) {
@@ -866,7 +867,7 @@ public class BpfCoordinator {
pw.println("No IPv4 rules");
return;
}
pw.println("[IPv4]: iif(iface) oif(iface) src nat dst");
pw.println("IPv4: [inDstMac] iif(iface) src -> nat -> dst");
pw.increaseIndent();
map.forEach((k, v) -> pw.println(ipv4RuleToString(k, v)));
} catch (ErrnoException e) {