Hello,

I would like to announce that I finally reached 80 mbps of download
via pure L2TP tunnel (without IPsec).

I digged through ppp(4) and pppd(8) code several times and I could not
find any bottlenecks. Looks like we need to change whole design of
ppp(4) to reach any usable download speed.

So I change direction and add pipex(4) support to ppp(4), only in Rx
path for now. And the same machine (Pentium D @3GHz) give me 80 mbps
of download rate instead of 20 mbps when run without pipex.

If somebody wants to reproduce the trick, you need a couple of patches
(one for ppp driver and second for xl2tpd) and utility to configure
pipex session (my version is here
https://github.com/rsa9000/pipexctl). Patches inlined below and
attached to mail due to gmail's rule to mangle whitespaces.

First of all you need to patch and rebuild the kernel. Then you need
to patch xl2tpd package and rebuild it too. Then activate pipex via
sysctl, configure and start xl2tpd as usual. Make sure that packets
are successfully traveling via established link.

Then the most trickly part: you need parse ouput of xl2tpd (to console
or syslog) and fetch Tunnel-Id & Session-Id values of running tunnel.
Then run (consult pipex man page for parameters description):
# pipexctl addsess l2tp <your params here>

Command should looks like:
# pipexctl addsess l2tp  AA  BB  A.B.C.D  E.F.G.H 255.255.255.0
I.J.K.L:1701  M.N.O.P:1701  CC  DD

Actually most parameters except your Session-Id could be zero.

My further plans includes following actions:
 - add pipex support to Tx path of ppp(4)
 - backport plugins support from upstream to pppd(8)
 - make a plugin for pppd(8) to facilitate pipex usage (a-la pppol2tp for Linux)
 - add pipex plugin configuration support to xl2tpd (both to our port
and to upstream)

I would like to ask, does someone have any objections against such changes?

I would like to complete this work until next release, but it all
depends on whether I have free time or not.

Kernel patch:
diff -ru sys.orig/net/if_ppp.c sys/net/if_ppp.c
--- sys.orig/net/if_ppp.c 2015-11-20 09:22:09.000000000 +0300
+++ sys/net/if_ppp.c 2016-06-21 02:41:59.000000000 +0300
@@ -129,6 +129,10 @@
 #include <netinet/in.h>
 #include <netinet/ip.h>

+#ifdef PIPEX
+#include <net/pipex.h>
+#endif
+
 #include "bpfilter.h"

 #ifdef VJC
@@ -199,6 +203,9 @@
 {
  LIST_INIT(&ppp_softc_list);
  if_clone_attach(&ppp_cloner);
+#ifdef PIPEX
+ pipex_init();
+#endif
 }

 int
@@ -236,6 +243,10 @@
  LIST_INSERT_HEAD(&ppp_softc_list, sc, sc_list);
  splx(s);

+#ifdef PIPEX
+ pipex_iface_init(&sc->pipex_iface, &sc->sc_if);
+#endif
+
  return (0);
 }

@@ -248,6 +259,10 @@
  if (sc->sc_devp != NULL)
  return (EBUSY);

+#ifdef PIPEX
+ pipex_iface_fini(&sc->pipex_iface);
+#endif
+
  s = splnet();
  LIST_REMOVE(sc, sc_list);
  splx(s);
@@ -564,6 +579,19 @@
  break;
 #endif

+#ifdef PIPEX
+ case PIPEXSMODE:
+ case PIPEXGMODE:
+ case PIPEXASESSION:
+ case PIPEXDSESSION:
+ case PIPEXCSESSION:
+ case PIPEXGSTAT:
+ s = splnet();
+ error = pipex_ioctl(&sc->pipex_iface, cmd, data);
+ splx(s);
+ return error;
+#endif
+
  default:
  return (-1);
  }
diff -ru sys.orig/net/if_pppvar.h sys/net/if_pppvar.h
--- sys.orig/net/if_pppvar.h 2015-11-06 12:04:36.000000000 +0300
+++ sys/net/if_pppvar.h 2016-06-21 02:41:59.000000000 +0300
@@ -140,6 +140,10 @@
  u_char sc_rawin[16]; /* chars as received */
  int sc_rawin_count; /* # in sc_rawin */
  LIST_ENTRY(ppp_softc) sc_list; /* all ppp interfaces */
+
+#ifdef PIPEX
+ struct pipex_iface_context pipex_iface; /* pipex context */
+#endif
 };

 #ifdef _KERNEL
diff -ru sys.orig/net/ppp_tty.c sys/net/ppp_tty.c
--- sys.orig/net/ppp_tty.c 2016-01-25 21:47:00.000000000 +0300
+++ sys/net/ppp_tty.c 2016-06-21 02:41:59.000000000 +0300
@@ -122,6 +122,10 @@
 #include <net/slcompress.h>
 #endif

+#ifdef PIPEX
+#include <net/pipex.h>
+#endif
+
 #include <net/bpf.h>
 #include <net/ppp_defs.h>
 #include <net/if_ppp.h>

