Skip to contentSkip to conversation

OpenVPN multi instancing

Openvpn-devel Christian Daniel 6 participants 12 messages Mar 1, 2004 – Mar 5, 2004

lore
Share & tools
lore
#0 lore raw

Hello everybody!

For a student research project I'm trying to add multi instance capability to OpenVPN. The basic idea is to rip the main openvpn()-function apart, put all variables in a struct and then have only one select()-call for all open tunnels at once.

Then there should be one unix-socket which can be connected by some to-be-written control-application, which manages the tunnels. In detail it should be possible to add and remove tunnels on demand just by sending the appropriate config down that unix-socket.

Each tunnel should have it's own tun/tap-device open - the linux kernel has no problem to cope with so many interfaces... I don't think, that it's a good idea, to create only one tun-device and then have some kind of internal routing-engine...

My main problems so far are:
- which code-base should I use? Should I start with 1.5 oder should I take code from CVS? CVS means shooting on a moving target...
- how to handle the garbage collection? Is it really necessary or is the code leak-free?

Is there any interest here to support that project? We will do it because it is out assignment - and we will finish it :)

Thank you for your help!
Christian

Signature · 7 lines
+-------------------------------------------------------+
| Christian Daniel                                      |
| Drechselblick 5        Mariannhillstraße 6 / App. 220 |
| D-97816 Lohr am Main   D-97074 Würzburg               |
+-----------------------+---------------+---------------+
| http://www.cdaniel.de | [email protected]... | ICQ: 95896119 |
+-----------------------+---------------+---------------+
#1 lore raw
Quoted 6 lines · Christian Daniel

Hello everybody!

For a student research project I'm trying to add multi instance capability to OpenVPN. The basic idea is to rip the main openvpn()-function apart, put all variables in a struct and then have only one select()-call for all open tunnels at once.

It's already been done :)

See the BETA20 branch in the CVS.

Having said that, I think it's great that you want to contribute to the code, and there's still a lot of work yet to be done.

Quoted 9 lines

Then there should be one unix-socket which can be connected by some to-be-written control-application, which manages the tunnels. In detail it should be possible to add and remove tunnels on demand just by sending the appropriate config down that unix-socket.

Each tunnel should have it's own tun/tap-device open - the linux kernel has no problem to cope with so many interfaces... I don't think, that it's a good idea, to create only one tun-device and then have some kind of internal routing-engine...

The current plan for 2.0 is to also handle the case of multiple tunnels through a single tun/tap interface. This will scale better overall, and will be necessary on some platforms such as Windows which cannot efficiently handle a large number of tun/tap interfaces.

Quoted 5 lines

My main problems so far are:
- which code-base should I use? Should I start with 1.5 oder should I take code from CVS? CVS means shooting on a moving target...
- how to handle the garbage collection? Is it really necessary or is the code leak-free?

The ./configure script has some options for leak checking -- right now the code doesn't have any known leaks.

The gc_* functions provide a simple GC infrastructure where the code defines a series of hierarchical scopes, and GC allocated storage only stays alive within it's own scope or scopes below it (think of it as a kind of cross between a stack and a heap). The main issue to keep in mind is that each thread needs its own gc_thread struct.

Quoted 2 lines

Is there any interest here to support that project? We will do it because it is out assignment - and we will finish it :)

Certainly, though I think if you want to contribute to the code, we should try to minimize overlap.

One area that currently needs some work is getting IPv6 working everywhere in the code. Right now OpenVPN supports IPv6 over IPv4 tunnels, but it would be nice if the tunnel itself could run over IPv6. This would involve modifying socket.[ch] to be comfortable with IPv6.

Also keep in mind that the 1.5 and 1.6 branches are relatively stable at this point and won't be accepting new patches except bug fixes and very simple, localized patches. All the big stuff is going into 2.0 which will be a fast moving target for the next few months.

James

#2 lore raw
Quoted 30 lines · James Yonan
Quoted 6 lines · Christian Daniel

Hello everybody!

For a student research project I'm trying to add multi instance capability to OpenVPN. The basic idea is to rip the main openvpn()-function apart, put all variables in a struct and then have only one select()-call for all open tunnels at once.

It's already been done :)

See the BETA20 branch in the CVS.

Having said that, I think it's great that you want to contribute to the code, and there's still a lot of work yet to be done.

Quoted 9 lines

Then there should be one unix-socket which can be connected by some to-be-written control-application, which manages the tunnels. In detail it should be possible to add and remove tunnels on demand just by sending the appropriate config down that unix-socket.

