Merge "Try to set the hop limit to something suitable for 64share"

This commit is contained in:
Treehugger Robot
2018-09-11 05:55:37 +00:00
committed by Gerrit Code Review

View File

@@ -119,13 +119,23 @@ public class RouterAdvertisementDaemon {
private volatile UnicastResponder mUnicastResponder; private volatile UnicastResponder mUnicastResponder;
public static class RaParams { public static class RaParams {
// Tethered traffic will have the hop limit properly decremented.
// Consequently, set the hoplimit greater by one than the upstream
// unicast hop limit.
//
// TODO: Dynamically pass down the IPV6_UNICAST_HOPS value from the
// upstream interface for more correct behaviour.
static final byte DEFAULT_HOPLIMIT = 65;
public boolean hasDefaultRoute; public boolean hasDefaultRoute;
public byte hopLimit;
public int mtu; public int mtu;
public HashSet<IpPrefix> prefixes; public HashSet<IpPrefix> prefixes;
public HashSet<Inet6Address> dnses; public HashSet<Inet6Address> dnses;
public RaParams() { public RaParams() {
hasDefaultRoute = false; hasDefaultRoute = false;
hopLimit = DEFAULT_HOPLIMIT;
mtu = IPV6_MIN_MTU; mtu = IPV6_MIN_MTU;
prefixes = new HashSet<IpPrefix>(); prefixes = new HashSet<IpPrefix>();
dnses = new HashSet<Inet6Address>(); dnses = new HashSet<Inet6Address>();
@@ -133,6 +143,7 @@ public class RouterAdvertisementDaemon {
public RaParams(RaParams other) { public RaParams(RaParams other) {
hasDefaultRoute = other.hasDefaultRoute; hasDefaultRoute = other.hasDefaultRoute;
hopLimit = other.hopLimit;
mtu = other.mtu; mtu = other.mtu;
prefixes = (HashSet) other.prefixes.clone(); prefixes = (HashSet) other.prefixes.clone();
dnses = (HashSet) other.dnses.clone(); dnses = (HashSet) other.dnses.clone();
@@ -273,10 +284,12 @@ public class RouterAdvertisementDaemon {
final ByteBuffer ra = ByteBuffer.wrap(mRA); final ByteBuffer ra = ByteBuffer.wrap(mRA);
ra.order(ByteOrder.BIG_ENDIAN); ra.order(ByteOrder.BIG_ENDIAN);
final boolean haveRaParams = (mRaParams != null);
boolean shouldSendRA = false; boolean shouldSendRA = false;
try { try {
putHeader(ra, mRaParams != null && mRaParams.hasDefaultRoute); putHeader(ra, haveRaParams && mRaParams.hasDefaultRoute,
haveRaParams ? mRaParams.hopLimit : RaParams.DEFAULT_HOPLIMIT);
putSlla(ra, mInterface.macAddr.toByteArray()); putSlla(ra, mInterface.macAddr.toByteArray());
mRaLength = ra.position(); mRaLength = ra.position();
@@ -287,7 +300,7 @@ public class RouterAdvertisementDaemon {
// //
// putExpandedFlagsOption(ra); // putExpandedFlagsOption(ra);
if (mRaParams != null) { if (haveRaParams) {
putMtu(ra, mRaParams.mtu); putMtu(ra, mRaParams.mtu);
mRaLength = ra.position(); mRaLength = ra.position();
@@ -348,7 +361,7 @@ public class RouterAdvertisementDaemon {
private static byte asByte(int value) { return (byte) value; } private static byte asByte(int value) { return (byte) value; }
private static short asShort(int value) { return (short) value; } private static short asShort(int value) { return (short) value; }
private static void putHeader(ByteBuffer ra, boolean hasDefaultRoute) { private static void putHeader(ByteBuffer ra, boolean hasDefaultRoute, byte hopLimit) {
/** /**
Router Advertisement Message Format Router Advertisement Message Format
@@ -366,11 +379,10 @@ public class RouterAdvertisementDaemon {
| Options ... | Options ...
+-+-+-+-+-+-+-+-+-+-+-+- +-+-+-+-+-+-+-+-+-+-+-+-
*/ */
final byte DEFAULT_HOPLIMIT = 64;
ra.put(ICMPV6_ND_ROUTER_ADVERT) ra.put(ICMPV6_ND_ROUTER_ADVERT)
.put(asByte(0)) .put(asByte(0))
.putShort(asShort(0)) .putShort(asShort(0))
.put(DEFAULT_HOPLIMIT) .put(hopLimit)
// RFC 4191 "high" preference, iff. advertising a default route. // RFC 4191 "high" preference, iff. advertising a default route.
.put(hasDefaultRoute ? asByte(0x08) : asByte(0)) .put(hasDefaultRoute ? asByte(0x08) : asByte(0))
.putShort(hasDefaultRoute ? asShort(DEFAULT_LIFETIME) : asShort(0)) .putShort(hasDefaultRoute ? asShort(DEFAULT_LIFETIME) : asShort(0))