Merge "Relief unnecessary dependencies of code order" into main am: c022bd47a8 am: 9fcd487878
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2715355
Change-Id: Ieb38a72540ce2671f2b4bcbace5f43d5b30e3f31
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/Tethering/src/android/net/ip/IpServer.java b/Tethering/src/android/net/ip/IpServer.java
index bb09d0d..eadba58 100644
--- a/Tethering/src/android/net/ip/IpServer.java
+++ b/Tethering/src/android/net/ip/IpServer.java
@@ -283,6 +283,7 @@
private List<TetheredClient> mDhcpLeases = Collections.emptyList();
private int mLastIPv6UpstreamIfindex = 0;
+ private boolean mUpstreamSupportsBpf = false;
private class MyNeighborEventConsumer implements IpNeighborMonitor.NeighborEventConsumer {
public void accept(NeighborEvent e) {
@@ -779,15 +780,15 @@
// If v6only is null, we pass in null to setRaParams(), which handles
// deprecation of any existing RA data.
-
setRaParams(params);
- // Be aware that updateIpv6ForwardingRules use mLastIPv6LinkProperties, so this line should
- // be eariler than updateIpv6ForwardingRules.
- // TODO: avoid this dependencies and move this logic into BpfCoordinator.
- mLastIPv6LinkProperties = v6only;
- updateIpv6ForwardingRules(mLastIPv6UpstreamIfindex, upstreamIfIndex, null);
+ // Not support BPF on virtual upstream interface
+ final boolean upstreamSupportsBpf = upstreamIface != null && !isVcnInterface(upstreamIface);
+ updateIpv6ForwardingRules(
+ mLastIPv6UpstreamIfindex, upstreamIfIndex, upstreamSupportsBpf, null);
+ mLastIPv6LinkProperties = v6only;
mLastIPv6UpstreamIfindex = upstreamIfIndex;
+ mUpstreamSupportsBpf = upstreamSupportsBpf;
if (mDadProxy != null) {
mDadProxy.setUpstreamIface(upstreamIfaceParams);
}
@@ -921,20 +922,14 @@
mBpfCoordinator.tetherOffloadRuleUpdate(this, newIfindex);
}
- private boolean isIpv6VcnNetworkInterface() {
- if (mLastIPv6LinkProperties == null) return false;
-
- return isVcnInterface(mLastIPv6LinkProperties.getInterfaceName());
- }
-
// Handles all updates to IPv6 forwarding rules. These can currently change only if the upstream
// changes or if a neighbor event is received.
private void updateIpv6ForwardingRules(int prevUpstreamIfindex, int upstreamIfindex,
- NeighborEvent e) {
- // If no longer have an upstream or it is virtual network, clear forwarding rules and do
+ boolean upstreamSupportsBpf, NeighborEvent e) {
+ // If no longer have an upstream or upstream not supports BPF, clear forwarding rules and do
// nothing else.
// TODO: Rather than always clear rules, ensure whether ipv6 ever enable first.
- if (upstreamIfindex == 0 || isIpv6VcnNetworkInterface()) {
+ if (upstreamIfindex == 0 || !upstreamSupportsBpf) {
clearIpv6ForwardingRules();
return;
}
@@ -995,7 +990,8 @@
if (mInterfaceParams != null
&& mInterfaceParams.index == e.ifindex
&& mInterfaceParams.hasMacAddress) {
- updateIpv6ForwardingRules(mLastIPv6UpstreamIfindex, mLastIPv6UpstreamIfindex, e);
+ updateIpv6ForwardingRules(mLastIPv6UpstreamIfindex, mLastIPv6UpstreamIfindex,
+ mUpstreamSupportsBpf, e);
updateClientInfoIpv4(e);
}
}