summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2014-05-14 12:47:01 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-05-14 12:47:02 +0000
commit131dcda9a223aaf3f92933278bf00841db9905e4 (patch)
treebe688a5ccfd58b4f609e14bbdb035110523c1da0 /services
parentdf3ef993cb787ade3c01bde1327b1ce76e23afa7 (diff)
parent992f25257938ecc0378514f21c6e6e6375272976 (diff)
downloadframeworks_base-131dcda9a223aaf3f92933278bf00841db9905e4.zip
frameworks_base-131dcda9a223aaf3f92933278bf00841db9905e4.tar.gz
frameworks_base-131dcda9a223aaf3f92933278bf00841db9905e4.tar.bz2
Merge "Separate network and interface addition/removal netd APIs. This should facilitate stacked interfaces (i.e. clatd)."
Diffstat (limited to 'services')
-rw-r--r--services/core/java/com/android/server/ConnectivityService.java28
-rw-r--r--services/core/java/com/android/server/NetworkManagementService.java26
2 files changed, 50 insertions, 4 deletions
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java
index cdb82e7..6cc738b 100644
--- a/services/core/java/com/android/server/ConnectivityService.java
+++ b/services/core/java/com/android/server/ConnectivityService.java
@@ -5088,6 +5088,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
LinkProperties newLp = networkAgent.linkProperties;
int netId = networkAgent.network.netId;
+ updateInterfaces(newLp, oldLp, netId);
updateMtu(newLp, oldLp);
// TODO - figure out what to do for clat
// for (LinkProperties lp : newLp.getStackedLinks()) {
@@ -5096,6 +5097,30 @@ public class ConnectivityService extends IConnectivityManager.Stub {
updateRoutes(newLp, oldLp, netId);
updateDnses(newLp, oldLp, netId);
}
+
+ private void updateInterfaces(LinkProperties newLp, LinkProperties oldLp, int netId) {
+ CompareResult<String> interfaceDiff = new CompareResult<String>();
+ if (oldLp != null) {
+ interfaceDiff = oldLp.compareAllInterfaceNames(newLp);
+ } else if (newLp != null) {
+ interfaceDiff.added = newLp.getAllInterfaceNames();
+ }
+ for (String iface : interfaceDiff.added) {
+ try {
+ mNetd.addInterfaceToNetwork(iface, netId);
+ } catch (Exception e) {
+ loge("Exception adding interface: " + e);
+ }
+ }
+ for (String iface : interfaceDiff.removed) {
+ try {
+ mNetd.removeInterfaceFromNetwork(iface, netId);
+ } catch (Exception e) {
+ loge("Exception removing interface: " + e);
+ }
+ }
+ }
+
private void updateRoutes(LinkProperties newLp, LinkProperties oldLp, int netId) {
CompareResult<RouteInfo> routeDiff = new CompareResult<RouteInfo>();
if (oldLp != null) {
@@ -5300,8 +5325,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
if (state == NetworkInfo.State.CONNECTED) {
// TODO - check if we want it (optimization)
try {
- mNetd.createNetwork(networkAgent.network.netId,
- networkAgent.linkProperties.getInterfaceName());
+ mNetd.createNetwork(networkAgent.network.netId);
} catch (Exception e) {
loge("Error creating Network " + networkAgent.network.netId);
}
diff --git a/services/core/java/com/android/server/NetworkManagementService.java b/services/core/java/com/android/server/NetworkManagementService.java
index a0da2c0..cf91782 100644
--- a/services/core/java/com/android/server/NetworkManagementService.java
+++ b/services/core/java/com/android/server/NetworkManagementService.java
@@ -1938,11 +1938,11 @@ public class NetworkManagementService extends INetworkManagementService.Stub
}
@Override
- public void createNetwork(int netId, String iface) {
+ public void createNetwork(int netId) {
mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);
try {
- mConnector.execute("network", "create", netId, iface);
+ mConnector.execute("network", "create", netId);
} catch (NativeDaemonConnectorException e) {
throw e.rethrowAsParcelableException();
}
@@ -1960,6 +1960,28 @@ public class NetworkManagementService extends INetworkManagementService.Stub
}
@Override
+ public void addInterfaceToNetwork(String iface, int netId) {
+ mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);
+
+ try {
+ mConnector.execute("network", "addiface", netId, iface);
+ } catch (NativeDaemonConnectorException e) {
+ throw e.rethrowAsParcelableException();
+ }
+ }
+
+ @Override
+ public void removeInterfaceFromNetwork(String iface, int netId) {
+ mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);
+
+ try {
+ mConnector.execute("network", "removeiface", netId, iface);
+ } catch (NativeDaemonConnectorException e) {
+ throw e.rethrowAsParcelableException();
+ }
+ }
+
+ @Override
public void addLegacyRouteForNetId(int netId, RouteInfo routeInfo, int uid) {
modifyLegacyRouteForNetId(netId, routeInfo, uid, ADD);
}