Skip to contentSkip to conversation

Introduce L2TP support

PATCH In review James Chapman 3 participants 4 messages May 26, 2008 – May 27, 2008

Subsystems (3)
lore
Share & tools
lore

James Chapman

author maintainer
#0 lore raw

PATCH 1/1 Introduce L2TP support

The attached patch set introduces L2TP support for Linux. There are 2 patches.

ppp-add-pppol2tp-plugin.patch
Adds a pppol2tp plugin which lets pppd use the Linux pppol2tp.ko kernel driver to pass PPP frames in L2TP tunnels using PPPoL2TP sockets.

ppp-add-openl2tp-plugin.patch
Adds an event interface which is used by the OpenL2TP implementation to receive events from pppd using a Unix socket.

These plugins are being actively used by users of OpenL2TP and other L2TP daemons. Please consider for inclusion in the next release of pppd.

Thanks!

Signature · 4 lines
James Chapman
Katalix Systems Ltd
http://www.katalix.com
Catalysts for your Embedded Linux software development

This patch adds support for L2TP. It allows pppd to interface with the pppol2tp driver in the Linux kernel. All data packets are handled by the Linux kernel in order that the datapath be as efficient as possible, while a userspace daemon implements the L2TP control protocol, handling tunnel/session setup and teardown. The implementation uses the PPPoX infrastructure; the architecture is similar to PPPoE/PPPoATM in that a userspace daemon spawns a pppd process per PPP session and uses a protocol-specific plugin to connect pppd with the kernel.

The pppol2tp Linux kernel driver was integrated in the Linux kernel from 2.6.23. For earlier kernels, an out of tree driver is available from the pppol2tp-kmod package on the OpenL2TP project site at
http://sourceforge.net/projects/openl2tp.

README.pppol2tp new file +66 -0
Index: ppp-2.4.4/README.pppol2tp
===================================================================
@@ -0,0 +1,66 @@
+PPPoL2TP plugin
+===============
+
+The pppol2tp plugin lets pppd use the Linux kernel driver pppol2tp.ko
+to pass PPP frames in L2TP tunnels. The driver was integrated into the
+kernel in the 2.6.23 release. For kernels before 2.6.23, an
+out-of-tree kernel module is available from the pppol2tp-kmod package
+in the OpenL2TP project.
+
+Note that pppd receives only PPP control frames over the PPPoL2TP
+socket; data frames are handled entirely by the kernel.
+
+The pppol2tp plugin adds extra arguments to pppd and uses the Linux kernel
+PPP-over-L2TP driver to set up each session's data path.
+
+Arguments are:-
+
+pppol2tp <fd>                   - FD for PPPoL2TP socket
+pppol2tp_lns_mode               - PPPoL2TP LNS behavior. Default off.
+pppol2tp_send_seq               - PPPoL2TP enable sequence numbers in
+                                  transmitted data packets. Default off.
+pppol2tp_recv_seq               - PPPoL2TP enforce sequence numbers in
+                                  received data packets. Default off.
+pppol2tp_reorderto <millisecs>  - PPPoL2TP data packet reorder timeout.
+                                  Default 0 (no reordering).
+pppol2tp_debug_mask <mask>      - PPPoL2TP debug mask. Bitwise OR of
+				  1 - verbose debug
+				  2 - control
+				  4 - kernel transport
+				  8 - ppp packet data
+				  Default: 0 (no debug).
+pppol2tp_ifname <ifname>	- Name of PPP network interface visible
+				  to "ifconfig" and "ip link".
+				  Default: "pppN"
+pppol2tp_tunnel_id <id>		- L2TP tunnel_id tunneling this PPP
+				  session.
+pppol2tp_session_id <id>	- L2TP session_id of this PPP session.
+				  The tunnel_id/session_id pair is used
+				  when sending event messages to openl2tpd.
+
+pppd will typically be started by an L2TP daemon for each L2TP sesion,
+supplying one or more of the above arguments as required. The pppd
+user will usually have no visibility of these arguments.
+
+Two hooks are exported by this plugin.
+
+void (*pppol2tp_send_accm_hook)(int tunnel_id, int session_id,
+     uint32_t send_accm, uint32_t recv_accm);
+void (*pppol2tp_ip_updown_hook)(int tunnel_id, int session_id, int up);
+
+Credits
+=======
+
+This plugin was developed by Katalix Systems as part of the OpenL2TP
+project, http://openl2tp.sourceforge.net. OpenL2TP is a full-featured
+L2TP client-server, suitable for use as an enterprise L2TP VPN server
+or a VPN client.
+
+Please copy problems to the OpenL2TP mailing list:
[email protected].
+
+Maintained by:
+	James Chapman
+	[email protected]
+	Katalix Systems Ltd
+	http://www.katalix.com
pppd/plugins/pppol2tp/Makefile.linux new file +29 -0
Index: ppp-2.4.4/pppd/plugins/pppol2tp/Makefile.linux
===================================================================
@@ -0,0 +1,29 @@
+CC	= gcc
+COPTS	= -O2 -g
+CFLAGS	= $(COPTS) -I../.. -I../../../include -fPIC
+LDFLAGS	= -shared
+INSTALL	= install
+
+#***********************************************************************
+
+DESTDIR = @DESTDIR@
+LIBDIR = $(DESTDIR)/lib/pppd/$(VERSION)
+
+VERSION = $(shell awk -F '"' '/VERSION/ { print $$2; }' ../../patchlevel.h)
+
+PLUGINS := pppol2tp.so
+
+all: $(PLUGINS)
+
+%.so: %.o
+	$(CC) $(CFLAGS) -o $@ -shared $^ $(LIBS)
+
+install: all
+	$(INSTALL) -d -m 755 $(LIBDIR)
+	$(INSTALL) -c -m 4550 $(PLUGIN) $(LIBDIR)
+
+clean:
+	rm -f *.o *.so
+
+%.o: %.c
+	$(CC) $(CFLAGS) -c -o $@ $<
pppd/plugins/pppol2tp/pppol2tp.c new file +500 -0