x2tpd patch:
--- network.c.orig
+++ network.c
@@ -25,6 +25,10 @@
 #ifndef LINUX
 # include <sys/uio.h>
 #endif
+#ifdef OPENBSD
+#include <net/if.h>
+#include <net/pipex.h>
+#endif
 #include "l2tp.h"
 #include "ipsecmast.h"
 #include "misc.h"    /* for IPADDY macro */
@@ -83,6 +87,10 @@

 #endif

+    arg=1;
+    if (setsockopt(server_socket, IPPROTO_IP, IP_PIPEX, &arg,
sizeof(arg)) != 0)
+    l2tp_log(LOG_CRIT, "setsockopt pipex: %s\n", strerror(errno));
+
 #ifdef USE_KERNEL
     if (gconfig.forceuserspace)
     {

-- 
Sergey
diff -ru sys.orig/net/if_ppp.c sys/net/if_ppp.c
--- sys.orig/net/if_ppp.c	2015-11-20 09:22:09.000000000 +0300
+++ sys/net/if_ppp.c	2016-06-21 02:41:59.000000000 +0300
@@ -129,6 +129,10 @@
 #include <netinet/in.h>
 #include <netinet/ip.h>
 
+#ifdef PIPEX
+#include <net/pipex.h>
+#endif
+
 #include "bpfilter.h"
 
 #ifdef VJC
@@ -199,6 +203,9 @@
 {
 	LIST_INIT(&ppp_softc_list);
 	if_clone_attach(&ppp_cloner);
+#ifdef PIPEX
+	pipex_init();
+#endif
 }
 
 int
@@ -236,6 +243,10 @@
 	LIST_INSERT_HEAD(&ppp_softc_list, sc, sc_list);
 	splx(s);
 
+#ifdef PIPEX
+	pipex_iface_init(&sc->pipex_iface, &sc->sc_if);
+#endif
+
 	return (0);
 }
 
@@ -248,6 +259,10 @@
 	if (sc->sc_devp != NULL)
 		return (EBUSY);
 
+#ifdef PIPEX
+	pipex_iface_fini(&sc->pipex_iface);
+#endif
+
 	s = splnet();
 	LIST_REMOVE(sc, sc_list);
 	splx(s);
@@ -564,6 +579,19 @@
 		break;
 #endif
 
+#ifdef PIPEX
+	case PIPEXSMODE:
+	case PIPEXGMODE:
+	case PIPEXASESSION:
+	case PIPEXDSESSION:
+	case PIPEXCSESSION:
+	case PIPEXGSTAT:
+		s = splnet();
+		error = pipex_ioctl(&sc->pipex_iface, cmd, data);
+		splx(s);
+		return error;
+#endif
+
 	default:
 		return (-1);
 	}
diff -ru sys.orig/net/if_pppvar.h sys/net/if_pppvar.h
--- sys.orig/net/if_pppvar.h	2015-11-06 12:04:36.000000000 +0300
+++ sys/net/if_pppvar.h	2016-06-21 02:41:59.000000000 +0300
@@ -140,6 +140,10 @@
 	u_char	sc_rawin[16];		/* chars as received */
 	int	sc_rawin_count;		/* # in sc_rawin */
 	LIST_ENTRY(ppp_softc) sc_list;	/* all ppp interfaces */
+
+#ifdef PIPEX
+	struct pipex_iface_context pipex_iface;	/* pipex context */
+#endif
 };
 
 #ifdef _KERNEL
diff -ru sys.orig/net/ppp_tty.c sys/net/ppp_tty.c
--- sys.orig/net/ppp_tty.c	2016-01-25 21:47:00.000000000 +0300
+++ sys/net/ppp_tty.c	2016-06-21 02:41:59.000000000 +0300
@@ -122,6 +122,10 @@
 #include <net/slcompress.h>
 #endif
 
+#ifdef PIPEX
+#include <net/pipex.h>
+#endif
+
 #include <net/bpf.h>
 #include <net/ppp_defs.h>
 #include <net/if_ppp.h>
--- network.c.orig
+++ network.c
@@ -25,6 +25,10 @@
 #ifndef LINUX
 # include <sys/uio.h>
 #endif
+#ifdef OPENBSD
+#include <net/if.h>
+#include <net/pipex.h>
+#endif
 #include "l2tp.h"
 #include "ipsecmast.h"
 #include "misc.h"    /* for IPADDY macro */
@@ -83,6 +87,10 @@
 
 #endif
 
+    arg=1;
+    if (setsockopt(server_socket, IPPROTO_IP, IP_PIPEX, &arg, sizeof(arg)) != 0)
+	    l2tp_log(LOG_CRIT, "setsockopt pipex: %s\n", strerror(errno));
+
 #ifdef USE_KERNEL
     if (gconfig.forceuserspace)
     {

Reply via email to