Skip to contentSkip to conversation

Fixing "passtos" on !Linux

Openvpn-devel Jeremie Le Hen 4 participants 7 messages Dec 17, 2012 – Dec 20, 2012

lore
Share & tools
lore
#0 lore raw

Hi!

On non-Linux systems (that is I checked on FreeBSD, NetBSD, OpenBSD, DragonflyBSD, Darwin, Solaris and IllumOS), setsockopt(2) with the IP_TOS option expects a pointer to a int rather than a char. Therefore this doesn't work on little-endian systems (x86 is the main victim).

The problem is well understood, a fix has been posted by Torsten Vielhak on the bug tracker nearly 2 years ago but the problem has remained ignored, probably because the author didn't bring it to your attention. The patch only handled FreeBSD though. See ticket/135.

I thereby kindly ask you to bring this patch in the source tree. I don't know about your release procedure, but it would be really nice if it could hit the tree before 2.3 is released.

Relevant manpages:
http://www.freebsd.org/cgi/man.cgi?query=ip&format=html
http://netbsd.gw.com/cgi-bin/man-cgi?ip
http://www.openbsd.org/cgi-bin/man.cgi?query=ip&format=html
http://leaf.dragonflybsd.org/cgi/web-man?command=ip&section=ANY
https://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man4/ip.4.html
http://docs.oracle.com/cd/E19082-01/819-2254/ip-7p/index.html
http://illumos.org/man/7p/ip

src/openvpn/socket.h +14 -0
index 9cb01fa..07224c4 100644
@@ -237,7 +237,21 @@ struct link_socket
 
 #if PASSTOS_CAPABILITY
   /* used to get/set TOS. */
+#if defined(TARGET_LINUX)
   uint8_t ptos;
+#elif defined(TARGET_SOLARIS)
+  int ptos;
+#elif defined(TARGET_OPENBSD)
+  int ptos;
+#elif defined(TARGET_NETBSD)
+  int ptos;
+#elif defined(TARGET_FREEBSD)
+  int ptos;
+#elif defined(TARGET_DRAGONFLY)
+  int ptos;
+#elif defined(TARGET_DARWIN)
+  int ptos;
+#endif
   bool ptos_defined;
 #endif
 

Cheers,

Signature · 4 lines
Jeremie Le Hen                        jeremie.le-hen.org jlh.freebsd.org
                              (emails above use SOA record-style format)
Scientists say the world is made up of Protons, Neutrons and Electrons.
They forgot to mention Morons.
#1 lore raw

Hi again,

I saw that 2.3-RC2 has been released. Any chance to get this committed before the release?

Regards,

Quoted 59 lines · Jeremie Le Hen

Hi!

On non-Linux systems (that is I checked on FreeBSD, NetBSD, OpenBSD, DragonflyBSD, Darwin, Solaris and IllumOS), setsockopt(2) with the IP_TOS option expects a pointer to a int rather than a char. Therefore this doesn't work on little-endian systems (x86 is the main victim).

The problem is well understood, a fix has been posted by Torsten Vielhak on the bug tracker nearly 2 years ago but the problem has remained ignored, probably because the author didn't bring it to your attention. The patch only handled FreeBSD though. See ticket/135.

I thereby kindly ask you to bring this patch in the source tree. I don't know about your release procedure, but it would be really nice if it could hit the tree before 2.3 is released.

Relevant manpages:
http://www.freebsd.org/cgi/man.cgi?query=ip&format=html
http://netbsd.gw.com/cgi-bin/man-cgi?ip
http://www.openbsd.org/cgi-bin/man.cgi?query=ip&format=html
http://leaf.dragonflybsd.org/cgi/web-man?command=ip&section=ANY
https://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man4/ip.4.html
http://docs.oracle.com/cd/E19082-01/819-2254/ip-7p/index.html
http://illumos.org/man/7p/ip

src/openvpn/socket.h +14 -0
index 9cb01fa..07224c4 100644
@@ -237,7 +237,21 @@ struct link_socket
 
 #if PASSTOS_CAPABILITY
   /* used to get/set TOS. */
+#if defined(TARGET_LINUX)
   uint8_t ptos;
+#elif defined(TARGET_SOLARIS)
+  int ptos;
+#elif defined(TARGET_OPENBSD)
+  int ptos;
+#elif defined(TARGET_NETBSD)
+  int ptos;
+#elif defined(TARGET_FREEBSD)
+  int ptos;
+#elif defined(TARGET_DRAGONFLY)
+  int ptos;
+#elif defined(TARGET_DARWIN)
+  int ptos;
+#endif
   bool ptos_defined;
 #endif
 

Cheers,

Signature · 4 lines
Jeremie Le Hen                        jeremie.le-hen.org jlh.freebsd.org
                              (emails above use SOA record-style format)
Scientists say the world is made up of Protons, Neutrons and Electrons.
They forgot to mention Morons.
Signature · 4 lines
Jeremie Le Hen

Scientists say the world is made up of Protons, Neutrons and Electrons.
They forgot to mention Morons.
#2 lore raw

Hi Jeremie,

I think this could and should be included in 2.3.0. Do any developers have an opinion?

Signature · 10 lines
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc

irc freenode net: mattock


PS. The Trac ticket is here:

<https://community.openvpn.net/openvpn/ticket/135>
Quoted 67 lines

Hi again,

I saw that 2.3-RC2 has been released. Any chance to get this committed before the release?

Regards,

Quoted 59 lines · Jeremie Le Hen

Hi!

On non-Linux systems (that is I checked on FreeBSD, NetBSD, OpenBSD, DragonflyBSD, Darwin, Solaris and IllumOS), setsockopt(2) with the IP_TOS option expects a pointer to a int rather than a char. Therefore this doesn't work on little-endian systems (x86 is the main victim).

The problem is well understood, a fix has been posted by Torsten Vielhak on the bug tracker nearly 2 years ago but the problem has remained ignored, probably because the author didn't bring it to your attention. The patch only handled FreeBSD though. See ticket/135.

I thereby kindly ask you to bring this patch in the source tree. I don't know about your release procedure, but it would be really nice if it could hit the tree before 2.3 is released.

Relevant manpages:
http://www.freebsd.org/cgi/man.cgi?query=ip&format=html
http://netbsd.gw.com/cgi-bin/man-cgi?ip
http://www.openbsd.org/cgi-bin/man.cgi?query=ip&format=html
http://leaf.dragonflybsd.org/cgi/web-man?command=ip&section=ANY
https://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man4/ip.4.html
http://docs.oracle.com/cd/E19082-01/819-2254/ip-7p/index.html
http://illumos.org/man/7p/ip

src/openvpn/socket.h +14 -0
index 9cb01fa..07224c4 100644
@@ -237,7 +237,21 @@ struct link_socket
 
 #if PASSTOS_CAPABILITY
   /* used to get/set TOS. */
+#if defined(TARGET_LINUX)
   uint8_t ptos;
+#elif defined(TARGET_SOLARIS)
+  int ptos;
+#elif defined(TARGET_OPENBSD)
+  int ptos;
+#elif defined(TARGET_NETBSD)
+  int ptos;
+#elif defined(TARGET_FREEBSD)
+  int ptos;
+#elif defined(TARGET_DRAGONFLY)
+  int ptos;
+#elif defined(TARGET_DARWIN)
+  int ptos;
+#endif
   bool ptos_defined;
 #endif
 

Cheers,

Signature · 4 lines
Jeremie Le Hen                        jeremie.le-hen.org jlh.freebsd.org
                              (emails above use SOA record-style format)
Scientists say the world is made up of Protons, Neutrons and Electrons.
They forgot to mention Morons.
#3 lore raw
In reply to Jeremie Le Hen

Hi,

Quoted 3 lines · Jeremie Le Hen

I thereby kindly ask you to bring this patch in the source tree. I don't know about your release procedure, but it would be really nice if it could hit the tree before 2.3 is released.

Thanks for the excessive links to documentation - it helps verifying things. I agree that this is a useful last-minute correction and should go in (feature-ACK).

I don't particularily like the way your patch is coded, though, as it's "all of them but Linux" that have "int" here (except Windows, which uses DWORD, but the docs say "use QoS API instead") - too many #ifdefs.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms738586(v=vs.85).aspx

so I'd propose to #ifdef it differently, patch appended.

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]...

From b6e0f27b4e6965de14cf0ec3e901a52d256cc88a Mon Sep 17 00:00:00 2001
From: Gert Doering <[email protected]...>
Date: Wed, 19 Dec 2012 22:12:41 +0100
Subject: [PATCH] Fix parameter type for IP_TOS setsockopt on non-Linux
systems.

