How force a route with ip6_output

From: Kajetan Staszkiewicz <vegeta_at_tuxpowered.net>
Date: Tue, 22 Aug 2023 18:05:32 UTC
Hello, group

I'm experimenting with another approach to pf route-to issues mentioned 
in D41517 and I can't get ip6_output do what I want.

How does one force ip6_output to use the provided next hop? ip_output 
does not seem to have problems with that. As long as ro and ro->nh are 
not NULL it will just do

dst = (struct sockaddr_in *)&ro->ro_dst;
…
gw = (const struct sockaddr *)dst;

and use those without calling fib4_lookup()


But I don't see the same logic in ip6_output. There's this check:

if (ro->ro_nh != NULL && fwd_tag == NULL &&
     ro->ro_dst.sin6_family == AF_INET6 &&
     IN6_ARE_ADDR_EQUAL(&ro->ro_dst.sin6_addr, &ip6->ip6_dst)) {
	/* Nexthop is valid and contains valid ifp */
	nh = ro->ro_nh;
}

Which fails beause the IP address in ro_dst is different than in ip6_dst 
- I am routing traffic to some host over a gateway different than that host.

The next block of code deals with fwd_tag, which I have not used, so it 
restores the destination for lookup to back to ip6->ip6_dst and that 
prevents ip6_output from using the supplied route.

Am I holding it wrong?

-- 
| pozdrawiam / greetings | Powered by macOS, Debian and FreeBSD |
|  Kajetan Staszkiewicz  |  www: http://vegeta.tuxpowered.net   |
`------------------------^--------------------------------------'