Each tunnel should have it's own tun/tap-device open - the linux kernel has no problem to cope with so many interfaces... I don't think, that it's a good idea, to create only one tun-device and then have some kind of internal routing-engine...

The current plan for 2.0 is to also handle the case of multiple tunnels through a single tun/tap interface. This will scale better overall, and will be necessary on some platforms such as Windows which cannot efficiently handle a large number of tun/tap interfaces.

#3 lore raw
Quoted 8 lines · Jon Nelson
Quoted 5 lines · James Yonan
Quoted 3 lines · Christian Daniel

Hello everybody!

For a student research project I'm trying to add multi instance

capability to

Quoted 11 lines
Quoted 11 lines
Quoted 3 lines

OpenVPN. The basic idea is to rip the main openvpn()-function apart, put all variables in a struct and then have only one select()-call for all open tunnels at once.

It's already been done :)

See the BETA20 branch in the CVS.

Having said that, I think it's great that you want to contribute to the code, and there's still a lot of work yet to be done.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Then there should be one unix-socket which can be connected by some to-be-written control-application, which manages the tunnels. In detail it should be possible to add and remove tunnels on demand just by sending the appropriate config down that unix-socket.

Each tunnel should have it's own tun/tap-device open - the linux kernel

has no

Quoted 15 lines
Quoted 10 lines
Quoted 3 lines

problem to cope with so many interfaces... I don't think, that it's a good idea, to create only one tun-device and then have some kind of internal routing-engine...

The current plan for 2.0 is to also handle the case of multiple tunnels through a single tun/tap interface. This will scale better overall, and will be necessary on some platforms such as Windows which cannot efficiently handle a large number of tun/tap interfaces.

From a security or network partitioning point of view, having each

"network" only accessible via *one* interface greatly simplifies things. Honestly, I couldn't care less about Windows, especially if supporting it impacts the usability and security of the software in a negative way. What is a "large" number of tun/tap interfaces, anyway?

Quoted 5 lines

Maybe I'm not understanding something, but isn't OpenVPN all about building Virtual Private Networks? Firewalls other programs can (do, and sometimes must) specify the interface name over which they communicate -- having one tun/tap for more than one "network" just sounds very bad. Maybe you can explain it to me.

One virtual interface per tunnel is supported now and will be supported going forward.

Many tunnels through a single virtual interface is a feature that will be interesting for certain kinds of applications. Suppose you want a VPN that links N networks, where communication between any two networks takes a direct path (not through a central server). This model is much easier to manage with a point-to-multipoint interface, and can scale to thousands of nodes. If you try to build this out of point-to-point tunnels, you end up having to manage (N*(N-1))/2 tunnels. With point-to-multipoint tunnels, you only need N of them.

James

#4 lore raw
Quoted 2 lines · James Yonan

One virtual interface per tunnel is supported now and will be supported going forward.

^^^^^^^^^^^^^ That's the part I needed to hear. Thanks!

--
Life's short and hard, kind of like a bodybuilding elf.

Jon Nelson <[email protected]...>

#10 lore raw
In reply to Christian Daniel
Quoted 6 lines · Christian Daniel

Hello everybody!

For a student research project I'm trying to add multi instance capability to OpenVPN. The basic idea is to rip the main openvpn()-function apart, put all variables in a struct and then have only one select()-call for all open tunnels at once.

Oh. You're in for plentiful fun with the various select() "features"^Wbugs across the various operating system kernels.

Better check out poll() and epoll() where available. These happen to (usually) be more scalable as the number of fds increases.

Quoted 4 lines

Each tunnel should have it's own tun/tap-device open - the linux kernel has no problem to cope with so many interfaces... I don't think, that it's a good idea, to create only one tun-device and then have some kind of internal routing-engine...

It cannot work. The interfaces have distinct addresses and netmasks, for some kind of internal routing-engine, you'd have to re-implement the stack on top of raw sockets. Not easy, not portable, not desirable.

Quoted 2 lines

- how to handle the garbage collection? Is it really necessary or is the code leak-free?

<ducks>go figure as a side project, going to fill your thesis or homework or whatever other paper or PDF you're going to turn in. :-)

Signature · 3 lines
Matthias Andree

Encrypt your mail: my GnuPG key ID is 0x052E7D95
#8 lore raw
In reply to James Yonan
Quoted 4 lines · James Yonan
Quoted 2 lines · Christian Daniel

Hello everybody!

Quoted 8 lines
Quoted 4 lines

For a student research project I'm trying to add multi instance capability to OpenVPN. The basic idea is to rip the main openvpn()-function apart, put all variables in a struct and then have only one select()-call for all open tunnels at once.

It's already been done :)

See the BETA20 branch in the CVS.

