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

Commit 810fae4d authored by Erik Kline's avatar Erik Kline Committed by android-build-merger
Browse files

Merge "Use IPv6 hop limit from upstream interface." am: 53f6d1b0

am: 30a90a4e

Change-Id: I9d3cca6e7a2963de13153ae21fd6a328d0a7025c
parents 3f758d8e 30a90a4e
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -430,6 +430,8 @@ public class IpServer extends StateMachine {
            params.mtu = v6only.getMtu();
            params.hasDefaultRoute = v6only.hasIPv6DefaultRoute();

            if (params.hasDefaultRoute) params.hopLimit = getHopLimit(v6only.getInterfaceName());

            for (LinkAddress linkAddr : v6only.getLinkAddresses()) {
                if (linkAddr.getPrefixLength() != RFC7421_PREFIX_LENGTH) continue;

@@ -549,6 +551,20 @@ public class IpServer extends StateMachine {
        }
    }

    private byte getHopLimit(String upstreamIface) {
        try {
            int upstreamHopLimit = Integer.parseUnsignedInt(
                    mNetd.getProcSysNet(INetd.IPV6, INetd.CONF, upstreamIface, "hop_limit"));
            // Add one hop to account for this forwarding device
            upstreamHopLimit++;
            // Cap the hop limit to 255.
            return (byte) Integer.min(upstreamHopLimit, 255);
        } catch (Exception e) {
            mLog.e("Failed to find upstream interface hop limit", e);
        }
        return RaParams.DEFAULT_HOPLIMIT;
    }

    private void setRaParams(RaParams newParams) {
        if (mRaDaemon != null) {
            final RaParams deprecatedParams =