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

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

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

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

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

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