Merge the following changes to tethering:
====== Fix a logic error in IpServerTest#addRemoveipv6ForwardingRules When checking that link-local and multicast neighbours are ignored, make sure the test neighbours are added on the correct interface. Otherwise, they might be ignored because events on the wrong interface are ignored, and not necessarily because link-local and multicast neighbours are ignored. Test: atest TetheringTests Change-Id: I4a624ea4ce9ee9a9352afccbc7bf866587d4cdfa ====== Clear IPv6 forwarding rules when losing upstream or stopping. Test: new unit test Change-Id: I8626932e43e0daa300dad5fe6a81f47a6d667030 ====== Bug: 149963652 Change-Id: I691053b22cb0b20e49419212f378cc473b1f35dc (cherry picked from commit 3384bb9a4d7bd85370fe64e59f2872a5cab644d7)
This commit is contained in:
committed by
Lorenzo Colitti
parent
230178c6af
commit
f1194880cb
@@ -810,7 +810,7 @@ public class IpServer extends StateMachine {
|
||||
rule.dstMac.toByteArray());
|
||||
mIpv6ForwardingRules.put(rule.address, rule);
|
||||
} catch (RemoteException | ServiceSpecificException e) {
|
||||
Log.e(TAG, "Could not add IPv6 downstream rule: " + e);
|
||||
mLog.e("Could not add IPv6 downstream rule: ", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -821,10 +821,17 @@ public class IpServer extends StateMachine {
|
||||
mIpv6ForwardingRules.remove(rule.address);
|
||||
}
|
||||
} catch (RemoteException | ServiceSpecificException e) {
|
||||
Log.e(TAG, "Could not remove IPv6 downstream rule: " + e);
|
||||
mLog.e("Could not remove IPv6 downstream rule: ", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void clearIpv6ForwardingRules() {
|
||||
for (Ipv6ForwardingRule rule : mIpv6ForwardingRules.values()) {
|
||||
removeIpv6ForwardingRule(rule, false /*removeFromMap*/);
|
||||
}
|
||||
mIpv6ForwardingRules.clear();
|
||||
}
|
||||
|
||||
// Convenience method to replace a rule with the same rule on a new upstream interface.
|
||||
// Allows replacing the rules in one iteration pass without ConcurrentModificationExceptions.
|
||||
// Relies on the fact that rules are in a map indexed by IP address.
|
||||
@@ -837,6 +844,12 @@ public class IpServer extends StateMachine {
|
||||
// changes or if a neighbor event is received.
|
||||
private void updateIpv6ForwardingRules(int prevUpstreamIfindex, int upstreamIfindex,
|
||||
NeighborEvent e) {
|
||||
// If we no longer have an upstream, clear forwarding rules and do nothing else.
|
||||
if (upstreamIfindex == 0) {
|
||||
clearIpv6ForwardingRules();
|
||||
return;
|
||||
}
|
||||
|
||||
// If the upstream interface has changed, remove all rules and re-add them with the new
|
||||
// upstream interface.
|
||||
if (prevUpstreamIfindex != upstreamIfindex) {
|
||||
@@ -846,13 +859,14 @@ public class IpServer extends StateMachine {
|
||||
}
|
||||
|
||||
// If we're here to process a NeighborEvent, do so now.
|
||||
// mInterfaceParams must be non-null or the event would not have arrived.
|
||||
if (e == null) return;
|
||||
if (!(e.ip instanceof Inet6Address) || e.ip.isMulticastAddress()
|
||||
|| e.ip.isLoopbackAddress() || e.ip.isLinkLocalAddress()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Ipv6ForwardingRule rule = new Ipv6ForwardingRule(mLastIPv6UpstreamIfindex,
|
||||
Ipv6ForwardingRule rule = new Ipv6ForwardingRule(upstreamIfindex,
|
||||
mInterfaceParams.index, (Inet6Address) e.ip, mInterfaceParams.macAddr,
|
||||
e.macAddr);
|
||||
if (e.isValid()) {
|
||||
@@ -1095,6 +1109,7 @@ public class IpServer extends StateMachine {
|
||||
|
||||
for (String ifname : mUpstreamIfaceSet.ifnames) cleanupUpstreamInterface(ifname);
|
||||
mUpstreamIfaceSet = null;
|
||||
clearIpv6ForwardingRules();
|
||||
}
|
||||
|
||||
private void cleanupUpstreamInterface(String upstreamIface) {
|
||||
|
||||
Reference in New Issue
Block a user