500 lines not on this page · raw message

pppd/plugins/Makefile.linux +1 -1
Index: ppp-2.4.4/pppd/plugins/Makefile.linux
===================================================================
@@ -9,7 +9,7 @@ BINDIR = $(DESTDIR)/sbin
 MANDIR = $(DESTDIR)/share/man/man8
 LIBDIR = $(DESTDIR)/lib/pppd/$(VERSION)
 
-SUBDIRS := rp-pppoe pppoatm
+SUBDIRS := rp-pppoe pppoatm pppol2tp
 # Uncomment the next line to include the radius authentication plugin
 SUBDIRS += radius
 PLUGINS := minconn.so passprompt.so passwordfd.so winbind.so
configure +2 -1
Index: ppp-2.4.4/configure
===================================================================
@@ -194,7 +194,8 @@ if [ -d "$ksrc" ]; then
     mkmkf $ksrc/Makefile.top Makefile
     mkmkf $ksrc/Makedefs$compiletype Makedefs.com
     for dir in pppd pppstats chat pppdump pppd/plugins pppd/plugins/rp-pppoe \
-	       pppd/plugins/radius pppd/plugins/pppoatm; do
+	       pppd/plugins/radius pppd/plugins/pppoatm \
+	       pppd/plugins/pppol2tp; do
 	mkmkf $dir/Makefile.$makext $dir/Makefile
     done
     if [ -f $ksrc/Makefile.$makext$archvariant ]; then
include/linux/if_pppol2tp.h new file +69 -0

69 lines not on this page · raw message

This patch adds a plugin that lets OpenL2TP receive events from pppd. It requires the pppol2tp plugin. Events are passed using a Unix socket.

pppd/plugins/pppol2tp/Makefile.linux +2 -2
Index: ppp-2.4.4/pppd/plugins/pppol2tp/Makefile.linux
===================================================================
@@ -1,6 +1,6 @@
 CC	= gcc
 COPTS	= -O2 -g
-CFLAGS	= $(COPTS) -I../.. -I../../../include -fPIC
+CFLAGS	= $(COPTS) -I. -I../.. -I../../../include -fPIC
 LDFLAGS	= -shared
 INSTALL	= install
 
@@ -11,7 +11,7 @@ LIBDIR = $(DESTDIR)/lib/pppd/$(VERSION)
 
 VERSION = $(shell awk -F '"' '/VERSION/ { print $$2; }' ../../patchlevel.h)
 
-PLUGINS := pppol2tp.so
+PLUGINS := pppol2tp.so openl2tp.so
 
 all: $(PLUGINS)
 
pppd/plugins/pppol2tp/l2tp_event.h new file +104 -0

104 lines not on this page · raw message

