Skip to contentSkip to conversation

Packet loss due to radius issues

Openvpn-devel Samuel Thibault 6 participants 18 messages Jul 30, 2015 – Aug 11, 2015

lore
Share & tools
lore
#0 lore raw

Hello,

We've been having issues on our VPN server due to the way authentication is done in openvpn. Basically, when a user would connect to the VPN server, no trafic would pass for a couple of seconds, thus making the VPN way less effective... This was an unfortunate combination of several issues described below. Our current setup is openvpn in multiple client mode, with the openvpn-auth-radius plugin to get authentication from a couple of radius servers on two other machines next to our VPN server.

Here is what happens:

- AIUI, when openvpn receives an authentication request, it gives hand to the authentication plugin, and thus while the authentication plugin is working on it, no trafic can be handled by openvpn. That is, I believe, an important issue, and will turn that into a bug report. The issue is that authentication might take time for whatever reason (see below for an example).

- The radius authentication plugin interrogates our two radius servers, gets a response, and gives back hand to openvpn.

- The issue we were having is that the first of the two radius servers is being replaced, and is thus currently turned off. Since the radius plugin tries the first server first and waits for a couple of seconds before trying the second one, the authentication currently always takes a couple of seconds. Unfortunately, that thus makes openvpn not process traffic for that couple of seconds... Of course I have now disabled the first radius server to avoid the issue, but a radius server downtime (e.g. reboot or whatever) should *not* make trafic stall, so it's not acceptable.

