When an inbound pfil hook chooses the next hop (ipfw fwd),
ip_tryforward() looks up the route to it and keeps the address in dest,
which if_output() gets as the next hop when the route has no gateway.
After the outbound hooks dest is set back to the destination of the
packet. ipfw always installs an outbound hook, so a packet forwarded
to a next hop on a connected network leaves on the right interface but
for the wrong neighbour: the router tries to resolve the destination
of the packet there ("arpresolve: can't allocate llinfo") and the
packet is lost. This worked until 9ac7c6cfed72, before which the
address came from the route lookup.
Set dest from the packet only when the outbound hooks changed the
destination or chose a next hop. To tell, compare with the destination
as it was before these hooks, as ip6_tryforward() does; the comparison
with the destination before the inbound hooks also dropped the next hop
of a packet whose destination an inbound hook had rewritten.
Fixes: 9ac7c6cfed72 ("Convert IP/IPv6 forwarding, ICMP processing...")
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")