Merge "Fix IPv6 on wifi"
This commit is contained in:
@@ -78,6 +78,16 @@ interface INetworkManagementService
|
|||||||
*/
|
*/
|
||||||
void setInterfaceIpv6PrivacyExtensions(String iface, boolean enable);
|
void setInterfaceIpv6PrivacyExtensions(String iface, boolean enable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable IPv6 on an interface
|
||||||
|
*/
|
||||||
|
void disableIpv6(String iface);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable IPv6 on an interface
|
||||||
|
*/
|
||||||
|
void enableIpv6(String iface);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the network routes currently configured on the specified
|
* Retrieves the network routes currently configured on the specified
|
||||||
* interface
|
* interface
|
||||||
|
|||||||
@@ -508,6 +508,28 @@ public class NetworkManagementService extends INetworkManagementService.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void enableIpv6(String iface) throws IllegalStateException {
|
||||||
|
mContext.enforceCallingOrSelfPermission(
|
||||||
|
android.Manifest.permission.CHANGE_NETWORK_STATE, "NetworkManagementService");
|
||||||
|
try {
|
||||||
|
mConnector.doCommand(String.format("interface ipv6 %s enable", iface));
|
||||||
|
} catch (NativeDaemonConnectorException e) {
|
||||||
|
throw new IllegalStateException(
|
||||||
|
"Unable to communicate to native daemon for enabling ipv6");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void disableIpv6(String iface) throws IllegalStateException {
|
||||||
|
mContext.enforceCallingOrSelfPermission(
|
||||||
|
android.Manifest.permission.CHANGE_NETWORK_STATE, "NetworkManagementService");
|
||||||
|
try {
|
||||||
|
mConnector.doCommand(String.format("interface ipv6 %s disable", iface));
|
||||||
|
} catch (NativeDaemonConnectorException e) {
|
||||||
|
throw new IllegalStateException(
|
||||||
|
"Unable to communicate to native daemon for disabling ipv6");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void addRoute(String interfaceName, RouteInfo route) {
|
public void addRoute(String interfaceName, RouteInfo route) {
|
||||||
modifyRoute(interfaceName, ADD, route);
|
modifyRoute(interfaceName, ADD, route);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1560,8 +1560,9 @@ public class WifiStateMachine extends StateMachine {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
mNwService.clearInterfaceAddresses(mInterfaceName);
|
mNwService.clearInterfaceAddresses(mInterfaceName);
|
||||||
|
mNwService.disableIpv6(mInterfaceName);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "Failed to clear IP addresses on disconnect" + e);
|
Log.e(TAG, "Failed to clear addresses or disable ipv6" + e);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reset data structures */
|
/* Reset data structures */
|
||||||
@@ -1841,6 +1842,21 @@ public class WifiStateMachine extends StateMachine {
|
|||||||
mWifiP2pManager = (WifiP2pManager) mContext.getSystemService(Context.WIFI_P2P_SERVICE);
|
mWifiP2pManager = (WifiP2pManager) mContext.getSystemService(Context.WIFI_P2P_SERVICE);
|
||||||
mWifiP2pChannel.connect(mContext, getHandler(), mWifiP2pManager.getMessenger());
|
mWifiP2pChannel.connect(mContext, getHandler(), mWifiP2pManager.getMessenger());
|
||||||
|
|
||||||
|
/* IPv6 is disabled at boot time and is controlled by framework
|
||||||
|
* to be enabled only as long as we are connected to an access point
|
||||||
|
*
|
||||||
|
* This fixes issues, a few being:
|
||||||
|
* - IPv6 addresses and routes stick around after disconnection
|
||||||
|
* - When connected, the kernel is unaware and can fail to start IPv6 negotiation
|
||||||
|
* - The kernel sometimes starts autoconfiguration when 802.1x is not complete
|
||||||
|
*/
|
||||||
|
try {
|
||||||
|
mNwService.disableIpv6(mInterfaceName);
|
||||||
|
} catch (RemoteException re) {
|
||||||
|
Log.e(TAG, "Failed to disable IPv6: " + re);
|
||||||
|
} catch (IllegalStateException e) {
|
||||||
|
Log.e(TAG, "Failed to disable IPv6: " + e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2734,7 +2750,15 @@ public class WifiStateMachine extends StateMachine {
|
|||||||
if (DBG) Log.d(TAG, getName() + "\n");
|
if (DBG) Log.d(TAG, getName() + "\n");
|
||||||
EventLog.writeEvent(EVENTLOG_WIFI_STATE_CHANGED, getName());
|
EventLog.writeEvent(EVENTLOG_WIFI_STATE_CHANGED, getName());
|
||||||
|
|
||||||
if (!WifiConfigStore.isUsingStaticIp(mLastNetworkId)) {
|
try {
|
||||||
|
mNwService.enableIpv6(mInterfaceName);
|
||||||
|
} catch (RemoteException re) {
|
||||||
|
Log.e(TAG, "Failed to enable IPv6: " + re);
|
||||||
|
} catch (IllegalStateException e) {
|
||||||
|
Log.e(TAG, "Failed to enable IPv6: " + e);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!WifiConfigStore.isUsingStaticIp(mLastNetworkId)) {
|
||||||
//start DHCP
|
//start DHCP
|
||||||
mDhcpStateMachine = DhcpStateMachine.makeDhcpStateMachine(
|
mDhcpStateMachine = DhcpStateMachine.makeDhcpStateMachine(
|
||||||
mContext, WifiStateMachine.this, mInterfaceName);
|
mContext, WifiStateMachine.this, mInterfaceName);
|
||||||
@@ -2758,7 +2782,7 @@ public class WifiStateMachine extends StateMachine {
|
|||||||
sendMessage(CMD_STATIC_IP_FAILURE);
|
sendMessage(CMD_STATIC_IP_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public boolean processMessage(Message message) {
|
public boolean processMessage(Message message) {
|
||||||
if (DBG) Log.d(TAG, getName() + message.toString() + "\n");
|
if (DBG) Log.d(TAG, getName() + message.toString() + "\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user