Skip to content
Snippets Groups Projects
Commit 68770343 authored by KH Shi's avatar KH Shi
Browse files

Relief unnecessary dependencies of code order

The original code requires updating mLastIPv6LinkProperties before
calling updateIpv6ForwardingRules because mLastIPv6LinkProperties will
be used inside an internal function later. Remove this unnecessary
dependency by passing the interface name into the function.

Bug: 294025403
Test: atest TetheringTests
Change-Id: I5699fba3d7caf3314d102b643b02da2b2797dd66
parent cf41958c
No related branches found
No related tags found
No related merge requests found
......@@ -283,6 +283,7 @@ public class IpServer extends StateMachine {
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 @@ public class IpServer extends StateMachine {
// 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 @@ public class IpServer extends StateMachine {
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 @@ public class IpServer extends StateMachine {
if (mInterfaceParams != null
&& mInterfaceParams.index == e.ifindex
&& mInterfaceParams.hasMacAddress) {
updateIpv6ForwardingRules(mLastIPv6UpstreamIfindex, mLastIPv6UpstreamIfindex, e);
updateIpv6ForwardingRules(mLastIPv6UpstreamIfindex, mLastIPv6UpstreamIfindex,
mUpstreamSupportsBpf, e);
updateClientInfoIpv4(e);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment