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

Commit 8e492f8d authored by Erik Kline's avatar Erik Kline
Browse files

Use IPv6 hop limit from upstream interface.

Test: as follows
    - built, flashed, booted
    - runtest frameworks-net passes
    - manually setting /proc/sys/net/ipv6/<upiface>/conf/hop_limit
      to various value yields RAs with expected hop limit settings
      in downstream RAs
Bug: 32163131
Change-Id: I248154ca9d836318bf21a2971d0884040525d9fc
parent 74152194
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 =