diff --git a/config-linuxmodule.h.in b/config-linuxmodule.h.in index edadabea88..7cae27a574 100644 --- a/config-linuxmodule.h.in +++ b/config-linuxmodule.h.in @@ -15,6 +15,9 @@ /* Define if your Linux kernel has Click transmit notification extensions. */ #undef HAVE_CLICK_KERNEL_TX_NOTIFY +/* Define if your Linux kernel has Click skb_recycle. */ +#undef HAVE_CLICK_SKB_RECYCLE + /* Define if fast checksum functions available. */ #define HAVE_FAST_CHECKSUM 1 diff --git a/configure b/configure index 52d5604683..7ad39f0a3d 100755 --- a/configure +++ b/configure @@ -11494,6 +11494,63 @@ $as_echo "#define HAVE_SKB_RECYCLE 1" >>confdefs.h fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether skb_recycle returns an sk_buff" >&5 +$as_echo_n "checking whether skb_recycle returns an sk_buff... " >&6; } +if ${ac_cv_linuxmodule_click_skb_recycle+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#if HAVE_LINUXMODULE_2_6 +# define KBUILD_STR(s) #s +# define KBUILD_BASENAME KBUILD_STR(click) +# define KBUILD_MODNAME KBUILD_STR(click) +#endif +#define new linux_new +#define this linux_this +#define delete linux_delete +#define class linux_class +#define virtual linux_virtual +#define typename linux_typename +#define private linux_private +#define protected linux_protected +#define public linux_public +#define namespace linux_namespace +#define false linux_false +#define true linux_true +#define CLICK_CXX_PROTECTED 1 +$linux_autoconf_include +#include +#include +int +main () +{ +extern struct sk_buff *b; b = skb_recycle(b); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_linuxmodule_click_skb_recycle=yes +else + ac_cv_linuxmodule_click_skb_recycle=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_linuxmodule_click_skb_recycle" >&5 +$as_echo "$ac_cv_linuxmodule_click_skb_recycle" >&6; } + if test $ac_cv_linuxmodule_click_skb_recycle = yes; then + +$as_echo "#define HAVE_CLICK_SKB_RECYCLE 1" >>confdefs.h + + fi + ac_fn_c_check_decl "$LINENO" "skb_linearize" "ac_cv_have_decl_skb_linearize" "#if HAVE_LINUXMODULE_2_6 # define KBUILD_STR(s) #s # define KBUILD_BASENAME KBUILD_STR(click) diff --git a/configure.in b/configure.in index 90f68321f1..16182271d1 100644 --- a/configure.in +++ b/configure.in @@ -1440,18 +1440,28 @@ void f1(int64_t) { // will fail if long long and int64_t are the same type AC_DEFINE([HAVE_LINUX_POLLING], [1], [Define if your Linux kernel has polling extensions.]) fi - AC_CHECK_DECL(skb_dst_drop, [ac_cv_skb_dst_drop=yes], [ac_cv_skb_dst_drop=no], [CLICK_LINUXMODULE_PROLOGUE()[ + AC_CHECK_DECL([skb_dst_drop], [ac_cv_skb_dst_drop=yes], [ac_cv_skb_dst_drop=no], [CLICK_LINUXMODULE_PROLOGUE()[ #include ]]) if test $ac_cv_skb_dst_drop = yes; then AC_DEFINE([HAVE_SKB_DST_DROP], [1], [Define if you have the skb_dst_drop function.]) fi - AC_CHECK_DECL(skb_recycle, [ac_cv_skb_recycle=yes], [ac_cv_skb_recycle=no], [CLICK_LINUXMODULE_PROLOGUE()[ + AC_CHECK_DECL([skb_recycle], [ac_cv_skb_recycle=yes], [ac_cv_skb_recycle=no], [CLICK_LINUXMODULE_PROLOGUE()[ #include ]]) if test $ac_cv_skb_recycle = yes; then AC_DEFINE([HAVE_SKB_RECYCLE], [1], [Define if you have the skb_recycle function.]) fi + AC_CACHE_CHECK([whether skb_recycle returns an sk_buff], [ac_cv_linuxmodule_click_skb_recycle], + [AC_LANG_C + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([CLICK_LINUXMODULE_PROLOGUE()[ +#include ]], +[[extern struct sk_buff *b; b = skb_recycle(b);]])], + [ac_cv_linuxmodule_click_skb_recycle=yes], [ac_cv_linuxmodule_click_skb_recycle=no])]) + if test $ac_cv_linuxmodule_click_skb_recycle = yes; then + AC_DEFINE([HAVE_CLICK_SKB_RECYCLE], [1], [Define if your Linux kernel has Click skb_recycle.]) + fi + AC_CHECK_DECL(skb_linearize, [ac_cv_skb_linearize=yes], [ac_cv_skb_linearize=no], [CLICK_LINUXMODULE_PROLOGUE()[ #include ]]) if test $ac_cv_skb_linearize = yes; then diff --git a/elements/linuxmodule/anydevice.hh b/elements/linuxmodule/anydevice.hh index e2ecc61856..21c41a6cf3 100644 --- a/elements/linuxmodule/anydevice.hh +++ b/elements/linuxmodule/anydevice.hh @@ -64,7 +64,8 @@ CLICK_CXX_UNPROTECT # define SET_STATS(a,b,c) /* nothing */ #endif -#if defined(HAVE_NETIF_RECEIVE_SKB) && !(HAVE___NETIF_RECEIVE_SKB || HAVE_NETIF_RECEIVE_SKB_EXTENDED) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 1, 0) || defined(HAVE_NETIF_RECEIVE_SKB)) \ + && !(HAVE___NETIF_RECEIVE_SKB || HAVE_NETIF_RECEIVE_SKB_EXTENDED) # define CLICK_DEVICE_UNRECEIVABLE_SK_BUFF 1 extern "C" { DECLARE_PER_CPU(sk_buff *, click_device_unreceivable_sk_buff); diff --git a/elements/linuxmodule/tohost.cc b/elements/linuxmodule/tohost.cc index 2e2f846bbb..d8dbdfb44d 100644 --- a/elements/linuxmodule/tohost.cc +++ b/elements/linuxmodule/tohost.cc @@ -225,7 +225,7 @@ ToHost::push(int port, Packet *p) int protocol = (_sniffers ? 0xFFFF : skb->protocol); // pass packet to Linux -#ifdef HAVE_NETIF_RECEIVE_SKB /* from Linux headers */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 1, 0) || defined(HAVE_NETIF_RECEIVE_SKB) /* from Linux headers */ struct net_device *dev = skb->dev; local_bh_disable(); dev_hold(dev); diff --git a/linuxmodule/clickfs.cc b/linuxmodule/clickfs.cc index e184ffc4df..7f6cc5706b 100644 --- a/linuxmodule/clickfs.cc +++ b/linuxmodule/clickfs.cc @@ -132,6 +132,9 @@ unlock_config_write(const char *file, int line) #else #define INODE_INFO(inode) (*((ClickInodeInfo *)(&(inode)->u))) #endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 2, 0) +#define set_nlink(inode, nlink) ((inode)->i_nlink = (nlink)) +#endif struct ClickInodeInfo { uint32_t config_generation; @@ -154,7 +157,7 @@ inode_out_of_date(struct inode *inode, int subdir_error) if ((error = click_ino.prepare(click_router, click_config_generation)) < 0) return error; INODE_INFO(inode).config_generation = click_config_generation; - inode->i_nlink = click_ino.nlink(inode->i_ino); + set_nlink(inode, click_ino.nlink(inode->i_ino)); } return 0; } @@ -185,7 +188,7 @@ click_inode(struct super_block *sb, ino_t ino) inode->i_gid = click_fsmode.gid; inode->i_op = click_handler_inode_ops; inode->i_fop = click_handler_file_ops; - inode->i_nlink = click_ino.nlink(ino); + set_nlink(inode, click_ino.nlink(ino)); } else { // can't happen iput(inode); @@ -198,7 +201,7 @@ click_inode(struct super_block *sb, ino_t ino) inode->i_gid = click_fsmode.gid; inode->i_op = click_dir_inode_ops; inode->i_fop = click_dir_file_ops; - inode->i_nlink = click_ino.nlink(ino); + set_nlink(inode, click_ino.nlink(ino)); } inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; @@ -267,7 +270,7 @@ click_dir_revalidate(struct dentry *dentry) /* preserve error */; else { INODE_INFO(inode).config_generation = click_config_generation; - inode->i_nlink = click_ino.nlink(inode->i_ino); + set_nlink(inode, click_ino.nlink(inode->i_ino)); } } UNLOCK_CONFIG_READ(); diff --git a/linuxmodule/fixincludes.pl b/linuxmodule/fixincludes.pl index 827e6f0f42..c4a5989b3e 100755 --- a/linuxmodule/fixincludes.pl +++ b/linuxmodule/fixincludes.pl @@ -247,6 +247,15 @@ ($$) 1 while s; 1 while s; } + if ($d eq "spinlock_types.h") { + s<(typedef\s+struct[^\}]+)(struct\s+__raw_tickets\s+)({[^\}]+})><$2$3;\n$1$2>; + } + if ($d eq "spinlock.h") { + s; + } + if ($d eq "compiler.h") { + s<^#define ACCESS_ONCE\(x\) \(\*\(volatile typeof\(x\) \*\)\&\(x\)\)><#define ACCESS_ONCE(x) (*(typeof(x) * volatile)&(x))>m; + } # CLICK_CXX_PROTECTED check if (m<\A[\s\200-\377]*\z>) { diff --git a/linuxmodule/skbmgr.cc b/linuxmodule/skbmgr.cc index bf5b08d1d4..19e0e983e0 100644 --- a/linuxmodule/skbmgr.cc +++ b/linuxmodule/skbmgr.cc @@ -281,7 +281,7 @@ RecycledSkbPool::recycle(struct sk_buff *skbs) struct sk_buff *skb = skbs; skbs = skbs->next; -#if HAVE_SKB_RECYCLE +#if HAVE_CLICK_SKB_RECYCLE // where should sk_buff go? # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24) unsigned char *skb_end = skb_end_pointer(skb);