LocalNetAccessKey - improve toString
while at it, improve dump to clarify default is true meaning global,
even though you could assume 0/false is the default, and that true means local...
$ adb shell dumpsys connectivity trafficcontroller </dev/null | grep LocalNetAccess
Before on bluejay (47 is wlan0, 51 is v4-wlan0):
sLocalNetAccessMap:
LocalNetAccessKey{lpmBitlen=132, ifIndex=47, remoteAddress=/::ffff:224.0.0.0, protocol=0, remotePort=0}: false
LocalNetAccessKey{lpmBitlen=160, ifIndex=47, remoteAddress=/::ffff:255.255.255.255, protocol=0, remotePort=0}: false
LocalNetAccessKey{lpmBitlen=96, ifIndex=47, remoteAddress=/2a00:79e1:2e00:3f01::, protocol=0, remotePort=0}: false
LocalNetAccessKey{lpmBitlen=96, ifIndex=47, remoteAddress=/fe80::, protocol=0, remotePort=0}: false
LocalNetAccessKey{lpmBitlen=40, ifIndex=47, remoteAddress=/ff00::, protocol=0, remotePort=0}: false
LocalNetAccessKey{lpmBitlen=132, ifIndex=51, remoteAddress=/::ffff:224.0.0.0, protocol=0, remotePort=0}: false
LocalNetAccessKey{lpmBitlen=160, ifIndex=51, remoteAddress=/::ffff:255.255.255.255, protocol=0, remotePort=0}: false
LocalNetAccessKey{lpmBitlen=40, ifIndex=51, remoteAddress=/ff00::, protocol=0, remotePort=0}: false
After this commit:
sLocalNetAccessMap (default is true meaning global):
LocalNetAccessKey{lpmBitlen=132 ifIndex=47 remoteAddress=224.0.0.0/4}: false
LocalNetAccessKey{lpmBitlen=160 ifIndex=47 remoteAddress=255.255.255.255}: false
LocalNetAccessKey{lpmBitlen=96 ifIndex=47 remoteAddress=2a00:79e1:2e00:3f01::/64}: false
LocalNetAccessKey{lpmBitlen=96 ifIndex=47 remoteAddress=fe80::/64}: false
LocalNetAccessKey{lpmBitlen=40 ifIndex=47 remoteAddress=ff00::/8}: false
LocalNetAccessKey{lpmBitlen=132 ifIndex=51 remoteAddress=224.0.0.0/4}: false
LocalNetAccessKey{lpmBitlen=160 ifIndex=51 remoteAddress=255.255.255.255}: false
LocalNetAccessKey{lpmBitlen=40 ifIndex=51 remoteAddress=ff00::/8}: false
On cuttlefish (15 is buried_eth0, 17 is wlan0):
sLocalNetAccessMap (default is true meaning global):
LocalNetAccessKey{lpmBitlen=144 ifIndex=15 remoteAddress=192.168.0.0/16}: false
LocalNetAccessKey{lpmBitlen=132 ifIndex=15 remoteAddress=224.0.0.0/4}: false
LocalNetAccessKey{lpmBitlen=160 ifIndex=15 remoteAddress=255.255.255.255}: false
LocalNetAccessKey{lpmBitlen=40 ifIndex=15 remoteAddress=ff00::/8}: false
LocalNetAccessKey{lpmBitlen=192 ifIndex=17 remoteAddress=192.168.99.1 protocol=6 remotePort=53}: true
LocalNetAccessKey{lpmBitlen=192 ifIndex=17 remoteAddress=192.168.99.1 protocol=17 remotePort=53}: true
LocalNetAccessKey{lpmBitlen=144 ifIndex=17 remoteAddress=192.168.0.0/16}: false
LocalNetAccessKey{lpmBitlen=132 ifIndex=17 remoteAddress=224.0.0.0/4}: false
LocalNetAccessKey{lpmBitlen=160 ifIndex=17 remoteAddress=255.255.255.255}: false
LocalNetAccessKey{lpmBitlen=96 ifIndex=17 remoteAddress=fe80::/64}: false
LocalNetAccessKey{lpmBitlen=40 ifIndex=17 remoteAddress=ff00::/8}: false
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ifcebc18c3804bc1d5d705752021bb4643ed58eb5
This commit is contained in:
parent
1a0473bd72
commit
969d82bc82
2 changed files with 42 additions and 8 deletions
|
|
@ -61,12 +61,46 @@ public class LocalNetAccessKey extends Struct {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LocalNetAccessKey{"
|
||||
+ "lpmBitlen=" + lpmBitlen
|
||||
+ ", ifIndex=" + ifIndex
|
||||
+ ", remoteAddress=" + remoteAddress
|
||||
+ ", protocol=" + protocol
|
||||
+ ", remotePort=" + remotePort
|
||||
+ "}";
|
||||
String s = "LocalNetAccessKey{lpmBitlen=" + lpmBitlen;
|
||||
|
||||
long bits = lpmBitlen;
|
||||
|
||||
// u32 ifIndex
|
||||
if (bits <= 0 && ifIndex != 0) s += " ??";
|
||||
if (bits > 0 || ifIndex != 0) s += " ifIndex=" + ifIndex;
|
||||
if (bits > 0 && bits < 32) s += "/" + bits + "[LE]";
|
||||
bits -= 32;
|
||||
|
||||
// u128 remoteAddress
|
||||
if (bits <= 0 && !remoteAddress.isAnyLocalAddress()) s += " ??";
|
||||
if (bits > 0 || !remoteAddress.isAnyLocalAddress()) {
|
||||
s += " remoteAddress=";
|
||||
String ip = remoteAddress.toString();
|
||||
if (ip.startsWith("/::ffff:")) { // technically wrong IPv4-mapped IPv6 address detection
|
||||
s += ip.substring(8);
|
||||
if (bits >= 96 && bits < 128) s += "/" + (bits - 96);
|
||||
} else if (ip.startsWith("/")) {
|
||||
s += ip.substring(1);
|
||||
if (bits >= 0 && bits < 128) s += "/" + bits;
|
||||
} else { // WTF, includes a hostname or what?
|
||||
s += ip;
|
||||
}
|
||||
}
|
||||
bits -= 128;
|
||||
|
||||
// u16 protocol
|
||||
if (bits <= 0 && protocol != 0) s += " ??";
|
||||
if (bits > 0 || protocol != 0) s += " protocol=" + protocol;
|
||||
if (bits > 0 && bits < 16) s += "/" + bits + "[LE16]";
|
||||
bits -= 16;
|
||||
|
||||
// be16 remotePort
|
||||
if (bits <= 0 && remotePort != 0) s += " ??";
|
||||
if (bits > 0 || remotePort != 0) s += " remotePort=" + remotePort;
|
||||
if (bits > 0 && bits < 16) s += "/" + bits + "[BE16]";
|
||||
bits -= 16;
|
||||
|
||||
s += "}";
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1327,7 +1327,7 @@ public class BpfNetMaps {
|
|||
+ value.iif1 + "(" + mDeps.getIfName(value.iif1) + "), "
|
||||
+ value.iif2 + "(" + mDeps.getIfName(value.iif2) + ")");
|
||||
if (sLocalNetBlockedUidMap != null) {
|
||||
BpfDump.dumpMap(sLocalNetAccessMap, pw, "sLocalNetAccessMap",
|
||||
BpfDump.dumpMap(sLocalNetAccessMap, pw, "sLocalNetAccessMap (default is true meaning global)",
|
||||
(key, value) -> "" + key + ": " + value.val);
|
||||
}
|
||||
if (sLocalNetBlockedUidMap != null) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue