Let's say openvpn 2.2.0
In function link_socket_read_udp_posix_recvmsg() writes:
struct cmsghdr *cmsg;
fromlen = mesg.msg_namelen;
cmsg = CMSG_FIRSTHDR (&mesg);
if (cmsg != NULL
&& CMSG_NXTHDR (&mesg, cmsg) == NULL
#ifdef IP_PKTINFO
&& cmsg->cmsg_level == SOL_IP
&& cmsg->cmsg_type == IP_PKTINFO
#elif defined(IP_RECVDSTADDR)
&& cmsg->cmsg_level == IPPROTO_IP
&& cmsg->cmsg_type == IP_RECVDSTADDR
#else
#error ENABLE_IP_PKTINFO is set without IP_PKTINFO xor IP_RECVDSTADDR (fix
syshead.h)
#endif
&& cmsg->cmsg_len >= sizeof (struct openvpn_in4_pktinfo))
{
#ifdef IP_PKTINFO
struct in_pktinfo *pkti = (struct in_pktinfo *) CMSG_DATA (cmsg);
from->pi.in4.ipi_ifindex = pkti->ipi_ifindex;
from->pi.in4.ipi_spec_dst = pkti->ipi_spec_dst;
#elif defined(IP_RECVDSTADDR)
from->pi.in4 = *(struct in_addr*) CMSG_DATA (cmsg);
#else
#error ENABLE_IP_PKTINFO is set without IP_PKTINFO xor IP_RECVDSTADDR (fix
syshead.h)
#endif
}
I looked up manpages and other web resources, normally they iterated in the
cmsghdr list then find the required information by
for (cmsg = CMSG_FIRSTHDR(&mesg); cmsg; cmsg = CMSG_NXTHDR(&mesg, cmsg))
if (cmsg->cmsg_level == SOL_IP && cmsg->cmsg_type == IP_PKTINFO
&& ... ) {
}
In the openvpn's code, it only examine the FIRSTHDR, and assuming CMSG_NXTHDR =
NULL, which is odd.
Anybody get "--multihome" worked?
--
Sincerely,
Yang Zhe