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

Commit 6599ee8b authored by Erik Kline's avatar Erik Kline
Browse files

Support removing specific routes from local_network

Bug: 9580643
Change-Id: Id0aaf4bc7424797e2beef03fb18a2c1885a86509
parent e3f28911
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -442,6 +442,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
@@ -2774,4 +2774,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);
                }
            }
        }