# OpenVPN: how to enable TCP nodelay?



## jcassette (Dec 6, 2012)

Hello,

I'm using OpenVPN on a server, it's running over TCP with tun(4), and is working fine. However I get very high latency through the tunnel.

After some research I came to this link: http://community.openvpn.net/openvpn/ticket/158

When is HAVE_SETSOCKOPT supposed to be defined? How may I set it?

Regards,


----------



## Anonymous (Dec 15, 2012)

hazynrg said:
			
		

> When is HAVE_SETSOCKOPT supposed to be defined?



I don't know.



			
				hazynrg said:
			
		

> How may I set it?



You may define it once you make OpenVPN from the ports:

`# cd /usr/ports/security/openvpn`
`# make CFLAGS="-DHAVE_SETSOCKOPT"`
`# make install clean`

I cannot tell, whether this gives to you the desired effect, though.


----------



## jcassette (Dec 16, 2012)

Thank you for your reply.

I was on the wrong way, HAVE_SETSOCKOPT is actually defined in "config.h"

I think the problem is TCP_NODELAY which is defined in the <netinet/tcp.h> header.

While having a look at "syshead.h", I discovered that it won't include <netinet/tcp.h>:


```
#ifdef TARGET_FREEBSD

#ifdef HAVE_SYS_UIO_H
#include <sys/uio.h>
#endif

#ifdef HAVE_NETINET_IN_SYSTM_H
#include <netinet/in_systm.h>
#endif

#ifdef HAVE_NETINET_IP_H
#include <netinet/ip.h>
#endif

#ifdef HAVE_NET_IF_TUN_H
#include <net/if_tun.h>
#endif

#endif /* TARGET_FREEBSD */
```

I will try to include it tomorrow...


----------



## jcassette (Dec 16, 2012)

I added:


> #ifdef HAVE_NETINET_TCP_H
> #include <netinet/tcp.h>
> #endif


just after the ip.h include and it's now working all good


----------

