Skip to contentSkip to conversation

Repair --multihome on FreeBSD for IPv4 sockets.

PATCH In review Gert Doering 1 participant 3 messages Jan 19, 2014 – Apr 25, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Repair --multihome on FreeBSD for IPv4 sockets.

The code in link_socket_write_udp_posix_sendmsg() for the IP_RECVDESTADDR case was sending a too-large control message (sizeof openvpn_pktinfo, which is a union for IPv4+IPv6) instead of just openvpn_in4_pktinfo, leading to sendmsg() refusing to send the packet.

Use RFC 2292 macros for alignment + size calculation.

Fix trac#327

---
 src/openvpn/socket.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
src/openvpn/socket.c +6 -2
index 100eedd..525b864 100644
@@ -2835,11 +2835,11 @@ link_socket_write_udp_posix_sendmsg (struct link_socket *sock,
         mesg.msg_name = &to->dest.addr.sa;
         mesg.msg_namelen = sizeof (struct sockaddr_in);
         mesg.msg_control = &opi;
-        mesg.msg_controllen = sizeof (struct openvpn_in4_pktinfo);
         mesg.msg_flags = 0;
+#ifdef HAVE_IN_PKTINFO
+        mesg.msg_controllen = sizeof (struct openvpn_in4_pktinfo);
         cmsg = CMSG_FIRSTHDR (&mesg);
         cmsg->cmsg_len = sizeof (struct openvpn_in4_pktinfo);
-#ifdef HAVE_IN_PKTINFO
         cmsg->cmsg_level = SOL_IP;
         cmsg->cmsg_type = IP_PKTINFO;
 	{
@@ -2850,6 +2850,10 @@ link_socket_write_udp_posix_sendmsg (struct link_socket *sock,
         pkti->ipi_addr.s_addr = 0;
 	}
 #elif defined(IP_RECVDSTADDR)
+	ASSERT( CMSG_SPACE(sizeof (struct in_addr)) <= sizeof(opi) );
+        mesg.msg_controllen = CMSG_SPACE(sizeof (struct in_addr));
+        cmsg = CMSG_FIRSTHDR (&mesg);
+        cmsg->cmsg_len = CMSG_LEN(sizeof(struct in_addr));
         cmsg->cmsg_level = IPPROTO_IP;
         cmsg->cmsg_type = IP_RECVDSTADDR;
         *(struct in_addr *) CMSG_DATA (cmsg) = to->pi.in4;
Signature · 1 line
1.8.3.2
#1 lore raw

As announced at the IRC meeting yesterday, I decided to apply lazy ACK rules here. The code is tested, fixes an actual bug, and nobody NAKed it for 4 months...

Patch has been applied to the master and release/2.3 branches.

commit 661d914c8732a208580b1eab167255c85da162c9 (master) commit fc759c2eb4fbf0792d0052966fcf36efebc5bf5d (master)

Author: Gert Doering
Date:   Sun Jan 19 21:51:37 2014 +0100
     Repair --multihome on FreeBSD for IPv4 sockets.

     Signed-off-by: Gert Doering <[email protected]...>
     Lazy-Ack-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: http://article.gmane.org/gmane.network.openvpn.devel/8250

--
kind regards,

Gert Doering

#2 lore raw

Hi,

Quoted 4 lines · Gert Doering

Patch has been applied to the master and release/2.3 branches.

commit 661d914c8732a208580b1eab167255c85da162c9 (master) commit fc759c2eb4fbf0792d0052966fcf36efebc5bf5d (master)

The second line is release/2.3, obviously. Sorry.

gert

Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
                                                           //www.muc.de/~gert/
Gert Doering - Munich, Germany                             [email protected]...
fax: +49-89-35655025                        [email protected]...