Loading services/core/java/com/android/server/connectivity/Nat464Xlat.java +8 −6 Original line number Diff line number Diff line Loading @@ -195,6 +195,9 @@ public class Nat464Xlat extends BaseNetworkObserver { } catch (ClassCastException | IllegalArgumentException | NullPointerException e) { Slog.e(TAG, "Invalid IPv6 address " + addrStr); } if (mPrefixDiscoveryRunning && !isPrefixDiscoveryNeeded()) { stopPrefixDiscovery(); } } /** Loading @@ -221,12 +224,11 @@ public class Nat464Xlat extends BaseNetworkObserver { if (isPrefixDiscoveryNeeded()) { if (!mPrefixDiscoveryRunning) { startPrefixDiscovery(); } else { // Prefix discovery is already running. Nothing to do. mState = State.DISCOVERING; } mState = State.DISCOVERING; } else { stopPrefixDiscovery(); // Enters IDLE state. stopPrefixDiscovery(); mState = State.IDLE; } } Loading Loading @@ -287,7 +289,6 @@ public class Nat464Xlat extends BaseNetworkObserver { } catch (RemoteException | ServiceSpecificException e) { Slog.e(TAG, "Error starting prefix discovery on netId " + getNetId() + ": " + e); } mState = State.DISCOVERING; mPrefixDiscoveryRunning = true; } Loading @@ -297,7 +298,6 @@ public class Nat464Xlat extends BaseNetworkObserver { } catch (RemoteException | ServiceSpecificException e) { Slog.e(TAG, "Error stopping prefix discovery on netId " + getNetId() + ": " + e); } mState = State.IDLE; mPrefixDiscoveryRunning = false; } Loading Loading @@ -330,6 +330,7 @@ public class Nat464Xlat extends BaseNetworkObserver { case IDLE: if (isPrefixDiscoveryNeeded()) { startPrefixDiscovery(); // Enters DISCOVERING state. mState = State.DISCOVERING; } else if (requiresClat(mNetwork)) { start(); // Enters STARTING state. } Loading @@ -344,6 +345,7 @@ public class Nat464Xlat extends BaseNetworkObserver { if (!requiresClat(mNetwork)) { // IPv4 address added. Go back to IDLE state. stopPrefixDiscovery(); mState = State.IDLE; return; } break; Loading tests/net/java/com/android/server/ConnectivityServiceTest.java +16 −0 Original line number Diff line number Diff line Loading @@ -6228,6 +6228,22 @@ public class ConnectivityServiceTest { inOrder.verify(mMockNetd).clatdStop(iface); inOrder.verify(mMockDnsResolver).startPrefix64Discovery(netId); // If the RA prefix appears while DNS discovery is in progress, discovery is stopped and // clatd is started with the prefix from the RA. lp.setNat64Prefix(pref64FromRa); mCellNetworkAgent.sendLinkProperties(lp); expectNat64PrefixChange(callback, mCellNetworkAgent, pref64FromRa); inOrder.verify(mMockNetd).clatdStart(iface, pref64FromRa.toString()); inOrder.verify(mMockDnsResolver).stopPrefix64Discovery(netId); // Withdraw the RA prefix so we can test the case where an RA prefix appears after DNS // discovery has succeeded. lp.setNat64Prefix(null); mCellNetworkAgent.sendLinkProperties(lp); expectNat64PrefixChange(callback, mCellNetworkAgent, null); inOrder.verify(mMockNetd).clatdStop(iface); inOrder.verify(mMockDnsResolver).startPrefix64Discovery(netId); mService.mNetdEventCallback.onNat64PrefixEvent(netId, true /* added */, pref64FromDnsStr, 96); expectNat64PrefixChange(callback, mCellNetworkAgent, pref64FromDns); Loading Loading
services/core/java/com/android/server/connectivity/Nat464Xlat.java +8 −6 Original line number Diff line number Diff line Loading @@ -195,6 +195,9 @@ public class Nat464Xlat extends BaseNetworkObserver { } catch (ClassCastException | IllegalArgumentException | NullPointerException e) { Slog.e(TAG, "Invalid IPv6 address " + addrStr); } if (mPrefixDiscoveryRunning && !isPrefixDiscoveryNeeded()) { stopPrefixDiscovery(); } } /** Loading @@ -221,12 +224,11 @@ public class Nat464Xlat extends BaseNetworkObserver { if (isPrefixDiscoveryNeeded()) { if (!mPrefixDiscoveryRunning) { startPrefixDiscovery(); } else { // Prefix discovery is already running. Nothing to do. mState = State.DISCOVERING; } mState = State.DISCOVERING; } else { stopPrefixDiscovery(); // Enters IDLE state. stopPrefixDiscovery(); mState = State.IDLE; } } Loading Loading @@ -287,7 +289,6 @@ public class Nat464Xlat extends BaseNetworkObserver { } catch (RemoteException | ServiceSpecificException e) { Slog.e(TAG, "Error starting prefix discovery on netId " + getNetId() + ": " + e); } mState = State.DISCOVERING; mPrefixDiscoveryRunning = true; } Loading @@ -297,7 +298,6 @@ public class Nat464Xlat extends BaseNetworkObserver { } catch (RemoteException | ServiceSpecificException e) { Slog.e(TAG, "Error stopping prefix discovery on netId " + getNetId() + ": " + e); } mState = State.IDLE; mPrefixDiscoveryRunning = false; } Loading Loading @@ -330,6 +330,7 @@ public class Nat464Xlat extends BaseNetworkObserver { case IDLE: if (isPrefixDiscoveryNeeded()) { startPrefixDiscovery(); // Enters DISCOVERING state. mState = State.DISCOVERING; } else if (requiresClat(mNetwork)) { start(); // Enters STARTING state. } Loading @@ -344,6 +345,7 @@ public class Nat464Xlat extends BaseNetworkObserver { if (!requiresClat(mNetwork)) { // IPv4 address added. Go back to IDLE state. stopPrefixDiscovery(); mState = State.IDLE; return; } break; Loading
tests/net/java/com/android/server/ConnectivityServiceTest.java +16 −0 Original line number Diff line number Diff line Loading @@ -6228,6 +6228,22 @@ public class ConnectivityServiceTest { inOrder.verify(mMockNetd).clatdStop(iface); inOrder.verify(mMockDnsResolver).startPrefix64Discovery(netId); // If the RA prefix appears while DNS discovery is in progress, discovery is stopped and // clatd is started with the prefix from the RA. lp.setNat64Prefix(pref64FromRa); mCellNetworkAgent.sendLinkProperties(lp); expectNat64PrefixChange(callback, mCellNetworkAgent, pref64FromRa); inOrder.verify(mMockNetd).clatdStart(iface, pref64FromRa.toString()); inOrder.verify(mMockDnsResolver).stopPrefix64Discovery(netId); // Withdraw the RA prefix so we can test the case where an RA prefix appears after DNS // discovery has succeeded. lp.setNat64Prefix(null); mCellNetworkAgent.sendLinkProperties(lp); expectNat64PrefixChange(callback, mCellNetworkAgent, null); inOrder.verify(mMockNetd).clatdStop(iface); inOrder.verify(mMockDnsResolver).startPrefix64Discovery(netId); mService.mNetdEventCallback.onNat64PrefixEvent(netId, true /* added */, pref64FromDnsStr, 96); expectNat64PrefixChange(callback, mCellNetworkAgent, pref64FromDns); Loading