Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c88c0464 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge changes from topic "am-be6a9190f28c4c1fa3990ea22425f5b8-rvc-dev" into rvc-dev am: 8ef4c5ba

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11818540

Change-Id: Ib411d9c54e887281d322f3e45ec0d0173c496561
parents 956e9819 8ef4c5ba
Loading
Loading
Loading
Loading
+15 −35
Original line number Diff line number Diff line
@@ -77,7 +77,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Objects;
import java.util.Random;
@@ -272,9 +271,6 @@ public class IpServer extends StateMachine {
        }
    }

    private final LinkedHashMap<Inet6Address, Ipv6ForwardingRule> mIpv6ForwardingRules =
            new LinkedHashMap<>();

    private final IpNeighborMonitor mIpNeighborMonitor;

    private LinkAddress mIpv4Address;
@@ -843,43 +839,29 @@ public class IpServer extends StateMachine {
        // TODO: Perhaps remove this protection check.
        if (!mUsingBpfOffload) return;

        try {
            mNetd.tetherOffloadRuleAdd(rule.toTetherOffloadRuleParcel());
            mIpv6ForwardingRules.put(rule.address, rule);
        } catch (RemoteException | ServiceSpecificException e) {
            mLog.e("Could not add IPv6 downstream rule: ", e);
        }
        mBpfCoordinator.tetherOffloadRuleAdd(this, rule);
    }

    private void removeIpv6ForwardingRule(Ipv6ForwardingRule rule, boolean removeFromMap) {
        // Theoretically, we don't need this check because IP neighbor monitor doesn't start if BPF
        // offload is disabled. Add this check just in case.
    private void removeIpv6ForwardingRule(Ipv6ForwardingRule rule) {
        // TODO: Perhaps remove this protection check.
        // See the related comment in #addIpv6ForwardingRule.
        if (!mUsingBpfOffload) return;

        try {
            mNetd.tetherOffloadRuleRemove(rule.toTetherOffloadRuleParcel());
            if (removeFromMap) {
                mIpv6ForwardingRules.remove(rule.address);
            }
        } catch (RemoteException | ServiceSpecificException e) {
            mLog.e("Could not remove IPv6 downstream rule: ", e);
        }
        mBpfCoordinator.tetherOffloadRuleRemove(this, rule);
    }

    private void clearIpv6ForwardingRules() {
        for (Ipv6ForwardingRule rule : mIpv6ForwardingRules.values()) {
            removeIpv6ForwardingRule(rule, false /*removeFromMap*/);
        }
        mIpv6ForwardingRules.clear();
        if (!mUsingBpfOffload) return;

        mBpfCoordinator.tetherOffloadRuleClear(this);
    }

    // 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.
    private void updateIpv6ForwardingRule(Ipv6ForwardingRule rule, int newIfindex) {
        addIpv6ForwardingRule(rule.onNewUpstream(newIfindex));
        removeIpv6ForwardingRule(rule, false /*removeFromMap*/);
    private void updateIpv6ForwardingRule(int newIfindex) {
        // TODO: Perhaps remove this protection check.
        // See the related comment in #addIpv6ForwardingRule.
        if (!mUsingBpfOffload) return;

        mBpfCoordinator.tetherOffloadRuleUpdate(this, newIfindex);
    }

    // Handles all updates to IPv6 forwarding rules. These can currently change only if the upstream
@@ -895,9 +877,7 @@ public class IpServer extends StateMachine {
        // If the upstream interface has changed, remove all rules and re-add them with the new
        // upstream interface.
        if (prevUpstreamIfindex != upstreamIfindex) {
            for (Ipv6ForwardingRule rule : mIpv6ForwardingRules.values()) {
                updateIpv6ForwardingRule(rule, upstreamIfindex);
            }
            updateIpv6ForwardingRule(upstreamIfindex);
        }

        // If we're here to process a NeighborEvent, do so now.
@@ -917,7 +897,7 @@ public class IpServer extends StateMachine {
        if (e.isValid()) {
            addIpv6ForwardingRule(rule);
        } else {
            removeIpv6ForwardingRule(rule, true /*removeFromMap*/);
            removeIpv6ForwardingRule(rule);
        }
    }

+310 −31

File changed.

Preview size limit exceeded, changes collapsed.

+2 −2
Original line number Diff line number Diff line
@@ -1709,7 +1709,7 @@ public class Tethering {
                }

                // TODO: Check the upstream interface if it is managed by BPF offload.
                mBpfCoordinator.start();
                mBpfCoordinator.startPolling();
            }

            @Override
@@ -1722,7 +1722,7 @@ public class Tethering {
                    mTetherUpstream = null;
                    reportUpstreamChanged(null);
                }
                mBpfCoordinator.stop();
                mBpfCoordinator.stopPolling();
            }

            private boolean updateUpstreamWanted() {
+124 −46

File changed.

Preview size limit exceeded, changes collapsed.

+3 −3

File changed.

Preview size limit exceeded, changes collapsed.