Linux uses uint8_t, all BSD based stacks and Solaris use "int" (Windows documentation says "DWORD" and "do not use, use QoS API instead").

Bug reported and fix provided by Torsten Vielhak and Jeremie Le Hen.

---
 src/openvpn/socket.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
src/openvpn/socket.h +4 -0
index 9cb01fa..4e7e7f8 100644
@@ -237,7 +237,11 @@ struct link_socket
 
 #if PASSTOS_CAPABILITY
   /* used to get/set TOS. */
+#if defined(TARGET_LINUX)
   uint8_t ptos;
+#else /* all the BSDs, Solaris, MacOS use plain "int" -> see "man ip" there */
+  int  ptos;
+#endif
   bool ptos_defined;
 #endif
 
Signature · 1 line
1.7.8.6
#4 lore raw

Hi Gert,

Quoted 10 lines · Gert Doering
Quoted 3 lines · Jeremie Le Hen

I thereby kindly ask you to bring this patch in the source tree. I don't know about your release procedure, but it would be really nice if it could hit the tree before 2.3 is released.

Thanks for the excessive links to documentation - it helps verifying things. I agree that this is a useful last-minute correction and should go in (feature-ACK).

Quoted 7 lines

I don't particularily like the way your patch is coded, though, as it's "all of them but Linux" that have "int" here (except Windows, which uses DWORD, but the docs say "use QoS API instead") - too many #ifdefs.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms738586(v=vs.85).aspx

so I'd propose to #ifdef it differently, patch appended.

Your patch looks fine to me. I went that way because I grep'ed the source for TARGET_ and saw similar occurences of what I did, though each part contained more lines :).

Thanks for your review.
Regards,

Signature · 4 lines
Jeremie Le Hen

Scientists say the world is made up of Protons, Neutrons and Electrons.
They forgot to mention Morons.
#5 lore raw

Hi,

Quoted 5 lines · Jeremie Le Hen
Quoted 1 line

so I'd propose to #ifdef it differently, patch appended.

Your patch looks fine to me. I went that way because I grep'ed the source for TARGET_ and saw similar occurences of what I did, though each part contained more lines :).

Yeah, some of the existing bits are seriously ugly... :)

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]...
#6 lore raw
In reply to Gert Doering
Quoted 29 lines · Gert Doering

Hi,

Quoted 3 lines · Jeremie Le Hen

I thereby kindly ask you to bring this patch in the source tree. I don't know about your release procedure, but it would be really nice if it could hit the tree before 2.3 is released.

Thanks for the excessive links to documentation - it helps verifying things. I agree that this is a useful last-minute correction and should go in (feature-ACK).

I don't particularily like the way your patch is coded, though, as it's "all of them but Linux" that have "int" here (except Windows, which uses DWORD, but the docs say "use QoS API instead") - too many #ifdefs.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms738586(v=vs.85).aspx

so I'd propose to #ifdef it differently, patch appended.

From b6e0f27b4e6965de14cf0ec3e901a52d256cc88a Mon Sep 17 00:00:00 2001
From: Gert Doering <[email protected]...>
Date: Wed, 19 Dec 2012 22:12:41 +0100
Subject: [PATCH] Fix parameter type for IP_TOS setsockopt on non-Linux
systems.

Linux uses uint8_t, all BSD based stacks and Solaris use "int" (Windows documentation says "DWORD" and "do not use, use QoS API instead").

Quoted 6 lines

Bug reported and fix provided by Torsten Vielhak and Jeremie Le Hen.

---
 src/openvpn/socket.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

ACK. Applied to master and beta/2.3

commit d39f31d96378aa5eeade74670ffd9e08bf4c7234 (master) commit a28048a20f46f718c3df3af95e230ab72234f915 (beta/2.3)

Author: Gert Doering <[email protected]...>
Date:   Wed Dec 19 22:12:41 2012 +0100
    Fix parameter type for IP_TOS setsockopt on non-Linux systems.
    
    Signed-off-by: Gert Doering <[email protected]...>
    Acked-by: David Sommerseth <[email protected]...>
    Message-Id: [email protected]...
    URL: http://article.gmane.org/gmane.network.openvpn.devel/7207
    Signed-off-by: David Sommerseth <[email protected]...>
Signature · 3 lines
kind regards,

David Sommerseth