@@ -51,8 +51,8 @@ bool FloodingRouter::shouldFilterReceived(const meshtastic_MeshPacket *p)
5151 LOG_DEBUG (" Repeated reliable tx" );
5252 // Check if it's still in the Tx queue, if not, we have to relay it again
5353 if (!findInTxQueue (p->from , p->id )) {
54- reprocessPacket (p);
55- perhapsRebroadcast (p);
54+ if ( reprocessPacket (p))
55+ perhapsRebroadcast (p);
5656 }
5757 } else {
5858 perhapsCancelDupe (p);
@@ -68,14 +68,21 @@ bool FloodingRouter::perhapsHandleUpgradedPacket(const meshtastic_MeshPacket *p)
6868{
6969 // isRebroadcaster() is duplicated in perhapsRebroadcast(), but this avoids confusing log messages
7070 if (isRebroadcaster () && iface && p->hop_limit > 0 ) {
71+ // Verify the replacement before deleting the valid lower-hop copy waiting in the TX queue.
72+ // This is intentionally redundant with ReliableRouter's ingress gate: it keeps this helper
73+ // safe if another caller is introduced later.
74+ if (passesRoutingAuthGate (const_cast <meshtastic_MeshPacket *>(p)) != RoutingAuthVerdict::ACCEPT )
75+ return true ;
76+
7177 // If we overhear a duplicate copy of the packet with more hops left than the one we are waiting to
7278 // rebroadcast, then remove the packet currently sitting in the TX queue and use this one instead.
7379 uint8_t dropThreshold = p->hop_limit ; // remove queued packets that have fewer hops remaining
7480 if (iface->removePendingTXPacket (getFrom (p), p->id , dropThreshold)) {
7581 LOG_DEBUG (" Processing upgraded packet 0x%08x for rebroadcast with hop limit %d (dropping queued < %d)" , p->id ,
7682 p->hop_limit , dropThreshold);
7783
78- reprocessPacket (p);
84+ if (!reprocessPacket (p))
85+ return true ;
7986 perhapsRebroadcast (p);
8087
8188 rxDupe++;
@@ -87,32 +94,24 @@ bool FloodingRouter::perhapsHandleUpgradedPacket(const meshtastic_MeshPacket *p)
8794 return false ;
8895}
8996
90- void FloodingRouter::reprocessPacket (const meshtastic_MeshPacket *p)
97+ bool FloodingRouter::reprocessPacket (const meshtastic_MeshPacket *p)
9198{
99+ if (p->which_payload_variant != meshtastic_MeshPacket_decoded_tag) {
100+ auto decodedState = perhapsDecode (const_cast <meshtastic_MeshPacket *>(p));
101+ if (decodedState != DecodeState::DECODE_SUCCESS && decodedState != DecodeState::DECODE_OPAQUE )
102+ return false ;
103+ }
104+
92105 if (nodeDB)
93106 nodeDB->updateFrom (*p);
94107
95108#if !MESHTASTIC_EXCLUDE_TRACEROUTE
96- if (traceRouteModule && p->which_payload_variant != meshtastic_MeshPacket_decoded_tag) {
97- // If we got a packet that is not decoded, try to decode it so we can check for traceroute.
98- auto decodedState = perhapsDecode (const_cast <meshtastic_MeshPacket *>(p));
99- if (decodedState == DecodeState::DECODE_SUCCESS ) {
100- // parsing was successful, print for debugging
101- printPacket (" reprocessPacket(DUP)" , p);
102- } else {
103- // Fatal decoding error, we can't do anything with this packet
104- LOG_WARN (
105- " FloodingRouter::reprocessPacket: Fatal decode error (state=%d, id=0x%08x, from=%u), can't check for traceroute" ,
106- static_cast <int >(decodedState), p->id , getFrom (p));
107- return ;
108- }
109- }
110-
111109 if (traceRouteModule && p->which_payload_variant == meshtastic_MeshPacket_decoded_tag &&
112110 p->decoded .portnum == meshtastic_PortNum_TRACEROUTE_APP) {
113111 traceRouteModule->processUpgradedPacket (*p);
114112 }
115113#endif
114+ return true ;
116115}
117116
118117bool FloodingRouter::roleAllowsCancelingDupe (const meshtastic_MeshPacket *p)
0 commit comments