One could argue that the radius plugin should perhaps try both servers at the same time and take the first answer it gets. That however drops the idea of load balancing, and in case both radius servers are down, the openvpn trafic will get interrupted everytime somebody tries to connect (and retry shortly after again and again since it'll fail), that's really not acceptable either.

Samuel

#1 lore raw

Hello Samuel,

Do you use radius plugin from http://www.nongnu.org/radiusplugin/ ? I think the way OpenVPN delegates authentication to a plugin (OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY hook) is asynchronous, as well as plugin implementation, i. e. OpenVPN does not wait for a response. Instead it periodically checks a tmp file to where plugin is supposed to write authentication result (1 or 0).

However, plugin may also hook on OPENVPN_PLUGIN_CLIENT_CONNECT_V2, which is called after authentication has been done. OpenVPN calls that hook synchronously, which may cause traffic to stall. There is a patch that makes OpenVPN behave asynchronously, however it is not (yet) merger to the master branch.

http://sourceforge.net/p/openvpn/mailman/message/33244190/

We used to have a packet loss issue due to synchronous nature of client-connect and that patch has solved it.

-Lev

2015-07-31 2:37 GMT+03:00 Samuel Thibault <[email protected]...>:

Quoted 47 lines

Hello,

We've been having issues on our VPN server due to the way authentication is done in openvpn. Basically, when a user would connect to the VPN server, no trafic would pass for a couple of seconds, thus making the VPN way less effective... This was an unfortunate combination of several issues described below. Our current setup is openvpn in multiple client mode, with the openvpn-auth-radius plugin to get authentication from a couple of radius servers on two other machines next to our VPN server.

Here is what happens:

- AIUI, when openvpn receives an authentication request, it gives hand to the authentication plugin, and thus while the authentication plugin is working on it, no trafic can be handled by openvpn. That is, I believe, an important issue, and will turn that into a bug report. The issue is that authentication might take time for whatever reason (see below for an example).

- The radius authentication plugin interrogates our two radius servers, gets a response, and gives back hand to openvpn.

- The issue we were having is that the first of the two radius servers is being replaced, and is thus currently turned off. Since the radius plugin tries the first server first and waits for a couple of seconds before trying the second one, the authentication currently always takes a couple of seconds. Unfortunately, that thus makes openvpn not process traffic for that couple of seconds... Of course I have now disabled the first radius server to avoid the issue, but a radius server downtime (e.g. reboot or whatever) should *not* make trafic stall, so it's not acceptable.

One could argue that the radius plugin should perhaps try both servers at the same time and take the first answer it gets. That however drops the idea of load balancing, and in case both radius servers are down, the openvpn trafic will get interrupted everytime somebody tries to connect (and retry shortly after again and again since it'll fail), that's really not acceptable either.

Samuel

------------------------------------------------------------------------------
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Signature · 1 line
-Lev
#9 lore raw
In reply to Samuel Thibault

Hello,

I've rewritten radius thing with .net, my plugin performs queries to multiple radius servers in parallel, I'm using it with Mono in production for few months:

https://github.com/skbkontur/openvpn-auth-radius

I can help with that plugin if you are interested

2015-07-31 4:37 GMT+05:00 Samuel Thibault <[email protected]...>:

Quoted 47 lines

Hello,

We've been having issues on our VPN server due to the way authentication is done in openvpn. Basically, when a user would connect to the VPN server, no trafic would pass for a couple of seconds, thus making the VPN way less effective... This was an unfortunate combination of several issues described below. Our current setup is openvpn in multiple client mode, with the openvpn-auth-radius plugin to get authentication from a couple of radius servers on two other machines next to our VPN server.

Here is what happens:

- AIUI, when openvpn receives an authentication request, it gives hand to the authentication plugin, and thus while the authentication plugin is working on it, no trafic can be handled by openvpn. That is, I believe, an important issue, and will turn that into a bug report. The issue is that authentication might take time for whatever reason (see below for an example).

- The radius authentication plugin interrogates our two radius servers, gets a response, and gives back hand to openvpn.

- The issue we were having is that the first of the two radius servers is being replaced, and is thus currently turned off. Since the radius plugin tries the first server first and waits for a couple of seconds before trying the second one, the authentication currently always takes a couple of seconds. Unfortunately, that thus makes openvpn not process traffic for that couple of seconds... Of course I have now disabled the first radius server to avoid the issue, but a radius server downtime (e.g. reboot or whatever) should *not* make trafic stall, so it's not acceptable.

One could argue that the radius plugin should perhaps try both servers at the same time and take the first answer it gets. That however drops the idea of load balancing, and in case both radius servers are down, the openvpn trafic will get interrupted everytime somebody tries to connect (and retry shortly after again and again since it'll fail), that's really not acceptable either.

Samuel

------------------------------------------------------------------------------
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#10 lore raw
Quoted 7 lines · Илья Шипицин, le Fri 31 Jul 2015 14:09:51 +0500, a écrit :

I've rewritten radius thing with .net, my plugin performs queries to multiple radius servers in parallel, I'm using it with Mono in production for few months:

https://github.com/skbkontur/openvpn-auth-radius

I can help with that plugin if you are interested

Mmm, it'd be great if the openvpn-auth-radius plugin could have a central repository, instead of a flurry of patched versions...

Samuel

#2 lore raw
In reply to Lev Stipakov

Hello,

Quoted 6 lines · Lev Stipakov, le Fri 31 Jul 2015 11:19:15 +0300, a écrit :

Do you use radius plugin from http://www.nongnu.org/radiusplugin/ ? I think the way OpenVPN delegates authentication to a plugin (OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY hook) is asynchronous, as well as plugin implementation, i. e. OpenVPN does not wait for a response. Instead it periodically checks a tmp file to where plugin is supposed to write authentication result (1 or 0).

Ok, I see where that is implemented, and I do see acf temp files being created. For some reason the plugin doesn't seem to be using the deferred case, so I'll dig further.

Samuel

#3 lore raw
Quoted 11 lines · Samuel Thibault, le Fri 31 Jul 2015 11:24:51 +0200, a écrit :
Quoted 6 lines · Lev Stipakov, le Fri 31 Jul 2015 11:19:15 +0300, a écrit :

Do you use radius plugin from http://www.nongnu.org/radiusplugin/ ? I think the way OpenVPN delegates authentication to a plugin (OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY hook) is asynchronous, as well as plugin implementation, i. e. OpenVPN does not wait for a response. Instead it periodically checks a tmp file to where plugin is supposed to write authentication result (1 or 0).

Ok, I see where that is implemented, and I do see acf temp files being created. For some reason the plugin doesn't seem to be using the deferred case, so I'll dig further.

Err...

# Allows the plugin to use auth control files if OpenVPN (>= 2.1 rc8) provides them.

# default is false
# useauthcontrolfile=false

Why is the default false??

Samuel

#11 lore raw
In reply to Samuel Thibault

auth-user-pass-verify is not as powerfull as "so" plugin. my plugin is synchronous by nature.

however, if your are familiar with c#, it might be easier to implement things like username manipulation,

for instance, we used to transform usernames like 'domain\user' and '[email protected]...' to just 'user'
it is too early to talk about central repository, currently I'm the only user of that plugin

2015-07-31 14:12 GMT+05:00 Samuel Thibault <[email protected]...>:

Quoted 13 lines
Quoted 7 lines · Илья Шипицин, le Fri 31 Jul 2015 14:09:51 +0500, a écrit :

I've rewritten radius thing with .net, my plugin performs queries to multiple radius servers in parallel, I'm using it with Mono in production for few months:

https://github.com/skbkontur/openvpn-auth-radius

I can help with that plugin if you are interested

Mmm, it'd be great if the openvpn-auth-radius plugin could have a central repository, instead of a flurry of patched versions...

Samuel

#4 lore raw
In reply to Samuel Thibault
Quoted 5 lines · Samuel Thibault, le Fri 31 Jul 2015 11:32:06 +0200, a écrit :

# Allows the plugin to use auth control files if OpenVPN (>= 2.1 rc8) provides them.

# default is false
# useauthcontrolfile=false

Why is the default false??

And still... The main loop uses

   pthread_mutex_lock(context->getMutexSend());
   context->addNewUser(newuser);
   pthread_cond_signal( context->getCondSend( ));
   pthread_mutex_unlock (context->getMutexSend());
   return OPENVPN_PLUGIN_FUNC_DEFERRED;

to signal the auth thread that a new connection is being tried, and the auth thread basically does

   pthread_mutex_lock(context->getMutexSend());
   while(1)
   {
     if (nobody_yet)
       pthread_cond_wait(context->getCondSend(),context->getMutexSend());
     ...
     Do auth
     ...
   }
   pthread_mutex_unlock(context->getMutexSend());

I.e. it keeps the MutexSend busy all along the authentication! So even with deferred authentication, the main loop can not manage to grasp the mutex until the auth thread has finished authenticating the previous user...

Anyway, this is an issue in the plugin, I'll switch over to the plugin mailing list.

Samuel

#12 lore raw
In reply to Илья Шипицин
Quoted 2 lines · Илья Шипицин, le Fri 31 Jul 2015 14:54:02 +0500, a écrit :

it is too early to talk about central repository, currently I'm the only user of that plugin

But without a central repository where people would get to know about your version, then it's even more probable that you'll remain the only user...

Samuel

#17 lore raw
In reply to Samuel Thibault
Quoted 11 lines · Samuel Thibault

Hello,

We've been having issues on our VPN server due to the way authentication is done in openvpn. Basically, when a user would connect to the VPN server, no trafic would pass for a couple of seconds, thus making the VPN way less effective... This was an unfortunate combination of several issues described below. Our current setup is openvpn in multiple client mode, with the openvpn-auth-radius plugin to get authentication from a couple of radius servers on two other machines next to our VPN server.

Quoted 8 lines

Here is what happens:

- AIUI, when openvpn receives an authentication request, it gives hand to the authentication plugin, and thus while the authentication plugin is working on it, no trafic can be handled by openvpn. That is, I believe, an important issue, and will turn that into a bug report. The issue is that authentication might take time for whatever reason (see below for an example).

This is correct, this is the behaviour unless the auth plugin uses deferred authentication. That means that the auth-plugin can receive the auth request and return OPENVPN_PLUGIN_FUNC_DEFERRED. The auth request must then continue in a different thread, which receives the results and returns it to OpenVPN via a auth_control_file. See the sample/sample-plugins/defer example for more details.

Signature · 3 lines
kind regards,

David Sommerseth
#13 lore raw
In reply to Samuel Thibault

Hi,

Quoted 3 lines · Samuel Thibault

But without a central repository where people would get to know about your version, then it's even more probable that you'll remain the only user...

Indeed. Who *is* maintaining the radius plugin these days? What is "the official" repo?

I found some stuff on

http://www.nongnu.org/radiusplugin/

(no change since 2010, but the debian package has "more recent" updates, and the ubuntu package even has a patch from Samuel Thibault :-) )

http://www.bytebucket.org/02strich/openvpn-auth-radius/src

(this seems to be a fork, many of the files have the commit message "initial commit - based on 2.1 Beta", but there has been a bit of activity in 2012 and 2014... not very much, so merging the stuff back should not be very hard)

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]...
#14 lore raw

I do not mind about "the official repo".
can you provide more details on that?

2015-08-01 18:07 GMT+05:00 Gert Doering <[email protected]...>:

Quoted 31 lines

Hi,

Quoted 3 lines · Samuel Thibault

But without a central repository where people would get to know about your version, then it's even more probable that you'll remain the only user...

Indeed. Who *is* maintaining the radius plugin these days? What is "the official" repo?

I found some stuff on

http://www.nongnu.org/radiusplugin/

(no change since 2010, but the debian package has "more recent" updates, and the ubuntu package even has a patch from Samuel Thibault :-) )

