dsdv: Do not send queued packets when the next-hop lookup fails

Fixes the crash reported in #1364 (same backtrace as #503 (closed)).

LookForQueuedPackets() discarded LookupRoute()'s return value and forwarded queued packets on the default-constructed entry. Because RoutingTableEntry's constructor unconditionally allocates the Ipv4Route, the entry's route is a non-null Ptr with a null output device — so the NS_ASSERT (route) on the next line can never fire (the assert !1652 (merged) reordered), SendRealOut's !route guard passes, and GetInterfaceForDevice (nullptr) returns −1: an assert in the default profile, a silent SIGSEGV in optimized.

This applies the same guarded idiom RouteOutput() already uses eleven lines earlier in the same file: on a failed lookup, log and leave the packets queued.

Verified with the reproducer from #1364 on master b677fede:

  • stock: NS_ASSERT failed, cond="interface >= 0" ... ipv4-l3-protocol.cc:960 (default) / exit 139 with empty stderr (optimized)
  • with this MR: no crash in either profile
  • controls unchanged: aodv/olsr/rip on the identical topology, and single-interface DSDV (--nNodes=2), all deliver as before

Scope note, stated plainly: this is a memory-safety fix, not a functional one. On the multi-interface reproducer the fixed build delivers 0 bytes — DSDV's self-advertisement uses a hardcoded GetAddress (1, 0), so a multi-interface node's other addresses are never announced and its neighbours' next hops never resolve (details in #1364). Multi-interface DSDV therefore remains non-routing after this MR; it just stops crashing/corrupting. The advertisement defect is proposed as a follow-up in #1364 rather than bundled here.

Merge request reports

Loading
Loading