]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Fix --mtu-disc maybe|yes on Linux.
authorGert Doering <gert@greenie.muc.de>
Tue, 22 Feb 2022 11:38:32 +0000 (12:38 +0100)
committerGert Doering <gert@greenie.muc.de>
Tue, 22 Feb 2022 12:23:32 +0000 (13:23 +0100)
--mtu-disc (on Linux) needs two components to work:
   - setsockopt() with IP_MTU_DISCOVER or IPV6_MTU_DISCOVER
   - "extended error reporting" (setsockopt(IP_RECVERR) and
     then via mtu.c/format_extended_socket_error()) to react on
     "packet too big" errors on sendto() / sendmsg()

Some configure.ac reorganization broke detection of <linux/errqueue.h>
and "struct sock_extended_err".  Re-add <linux/errqueue.h> to configure.ac,
remove all the other conditionals in syshead.h, and remove the
"struct sock_extended_err" check completely (assumption: if errqueue.h
exists, it contains what we need).

Thus, the "non-helpful" socket error message turns into:

2022-02-22 12:31:42 write UDPv4 [EMSGSIZE Path-MTU=800]: Message too long (fd=3,code=90)
2022-02-22 12:31:42 Note adjusting 'mssfix 1400 mtu' to 'mssfix 800 mtu' according to path MTU discovery
2022-02-22 12:31:42 Note adjusting 'fragment 1400 mtu' to 'fragment 800 mtu' according to path MTU discovery

... while at it, fix extra space in first part of these messages, and
print o->ce.fragment for the "fragment" message...

v2: assume that "if it's linux, and has these two headers, everything
else will be there as well" and get rid of most of the #ifdef checks

Trac: #1452

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20220222113832.13383-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23863.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
configure.ac
src/openvpn/mss.c
src/openvpn/syshead.h

index d42185d02b5bdb49564d673c5424d9d2acebf5d6..9c8987189abed3925582c1eecb78d9231a5f7ee0 100644 (file)
@@ -425,7 +425,7 @@ AC_CHECK_HEADERS([ \
        unistd.h libgen.h stropts.h \
        syslog.h pwd.h grp.h termios.h \
        sys/sockio.h sys/uio.h linux/sockios.h \
-       linux/types.h poll.h sys/epoll.h err.h \
+       linux/types.h linux/errqueue.h poll.h sys/epoll.h err.h \
 ])
 
 SOCKET_INCLUDES="
@@ -484,12 +484,6 @@ AC_CHECK_TYPE(
        ,
        [[${SOCKET_INCLUDES}]]
 )
-AC_CHECK_TYPE(
-       [struct sock_extended_err],
-       [AC_DEFINE([HAVE_SOCK_EXTENDED_ERR], [1], [struct sock_extended_err needed for extended socket error support])],
-       ,
-       [[${SOCKET_INCLUDES}]]
-)
 AC_CHECK_TYPE(
        [struct msghdr],
        [AC_DEFINE([HAVE_MSGHDR], [1], [struct msghdr needed for extended socket error support])],
index 81692e9169b5021811265951057943f2471fcc49..25b264059fb0318193ec4f30eb23a32d664ba10c 100644 (file)
@@ -361,7 +361,7 @@ frame_adjust_path_mtu(struct context *c)
         || (o->ce.mssfix_encap && pmtu < o->ce.mssfix + encap_overhead))
     {
         const char* mtustr = o->ce.mssfix_encap ? " mtu" : "";
-        msg(D_MTU_INFO, "Note adjusting 'mssfix %d %s' to 'mssfix %d mtu' "
+        msg(D_MTU_INFO, "Note adjusting 'mssfix %d%s' to 'mssfix %d mtu' "
                         "according to path MTU discovery", o->ce.mssfix,
             mtustr, pmtu);
         o->ce.mssfix = pmtu;
@@ -374,8 +374,8 @@ frame_adjust_path_mtu(struct context *c)
         (o->ce.fragment_encap && pmtu < o->ce.fragment + encap_overhead))
     {
         const char* mtustr = o->ce.fragment_encap ? " mtu" : "";
-        msg(D_MTU_INFO, "Note adjusting 'fragment %d %s' to 'fragment %d mtu' "
-                        "according to path MTU discovery", o->ce.mssfix,
+        msg(D_MTU_INFO, "Note adjusting 'fragment %d%s' to 'fragment %d mtu' "
+                        "according to path MTU discovery", o->ce.fragment,
             mtustr, pmtu);
         o->ce.fragment = pmtu;
         o->ce.fragment_encap = true;
index d699c608e22d658eaa083d146032dec0a2384dad..a638b3ddb158be10b34339d5c58d1c8c6ef35d7d 100644 (file)
@@ -371,7 +371,7 @@ typedef int MIB_TCP_STATE;
 /*
  * Do we have the capability to report extended socket errors?
  */
-#if defined(HAVE_LINUX_TYPES_H) && defined(HAVE_LINUX_ERRQUEUE_H) && defined(HAVE_SOCK_EXTENDED_ERR) && defined(HAVE_MSGHDR) && defined(HAVE_CMSGHDR) && defined(CMSG_FIRSTHDR) && defined(CMSG_NXTHDR) && defined(IP_RECVERR) && defined(MSG_ERRQUEUE) && defined(SOL_IP)
+#if defined(HAVE_LINUX_TYPES_H) && defined(HAVE_LINUX_ERRQUEUE_H)
 #define EXTENDED_SOCKET_ERROR_CAPABILITY 1
 #else
 #define EXTENDED_SOCKET_ERROR_CAPABILITY 0