Skip to content
Snippets Groups Projects
Commit 316346be authored by Anton Kulakov's avatar Anton Kulakov
Browse files

Revert "Simplify addRoutesToLocalNetwork calls"

Revert submission 2777667

Reason for revert: DroidMonitor-triggered revert due to breakage, bug b/305187495

Reverted changes: /q/submissionid:2777667

Bug: 305187495

Change-Id: I516d40b20d775e9c61b2f825bc094329d016d0c3
parent d2d3b5dd
No related branches found
No related tags found
No related merge requests found
......@@ -16,6 +16,8 @@
package android.net.ip;
import static android.net.RouteInfo.RTN_UNICAST;
import static com.android.net.module.util.NetworkStackConstants.ETHER_HEADER_LEN;
import static com.android.net.module.util.NetworkStackConstants.ETHER_TYPE_IPV6;
import static com.android.net.module.util.NetworkStackConstants.ICMPV6_ND_OPTION_MTU;
......@@ -40,13 +42,12 @@ import android.content.Context;
import android.net.INetd;
import android.net.IpPrefix;
import android.net.MacAddress;
import android.net.RouteInfo;
import android.net.ip.RouterAdvertisementDaemon.RaParams;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.IBinder;
import android.os.Looper;
import android.os.RemoteException;
import android.os.ServiceSpecificException;
import androidx.test.InstrumentationRegistry;
import androidx.test.filters.SmallTest;
......@@ -54,6 +55,7 @@ import androidx.test.runner.AndroidJUnit4;
import com.android.net.module.util.InterfaceParams;
import com.android.net.module.util.Ipv6Utils;
import com.android.net.module.util.NetdUtils;
import com.android.net.module.util.Struct;
import com.android.net.module.util.structs.EthernetHeader;
import com.android.net.module.util.structs.Icmpv6Header;
......@@ -78,6 +80,7 @@ import java.net.Inet6Address;
import java.net.InetAddress;
import java.nio.ByteBuffer;
import java.util.HashSet;
import java.util.List;
@RunWith(AndroidJUnit4.class)
@SmallTest
......@@ -329,12 +332,10 @@ public final class RouterAdvertisementDaemonTest {
// Add a default route "fe80::/64 -> ::" to local network, otherwise, device will fail to
// send the unicast RA out due to the ENETUNREACH error(No route to the peer's link-local
// address is present).
try {
sNetd.networkAddRoute(INetd.LOCAL_NET_ID, mTetheredParams.name,
"fe80::/64", INetd.NEXTHOP_NONE);
} catch (RemoteException | ServiceSpecificException e) {
throw new IllegalStateException(e);
}
final String iface = mTetheredParams.name;
final RouteInfo linkLocalRoute =
new RouteInfo(new IpPrefix("fe80::/64"), null, iface, RTN_UNICAST);
NetdUtils.addRoutesToLocalNetwork(sNetd, iface, List.of(linkLocalRoute));
final ByteBuffer rs = createRsPacket("fe80::1122:3344:5566:7788");
mTetheredPacketReader.sendResponse(rs);
......
......@@ -159,11 +159,9 @@ public class NetdUtils {
throws RemoteException, ServiceSpecificException {
netd.tetherInterfaceAdd(iface);
networkAddInterface(netd, iface, maxAttempts, pollingIntervalMs);
// Activate a route to dest and IPv6 link local.
modifyRoute(netd, ModifyOperation.ADD, INetd.LOCAL_NET_ID,
new RouteInfo(dest, null, iface, RTN_UNICAST));
modifyRoute(netd, ModifyOperation.ADD, INetd.LOCAL_NET_ID,
new RouteInfo(new IpPrefix("fe80::/64"), null, iface, RTN_UNICAST));
List<RouteInfo> routes = new ArrayList<>();
routes.add(new RouteInfo(dest, null, iface, RTN_UNICAST));
addRoutesToLocalNetwork(netd, iface, routes);
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment