ip_output has a big chunk of code used to handle special cases with pfil consumers which also forces a reloop on it.
Gather all this code together to make it readable and properly handle the reloop cases.
Some of the issues identified:
- M_IP_NEXTHOP is not handled properly in existing code.
- route reference leaking is possible with in FIB number change
- route flags checking is not consistent in the function