pppd/plugins/pppol2tp/openl2tp.c new file +308 -0

308 lines not on this page · raw message

#1 lore raw
Quoted 3 lines · James Chapman

These plugins are being actively used by users of OpenL2TP and other L2TP daemons. Please consider for inclusion in the next release of pppd.

Looks OK. I want to do a new release of pppd fairly soon, so this is timely.

pppd/plugins/pppol2tp/l2tp_event.h line 8

Quoted 12 lines

Index: ppp-2.4.4/pppd/plugins/pppol2tp/l2tp_event.h =================================> --- /dev/null +++ ppp-2.4.4/pppd/plugins/pppol2tp/l2tp_event.h

pppd/plugins/pppol2tp/l2tp_event.h new file +8 -0
@@ -0,0 +1,104 @@
+/*****************************************************************************
+ * Copyright (C) 2008 Katalix Systems Ltd
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ *****************************************************************************/

Could you add the explicit "you can redistribute it and/or modify it..." permission statement here please?

pppd/plugins/pppol2tp/openl2tp.c line 273

Quoted 7 lines
pppd/plugins/pppol2tp/openl2tp.c new file +7 -0
+ * Unfortunately, pppd provides no easy way to tell that the new link
+ * successfully attaches to the bundle. We use its new_phase_hook to
+ * watch state changes. If the new interface reaches PHASE_NETWORK,
+ * then it is up. However, pppd sets variables that we need to test
+ * _after_ it reaches PHASE_NETWORK, so we use a timer to check the
+ * variables. This is messy. It would be much easier if pppd exported
+ * a hook for multilink interface up.

So, send me a patch to do that... :)

Paul.

author maintainer
#2 lore raw

