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

Commit 98e7e0a1 authored by Remi NGUYEN VAN's avatar Remi NGUYEN VAN Committed by Automerger Merge Worker
Browse files

Merge "Fix potential exceptions in FdEventReader users" am: 10ebb3db am:...

Merge "Fix potential exceptions in FdEventReader users" am: 10ebb3db am: 5d5e7442 am: 9978071c am: 32ac8f27 am: 8fd33477

Change-Id: I7cd28b9a897df399bef6d86b84341ffdb1252147
parents 775fd8bb 8fd33477
Loading
Loading
Loading
Loading
+17 −13
Original line number Diff line number Diff line
@@ -106,6 +106,7 @@ public class NetlinkMonitor extends PacketReader {
        byteBuffer.order(ByteOrder.nativeOrder());

        while (byteBuffer.remaining() > 0) {
            try {
                final int position = byteBuffer.position();
                final NetlinkMessage nlMsg = NetlinkMessage.parse(byteBuffer);
                if (nlMsg == null || nlMsg.getHeader() == null) {
@@ -120,6 +121,9 @@ public class NetlinkMonitor extends PacketReader {
                }

                processNetlinkMessage(nlMsg, whenMs);
            } catch (Throwable e) {
                mLog.e("Error handling netlink message", e);
            }
        }
    }

+2 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.os.Looper;
import android.os.MessageQueue;
import android.system.ErrnoException;
import android.system.OsConstants;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -244,6 +245,7 @@ public abstract class FdEventsReader<BufferType> {
                handlePacket(mBuffer, bytesRead);
            } catch (Exception e) {
                logError("handlePacket error: ", e);
                Log.wtf(FdEventsReader.class.getSimpleName(), "Error handling packet: stopping", e);
                break;
            }
        }
+3 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.net.dhcp;
import android.net.util.FdEventsReader;
import android.os.Handler;
import android.system.Os;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -59,6 +60,8 @@ abstract class DhcpPacketListener extends FdEventsReader<DhcpPacketListener.Payl
            onReceive(packet, recvbuf.mSrcAddr, recvbuf.mSrcPort);
        } catch (DhcpPacket.ParseException e) {
            logParseError(recvbuf.mBytes, length, e);
        } catch (Throwable e) {
            Log.wtf(DhcpPacketListener.class.getSimpleName(), "Error handling DHCP packet", e);
        }
    }

+8 −3
Original line number Diff line number Diff line
@@ -133,9 +133,14 @@ public class ConnectivityPacketTracker {
                return;
            }

            final String summary = ConnectivityPacketSummary.summarize(
                    mInterface.macAddr, recvbuf, length);
            final String summary;
            try {
                summary = ConnectivityPacketSummary.summarize(mInterface.macAddr, recvbuf, length);
                if (summary == null) return;
            } catch (Exception e) {
                if (DBG) Log.d(mTag, "Error creating packet summary", e);
                return;
            }

            if (DBG) Log.d(mTag, summary);
            addLogEntry(summary + "\n[" + HexDump.toHexString(recvbuf, 0, length) + "]");
+12 −3
Original line number Diff line number Diff line
@@ -340,7 +340,14 @@ public class IpReachabilityMonitor {
            // TODO: Consider using NeighborEvent#isValid() here; it's more
            // strict but may interact badly if other entries are somehow in
            // NUD_INCOMPLETE (say, during network attach).
            if (entry.getValue().nudState != StructNdMsg.NUD_FAILED) continue;
            final NeighborEvent val = entry.getValue();

            // Find all the neighbors that have gone into FAILED state.
            // Ignore entries for which we have never received an event. If there are neighbors
            // that never respond to ARP/ND, the kernel will send several FAILED event, then
            // an INCOMPLETE event, and then more FAILED events. The INCOMPLETE event will
            // populate the map and the subsequent FAILED event will be processed.
            if (val == null || val.nudState != StructNdMsg.NUD_FAILED) continue;

            ip = entry.getKey();
            for (RouteInfo route : mLinkProperties.getRoutes()) {
@@ -377,10 +384,12 @@ public class IpReachabilityMonitor {
                Log.d(TAG, "neighbour IPv4(v6): " + entry.getKey() + " neighbour state: "
                        + StructNdMsg.stringForNudState(entry.getValue().nudState));
            }
            if (entry.getValue().nudState != StructNdMsg.NUD_REACHABLE) return;
            final NeighborEvent val = entry.getValue();
            // If an entry is null, consider that probing for that neighbour has completed.
            if (val == null || val.nudState != StructNdMsg.NUD_REACHABLE) return;
        }

        // All neighbours in the watchlist are in REACHABLE state and connection is stable,
        // Probing for all neighbours in the watchlist is complete and the connection is stable,
        // restore NUD probe parameters to steadystate value. In the case where neighbours
        // are responsive, this code will run before the wakelock expires.
        setNeighbourParametersForSteadyState();
Loading