Skip to content

Commit e83d181

Browse files
author
Robert Greenwalt
committed
Fix some policy-base routing issues.
Secondary nets sometimes come up with no routes, but parsing errors end up with null routes getting added. Trim that away. Also added some dumpstate logging of the secondary route tables and rules. bug:5615697 Change-Id: I94c9d888bab958df44891b9117236436e046cc7f
1 parent 4c6a65b commit e83d181

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

cmds/dumpstate/dumpstate.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ static void dumpstate() {
120120

121121
dump_file("NETWORK ROUTES", "/proc/net/route");
122122
dump_file("NETWORK ROUTES IPV6", "/proc/net/ipv6_route");
123+
run_command("IP RULES", 10, "ip", "rule", "show", NULL);
124+
run_command("IP RULES v6", 10, "ip", "-6", "rule", "show", NULL);
125+
run_command("ROUTE TABLE 60", 10, "ip", "route", "show", "table", "60", NULL);
126+
run_command("ROUTE TABLE 61 v6", 10, "ip", "-6", "route", "show", "table", "60", NULL);
127+
run_command("ROUTE TABLE 61", 10, "ip", "route", "show", "table", "61", NULL);
128+
run_command("ROUTE TABLE 61 v6", 10, "ip", "-6", "route", "show", "table", "61", NULL);
123129
dump_file("ARP CACHE", "/proc/net/arp");
124130
run_command("IPTABLES", 10, "su", "root", "iptables", "-L", "-nvx", NULL);
125131
run_command("IP6TABLES", 10, "su", "root", "ip6tables", "-L", "-nvx", NULL);

services/java/com/android/server/NetworkManagementService.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -856,13 +856,17 @@ private void modifyNat(String cmd, String internalInterface, String externalInte
856856

857857
NetworkInterface internalNetworkInterface =
858858
NetworkInterface.getByName(internalInterface);
859-
Collection<InterfaceAddress>interfaceAddresses =
860-
internalNetworkInterface.getInterfaceAddresses();
861-
cmd += " " + interfaceAddresses.size();
862-
for (InterfaceAddress ia : interfaceAddresses) {
863-
InetAddress addr = NetworkUtils.getNetworkPart(ia.getAddress(),
864-
ia.getNetworkPrefixLength());
865-
cmd = cmd + " " + addr.getHostAddress() + "/" + ia.getNetworkPrefixLength();
859+
if (internalNetworkInterface == null) {
860+
cmd += " 0";
861+
} else {
862+
Collection<InterfaceAddress>interfaceAddresses =
863+
internalNetworkInterface.getInterfaceAddresses();
864+
cmd += " " + interfaceAddresses.size();
865+
for (InterfaceAddress ia : interfaceAddresses) {
866+
InetAddress addr = NetworkUtils.getNetworkPart(ia.getAddress(),
867+
ia.getNetworkPrefixLength());
868+
cmd = cmd + " " + addr.getHostAddress() + "/" + ia.getNetworkPrefixLength();
869+
}
866870
}
867871

868872
mConnector.doCommand(cmd);

telephony/java/com/android/internal/telephony/DataCallState.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ public SetupResult setLinkProperties(LinkProperties linkProperties,
126126
// set link addresses
127127
if (addresses != null && addresses.length > 0) {
128128
for (String addr : addresses) {
129+
addr = addr.trim();
130+
if (addr.isEmpty()) continue;
129131
LinkAddress la;
130132
int addrPrefixLen;
131133

@@ -159,6 +161,8 @@ public SetupResult setLinkProperties(LinkProperties linkProperties,
159161
// set dns servers
160162
if (dnses != null && dnses.length > 0) {
161163
for (String addr : dnses) {
164+
addr = addr.trim();
165+
if (addr.isEmpty()) continue;
162166
InetAddress ia;
163167
try {
164168
ia = NetworkUtils.numericToInetAddress(addr);
@@ -174,6 +178,8 @@ public SetupResult setLinkProperties(LinkProperties linkProperties,
174178
dnsServers[0] = SystemProperties.get(propertyPrefix + "dns1");
175179
dnsServers[1] = SystemProperties.get(propertyPrefix + "dns2");
176180
for (String dnsAddr : dnsServers) {
181+
dnsAddr = dnsAddr.trim();
182+
if (dnsAddr.isEmpty()) continue;
177183
InetAddress ia;
178184
try {
179185
ia = NetworkUtils.numericToInetAddress(dnsAddr);
@@ -198,6 +204,8 @@ public SetupResult setLinkProperties(LinkProperties linkProperties,
198204
}
199205
}
200206
for (String addr : gateways) {
207+
addr = addr.trim();
208+
if (addr.isEmpty()) continue;
201209
InetAddress ia;
202210
try {
203211
ia = NetworkUtils.numericToInetAddress(addr);

0 commit comments

Comments
 (0)