Merge changes from topic "wrap_fd_to_parcelfiledescriptor" am: f889ed7a30

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2095630

Change-Id: Ia3e8cb1f3446e32f7289f788bd56bbc0f64065b8
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Nucca Chen
2022-05-12 14:07:34 +00:00
committed by Automerger Merge Worker
2 changed files with 10 additions and 9 deletions

View File

@@ -77,6 +77,7 @@ import com.android.net.module.util.netlink.NetlinkSocket;
import com.android.networkstack.tethering.apishim.common.BpfCoordinatorShim;
import com.android.networkstack.tethering.util.TetheringUtils.ForwardedStats;
import java.io.IOException;
import java.net.Inet4Address;
import java.net.Inet6Address;
import java.net.InetAddress;
@@ -1024,7 +1025,7 @@ public class BpfCoordinator {
map.forEach((k, v) -> {
pw.println(String.format("%s: %s", k, v));
});
} catch (ErrnoException e) {
} catch (ErrnoException | IOException e) {
pw.println("Error dumping BPF stats map: " + e);
}
}
@@ -1072,7 +1073,7 @@ public class BpfCoordinator {
return;
}
map.forEach((k, v) -> pw.println(ipv6UpstreamRuletoString(k, v)));
} catch (ErrnoException e) {
} catch (ErrnoException | IOException e) {
pw.println("Error dumping IPv6 upstream map: " + e);
}
}
@@ -1116,7 +1117,7 @@ public class BpfCoordinator {
if (CollectionUtils.contains(args, DUMPSYS_RAWMAP_ARG_STATS)) {
try (BpfMap<TetherStatsKey, TetherStatsValue> statsMap = mDeps.getBpfStatsMap()) {
dumpRawMap(statsMap, pw);
} catch (ErrnoException e) {
} catch (ErrnoException | IOException e) {
pw.println("Error dumping stats map: " + e);
}
return;
@@ -1124,7 +1125,7 @@ public class BpfCoordinator {
if (CollectionUtils.contains(args, DUMPSYS_RAWMAP_ARG_UPSTREAM4)) {
try (BpfMap<Tether4Key, Tether4Value> upstreamMap = mDeps.getBpfUpstream4Map()) {
dumpRawMap(upstreamMap, pw);
} catch (ErrnoException e) {
} catch (ErrnoException | IOException e) {
pw.println("Error dumping IPv4 map: " + e);
}
return;
@@ -1195,7 +1196,7 @@ public class BpfCoordinator {
pw.increaseIndent();
dumpIpv4ForwardingRuleMap(now, DOWNSTREAM, downstreamMap, pw);
pw.decreaseIndent();
} catch (ErrnoException e) {
} catch (ErrnoException | IOException e) {
pw.println("Error dumping IPv4 map: " + e);
}
}
@@ -1220,7 +1221,7 @@ public class BpfCoordinator {
}
if (v.val > 0) pw.println(String.format("%s: %d", counterName, v.val));
});
} catch (ErrnoException e) {
} catch (ErrnoException | IOException e) {
pw.println("Error dumping counter map: " + e);
}
}
@@ -1244,7 +1245,7 @@ public class BpfCoordinator {
pw.println(String.format("%d (%s) -> %d (%s)", k.ifIndex, getIfName(k.ifIndex),
v.ifIndex, getIfName(v.ifIndex)));
});
} catch (ErrnoException e) {
} catch (ErrnoException | IOException e) {
pw.println("Error dumping dev map: " + e);
}
pw.decreaseIndent();

View File

@@ -358,8 +358,8 @@ public final class BpfMapTest {
try {
mTestMap.clear();
fail("clearing already-closed map should throw");
} catch (ErrnoException expected) {
assertEquals(OsConstants.EBADF, expected.errno);
} catch (IllegalStateException expected) {
// ParcelFileDescriptor.getFd throws IllegalStateException: Already closed.
}
}