http://www.bytebucket.org/02strich/openvpn-auth-radius/src

(this seems to be a fork, many of the files have the commit message "initial commit - based on 2.1 Beta", but there has been a bit of activity in 2012 and 2014... not very much, so merging the stuff back should not be very hard)

gert

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

#15 lore raw
In reply to Gert Doering
Quoted 18 lines

Hi,

Quoted 3 lines · Samuel Thibault

But without a central repository where people would get to know about your version, then it's even more probable that you'll remain the only user...

Indeed. Who *is* maintaining the radius plugin these days? What is "the official" repo?

I found some stuff on

http://www.nongnu.org/radiusplugin/

(no change since 2010, but the debian package has "more recent" updates, and the ubuntu package even has a patch from Samuel Thibault :-) )

Quoted 8 lines

http://www.bytebucket.org/02strich/openvpn-auth-radius/src

(this seems to be a fork, many of the files have the commit message "initial commit - based on 2.1 Beta", but there has been a bit of activity in 2012 and 2014... not very much, so merging the stuff back should not be very hard)

gert

Maybe we should create an official repository for the RADIUS plugin, say, on GitHub? We could collect all the patches in there and if somebody wants to maintain it we could grant access to that (sub)project only.

Thoughts?

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

irc freenode net: mattock
#16 lore raw