Is there a document that mentions the development tags so the daring know what to check out? Or a mailing list I should subscribe to?

May I suggest to post the pointer to the document or add one to openvpn.sourceforge.net?

Thanks. (It's incredible how much room for improvement OpenVPN still has, while having been stable and production-ready for so long already.)

Signature · 3 lines
Matthias Andree

Encrypt your mail: my GnuPG key ID is 0x052E7D95
#5 lore raw
In reply to Jon Nelson

Hello, James hello, Christian,

is it also going to be supported in 2.0 to have multiple tup/tap interfaces but only a single TCP-port on the server side waiting for incoming connections?

Regards,

Christian Lademann

Signature · 6 lines
*  Christian A. Lademann, ZLS Software GmbH          mailto:[email protected].....
*  ZLS Software GmbH
*  Frankfurter Strasse 59       Postfach 1628             mailto:[email protected].....
*  D-65779 Kelkheim             D-65766 Kelkheim          http://www.zls.de
*  Telefon +49-6195-9902-0      Telefax +49-6195-900600
*  Geschäftsführer John A. Shuter     -     Amtsgericht Königstein HRB 3105
#6 lore raw
In reply to Jon Nelson

Hello, James hello, Christian,

is it also going to be supported in 2.0 to have multiple tup/tap interfaces but only a single TCP-port on the server side waiting for incoming connections?

Regards,

Christian Lademann

#9 lore raw
In reply to Matthias Andree
Quoted 7 lines · Matthias Andree
Quoted 5 lines · James Yonan
Quoted 3 lines · Christian Daniel

Hello everybody!

For a student research project I'm trying to add multi instance

capability to

Quoted 1 line
Quoted 1 line
Quoted 1 line

OpenVPN. The basic idea is to rip the main openvpn()-function apart, put

all

Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

variables in a struct and then have only one select()-call for all open tunnels at once.

It's already been done :)

See the BETA20 branch in the CVS.

Is there a document that mentions the development tags so the daring know what to check out? Or a mailing list I should subscribe to?

It's not too complicated. The HEAD branch is stable, or a beta series which is leading to a stable release, i.e. 1.6-betaX. The BETA20 branch at this point mostly contains a lot of refactorization. All the stuff that used to be on the stack in the openvpn() function is now kept in a struct context. openvpn.c and the main() function is clean and minimalistic once again.

Every major or beta release gets a tag that is constructed from the version number. When I do a cvs commit I use this simple script:

cvs commit -m "version $OPENVPN_VER" && cvs tag echo openvpn-$OPENVPN_VER | tr . -

where $OPENVPN_VER is something like "1.6-beta7" or "1.5.0".

Quoted 2 lines

May I suggest to post the pointer to the document or add one to openvpn.sourceforge.net?

There's not a lot of people actually working on the code right now, so it's easier to just ask questions on the list or search the archives.

James

#7 lore raw
In reply to Christian Lademann
Quoted 4 lines · Christian Lademann

Hello, James hello, Christian,

is it also going to be supported in 2.0 to have multiple tup/tap interfaces but only a single TCP-port on the server side waiting for incoming connections?

The ultimate goal is to have all connection options open in either point-to-point or point-to-multipoint mode. The initial 2.0 beta will specialize in serving multiple clients on a single UDP port, single tun/tap interface, and single config file.

Actually if you want single TCP-port, one tun/tap interface per client, that sounds like the inetd-based forking server model which is already functional (in a limited sense) in the 1.6 beta series. The limitation is that you use SSL/TLS + bridging. See the FAQ for more info.

James

#11 lore raw
In reply to Matthias Andree
Quoted 9 lines · Matthias Andree
Quoted 6 lines · Christian Daniel

Hello everybody!

For a student research project I'm trying to add multi instance capability to OpenVPN. The basic idea is to rip the main openvpn()-function apart, put all variables in a struct and then have only one select()-call for all open tunnels at once.

Quoted 5 lines

Oh. You're in for plentiful fun with the various select() "features"^Wbugs across the various operating system kernels.

Better check out poll() and epoll() where available. These happen to (usually) be more scalable as the number of fds increases.

Luckily, UDP scales up fairly well without hitting up against the limitations of select() since a single UDP socket can be used to communicate with an unlimited number of clients. TCP will be harder to scale with select() because every incoming client will need its own socket.

I don't see how poll() is that much of an improvement over select() because it still requires that you scan all the FDs to see which ones require service.

epoll() looks like a real improvement, and has obviously been designed with scalability in mind.

It's too bad that poll and epoll move the timeout from microsecond to millisecond resolution, as that makes things like traffic shaping harder to implement.

James