On 21/06/2018 09:21, Edgar Fuß wrote:
See ip(4) which describes a CMSG instruction called IP_PKTINFOAh, thanks. Unfortunately, this doesn't seem to be available in 6, which my production servers are still on.where you can set ipi_ifindex to the index of the outbound interface.The manpage (from 7) says The IP_PKTINFO option can be used to turn on receiving of information about the source address of the packet, and the interface index. which doesn't sound (to me) like you can set the outgoing interface. What does dhcpcd do? If it doesen't go the bpf route, can you point me at the relevant code?
For all platforms, dhcpcd uses BPF for ARP and BOOTP/DHCP requests.This is because not many platforms dhcpcd supports support IP_PKTINFO and even some don't support it for sending. In any case, I would need to bind to the unspecified address which would then rule out running a dhcpcd instance per interface which is how some people like to run it (because rc.conf *must* control everything it seems).
However, for RA and DHCP6, dhcpcd can bind to the unspecified address OR the LL address. You can find this implementation here:
https://roy.marples.name/git/dhcpcd.git/tree/src/ipv6nd.c#n304 https://roy.marples.name/git/dhcpcd.git/tree/src/dhcp6.c#n1310 Roy