I can maitain such a repo.

also, did you consider to employ students from GSoC ? for example, ToX (which I like very much) employed 9 students. it might give some drive into development.

2015-08-02 16:36 GMT+05:00 Samuli Seppänen <[email protected]...>:

Quoted 43 lines

Hi,

Quoted 18 lines · Samuel Thibault
Quoted 5 lines

But without a central repository where people would get to know about your version, then it's even more probable that you'll remain the only user...

Indeed. Who *is* maintaining the radius plugin these days? What is "the official" repo?

I found some stuff on

http://www.nongnu.org/radiusplugin/

(no change since 2010, but the debian package has "more recent" updates, and the ubuntu package even has a patch from Samuel Thibault :-) )

Quoted 9 lines

http://www.bytebucket.org/02strich/openvpn-auth-radius/src

(this seems to be a fork, many of the files have the commit message "initial commit - based on 2.1 Beta", but there has been a bit of activity in 2012 and 2014... not very much, so merging the stuff back should not be very hard)

gert

Maybe we should create an official repository for the RADIUS plugin, say, on GitHub? We could collect all the patches in there and if somebody wants to maintain it we could grant access to that (sub)project only.

Thoughts?

--
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc

irc freenode net: mattock

#5 lore raw
In reply to Lev Stipakov

Hello,

Quoted 6 lines · Lev Stipakov, le Fri 31 Jul 2015 11:19:15 +0300, a écrit :

Do you use radius plugin from http://www.nongnu.org/radiusplugin/ ? I think the way OpenVPN delegates authentication to a plugin (OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY hook) is asynchronous, as well as plugin implementation, i. e. OpenVPN does not wait for a response. Instead it periodically checks a tmp file to where plugin is supposed to write authentication result (1 or 0).