PATCH 1/1 Introduce L2TP support (#2)

In reply to James Chapman

The attached patch set introduces L2TP support for Linux. There are now 3 patches. These patches have been updated to include the changes requested.

ppp-add-pppol2tp-plugin.patch
Adds a pppol2tp plugin which lets pppd use the Linux pppol2tp.ko kernel driver to pass PPP frames in L2TP tunnels using PPPoL2TP sockets.

ppp-add-multilink-join-hook.patch
Adds a new hook: multilink_join_hook. This is called for multilink interfaces in start_networks() and allows plugins to be told when a new interface joins a multilink bundle. The openl2tp.so plugin previously used new_phase_hook to watch when new interfaces joined a bundle, but this new hook is a much cleaner way of achieving the same result.

ppp-add-openl2tp-plugin.patch
Adds an event interface which is used by the OpenL2TP implementation to
receive events from pppd using a Unix socket. Updated to use
multilink_join_hook.

The L2TP plugins are being actively used by users of OpenL2TP and other L2TP daemons. Please consider for inclusion in the next release of pppd.

Thanks!

Signature · 4 lines
James Chapman
Katalix Systems Ltd
http://www.katalix.com
Catalysts for your Embedded Linux software development

ppp-add-pppol2tp-plugin.patch
ppp-add-multilink-join-hook.patch
ppp-add-openl2tp-plugin.patch

This patch adds support for L2TP. It allows pppd to interface with the pppol2tp driver in the Linux kernel. All data packets are handled by the Linux kernel in order that the datapath be as efficient as possible, while a userspace daemon implements the L2TP control protocol, handling tunnel/session setup and teardown. The implementation uses the PPPoX infrastructure; the architecture is similar to PPPoE/PPPoATM in that a userspace daemon spawns a pppd process per PPP session and uses a protocol-specific plugin to connect pppd with the kernel.

The pppol2tp Linux kernel driver was integrated in the Linux kernel from 2.6.23. For earlier kernels, an out of tree driver is available from the pppol2tp-kmod package on the OpenL2TP project site at
http://sourceforge.net/projects/openl2tp.

README.pppol2tp new file +66 -0
Index: ppp-2.4.4/README.pppol2tp
===================================================================
@@ -0,0 +1,66 @@
+PPPoL2TP plugin
+===============
+
+The pppol2tp plugin lets pppd use the Linux kernel driver pppol2tp.ko
+to pass PPP frames in L2TP tunnels. The driver was integrated into the
+kernel in the 2.6.23 release. For kernels before 2.6.23, an
+out-of-tree kernel module is available from the pppol2tp-kmod package
+in the OpenL2TP project.
+
+Note that pppd receives only PPP control frames over the PPPoL2TP
+socket; data frames are handled entirely by the kernel.
+
+The pppol2tp plugin adds extra arguments to pppd and uses the Linux kernel
+PPP-over-L2TP driver to set up each session's data path.
+
+Arguments are:-
+
+pppol2tp <fd>                   - FD for PPPoL2TP socket
+pppol2tp_lns_mode               - PPPoL2TP LNS behavior. Default off.
+pppol2tp_send_seq               - PPPoL2TP enable sequence numbers in
+                                  transmitted data packets. Default off.
+pppol2tp_recv_seq               - PPPoL2TP enforce sequence numbers in
+                                  received data packets. Default off.
+pppol2tp_reorderto <millisecs>  - PPPoL2TP data packet reorder timeout.
+                                  Default 0 (no reordering).
+pppol2tp_debug_mask <mask>      - PPPoL2TP debug mask. Bitwise OR of
+				  1 - verbose debug
+				  2 - control
+				  4 - kernel transport
+				  8 - ppp packet data
+				  Default: 0 (no debug).
+pppol2tp_ifname <ifname>	- Name of PPP network interface visible
+				  to "ifconfig" and "ip link".
+				  Default: "pppN"
+pppol2tp_tunnel_id <id>		- L2TP tunnel_id tunneling this PPP
+				  session.
+pppol2tp_session_id <id>	- L2TP session_id of this PPP session.
+				  The tunnel_id/session_id pair is used
+				  when sending event messages to openl2tpd.
+
+pppd will typically be started by an L2TP daemon for each L2TP sesion,
+supplying one or more of the above arguments as required. The pppd
+user will usually have no visibility of these arguments.
+
+Two hooks are exported by this plugin.
+
+void (*pppol2tp_send_accm_hook)(int tunnel_id, int session_id,
+     uint32_t send_accm, uint32_t recv_accm);
+void (*pppol2tp_ip_updown_hook)(int tunnel_id, int session_id, int up);
+
+Credits
+=======
+
+This plugin was developed by Katalix Systems as part of the OpenL2TP
+project, http://openl2tp.sourceforge.net. OpenL2TP is a full-featured
+L2TP client-server, suitable for use as an enterprise L2TP VPN server
+or a VPN client.
+
+Please copy problems to the OpenL2TP mailing list:
[email protected].
+
+Maintained by:
+	James Chapman
+	[email protected]
+	Katalix Systems Ltd
+	http://www.katalix.com
pppd/plugins/pppol2tp/Makefile.linux new file +29 -0
Index: ppp-2.4.4/pppd/plugins/pppol2tp/Makefile.linux
===================================================================
@@ -0,0 +1,29 @@
+CC	= gcc
+COPTS	= -O2 -g
+CFLAGS	= $(COPTS) -I../.. -I../../../include -fPIC
+LDFLAGS	= -shared
+INSTALL	= install
+
+#***********************************************************************
+
+DESTDIR = @DESTDIR@
+LIBDIR = $(DESTDIR)/lib/pppd/$(VERSION)
+
+VERSION = $(shell awk -F '"' '/VERSION/ { print $$2; }' ../../patchlevel.h)
+
+PLUGINS := pppol2tp.so
+
+all: $(PLUGINS)
+
+%.so: %.o
+	$(CC) $(CFLAGS) -o $@ -shared $^ $(LIBS)
+
+install: all
+	$(INSTALL) -d -m 755 $(LIBDIR)
+	$(INSTALL) -c -m 4550 $(PLUGIN) $(LIBDIR)
+
+clean:
+	rm -f *.o *.so
+
+%.o: %.c
+	$(CC) $(CFLAGS) -c -o $@ $<
pppd/plugins/pppol2tp/pppol2tp.c new file +526 -0

526 lines not on this page · raw message

pppd/plugins/Makefile.linux +1 -1
Index: ppp-2.4.4/pppd/plugins/Makefile.linux
===================================================================
@@ -9,7 +9,7 @@ BINDIR = $(DESTDIR)/sbin
 MANDIR = $(DESTDIR)/share/man/man8
 LIBDIR = $(DESTDIR)/lib/pppd/$(VERSION)
 
-SUBDIRS := rp-pppoe pppoatm
+SUBDIRS := rp-pppoe pppoatm pppol2tp
 # Uncomment the next line to include the radius authentication plugin
 SUBDIRS += radius
 PLUGINS := minconn.so passprompt.so passwordfd.so winbind.so
configure +2 -1
Index: ppp-2.4.4/configure
===================================================================
@@ -194,7 +194,8 @@ if [ -d "$ksrc" ]; then
     mkmkf $ksrc/Makefile.top Makefile
     mkmkf $ksrc/Makedefs$compiletype Makedefs.com
     for dir in pppd pppstats chat pppdump pppd/plugins pppd/plugins/rp-pppoe \
-	       pppd/plugins/radius pppd/plugins/pppoatm; do
+	       pppd/plugins/radius pppd/plugins/pppoatm \
+	       pppd/plugins/pppol2tp; do
 	mkmkf $dir/Makefile.$makext $dir/Makefile
     done
     if [ -f $ksrc/Makefile.$makext$archvariant ]; then
include/linux/if_pppol2tp.h new file +69 -0

69 lines not on this page · raw message

This patch adds a multilink_join_hook for plugins to hear about new interfaces added to a multilink bundle.

pppd/auth.c +8 -0
Index: ppp-2.4.4/pppd/auth.c
===================================================================
@@ -195,6 +195,11 @@ int (*null_auth_hook) __P((struct wordli
 
 int (*allowed_address_hook) __P((u_int32_t addr)) = NULL;
 
+#ifdef HAVE_MULTILINK
+/* Hook for plugin to hear when an interface joins a multilink bundle */
+void (*multilink_join_hook) __P((void)) = NULL;
+#endif
+
 /* A notifier for when the peer has authenticated itself,
    and we are proceeding to the network phase. */
 struct notifier *auth_up_notifier = NULL;
@@ -853,6 +858,9 @@ start_networks(unit)
 #ifdef HAVE_MULTILINK
     if (multilink) {
 	if (mp_join_bundle()) {
+	    if (multilink_join_hook) {
+		(*multilink_join_hook)();
+	    }
 	    if (updetach && !nodetach)
 		detach();
 	    return;
pppd/pppd.h +1 -0
Index: ppp-2.4.4/pppd/pppd.h
===================================================================
@@ -714,6 +714,7 @@ extern void (*ip_choose_hook) __P((u_int
 
 extern int (*chap_check_hook) __P((void));
 extern int (*chap_passwd_hook) __P((char *user, char *passwd));
+extern void (*multilink_join_hook) __P((void));
 
 /* Let a plugin snoop sent and received packets.  Useful for L2TP */
 extern void (*snoop_recv_hook) __P((unsigned char *p, int len));

This patch adds a plugin that lets OpenL2TP receive events from pppd. It requires the pppol2tp plugin. Events are passed using a Unix socket.

pppd/plugins/pppol2tp/Makefile.linux +2 -2
Index: ppp-2.4.4/pppd/plugins/pppol2tp/Makefile.linux
===================================================================
@@ -1,6 +1,6 @@
 CC	= gcc
 COPTS	= -O2 -g
-CFLAGS	= $(COPTS) -I../.. -I../../../include -fPIC
+CFLAGS	= $(COPTS) -I. -I../.. -I../../../include -fPIC
 LDFLAGS	= -shared
 INSTALL	= install
 
@@ -11,7 +11,7 @@ LIBDIR = $(DESTDIR)/lib/pppd/$(VERSION)
 
 VERSION = $(shell awk -F '"' '/VERSION/ { print $$2; }' ../../patchlevel.h)
 
-PLUGINS := pppol2tp.so
+PLUGINS := pppol2tp.so openl2tp.so
 
 all: $(PLUGINS)
 
pppd/plugins/pppol2tp/l2tp_event.h new file +115 -0

115 lines not on this page · raw message

pppd/plugins/pppol2tp/openl2tp.c new file +294 -0

294 lines not on this page · raw message

#3 lore raw
In reply to James Chapman
Quoted 12 lines · Paul Mackerras
Quoted 4 lines · James Chapman

These plugins are being actively used by users of OpenL2TP and other L2TP daemons. Please consider for inclusion in the next release of pppd.

Looks OK. I want to do a new release of pppd fairly soon, so this is timely.

Hi Paul,

I've just put up a webpage with the latest EAP-TLS+MPPE patch
http://www.nikhef.nl/~janjust/ppp/

it is based on openssl - any chance of including that one as well ;-) ? I'll grab the L2TP patch and see if there are any conflicts: it is actually quite interesting to be able to do L2TP+EAP-TLS+MPPE for added security...

cheers,

JJK / Jan Just Keijser