tech-net archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: IP_PKTINFO, sendmsg(2) and routing.





On 09/02/2019 16:35, Tom Ivar Helbekkmo wrote:
Dennis Ferguson <dennis.c.ferguson%gmail.com@localhost> writes:

It should send the packet out the IP_PKTINFO interface if packet is sent
with MSG_DONTROUTE/SO_DONTROUTE. If this isn’t working it should probably
be made to, routing protocols in general depend on being able to do that.

I believe I was the last person to make significant changes to this
code, about a year ago.  The plan for my changes back then is here:
https://mail-index.netbsd.org/tech-net/2017/12/28/msg006579.html
...and the completed result was presented here:
https://mail-index.netbsd.org/tech-net/2017/12/31/msg006591.html

The bit that does the actual work on an outgoing packet is the function
ip_pktinfo_prepare() in sys/netinet/ip_output.c.  The way it is now
works for all the software I've seen that uses it, but I've never seen
those *_DONTROUTE options used.  Note, though, that we set the
IP_ROUTETOIFINDEX flag if an interface was specified, and I believe this
ends up doing what you say it should.

If you can point me to some clear information on how IP_PKTINFO should
behave in various configurations of multi-homed machines, to satisfy
routing protocol implementations, I'd love to play with it, and get our
implementation to do the right thing.

https://nxr.netbsd.org/xref/src/sys/netinet/ip_output.c#1167
Well the most obvious thing that I would say is "wrong" is that it boils down to an address. If I don't give an address, the implementation shouldn't use one. I just want it to go out of the specified interface.

As a side effect of this implementation, it won't work if the same address is present on more than one interface which is not only possible, but last I checked, supported by our stack.

Where it starts to get interesting is how we handle ARP, which is also tied into our routing. In theory, the interface we want the packet to go out on should also be used for ARP resolution, but there is no guarantee that the prefix route for it is on the same interface.
It might well be that we need route metrics to get it to work well.

But, in a nutshell, the most basic multi-homed implementation is the DHCP client. IP_PKTINFO allows us NOT to need BPF. We should be able to send from the unspecified address to the broadcast address on a specific interface using IP_PKTINFO for the DHCP_DISCOVER message.

Now, if we could send and receive ARP without BPF then dhcpcd woudln't need BPF at all, but that's starting to get out of scope of this conversation, so I'll shutup now.

Roy


Home | Main Index | Thread Index | Old Index