Loading core/java/android/os/INetworkManagementService.aidl +5 −0 Original line number Diff line number Diff line Loading @@ -91,6 +91,11 @@ interface INetworkManagementService */ void enableIpv6(String iface); /** * Enables or enables IPv6 ND offload. */ void setInterfaceIpv6NdOffload(String iface, boolean enable); /** * Retrieves the network routes currently configured on the specified * interface Loading services/core/java/com/android/server/NetworkManagementService.java +11 −0 Original line number Diff line number Diff line Loading @@ -939,6 +939,17 @@ public class NetworkManagementService extends INetworkManagementService.Stub } } @Override public void setInterfaceIpv6NdOffload(String iface, boolean enable) { mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); try { mConnector.execute( "interface", "ipv6ndoffload", iface, (enable ? "enable" : "disable")); } catch (NativeDaemonConnectorException e) { throw e.rethrowAsParcelableException(); } } @Override public void addRoute(int netId, RouteInfo route) { modifyRoute("add", "" + netId, route); Loading services/core/java/com/android/server/connectivity/Nat464Xlat.java +30 −10 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.server.connectivity; import static android.net.ConnectivityManager.TYPE_MOBILE; import static android.net.ConnectivityManager.TYPE_WIFI; import java.net.Inet4Address; Loading Loading @@ -53,7 +54,7 @@ public class Nat464Xlat extends BaseNetworkObserver { // ConnectivityService Handler for LinkProperties updates. private final Handler mHandler; // The network we're running on. // The network we're running on, and its type. private final NetworkAgentInfo mNetwork; // Internal state variables. Loading Loading @@ -211,23 +212,41 @@ public class Nat464Xlat extends BaseNetworkObserver { return stacked; } private LinkAddress getLinkAddress(String iface) { try { InterfaceConfiguration config = mNMService.getInterfaceConfig(iface); return config.getLinkAddress(); } catch(RemoteException|IllegalStateException e) { Slog.e(TAG, "Error getting link properties: " + e); return null; } } private void maybeSetIpv6NdOffload(String iface, boolean on) { if (mNetwork.networkInfo.getType() != TYPE_WIFI) { return; } try { Slog.d(TAG, (on ? "En" : "Dis") + "abling ND offload on " + iface); mNMService.setInterfaceIpv6NdOffload(iface, on); } catch(RemoteException|IllegalStateException e) { Slog.w(TAG, "Changing IPv6 ND offload on " + iface + "failed: " + e); } } @Override public void interfaceAdded(String iface) { // Called by the InterfaceObserver on its own thread, so can race with stop(). if (isStarted() && mIface.equals(iface)) { Slog.i(TAG, "interface " + iface + " added, mIsRunning " + mIsRunning + "->true"); LinkAddress clatAddress; try { InterfaceConfiguration config = mNMService.getInterfaceConfig(iface); clatAddress = config.getLinkAddress(); } catch(RemoteException e) { Slog.e(TAG, "Error getting link properties: " + e); if (!mIsRunning) { LinkAddress clatAddress = getLinkAddress(iface); if (clatAddress == null) { return; } if (!mIsRunning) { mIsRunning = true; maybeSetIpv6NdOffload(mBaseIface, false); LinkProperties lp = new LinkProperties(mNetwork.linkProperties); lp.addStackedLink(makeLinkProperties(clatAddress)); Slog.i(TAG, "Adding stacked link " + mIface + " on top of " + mBaseIface); Loading Loading @@ -255,6 +274,7 @@ public class Nat464Xlat extends BaseNetworkObserver { } catch (RemoteException|IllegalStateException e) { // Well, we tried. } maybeSetIpv6NdOffload(mBaseIface, true); LinkProperties lp = new LinkProperties(mNetwork.linkProperties); lp.removeStackedLink(mIface); clear(); Loading Loading
core/java/android/os/INetworkManagementService.aidl +5 −0 Original line number Diff line number Diff line Loading @@ -91,6 +91,11 @@ interface INetworkManagementService */ void enableIpv6(String iface); /** * Enables or enables IPv6 ND offload. */ void setInterfaceIpv6NdOffload(String iface, boolean enable); /** * Retrieves the network routes currently configured on the specified * interface Loading
services/core/java/com/android/server/NetworkManagementService.java +11 −0 Original line number Diff line number Diff line Loading @@ -939,6 +939,17 @@ public class NetworkManagementService extends INetworkManagementService.Stub } } @Override public void setInterfaceIpv6NdOffload(String iface, boolean enable) { mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); try { mConnector.execute( "interface", "ipv6ndoffload", iface, (enable ? "enable" : "disable")); } catch (NativeDaemonConnectorException e) { throw e.rethrowAsParcelableException(); } } @Override public void addRoute(int netId, RouteInfo route) { modifyRoute("add", "" + netId, route); Loading
services/core/java/com/android/server/connectivity/Nat464Xlat.java +30 −10 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.server.connectivity; import static android.net.ConnectivityManager.TYPE_MOBILE; import static android.net.ConnectivityManager.TYPE_WIFI; import java.net.Inet4Address; Loading Loading @@ -53,7 +54,7 @@ public class Nat464Xlat extends BaseNetworkObserver { // ConnectivityService Handler for LinkProperties updates. private final Handler mHandler; // The network we're running on. // The network we're running on, and its type. private final NetworkAgentInfo mNetwork; // Internal state variables. Loading Loading @@ -211,23 +212,41 @@ public class Nat464Xlat extends BaseNetworkObserver { return stacked; } private LinkAddress getLinkAddress(String iface) { try { InterfaceConfiguration config = mNMService.getInterfaceConfig(iface); return config.getLinkAddress(); } catch(RemoteException|IllegalStateException e) { Slog.e(TAG, "Error getting link properties: " + e); return null; } } private void maybeSetIpv6NdOffload(String iface, boolean on) { if (mNetwork.networkInfo.getType() != TYPE_WIFI) { return; } try { Slog.d(TAG, (on ? "En" : "Dis") + "abling ND offload on " + iface); mNMService.setInterfaceIpv6NdOffload(iface, on); } catch(RemoteException|IllegalStateException e) { Slog.w(TAG, "Changing IPv6 ND offload on " + iface + "failed: " + e); } } @Override public void interfaceAdded(String iface) { // Called by the InterfaceObserver on its own thread, so can race with stop(). if (isStarted() && mIface.equals(iface)) { Slog.i(TAG, "interface " + iface + " added, mIsRunning " + mIsRunning + "->true"); LinkAddress clatAddress; try { InterfaceConfiguration config = mNMService.getInterfaceConfig(iface); clatAddress = config.getLinkAddress(); } catch(RemoteException e) { Slog.e(TAG, "Error getting link properties: " + e); if (!mIsRunning) { LinkAddress clatAddress = getLinkAddress(iface); if (clatAddress == null) { return; } if (!mIsRunning) { mIsRunning = true; maybeSetIpv6NdOffload(mBaseIface, false); LinkProperties lp = new LinkProperties(mNetwork.linkProperties); lp.addStackedLink(makeLinkProperties(clatAddress)); Slog.i(TAG, "Adding stacked link " + mIface + " on top of " + mBaseIface); Loading Loading @@ -255,6 +274,7 @@ public class Nat464Xlat extends BaseNetworkObserver { } catch (RemoteException|IllegalStateException e) { // Well, we tried. } maybeSetIpv6NdOffload(mBaseIface, true); LinkProperties lp = new LinkProperties(mNetwork.linkProperties); lp.removeStackedLink(mIface); clear(); Loading