Since I was still getting trafic misses even with acf properly working, I dug a bit further, and the issue I'm still having is with accounting. Here is the log I'm having, for instance on a :

Tue Aug 11 00:54:10 2015 RADIUS-PLUGIN: BACKGROUND ACCT: New User.
Tue Aug 11 00:54:10 2015 RADIUS-PLUGIN: BACKGROUND ACCT: New user acct: username: [email protected]..., interval: 0, calling station: ::ffff:92.146.150.249, commonname: [email protected]..., framed ip: 80.67.179.7, framed ipv6: 2001:0910:0802:0000:0000:0000:0000:1307.

[during these two seconds, openvpn doesn't trafic any more]

Tue Aug 11 00:54:12 2015 RADIUS-PLUGIN: BACKGROUND-ACCT: Get ACCOUNTING_RESPONSE-Packet. Tue Aug 11 00:54:12 2015 RADIUS-PLUGIN: BACKGROUND ACCT: Start packet was send. Tue Aug 11 00:54:12 2015 RADIUS-PLUGIN: BACKGROUND ACCT: User was added to accounting scheduler.

Tue Aug 11 00:54:12 2015 RADIUS-PLUGIN: BACKGROUND-ACCT:  No routes for user.
Tue Aug 11 00:54:12 2015 RADIUS-PLUGIN: BACKGROUND-ACCT:  Create IPv6 route string ip -6 route add 2001:910:1307::/48 dev tun2 proto static 2> /dev/null dev tun2.
Tue Aug 11 00:54:12 2015 RADIUS-PLUGIN: BACKGROUND-ACCT:  Add route to system routing table.

[and now trafic passes again]

Looking at the source code in openvpn_plugin_open_v2, I see:

context->acctsocketbackgr.send ( ADD_USER );
...
context->acctsocketbackgr.send ( newuser->getVsaBuf(), newuser->getVsaBufLen() ); //get the response
const int status = context->acctsocketbackgr.recvInt();

This is again synchronous code, and this time I don't see any option to make it asynchronous... I can see that when accounting fails, an exception is thrown, to return an error to openvpn and thus prevent the connection. I guess this is an important part that shouldn't be dropped, but I don't see a way to make it asynchronous without modifying the openvpn core.

In our case we don't actually make use of radius accounting...

Samuel

#6 lore raw
Quoted 1 line · Samuel Thibault, le Tue 11 Aug 2015 01:28:02 +0200, a écrit :

Here is the log I'm having, for instance on a :

user connection, I meant

Samuel

#7 lore raw
In reply to Samuel Thibault

Hi,

Quoted 10 lines · Samuel Thibault

Looking at the source code in openvpn_plugin_open_v2, I see:

context->acctsocketbackgr.send ( ADD_USER );
...
context->acctsocketbackgr.send ( newuser->getVsaBuf(), newuser->getVsaBufLen() ); //get the response
const int status = context->acctsocketbackgr.recvInt();

This is again synchronous code, and this time I don't see any option to make it asynchronous...

I'm not proposing anything right now (this stuff is not exactly my field of expertise with OpenVPN code), but maybe a quick hack...

Quoted 7 lines

I can see that when accounting fails, an
exception is thrown, to return an error to openvpn and thus prevent the connection. I guess this is an important part that shouldn't be dropped, but I don't see a way to make it asynchronous without modifying the openvpn core.

In our case we don't actually make use of radius accounting...

... you could modify the radiusplugin to just "do not do accounting" - just return "success!" right away, and quickly so...

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]...
#8 lore raw
Quoted 10 lines · Gert Doering, le Tue 11 Aug 2015 07:59:06 +0200, a écrit :
Quoted 7 lines

I can see that when accounting fails, an
exception is thrown, to return an error to openvpn and thus prevent the connection. I guess this is an important part that shouldn't be dropped, but I don't see a way to make it asynchronous without modifying the openvpn core.

In our case we don't actually make use of radius accounting...

... you could modify the radiusplugin to just "do not do accounting" - just return "success!" right away, and quickly so...

Yep, already done so on our platform, so we at least avoid the issue :)

It still needs to be fixed upstream :)

Samuel