On Mi, 2017-02-22 at 20:51 +0000, Simon Kelley wrote:
> > You can get the destination address for datagrams from the
> > IP_PTKINFO auxiliary data:
> > 
> > man 7 ip IP_PKTINFO (since Linux 2.2) Pass an IP_PKTINFO ancillary
> > message that contains a pktinfo structure that supplies some
> > information about the incoming packet. This only works for datagram
> > oriented sockets.  The argument is a flag that tells the socket
> > whether the IP_PKTINFO message should be passed or not. The message
> > itself can only be sent/retrieved as control message with a packet
> > using recvmsg(2) or sendmsg(2).
> > 
> > struct in_pktinfo { unsigned int   ipi_ifindex;  /* Interface index
> > */ struct in_addr ipi_spec_dst; /* Local address */ struct in_addr
> > ipi_addr;     /* Header Destination address */ };
> > 
> 
> Indeed. And that gives you, in one hand, the destination address of
> the datagram, and in the other hand, a whitelist of interface labels.
> The only way to compare the two is to enumerate all the interfaces
> using the netlink interface, which gives you all the addresses of
> each
> interface and their associated labels. If the interface set and
> configuration can change arbitrarily, you need to do that for every
> datagram, which gets expensive.

But you can also be notified about interface changes via a netlink
socket, so you can cache the interface information.

Regards,

Stefan
_______________________________________________
Dnsmasq-discuss mailing list
Dnsmasq-discuss@lists.thekelleys.org.uk
http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss

Reply via email to