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

Commit f9b4d505 authored by Erik Kline's avatar Erik Kline Committed by android-build-merger
Browse files

Support removing specific routes from local_network am: 6599ee8b

am: 51c8fe90

Change-Id: I02c0805c38e11226bd11b815da5418f1afc1ab89
parents 58e343ef 51c8fe90
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -437,6 +437,7 @@ interface INetworkManagementService

    void addInterfaceToLocalNetwork(String iface, in List<RouteInfo> routes);
    void removeInterfaceFromLocalNetwork(String iface);
    int removeRoutesFromLocalNetwork(in List<RouteInfo> routes);

    void setAllowOnlyVpnForUids(boolean enable, in UidRange[] uidRanges);
}
+15 −0
Original line number Diff line number Diff line
@@ -2751,4 +2751,19 @@ public class NetworkManagementService extends INetworkManagementService.Stub
    public void removeInterfaceFromLocalNetwork(String iface) {
        modifyInterfaceInNetwork("remove", "local", iface);
    }

    @Override
    public int removeRoutesFromLocalNetwork(List<RouteInfo> routes) {
        int failures = 0;

        for (RouteInfo route : routes) {
            try {
                modifyRoute("remove", "local", route);
            } catch (IllegalStateException e) {
                failures++;
            }
        }

        return failures;
    }
}
+11 −2
Original line number Diff line number Diff line
@@ -157,8 +157,17 @@ class IPv6TetheringInterfaceServices {
            }
        } else {
            if (mLastLocalRoutes != null && !mLastLocalRoutes.isEmpty()) {
                // TODO: Remove only locally added network routes.
                // mNMSwervice.removeInterfaceFromLocalNetwork(mIfName);
                try {
                    final int removalFailures =
                            mNMService.removeRoutesFromLocalNetwork(mLastLocalRoutes);
                    if (removalFailures > 0) {
                        Log.e(TAG,
                                String.format("Failed to remove %d IPv6 routes from local table.",
                                removalFailures));
                    }
                } catch (RemoteException e) {
                    Log.e(TAG, "Failed to remove IPv6 routes from local table: ", e);
                }
            }
        }