Skip to contentSkip to conversation

Dynamic Routing Patch

Openvpn-devel reg9009 1 participant 1 message Jun 8, 2010 Kbuild

lore
Share & tools
lore

reg9009

author
#0 lore raw

Hi all,

here's the 2nd and hopefully cleaner version of the dynamic routing patch.

Regards,
Sebastian

From a122b9cfc5962e6fc3591e57a59599381a6d278c Mon Sep 17 00:00:00 2001
From: shundertmark <[email protected]...>
Date: Mon, 7 Jun 2010 13:58:38 +0200
Subject: [PATCH] First test with 'dynamic routing'

---
 Makefile.am  |    4 +
 configure.ac |   12 +++
 dynroute.c   |  285 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 dynroute.h   |   24 +++++
 multi.c      |   10 ++
 5 files changed, 335 insertions(+), 0 deletions(-)
 create mode 100644 dynroute.c
 create mode 100644 dynroute.h
Makefile.am +4 -0
index 2980dac..84e10d9 100644
@@ -152,3 +152,7 @@ openvpn.8.html: $(srcdir)/openvpn.8
 else
 dist_man_MANS = openvpn.8
 endif
+
+if ENABLE_DYNROUTE
+	openvpn_SOURCES += dynroute.c
+endif
configure.ac +12 -0
index 5575705..c7da5ff 100644
@@ -212,6 +212,12 @@ AC_ARG_ENABLE(selinux,
    [SELINUX="yes"]
 )
 
+AC_ARG_ENABLE(dynroute,
+   [  --enable-dynroute       Enable dynamic routing],
+   [DYNROUTE="$enableval"],
+   [DYNROUTE="no"]
+)
+
 AC_ARG_WITH(ssl-headers,
    [  --with-ssl-headers=DIR  Crypto/SSL Include files location],
    [CS_HDR_DIR="$withval"]
@@ -869,6 +875,12 @@ if test "$PASSWORD_SAVE" = "yes"; then
    AC_DEFINE(ENABLE_PASSWORD_SAVE, 1, [Allow --askpass and --auth-user-pass passwords to be read from a file])
 fi
 
+dnl enable dynroute
+if test "$DYNROUTE" = "yes"; then
+   AC_DEFINE(ENABLE_DYNROUTE, 1, [Enable dynamic routing])
+fi
+AM_CONDITIONAL(ENABLE_DYNROUTE, test "${DYNROUTE}" = "yes")
+
 dnl
 dnl check for SELinux library and headers
 dnl
dynroute.c new file +285 -0

285 lines not on this page · raw message

dynroute.h new file +24 -0
new file mode 100644
index 0000000..6dd5694
@@ -0,0 +1,24 @@
+#include <linux/rtnetlink.h>
+
+#ifndef DYNROUTE_H
+#define DYNROUTE_H
+
+//#define DYNROUTE_DEBUG_CHATTY 2
+//#define DYNROUTE_DEBUG DYNROUTE_DEBUG_CHATTY-1
+
+#define DRA_NONE 0
+#define DRA_NEW 1
+#define DRA_REP 2
+#define DRA_DEL 3
+
+struct dynroute
+{
+  int sock;  
+  int last_error;
+  bool initialized;
+  bool nope;
+  int action;
+  in_addr_t gateway;
+  struct iroute ir;
+};
+#endif /* DYNROUTE_H */
multi.c +10 -0
index 5c80c46..e1da1f6 100644
@@ -37,6 +37,10 @@
 #include "forward-inline.h"
 #include "pf-inline.h"
 
+#ifdef ENABLE_DYNROUTE
+#include "dynroute.c"
+#endif
+
 /*#define MULTI_DEBUG_EVENT_LOOP*/
 
 #ifdef MULTI_DEBUG_EVENT_LOOP
@@ -2273,6 +2277,12 @@ multi_process_timeout (struct multi_context *m, const unsigned int mpp_flags)
 {
   bool ret = true;
 
+#ifdef ENABLE_DYNROUTE
+  if (!dr.nope)
+    if (dynroute_read (&dr))
+      dynroute_eval (m, &dr);
+#endif
+
 #ifdef MULTI_DEBUG_EVENT_LOOP
   printf ("%s -> TIMEOUT\n", id(m->earliest_wakeup));
 #endif
Signature · 1 line
1.7.0.2.msysgit.0