Merge "Minor logging fixes for new DHCP server"
am: eb5f458884
Change-Id: I73be22fce02d20c5009164787124770e62e180c2
diff --git a/services/core/java/com/android/server/connectivity/tethering/TetheringConfiguration.java b/services/core/java/com/android/server/connectivity/tethering/TetheringConfiguration.java
index 6699444..2b1d919 100644
--- a/services/core/java/com/android/server/connectivity/tethering/TetheringConfiguration.java
+++ b/services/core/java/com/android/server/connectivity/tethering/TetheringConfiguration.java
@@ -162,6 +162,9 @@
dumpStringArray(pw, "provisioningApp", provisioningApp);
pw.print("provisioningAppNoUi: ");
pw.println(provisioningAppNoUi);
+
+ pw.print("enableLegacyDhcpServer: ");
+ pw.println(enableLegacyDhcpServer);
}
public String toString() {
@@ -176,6 +179,7 @@
makeString(preferredUpstreamNames(preferredUpstreamIfaceTypes))));
sj.add(String.format("provisioningApp:%s", makeString(provisioningApp)));
sj.add(String.format("provisioningAppNoUi:%s", provisioningAppNoUi));
+ sj.add(String.format("enableLegacyDhcpServer:%s", enableLegacyDhcpServer));
return String.format("TetheringConfiguration{%s}", sj.toString());
}
diff --git a/services/net/java/android/net/dhcp/DhcpLease.java b/services/net/java/android/net/dhcp/DhcpLease.java
index d2a15b3..6cdd2aa 100644
--- a/services/net/java/android/net/dhcp/DhcpLease.java
+++ b/services/net/java/android/net/dhcp/DhcpLease.java
@@ -130,9 +130,14 @@
return HexDump.toHexString(bytes);
}
+ static String inet4AddrToString(@Nullable Inet4Address addr) {
+ return (addr == null) ? "null" : addr.getHostAddress();
+ }
+
@Override
public String toString() {
return String.format("clientId: %s, hwAddr: %s, netAddr: %s, expTime: %d, hostname: %s",
- clientIdToString(mClientId), mHwAddr.toString(), mNetAddr, mExpTime, mHostname);
+ clientIdToString(mClientId), mHwAddr.toString(), inet4AddrToString(mNetAddr),
+ mExpTime, mHostname);
}
}
diff --git a/services/net/java/android/net/dhcp/DhcpLeaseRepository.java b/services/net/java/android/net/dhcp/DhcpLeaseRepository.java
index 9f77ed0..2fb9346 100644
--- a/services/net/java/android/net/dhcp/DhcpLeaseRepository.java
+++ b/services/net/java/android/net/dhcp/DhcpLeaseRepository.java
@@ -20,6 +20,7 @@
import static android.net.NetworkUtils.intToInet4AddressHTH;
import static android.net.NetworkUtils.prefixLengthToV4NetmaskIntHTH;
import static android.net.dhcp.DhcpLease.EXPIRATION_NEVER;
+import static android.net.dhcp.DhcpLease.inet4AddrToString;
import static android.net.util.NetworkConstants.IPV4_ADDR_BITS;
import static java.lang.Math.min;
@@ -252,7 +253,7 @@
final DhcpLease lease =
checkClientAndMakeLease(clientId, hwAddr, leaseAddr, hostname, currentTime);
mLog.logf("DHCPREQUEST assignedLease %s, reqAddr=%s, sidSet=%s: created/renewed lease %s",
- assignedLease, reqAddr, sidSet, lease);
+ assignedLease, inet4AddrToString(reqAddr), sidSet, lease);
return lease;
}
@@ -304,7 +305,7 @@
@NonNull Inet4Address addr) {
final DhcpLease currentLease = mCommittedLeases.getOrDefault(addr, null);
if (currentLease == null) {
- mLog.w("Could not release unknown lease for " + addr);
+ mLog.w("Could not release unknown lease for " + inet4AddrToString(addr));
return false;
}
if (currentLease.matchesClient(clientId, hwAddr)) {
@@ -319,12 +320,13 @@
public void markLeaseDeclined(@NonNull Inet4Address addr) {
if (mDeclinedAddrs.containsKey(addr) || !isValidAddress(addr)) {
- mLog.logf("Not marking %s as declined: already declined or not assignable", addr);
+ mLog.logf("Not marking %s as declined: already declined or not assignable",
+ inet4AddrToString(addr));
return;
}
final long expTime = mClock.elapsedRealtime() + mLeaseTimeMs;
mDeclinedAddrs.put(addr, expTime);
- mLog.logf("Marked %s as declined expiring %d", addr, expTime);
+ mLog.logf("Marked %s as declined expiring %d", inet4AddrToString(addr), expTime);
maybeUpdateEarliestExpiration(expTime);
}
@@ -515,7 +517,8 @@
while (it.hasNext()) {
final Inet4Address addr = it.next();
it.remove();
- mLog.logf("Out of addresses in address pool: dropped declined addr %s", addr);
+ mLog.logf("Out of addresses in address pool: dropped declined addr %s",
+ inet4AddrToString(addr));
// isValidAddress() is always verified for entries in mDeclinedAddrs.
// However declined addresses may have been requested (typically by the machine that was
// already using the address) after being declined.