Merge "Do not open BPF maps when running on R."
This commit is contained in:
@@ -261,6 +261,7 @@ public class BpfCoordinator {
|
|||||||
|
|
||||||
/** Get downstream4 BPF map. */
|
/** Get downstream4 BPF map. */
|
||||||
@Nullable public BpfMap<Tether4Key, Tether4Value> getBpfDownstream4Map() {
|
@Nullable public BpfMap<Tether4Key, Tether4Value> getBpfDownstream4Map() {
|
||||||
|
if (!isAtLeastS()) return null;
|
||||||
try {
|
try {
|
||||||
return new BpfMap<>(TETHER_DOWNSTREAM4_MAP_PATH,
|
return new BpfMap<>(TETHER_DOWNSTREAM4_MAP_PATH,
|
||||||
BpfMap.BPF_F_RDWR, Tether4Key.class, Tether4Value.class);
|
BpfMap.BPF_F_RDWR, Tether4Key.class, Tether4Value.class);
|
||||||
@@ -272,6 +273,7 @@ public class BpfCoordinator {
|
|||||||
|
|
||||||
/** Get upstream4 BPF map. */
|
/** Get upstream4 BPF map. */
|
||||||
@Nullable public BpfMap<Tether4Key, Tether4Value> getBpfUpstream4Map() {
|
@Nullable public BpfMap<Tether4Key, Tether4Value> getBpfUpstream4Map() {
|
||||||
|
if (!isAtLeastS()) return null;
|
||||||
try {
|
try {
|
||||||
return new BpfMap<>(TETHER_UPSTREAM4_MAP_PATH,
|
return new BpfMap<>(TETHER_UPSTREAM4_MAP_PATH,
|
||||||
BpfMap.BPF_F_RDWR, Tether4Key.class, Tether4Value.class);
|
BpfMap.BPF_F_RDWR, Tether4Key.class, Tether4Value.class);
|
||||||
@@ -283,6 +285,7 @@ public class BpfCoordinator {
|
|||||||
|
|
||||||
/** Get downstream6 BPF map. */
|
/** Get downstream6 BPF map. */
|
||||||
@Nullable public BpfMap<TetherDownstream6Key, Tether6Value> getBpfDownstream6Map() {
|
@Nullable public BpfMap<TetherDownstream6Key, Tether6Value> getBpfDownstream6Map() {
|
||||||
|
if (!isAtLeastS()) return null;
|
||||||
try {
|
try {
|
||||||
return new BpfMap<>(TETHER_DOWNSTREAM6_FS_PATH,
|
return new BpfMap<>(TETHER_DOWNSTREAM6_FS_PATH,
|
||||||
BpfMap.BPF_F_RDWR, TetherDownstream6Key.class, Tether6Value.class);
|
BpfMap.BPF_F_RDWR, TetherDownstream6Key.class, Tether6Value.class);
|
||||||
@@ -294,6 +297,7 @@ public class BpfCoordinator {
|
|||||||
|
|
||||||
/** Get upstream6 BPF map. */
|
/** Get upstream6 BPF map. */
|
||||||
@Nullable public BpfMap<TetherUpstream6Key, Tether6Value> getBpfUpstream6Map() {
|
@Nullable public BpfMap<TetherUpstream6Key, Tether6Value> getBpfUpstream6Map() {
|
||||||
|
if (!isAtLeastS()) return null;
|
||||||
try {
|
try {
|
||||||
return new BpfMap<>(TETHER_UPSTREAM6_FS_PATH, BpfMap.BPF_F_RDWR,
|
return new BpfMap<>(TETHER_UPSTREAM6_FS_PATH, BpfMap.BPF_F_RDWR,
|
||||||
TetherUpstream6Key.class, Tether6Value.class);
|
TetherUpstream6Key.class, Tether6Value.class);
|
||||||
@@ -305,6 +309,7 @@ public class BpfCoordinator {
|
|||||||
|
|
||||||
/** Get stats BPF map. */
|
/** Get stats BPF map. */
|
||||||
@Nullable public BpfMap<TetherStatsKey, TetherStatsValue> getBpfStatsMap() {
|
@Nullable public BpfMap<TetherStatsKey, TetherStatsValue> getBpfStatsMap() {
|
||||||
|
if (!isAtLeastS()) return null;
|
||||||
try {
|
try {
|
||||||
return new BpfMap<>(TETHER_STATS_MAP_PATH,
|
return new BpfMap<>(TETHER_STATS_MAP_PATH,
|
||||||
BpfMap.BPF_F_RDWR, TetherStatsKey.class, TetherStatsValue.class);
|
BpfMap.BPF_F_RDWR, TetherStatsKey.class, TetherStatsValue.class);
|
||||||
@@ -316,6 +321,7 @@ public class BpfCoordinator {
|
|||||||
|
|
||||||
/** Get limit BPF map. */
|
/** Get limit BPF map. */
|
||||||
@Nullable public BpfMap<TetherLimitKey, TetherLimitValue> getBpfLimitMap() {
|
@Nullable public BpfMap<TetherLimitKey, TetherLimitValue> getBpfLimitMap() {
|
||||||
|
if (!isAtLeastS()) return null;
|
||||||
try {
|
try {
|
||||||
return new BpfMap<>(TETHER_LIMIT_MAP_PATH,
|
return new BpfMap<>(TETHER_LIMIT_MAP_PATH,
|
||||||
BpfMap.BPF_F_RDWR, TetherLimitKey.class, TetherLimitValue.class);
|
BpfMap.BPF_F_RDWR, TetherLimitKey.class, TetherLimitValue.class);
|
||||||
@@ -828,7 +834,7 @@ public class BpfCoordinator {
|
|||||||
}
|
}
|
||||||
map.forEach((k, v) -> pw.println(ipv6UpstreamRuletoString(k, v)));
|
map.forEach((k, v) -> pw.println(ipv6UpstreamRuletoString(k, v)));
|
||||||
} catch (ErrnoException e) {
|
} catch (ErrnoException e) {
|
||||||
pw.println("Error dumping IPv4 map: " + e);
|
pw.println("Error dumping IPv6 upstream map: " + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -875,6 +881,10 @@ public class BpfCoordinator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void dumpCounters(@NonNull IndentingPrintWriter pw) {
|
private void dumpCounters(@NonNull IndentingPrintWriter pw) {
|
||||||
|
if (!mDeps.isAtLeastS()) {
|
||||||
|
pw.println("No counter support");
|
||||||
|
return;
|
||||||
|
}
|
||||||
try (BpfMap<U32Struct, U32Struct> map = new BpfMap<>(TETHER_ERROR_MAP_PATH,
|
try (BpfMap<U32Struct, U32Struct> map = new BpfMap<>(TETHER_ERROR_MAP_PATH,
|
||||||
BpfMap.BPF_F_RDONLY, U32Struct.class, U32Struct.class)) {
|
BpfMap.BPF_F_RDONLY, U32Struct.class, U32Struct.class)) {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user