Blob Blame History Raw
This implements the --nohostroute option that routing.c talks about. It
prevents pptp from adding a host route towards the VPN server and would
usually be used with either "Split tunneling" or the --rtmark option.
Also document it appropriately.

(routing.c had it as --no-host-route, however the dashes are
inconsistent with --nobuffer and --nolaunchpppd)

Signed-off-by: David Lamparter <david.lamparter@adyton.net>
Cc: David Lamparter <equinox@diac24.net>
Cc: Franco Fichtner <franco.fichtner@adyton.net>
---
Attached code is put into public domain affirmed by both me
(David Lamparter, the author) as well as my employer (Adyton
Systems AG) who paid for it to be written. Assigning copyright
to the FSF is impossible under German law.

David Lamparter | Software Developer | Adyton Systems AG
Mozartstr. 3 | 04107 Leipzig | Germany
phone +49 341.39 299 343 | fax +49 341.39 299 343-9
trade register: Amtsgericht Leipzig HRB26578

 ChangeLog      |    6 ++++++
 NEWS           |    1 +
 pptp.8         |   27 +++++++++++++++++++++++++++
 pptp.c         |    5 +++++
 pptp_callmgr.c |    7 +++++--
 routing.c      |    2 +-
 6 files changed, 45 insertions(+), 3 deletions(-)

diff --git a/pptp.8 b/pptp.8
index 2da66c9..017b5db 100644
--- a/pptp.8
+++ b/pptp.8
@@ -92,6 +92,11 @@ can be used with
 
 (requires root privileges or the CAP_NET_ADMIN capability.)
 .TP
+.B \-\-nohostroute
+Do not configure a host route pointing towards the PPTP server.
+(cf. ROUTING below)
+
+.TP
 .B \-\-loglevel <level>
 Sets the debugging level (0=low, 1=default, 2=high)
 
@@ -115,6 +120,28 @@ Default is 100.  Has no effect if test-type is zero.  The result of
 test types 2 and 3 are undefined if this value is less than ten.
 
 
+.SH "ROUTING"
+When PPTP is used in conjunction with a default route on top of the
+tunnel (or just any route encompassing the PPTP server),
+the mechanics of routing would cause the PPTP packets themselves
+to be routed over the tunnel. This would result in an encapsulation
+loop, destroying connectivity.
+
+.B pptp
+by default works around this by looking up the route towards the
+PPTP server at startup and configures a host route with that data.
+This essentially "freezes" routing for PPTP packets at the startup
+configuration. This behaviour can be disabled with
+.B --nohostroute
+if undesired (like when using
+.B --rtmark
+to implement policy routing).
+
+.B NB:
+the route added by
+.B pptp
+is currently not deleted at exit!
+
 .SH "QUIRKS"
 
 .TP
diff --git a/pptp.c b/pptp.c
index 26b6006..a3d4ad6 100644
--- a/pptp.c
+++ b/pptp.c
@@ -121,6 +121,7 @@ void usage(char *progname)
 #ifdef SO_MARK
             "  --rtmark <n>	Use specified policy routing mark for all packets\n"
 #endif
+            "  --nohostroute		Do not add host route towards <hostname>\n"
             "  --loglevel <level>	Sets the debugging level (0=low, 1=default, 2=high)\n"
             "  --test-type <type>	Damage the packet stream by reordering\n"
             "  --test-rate <n>		Do the test every n packets\n",
@@ -136,6 +137,7 @@ struct in_addr localbind = { .s_addr = INADDR_ANY };
 struct in_addr localbind = { INADDR_NONE };
 #endif
 int rtmark = 0;
+int nohostroute = 0;
 static int signaled = 0;
 
 /*** do nothing signal handler ************************************************/
@@ -217,6 +219,7 @@ int main(int argc, char **argv, char **envp)
 	    {"test-type", 1, 0, 0},
 	    {"test-rate", 1, 0, 0},
 	    {"rtmark", 1, 0, 0},
+	    {"nohostroute", 0, 0, 0},
             {0, 0, 0, 0}
         };
         int option_index = 0;
@@ -303,6 +306,8 @@ int main(int argc, char **argv, char **envp)
 				    "this binary was compiled.\n");
 		    exit(2);
 #endif
+		} else if (option_index == 16) { /* --nohostroute */
+		    nohostroute = 1;
                 }
                 break;
             case '?': /* unrecognised option */
diff --git a/pptp_callmgr.c b/pptp_callmgr.c
index e6b6fd3..3c5b83d 100644
--- a/pptp_callmgr.c
+++ b/pptp_callmgr.c
@@ -32,6 +32,7 @@
 
 extern struct in_addr localbind; /* from pptp.c */
 extern int rtmark;
+extern int nohostroute;
 
 int open_inetsock(struct in_addr inetaddr);
 int open_unixsock(struct in_addr inetaddr);
@@ -124,8 +125,10 @@ int callmgr_main(int argc, char **argv, char **envp)
     phonenr = argc == 3 ? argv[2] : NULL;
     if (inet_aton(argv[1], &inetaddr) == 0)
         fatal("Invalid IP address: %s", argv[1]);
-    routing_init(inet_ntoa(inetaddr));
-    routing_start();
+    if (!nohostroute) {
+        routing_init(inet_ntoa(inetaddr));
+        routing_start();
+    }
     /* Step 1: Open sockets. */
     if ((inet_sock = open_inetsock(inetaddr)) < 0)
         fatal("Could not open control connection to %s", argv[1]);
diff --git a/routing.c b/routing.c
index b132d64..7ef5724 100644
--- a/routing.c
+++ b/routing.c
@@ -51,7 +51,7 @@ Design discussion.
 The primary task of this module is to add a host route to the PPTP
 server so that the kernel continues to deliver PPTP control and data
 connection packets to the server despite the new PPP interface that is
-created.  The flag --no-host-route is to disable this (not yet implemented).
+created.  The flag --nohostroute is to disable this.
 
 A secondary task may be to implement all-to-tunnel routing if the
 appropriate flag is specified on the command line.  The flag