[Xorp-cvs] SF.net SVN: xorp:[11665] trunk/xorp
bms_fbsd at users.sourceforge.net
bms_fbsd at users.sourceforge.net
Thu Dec 3 15:10:07 PST 2009
Revision: 11665
http://xorp.svn.sourceforge.net/xorp/?rev=11665&view=rev
Author: bms_fbsd
Date: 2009-12-03 23:10:07 +0000 (Thu, 03 Dec 2009)
Log Message:
-----------
Add option 'transport' to control which protocol libxipc will
chose for inter-process communication by default.
The default, 'transport=local', causes UNIX domain stream sockets
to be used.
Users who need to be able to distribute XORP components across
multiple IP addresses should choose 'transport=tcp' when compiling,
or else set XORP_PF=t in the environment when running XORP components.
Implementation note:
The XRL_PF preprocessor macro is passed as an ordinal character constant,
to avoid shell quoting issues, as it is specified by 1 character.
It needs to be passed from the top level to make sure the option
is propagated correctly, because anything which includes
<libxipc/xrl_std_router.hh> will be affected by this option.
Discussed on: xorp-hackers@
Modified Paths:
--------------
trunk/xorp/SConstruct
trunk/xorp/libxipc/xrl_std_router.cc
trunk/xorp/libxipc/xrl_std_router.hh
Modified: trunk/xorp/SConstruct
===================================================================
--- trunk/xorp/SConstruct 2009-12-03 22:54:21 UTC (rev 11664)
+++ trunk/xorp/SConstruct 2009-12-03 23:10:07 UTC (rev 11665)
@@ -74,6 +74,9 @@
EnumVariable('profile', 'Build with profiling', 'no',
allowed_values=('no', 'gprof', 'pprof', 'override'),
map={}, ignorecase=2),
+ EnumVariable('transport', 'Set default XRL transport protocol', 'local',
+ allowed_values=('tcp', 'local'),
+ map={}, ignorecase=2),
PathVariable('prefix', 'Install prefix',
'/usr/local/xorp', PathVariable.PathAccept),
)
@@ -170,6 +173,9 @@
# Default to disable; wrapper for compiler profiling support.
print 'Profile code: ', env['profile']
+# Default to local (UNIX domain sockets).
+print 'Default XRL transport:', env['transport']
+
# Most of our shared library tweaks are specific to GNU ld.
# Check if the GNU linker is available, and print a warning if not.
if env['shared']:
@@ -495,7 +501,25 @@
env.AppendUnique( LIBS = [ 'profiler' ] )
#env.AppendUnique( CPPDEFINES = [ 'WITH_PPROF' ] )
+#
+# Apply top-level 'transport' protocol option, which controls the
+# default transport protocol chosen by libxipc.
+#
+# We pass it as an ordinal character constant to avoid shell
+# quoting issues, as it is specified by 1 character.
+#
+# Note: We need to do this at top level to make sure the option
+# is propagated correctly, because anything which includes
+# <libxipc/xrl_std_router.hh> will be affected by this option.
+#
+xrl_pf_dict = { 'tcp': 't', 'local': 'x' }
env.AppendUnique(CPPDEFINES = [
+ ( 'XRL_PF', ord(xrl_pf_dict[env['transport']]) ),
+ ])
+
+# Forcibly disable GCC's SSP support., as it may be incompatible
+# with the XORP code base.
+env.AppendUnique(CPPDEFINES = [
( '_FORTIFY_SOURCE', 0 ),
])
Modified: trunk/xorp/libxipc/xrl_std_router.cc
===================================================================
--- trunk/xorp/libxipc/xrl_std_router.cc 2009-12-03 22:54:21 UTC (rev 11664)
+++ trunk/xorp/libxipc/xrl_std_router.cc 2009-12-03 23:10:07 UTC (rev 11665)
@@ -23,42 +23,55 @@
#include "xrl_module.h"
#include "xrl_std_router.hh"
-//#include "xrl_pf_inproc.hh"
+//#include "xrl_pf_inproc.hh" // Inproc is deprecated.
#include "xrl_pf_stcp.hh"
-//#include "xrl_pf_sudp.hh"
+//#include "xrl_pf_sudp.hh" // UDP is deprecated.
#include "xrl_pf_unix.hh"
#include "libxorp/xlog.h"
+
// ----------------------------------------------------------------------------
// Helper methods
+#if !defined(XRL_PF)
+#error "A default transport for XRL must be defined using the preprocessor."
+#endif
+
+static const char default_pf[] = { XRL_PF, '\0' };
+
XrlPFListener*
XrlStdRouter::create_listener()
{
const char* pf = getenv("XORP_PF");
+ if (pf == NULL)
+ pf = default_pf;
- if (pf != NULL) {
- switch (pf[0]) {
-#if 0
+ switch (pf[0]) {
+#if 0 // Inproc is deprecated.
case 'i':
return new XrlPFInProcListener(_e, this);
-
+#endif
+ // For the benefit of bench_ipc.sh.
+ case 't':
+ return new XrlPFSTCPListener(_e, this);
+ break;
+#if 0 // UDP is deprecated.
case 'u':
return new XrlPFSUDPListener(_e, this);
#endif
-
case 'x':
+#if XRL_PF != 'x'
XLOG_ASSERT(_unix == NULL);
+#endif
return new XrlPFUNIXListener(_e, this);
-
default:
XLOG_ERROR("Unknown PF %s\n", pf);
XLOG_ASSERT(false);
break;
- }
}
- return new XrlPFSTCPListener(_e, this);
+ XLOG_UNREACHABLE();
+ return 0;
}
static void
@@ -125,6 +138,14 @@
{
_unix = _l = NULL;
+ // We need to check the environment otherwise
+ // we get the compiled-in default.
+ const char* pf = getenv("XORP_PF");
+ if (pf == NULL)
+ pf = default_pf;
+ if (pf[0] != 'x')
+ unix_socket = false;
+
if (unix_socket)
create_unix_listener();
Modified: trunk/xorp/libxipc/xrl_std_router.hh
===================================================================
--- trunk/xorp/libxipc/xrl_std_router.hh 2009-12-03 22:54:21 UTC (rev 11664)
+++ trunk/xorp/libxipc/xrl_std_router.hh 2009-12-03 23:10:07 UTC (rev 11665)
@@ -27,7 +27,11 @@
#include "xrl_router.hh"
#include "xrl_pf.hh"
+#if !defined(XRL_PF) || (XRL_PF == 'x')
+#define UNIX_SOCKET_DEFAULT true
+#else
#define UNIX_SOCKET_DEFAULT false
+#endif
/**
* @short Standard XRL transmission and reception point.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Xorp-cvs
mailing list