Rename the *Nat64Prefix to *Nat64PrefixFromDns.

This just a rename with no functional changes at all. It is
preparation for supporting getting the NAT64 prefix from the
RA.

Bug: 150648313
Test: covered by existing ConnectivityServiceTest and Nat464XlatTest
Merged-In: Ia9a09a708870827b1e4cf068f930fa9542dd116c
Change-Id: Ia9a09a708870827b1e4cf068f930fa9542dd116c
This commit is contained in:
Lorenzo Colitti
2020-04-02 15:24:59 +00:00
parent 26fc3f31ff
commit 6c0cbccf96
3 changed files with 19 additions and 15 deletions

View File

@@ -3153,7 +3153,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
} }
} }
nai.clatd.setNat64Prefix(prefix); nai.clatd.setNat64PrefixFromDns(prefix);
handleUpdateLinkProperties(nai, new LinkProperties(nai.linkProperties)); handleUpdateLinkProperties(nai, new LinkProperties(nai.linkProperties));
} }
@@ -5865,9 +5865,9 @@ public class ConnectivityService extends IConnectivityManager.Stub
@NonNull LinkProperties oldLp) { @NonNull LinkProperties oldLp) {
int netId = networkAgent.network.netId; int netId = networkAgent.network.netId;
// The NetworkAgentInfo does not know whether clatd is running on its network or not, or // The NetworkAgent does not know whether clatd is running on its network or not, or whether
// whether there is a NAT64 prefix. Before we do anything else, make sure its LinkProperties // a NAT64 prefix was discovered by the DNS resolver. Before we do anything else, make sure
// are accurate. // the LinkProperties for the network are accurate.
networkAgent.clatd.fixupLinkProperties(oldLp, newLp); networkAgent.clatd.fixupLinkProperties(oldLp, newLp);
updateInterfaces(newLp, oldLp, netId, networkAgent.networkCapabilities, updateInterfaces(newLp, oldLp, netId, networkAgent.networkCapabilities,

View File

@@ -81,7 +81,7 @@ public class Nat464Xlat extends BaseNetworkObserver {
RUNNING, // start() called, and the stacked iface is known to be up. RUNNING, // start() called, and the stacked iface is known to be up.
} }
private IpPrefix mNat64Prefix; private IpPrefix mNat64PrefixFromDns;
private String mBaseIface; private String mBaseIface;
private String mIface; private String mIface;
private Inet6Address mIPv6Address; private Inet6Address mIPv6Address;
@@ -100,7 +100,7 @@ public class Nat464Xlat extends BaseNetworkObserver {
* currently connected and where the NetworkAgent has not disabled 464xlat. It is the signal to * currently connected and where the NetworkAgent has not disabled 464xlat. It is the signal to
* enable NAT64 prefix discovery. * enable NAT64 prefix discovery.
* *
* @param network the NetworkAgentInfo corresponding to the network. * @param nai the NetworkAgentInfo corresponding to the network.
* @return true if the network requires clat, false otherwise. * @return true if the network requires clat, false otherwise.
*/ */
@VisibleForTesting @VisibleForTesting
@@ -180,7 +180,7 @@ public class Nat464Xlat extends BaseNetworkObserver {
String addrStr = null; String addrStr = null;
try { try {
addrStr = mNetd.clatdStart(baseIface, mNat64Prefix.toString()); addrStr = mNetd.clatdStart(baseIface, getNat64Prefix().toString());
} catch (RemoteException | ServiceSpecificException e) { } catch (RemoteException | ServiceSpecificException e) {
Slog.e(TAG, "Error starting clatd on " + baseIface + ": " + e); Slog.e(TAG, "Error starting clatd on " + baseIface + ": " + e);
} }
@@ -318,8 +318,12 @@ public class Nat464Xlat extends BaseNetworkObserver {
} }
} }
public void setNat64Prefix(IpPrefix nat64Prefix) { private IpPrefix getNat64Prefix() {
mNat64Prefix = nat64Prefix; return mNat64PrefixFromDns;
}
public void setNat64PrefixFromDns(IpPrefix prefix) {
mNat64PrefixFromDns = prefix;
} }
/** /**
@@ -328,7 +332,7 @@ public class Nat464Xlat extends BaseNetworkObserver {
* has no idea that 464xlat is running on top of it. * has no idea that 464xlat is running on top of it.
*/ */
public void fixupLinkProperties(@NonNull LinkProperties oldLp, @NonNull LinkProperties lp) { public void fixupLinkProperties(@NonNull LinkProperties oldLp, @NonNull LinkProperties lp) {
lp.setNat64Prefix(mNat64Prefix); lp.setNat64Prefix(getNat64Prefix());
if (!isRunning()) { if (!isRunning()) {
return; return;

View File

@@ -181,7 +181,7 @@ public class Nat464XlatTest {
Nat464Xlat nat = makeNat464Xlat(); Nat464Xlat nat = makeNat464Xlat();
ArgumentCaptor<LinkProperties> c = ArgumentCaptor.forClass(LinkProperties.class); ArgumentCaptor<LinkProperties> c = ArgumentCaptor.forClass(LinkProperties.class);
nat.setNat64Prefix(new IpPrefix(NAT64_PREFIX)); nat.setNat64PrefixFromDns(new IpPrefix(NAT64_PREFIX));
// Start clat. // Start clat.
nat.start(); nat.start();
@@ -222,7 +222,7 @@ public class Nat464XlatTest {
ArgumentCaptor<LinkProperties> c = ArgumentCaptor.forClass(LinkProperties.class); ArgumentCaptor<LinkProperties> c = ArgumentCaptor.forClass(LinkProperties.class);
InOrder inOrder = inOrder(mNetd, mConnectivity); InOrder inOrder = inOrder(mNetd, mConnectivity);
nat.setNat64Prefix(new IpPrefix(NAT64_PREFIX)); nat.setNat64PrefixFromDns(new IpPrefix(NAT64_PREFIX));
nat.start(); nat.start();
@@ -309,7 +309,7 @@ public class Nat464XlatTest {
Nat464Xlat nat = makeNat464Xlat(); Nat464Xlat nat = makeNat464Xlat();
ArgumentCaptor<LinkProperties> c = ArgumentCaptor.forClass(LinkProperties.class); ArgumentCaptor<LinkProperties> c = ArgumentCaptor.forClass(LinkProperties.class);
nat.setNat64Prefix(new IpPrefix(NAT64_PREFIX)); nat.setNat64PrefixFromDns(new IpPrefix(NAT64_PREFIX));
nat.start(); nat.start();
@@ -348,7 +348,7 @@ public class Nat464XlatTest {
public void testStopBeforeClatdStarts() throws Exception { public void testStopBeforeClatdStarts() throws Exception {
Nat464Xlat nat = makeNat464Xlat(); Nat464Xlat nat = makeNat464Xlat();
nat.setNat64Prefix(new IpPrefix(NAT64_PREFIX)); nat.setNat64PrefixFromDns(new IpPrefix(NAT64_PREFIX));
nat.start(); nat.start();
@@ -380,7 +380,7 @@ public class Nat464XlatTest {
public void testStopAndClatdNeverStarts() throws Exception { public void testStopAndClatdNeverStarts() throws Exception {
Nat464Xlat nat = makeNat464Xlat(); Nat464Xlat nat = makeNat464Xlat();
nat.setNat64Prefix(new IpPrefix(NAT64_PREFIX)); nat.setNat64PrefixFromDns(new IpPrefix(NAT64_PREFIX));
nat.start(); nat.start();