From 263aa64c49cb92e26e608fb7fecfcbaf3b20db9e Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Thu, 28 Aug 2008 17:36:33 -0700 Subject: [PATCH] Add support for extensions submodule. --- .gitignore | 1 + .gitmodules | 3 ++ Make.vars | 15 +++--- Makefile.am | 6 +++ acinclude.m4 | 79 ++++++++++++++++++++++++++-- configure.ac | 104 ++++-------------------------------- ext | 1 + include/Makefile.am | 1 + include/vlog-modules.def | 36 +++++++++++++ include/vlog.h | 34 +----------- lib/vlog.c | 3 +- m4/libopenflow.m4 | 111 +++++++++++++++++++++++++++++++++++++++ 12 files changed, 253 insertions(+), 141 deletions(-) create mode 100644 .gitmodules create mode 160000 ext create mode 100644 include/vlog-modules.def create mode 100644 m4/libopenflow.m4 diff --git a/.gitignore b/.gitignore index ff011f2a..105f561e 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,7 @@ /autom4te.cache /build-arch-stamp /build-indep-stamp +/compile /config.guess /config.h /config.h.in diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..57d67d1f --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "ext"] + path = ext + url = ../openflowext diff --git a/Make.vars b/Make.vars index 583d3eb0..37727732 100644 --- a/Make.vars +++ b/Make.vars @@ -1,19 +1,20 @@ # -*- makefile -*- AM_CPPFLAGS = $(SSL_CFLAGS) - -COMMON_FLAGS = -DVERSION=\"$(VERSION)\" -if NDEBUG -COMMON_FLAGS += -DNDEBUG -fomit-frame-pointer +AM_CPPFLAGS += -I $(ofp_top_srcdir)/include +if HAVE_EXT +AM_CPPFLAGS += -I $(ofp_top_srcdir)/ext/include endif -AM_CFLAGS = $(COMMON_FLAGS) -AM_CFLAGS += -Wstrict-prototypes -I $(top_srcdir)/include +AM_CFLAGS = -DVERSION=\"$(VERSION)\" +AM_CFLAGS += -Wstrict-prototypes rundir = $(localstatedir)/run AM_CFLAGS += -DRUNDIR=\"$(rundir)\" -if !NDEBUG +if NDEBUG +AM_CFLAGS += -DNDEBUG -fomit-frame-pointer +else AM_LDFLAGS = -export-dynamic endif diff --git a/Makefile.am b/Makefile.am index 4644b057..d78bc2c8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,12 @@ AUTOMAKE_OPTIONS=foreign +ACLOCAL_AMFLAGS = -I m4 SUBDIRS = lib datapath secchan controller if HAVE_IF_PACKET SUBDIRS += switch endif SUBDIRS += utilities tests include third-party +if HAVE_EXT +SUBDIRS += ext +endif + +EXTRA_DIST = README.hwtables diff --git a/acinclude.m4 b/acinclude.m4 index bd16b997..4dacae87 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -30,12 +30,10 @@ # advertising or publicity pertaining to the Software or any # derivatives without specific, written prior permission. -dnl -- -dnl CHECK_LINUX(OPTION, VERSION, VARIABLE, CONDITIONAL) +dnl OFP_CHECK_LINUX(OPTION, VERSION, VARIABLE, CONDITIONAL) dnl dnl Configure linux kernel source tree -dnl -- -AC_DEFUN([CHECK_LINUX], [ +AC_DEFUN([OFP_CHECK_LINUX], [ AC_ARG_WITH([$1], [AC_HELP_STRING([--with-$1=/path/to/linux-$3], [Specify the linux $3 kernel sources])], @@ -66,3 +64,76 @@ AC_DEFUN([CHECK_LINUX], [ fi AM_CONDITIONAL($5, test -n "$path") ]) + +dnl Checks for --enable-hw-tables and substitutes HW_TABLES to any +dnl requested hardware table modules. +AC_DEFUN([OFP_CHECK_HWTABLES], + [AC_ARG_ENABLE( + [hw-tables], + [AC_HELP_STRING([--enable-hw-tables=MODULE...], + [Configure and build the specified externally supplied + hardware table support modules])]) + case "${enable_hw_tables}" in # ( + yes) + AC_MSG_ERROR([--enable-hw-tables has a required argument]) + ;; # ( + ''|no) + hw_tables= + ;; # ( + *) + hw_tables=`echo "$enable_hw_tables" | sed 's/,/ /g'` + ;; + esac + for d in $hw_tables; do + mk=datapath/hwtable_$d/Modules.mk + if test ! -e $srcdir/$mk; then + AC_MSG_ERROR([--enable-hw-tables=$d specified but $mk is missing]) + fi + HW_TABLES="$HW_TABLES \$(top_srcdir)/$mk" + done + AC_SUBST(HW_TABLES)]) + +dnl Checks for net/if_packet.h. +AC_DEFUN([OFP_CHECK_IF_PACKET], + [AC_CHECK_HEADER([net/if_packet.h], + [HAVE_IF_PACKET=yes], + [HAVE_IF_PACKET=no]) + AM_CONDITIONAL([HAVE_IF_PACKET], [test "$HAVE_IF_PACKET" = yes]) + if test "$HAVE_IF_PACKET" = yes; then + AC_DEFINE([HAVE_IF_PACKET], [1], + [Define to 1 if net/if_packet.h is available.]) + fi]) + +dnl Enable OpenFlow extension submodule. +AC_DEFUN([OFP_ENABLE_EXT], + [AC_ARG_ENABLE([ext], + AS_HELP_STRING([--enable-ext], + [use OpenFlow extensions + (default is yes if "ext" dir exists)])) + case "${enable_ext}" in + (yes) + HAVE_EXT=yes + ;; + (no) + HAVE_EXT=no + ;; + (*) + if test -d "$srcdir/ext"; then + HAVE_EXT=yes + else + HAVE_EXT=no + fi + ;; + esac + if test $HAVE_EXT = yes; then + if test -d "$srcdir/ext"; then + : + else + AC_MSG_ERROR([cannot configure extensions without "ext" directory]) + fi + AC_CONFIG_SUBDIRS([ext]) + AC_DEFINE([HAVE_EXT], [1], + [Whether the OpenFlow extensions submodule is available]) + fi + AC_SUBST([ofp_top_srcdir], ['$(top_srcdir)']) + AM_CONDITIONAL([HAVE_EXT], [test $HAVE_EXT = yes])]) diff --git a/configure.ac b/configure.ac index 3f0142e0..18dd1af5 100644 --- a/configure.ac +++ b/configure.ac @@ -32,6 +32,8 @@ AC_PREREQ(2.59) AC_INIT(openflow, v0.8.1, info@openflowswitch.org) +AC_CONFIG_SRCDIR([README.hwtables]) +AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_HEADERS([config.h]) AM_INIT_AUTOMAKE @@ -45,107 +47,19 @@ if test "$PERL" = no; then AC_MSG_ERROR([Perl interpreter not found in $PATH or $PERL.]) fi -AC_USE_SYSTEM_EXTENSIONS - -AC_ARG_ENABLE( - [ndebug], - [AC_HELP_STRING([--enable-ndebug], - [Disable debugging features for max performance])], - [case "${enableval}" in # ( - yes) ndebug=true ;; # ( - no) ndebug=false ;; # ( - *) AC_MSG_ERROR([bad value ${enableval} for --enable-ndebug]) ;; - esac], - [ndebug=false]) -AM_CONDITIONAL([NDEBUG], [test x$ndebug = xtrue]) - -AC_ARG_ENABLE( - [hw-tables], - [AC_HELP_STRING([--enable-hw-tables=MODULE...], - [Configure and build the specified externally supplied - hardware table support modules])]) -case "${enable_hw_tables}" in # ( - yes) - AC_MSG_ERROR([--enable-hw-tables has a required argument]) - ;; # ( - ''|no) - hw_tables= - ;; # ( - *) - hw_tables=`echo "$enable_hw_tables" | sed 's/,/ /g'` - ;; -esac -for d in $hw_tables; do - mk=datapath/hwtable_$d/Modules.mk - if test ! -e $srcdir/$mk; then - AC_MSG_ERROR([--enable-hw-tables=$d specified but $mk is missing]) - fi - HW_TABLES="$HW_TABLES \$(top_srcdir)/$mk" -done -AC_SUBST(HW_TABLES) +OFP_CHECK_LIBOPENFLOW +OFP_CHECK_IF_PACKET +OFP_CHECK_HWTABLES AC_ARG_VAR(KARCH, [Kernel Architecture String]) AC_SUBST(KARCH) - -CHECK_LINUX(l26, 2.6, 2.6, KSRC26, L26_ENABLED) -CHECK_LINUX(l24, 2.4, 2.4, KSRC24, L24_ENABLED) - -AC_CHECK_HEADER([linux/netlink.h], - [HAVE_NETLINK=yes], - [HAVE_NETLINK=no], - [#include -#include ]) -AM_CONDITIONAL([HAVE_NETLINK], [test "$HAVE_NETLINK" = yes]) -if test "$HAVE_NETLINK" = yes; then - AC_DEFINE([HAVE_NETLINK], [1], - [Define to 1 if Netlink protocol is available.]) -fi - -AC_CHECK_HEADER([net/if_packet.h], - [HAVE_IF_PACKET=yes], - [HAVE_IF_PACKET=no]) -AM_CONDITIONAL([HAVE_IF_PACKET], [test "$HAVE_IF_PACKET" = yes]) -if test "$HAVE_IF_PACKET" = yes; then - AC_DEFINE([HAVE_IF_PACKET], [1], - [Define to 1 if net/if_packet.h is available.]) -fi - -AC_ARG_ENABLE( - [ssl], - [AC_HELP_STRING([--enable-ssl], - [Enable ssl support (requires libssl)])], - [case "${enableval}" in # ( - yes) ssl=true ;; # ( - no) ssl=false ;; # ( - *) AC_MSG_ERROR([bad value ${enableval} for --enable-ssl]) ;; - esac], - [ssl=false]) - -if test "$ssl" = true; then -dnl Make sure that pkg-config is installed. -m4_pattern_forbid([PKG_CHECK_MODULES]) -PKG_CHECK_MODULES([SSL], [libssl], - [HAVE_OPENSSL=yes], - [HAVE_OPENSSL=no - AC_MSG_WARN([Cannot find libssl: - -$SSL_PKG_ERRORS - -OpenFlow will not support SSL connections.])]) - -fi -AM_CONDITIONAL([HAVE_OPENSSL], [test "$HAVE_OPENSSL" = yes]) -if test "$HAVE_OPENSSL" = yes; then - AC_DEFINE([HAVE_OPENSSL], [1], [Define to 1 if OpenSSL is installed.]) -fi - -AC_CHECK_LIB([socket], [connect]) -AC_SEARCH_LIBS([gethostbyname], [resolv], [RESOLVER_LIBS=-lresolv]) -AC_CHECK_LIB([dl], [dladdr], [FAULT_LIBS=-ldl]) -AC_SUBST([FAULT_LIBS]) +OFP_CHECK_LINUX(l26, 2.6, 2.6, KSRC26, L26_ENABLED) +OFP_CHECK_LINUX(l24, 2.4, 2.4, KSRC24, L24_ENABLED) CFLAGS="$CFLAGS -Wall -Wno-sign-compare" +OFP_ENABLE_EXT + AC_CONFIG_FILES([Makefile datapath/Makefile lib/Makefile diff --git a/ext b/ext new file mode 160000 index 00000000..b3227406 --- /dev/null +++ b/ext @@ -0,0 +1 @@ +Subproject commit b3227406a713f5cae10d31a7be7249c6ebe16bff diff --git a/include/Makefile.am b/include/Makefile.am index 5af741e7..741618a3 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -35,5 +35,6 @@ noinst_HEADERS = \ vconn-ssl.h \ vconn-stream.h \ vlog-socket.h \ + vlog-modules.def \ vlog.h \ xtoxll.h diff --git a/include/vlog-modules.def b/include/vlog-modules.def new file mode 100644 index 00000000..22553de9 --- /dev/null +++ b/include/vlog-modules.def @@ -0,0 +1,36 @@ +/* Modules that can emit log messages. */ +VLOG_MODULE(chain) +VLOG_MODULE(controller) +VLOG_MODULE(ctlpath) +VLOG_MODULE(daemon) +VLOG_MODULE(datapath) +VLOG_MODULE(dhcp) +VLOG_MODULE(dhcp_client) +VLOG_MODULE(dpif) +VLOG_MODULE(dpctl) +VLOG_MODULE(fault) +VLOG_MODULE(flow) +VLOG_MODULE(learning_switch) +VLOG_MODULE(mac_learning) +VLOG_MODULE(netdev) +VLOG_MODULE(netlink) +VLOG_MODULE(ofp_discover) +VLOG_MODULE(poll_loop) +VLOG_MODULE(secchan) +VLOG_MODULE(rconn) +VLOG_MODULE(switch) +VLOG_MODULE(terminal) +VLOG_MODULE(socket_util) +VLOG_MODULE(vconn_netlink) +VLOG_MODULE(vconn_tcp) +VLOG_MODULE(vconn_ssl) +VLOG_MODULE(vconn_stream) +VLOG_MODULE(vconn_unix) +VLOG_MODULE(vconn) +VLOG_MODULE(vlog) + +#ifdef HAVE_EXT +#include "ext/vlogext-modules.def" +#endif + +#undef VLOG_MODULE diff --git a/include/vlog.h b/include/vlog.h index 31967436..7582681a 100644 --- a/include/vlog.h +++ b/include/vlog.h @@ -63,42 +63,10 @@ enum vlog_facility { const char *vlog_get_facility_name(enum vlog_facility); enum vlog_facility vlog_get_facility_val(const char *name); -/* Modules that can emit log messages. */ -#define VLOG_MODULES \ - VLOG_MODULE(chain) \ - VLOG_MODULE(controller) \ - VLOG_MODULE(ctlpath) \ - VLOG_MODULE(daemon) \ - VLOG_MODULE(datapath) \ - VLOG_MODULE(dhcp) \ - VLOG_MODULE(dhcp_client) \ - VLOG_MODULE(dpif) \ - VLOG_MODULE(dpctl) \ - VLOG_MODULE(fault) \ - VLOG_MODULE(flow) \ - VLOG_MODULE(learning_switch) \ - VLOG_MODULE(mac_learning) \ - VLOG_MODULE(netdev) \ - VLOG_MODULE(netlink) \ - VLOG_MODULE(ofp_discover) \ - VLOG_MODULE(poll_loop) \ - VLOG_MODULE(secchan) \ - VLOG_MODULE(rconn) \ - VLOG_MODULE(switch) \ - VLOG_MODULE(socket_util) \ - VLOG_MODULE(vconn_netlink) \ - VLOG_MODULE(vconn_tcp) \ - VLOG_MODULE(vconn_ssl) \ - VLOG_MODULE(vconn_stream) \ - VLOG_MODULE(vconn_unix) \ - VLOG_MODULE(vconn) \ - VLOG_MODULE(vlog) \ - /* VLM_ constant for each vlog module. */ enum vlog_module { #define VLOG_MODULE(NAME) VLM_##NAME, - VLOG_MODULES -#undef VLOG_MODULE +#include "vlog-modules.def" VLM_N_MODULES, VLM_ANY_MODULE = -1 }; diff --git a/lib/vlog.c b/lib/vlog.c index 663b3df0..7eeb9820 100644 --- a/lib/vlog.c +++ b/lib/vlog.c @@ -66,8 +66,7 @@ static const char *facility_names[VLF_N_FACILITIES] = { /* Name for each logging module */ static const char *module_names[VLM_N_MODULES] = { #define VLOG_MODULE(NAME) #NAME, - VLOG_MODULES -#undef VLOG_MODULES +#include "vlog-modules.def" }; static int levels[VLM_N_MODULES][VLF_N_FACILITIES]; diff --git a/m4/libopenflow.m4 b/m4/libopenflow.m4 new file mode 100644 index 00000000..5c8520d2 --- /dev/null +++ b/m4/libopenflow.m4 @@ -0,0 +1,111 @@ +# Copyright (c) 2008 The Board of Trustees of The Leland Stanford +# Junior University +# +# We are making the OpenFlow specification and associated documentation +# (Software) available for public use and benefit with the expectation +# that others will use, modify and enhance the Software and contribute +# those enhancements back to the community. However, since we would +# like to make the Software available for broadest use, with as few +# restrictions as possible permission is hereby granted, free of +# charge, to any person obtaining a copy of this Software to deal in +# the Software under the copyrights without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +# The name and trademarks of copyright holder(s) may NOT be used in +# advertising or publicity pertaining to the Software or any +# derivatives without specific, written prior permission. + +dnl Checks for --enable-ndebug and defines NDEBUG if it is specified. +AC_DEFUN([OFP_CHECK_NDEBUG], + [AC_ARG_ENABLE( + [ndebug], + [AC_HELP_STRING([--enable-ndebug], + [Disable debugging features for max performance])], + [case "${enableval}" in + (yes) ndebug=true ;; + (no) ndebug=false ;; + (*) AC_MSG_ERROR([bad value ${enableval} for --enable-ndebug]) ;; + esac], + [ndebug=false]) + AM_CONDITIONAL([NDEBUG], [test x$ndebug = xtrue])]) + +dnl Checks for Netlink support. +AC_DEFUN([OFP_CHECK_NETLINK], + [AC_CHECK_HEADER([linux/netlink.h], + [HAVE_NETLINK=yes], + [HAVE_NETLINK=no], + [#include + #include + ]) + AM_CONDITIONAL([HAVE_NETLINK], [test "$HAVE_NETLINK" = yes]) + if test "$HAVE_NETLINK" = yes; then + AC_DEFINE([HAVE_NETLINK], [1], + [Define to 1 if Netlink protocol is available.]) + fi]) + +dnl Checks for OpenSSL, if --enable-ssl is passed in. +AC_DEFUN([OFP_CHECK_OPENSSL], + [AC_ARG_ENABLE( + [ssl], + [AC_HELP_STRING([--enable-ssl], + [Enable ssl support (requires libssl)])], + [case "${enableval}" in + (yes) ssl=true ;; + (no) ssl=false ;; + (*) AC_MSG_ERROR([bad value ${enableval} for --enable-ssl]) ;; + esac], + [ssl=false]) + + if test "$ssl" = true; then + dnl Make sure that pkg-config is installed. + m4_pattern_forbid([PKG_CHECK_MODULES]) + PKG_CHECK_MODULES([SSL], [libssl], + [HAVE_OPENSSL=yes], + [HAVE_OPENSSL=no + AC_MSG_WARN([Cannot find libssl: + + $SSL_PKG_ERRORS + + OpenFlow will not support SSL connections.])]) + + fi + AM_CONDITIONAL([HAVE_OPENSSL], [test "$HAVE_OPENSSL" = yes]) + if test "$HAVE_OPENSSL" = yes; then + AC_DEFINE([HAVE_OPENSSL], [1], [Define to 1 if OpenSSL is installed.]) + fi]) + +dnl Checks for libraries needed by lib/fault.c. +AC_DEFUN([OFP_CHECK_FAULT_LIBS], + [AC_CHECK_LIB([dl], [dladdr], [FAULT_LIBS=-ldl]) + AC_SUBST([FAULT_LIBS])]) + +dnl Checks for libraries needed by lib/socket-util.c. +AC_DEFUN([OFP_CHECK_SOCKET_LIBS], + [AC_CHECK_LIB([socket], [connect]) + AC_SEARCH_LIBS([gethostbyname], [resolv], [RESOLVER_LIBS=-lresolv])]) + +dnl Runs the checks required to include the headers in include/ and +dnl link against lib/libopenflow.a. +AC_DEFUN([OFP_CHECK_LIBOPENFLOW], + [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) + AC_REQUIRE([OFP_CHECK_NDEBUG]) + AC_REQUIRE([OFP_CHECK_NETLINK]) + AC_REQUIRE([OFP_CHECK_OPENSSL]) + AC_REQUIRE([OFP_CHECK_FAULT_LIBS]) + AC_REQUIRE([OFP_CHECK_SOCKET_LIBS])]) + -- 2.30.2