Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 666bb5cf authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

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

parents beeb35f0 abb70339
Loading
Loading
Loading
Loading
+17 −5
Original line number Diff line number Diff line
@@ -119,13 +119,23 @@ public class RouterAdvertisementDaemon {
    private volatile UnicastResponder mUnicastResponder;

    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 byte hopLimit;
        public int mtu;
        public HashSet<IpPrefix> prefixes;
        public HashSet<Inet6Address> dnses;

        public RaParams() {
            hasDefaultRoute = false;
            hopLimit = DEFAULT_HOPLIMIT;
            mtu = IPV6_MIN_MTU;
            prefixes = new HashSet<IpPrefix>();
            dnses = new HashSet<Inet6Address>();
@@ -133,6 +143,7 @@ public class RouterAdvertisementDaemon {

        public RaParams(RaParams other) {
            hasDefaultRoute = other.hasDefaultRoute;
            hopLimit = other.hopLimit;
            mtu = other.mtu;
            prefixes = (HashSet) other.prefixes.clone();
            dnses = (HashSet) other.dnses.clone();
@@ -273,10 +284,12 @@ public class RouterAdvertisementDaemon {
        final ByteBuffer ra = ByteBuffer.wrap(mRA);
        ra.order(ByteOrder.BIG_ENDIAN);

        final boolean haveRaParams = (mRaParams != null);
        boolean shouldSendRA = false;

        try {
            putHeader(ra, mRaParams != null && mRaParams.hasDefaultRoute);
            putHeader(ra, haveRaParams && mRaParams.hasDefaultRoute,
                    haveRaParams ? mRaParams.hopLimit : RaParams.DEFAULT_HOPLIMIT);
            putSlla(ra, mInterface.macAddr.toByteArray());
            mRaLength = ra.position();

@@ -287,7 +300,7 @@ public class RouterAdvertisementDaemon {
            //
            // putExpandedFlagsOption(ra);

            if (mRaParams != null) {
            if (haveRaParams) {
                putMtu(ra, mRaParams.mtu);
                mRaLength = ra.position();

@@ -348,7 +361,7 @@ public class RouterAdvertisementDaemon {
    private static byte asByte(int value) { return (byte) 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

@@ -366,11 +379,10 @@ public class RouterAdvertisementDaemon {
            |   Options ...
            +-+-+-+-+-+-+-+-+-+-+-+-
        */
        final byte DEFAULT_HOPLIMIT = 64;
        ra.put(ICMPV6_ND_ROUTER_ADVERT)
          .put(asByte(0))
          .putShort(asShort(0))
          .put(DEFAULT_HOPLIMIT)
          .put(hopLimit)
          // RFC 4191 "high" preference, iff. advertising a default route.
          .put(hasDefaultRoute ? asByte(0x08) : asByte(0))
          .putShort(hasDefaultRoute ? asShort(DEFAULT_LIFETIME) : asShort(0))