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

Commit 3edb9bab authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Don't crash when receiving an RTM_DELNEIGH or NUD_FAILED." into rvc-dev

parents c026d54c 8bc1e54d
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -122,6 +122,8 @@ public class IpServer extends StateMachine {
    // TODO: have this configurable
    private static final int DHCP_LEASE_TIME_SECS = 3600;

    private static final MacAddress NULL_MAC_ADDRESS = MacAddress.fromString("00:00:00:00:00:00");

    private static final String TAG = "IpServer";
    private static final boolean DBG = false;
    private static final boolean VDBG = false;
@@ -902,9 +904,12 @@ public class IpServer extends StateMachine {
            return;
        }

        // When deleting rules, we still need to pass a non-null MAC, even though it's ignored.
        // Do this here instead of in the Ipv6ForwardingRule constructor to ensure that we never
        // add rules with a null MAC, only delete them.
        MacAddress dstMac = e.isValid() ? e.macAddr : NULL_MAC_ADDRESS;
        Ipv6ForwardingRule rule = new Ipv6ForwardingRule(upstreamIfindex,
                mInterfaceParams.index, (Inet6Address) e.ip, mInterfaceParams.macAddr,
                e.macAddr);
                mInterfaceParams.index, (Inet6Address) e.ip, mInterfaceParams.macAddr, dstMac);
        if (e.isValid()) {
            addIpv6ForwardingRule(rule);
        } else {
+5 −3
Original line number Diff line number Diff line
@@ -587,6 +587,7 @@ public class IpServerTest {
        final InetAddress neighB = InetAddresses.parseNumericAddress("2001:db8::2");
        final InetAddress neighLL = InetAddresses.parseNumericAddress("fe80::1");
        final InetAddress neighMC = InetAddresses.parseNumericAddress("ff02::1234");
        final MacAddress macNull = MacAddress.fromString("00:00:00:00:00:00");
        final MacAddress macA = MacAddress.fromString("00:00:00:00:00:0a");
        final MacAddress macB = MacAddress.fromString("11:22:33:00:00:0b");

@@ -612,13 +613,14 @@ public class IpServerTest {
        verifyNoMoreInteractions(mNetd);

        // A neighbor that is no longer valid causes the rule to be removed.
        recvNewNeigh(myIfindex, neighA, NUD_FAILED, macA);
        verify(mNetd).tetherOffloadRuleRemove(matches(UPSTREAM_IFINDEX, neighA, macA));
        // NUD_FAILED events do not have a MAC address.
        recvNewNeigh(myIfindex, neighA, NUD_FAILED, null);
        verify(mNetd).tetherOffloadRuleRemove(matches(UPSTREAM_IFINDEX, neighA, macNull));
        reset(mNetd);

        // A neighbor that is deleted causes the rule to be removed.
        recvDelNeigh(myIfindex, neighB, NUD_STALE, macB);
        verify(mNetd).tetherOffloadRuleRemove(matches(UPSTREAM_IFINDEX, neighB, macB));
        verify(mNetd).tetherOffloadRuleRemove(matches(UPSTREAM_IFINDEX, neighB, macNull));
        reset(mNetd);

        // Upstream changes result in deleting and re-adding the rules.