From 88f1516a323da620b8db8281239f65b29ff13c57 Mon Sep 17 00:00:00 2001 From: Cliff Frey Date: Fri, 15 Feb 2013 14:59:20 -0800 Subject: [PATCH] linuxmodule: correctly zero out packet txflags in linux 2.6.32 Signed-off-by: Cliff Frey --- config-linuxmodule.h.in | 3 +++ configure | 57 +++++++++++++++++++++++++++++++++++++++++ configure.in | 10 ++++++++ lib/packet.cc | 3 +++ 4 files changed, 73 insertions(+) diff --git a/config-linuxmodule.h.in b/config-linuxmodule.h.in index 05d5015c01..ab84a9a78f 100644 --- a/config-linuxmodule.h.in +++ b/config-linuxmodule.h.in @@ -91,6 +91,9 @@ /* Define if 'struct skb_shared_info' has an 'ip6_frag_id' member. */ #undef HAVE_LINUX_SKB_SHINFO_IP6_FRAG_ID +/* Define if 'struct skb_shared_info' has an 'tx_flags.flags' member. */ +#undef HAVE_LINUX_SKB_SHINFO_TX_FLAGS_UNION + /* Define if 'struct skb_shared_info' has an 'tx_flags' member defining 'SKBTX_DEV_ZEROCOPY'. */ #undef HAVE_LINUX_SKB_SHINFO_TX_FLAGS_SKBTX_DEV_ZEROCOPY diff --git a/configure b/configure index 91d934406a..610faa4633 100755 --- a/configure +++ b/configure @@ -11522,6 +11522,63 @@ $as_echo "#define HAVE_LINUX_SKB_SHINFO_TX_FLAGS_SKBTX_DEV_ZEROCOPY 1" >>confdef fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether skb_shinfo has tx_flags.flags" >&5 +$as_echo_n "checking whether skb_shinfo has tx_flags.flags... " >&6; } +if ${ac_cv_linuxmodule_skb_shinfo_tx_flags_union+:} 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 *s; skb_shinfo(s)->tx_flags.flags = 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_linuxmodule_skb_shinfo_tx_flags_union=yes +else + ac_cv_linuxmodule_skb_shinfo_tx_flags_union=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_skb_shinfo_tx_flags_union" >&5 +$as_echo "$ac_cv_linuxmodule_skb_shinfo_tx_flags_union" >&6; } + if test $ac_cv_linuxmodule_skb_shinfo_tx_flags_union = yes; then + +$as_echo "#define HAVE_LINUX_SKB_SHINFO_TX_FLAGS_UNION 1" >>confdefs.h + + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for device polling kernel extension" >&5 $as_echo_n "checking for device polling kernel extension... " >&6; } if ${ac_cv_linuxmodule_net_device_polling+:} false; then : diff --git a/configure.in b/configure.in index c2771cac4d..fd06769b49 100644 --- a/configure.in +++ b/configure.in @@ -1490,6 +1490,16 @@ void f1(int64_t) { // will fail if long long and int64_t are the same type AC_DEFINE([HAVE_LINUX_SKB_SHINFO_TX_FLAGS_SKBTX_DEV_ZEROCOPY], [1], [Define if 'struct skb_shared_info' has an 'tx_flags' member defining 'SKBTX_DEV_ZEROCOPY'.]) fi + AC_CACHE_CHECK([whether skb_shinfo has tx_flags.flags], [ac_cv_linuxmodule_skb_shinfo_tx_flags_union], + [AC_LANG_C + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([CLICK_LINUXMODULE_PROLOGUE()[ +#include ]], +[[extern struct sk_buff *s; skb_shinfo(s)->tx_flags.flags = 0;]])], + [ac_cv_linuxmodule_skb_shinfo_tx_flags_union=yes], [ac_cv_linuxmodule_skb_shinfo_tx_flags_union=no])]) + if test $ac_cv_linuxmodule_skb_shinfo_tx_flags_union = yes; then + AC_DEFINE([HAVE_LINUX_SKB_SHINFO_TX_FLAGS_UNION], [1], [Define if 'struct skb_shared_info' has a 'tx_flags.flags' member.]) + fi + AC_CACHE_CHECK([for device polling kernel extension], [ac_cv_linuxmodule_net_device_polling], [AC_LANG_C AC_COMPILE_IFELSE([AC_LANG_PROGRAM([CLICK_LINUXMODULE_PROLOGUE()[ diff --git a/lib/packet.cc b/lib/packet.cc index 655e2728ce..65c35c063a 100644 --- a/lib/packet.cc +++ b/lib/packet.cc @@ -693,6 +693,9 @@ Packet::expensive_uniqueify(int32_t extra_headroom, int32_t extra_tailroom, # if HAVE_LINUX_SKB_SHINFO_IP6_FRAG_ID nskb_shinfo->ip6_frag_id = 0; # endif +# if HAVE_LINUX_SKB_SHINFO_TX_FLAGS_UNION + nskb_shinfo->tx_flags.flags = 0; +# endif # if HAVE_LINUX_SKB_SHINFO_TX_FLAGS_SKBTX_DEV_ZEROCOPY nskb_shinfo->tx_flags = 0; # endif