Skip to content

Commit

Permalink
Patchless supports Linux 3.2.0.
Browse files Browse the repository at this point in the history
Signed-off-by: Eddie Kohler <[email protected]>
  • Loading branch information
kohler committed Aug 9, 2012
1 parent e01bf3e commit 1c53ca8
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 9 deletions.
3 changes: 3 additions & 0 deletions config-linuxmodule.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
57 changes: 57 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -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 <asm/types.h>
#include <linux/skbuff.h>
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)
Expand Down
14 changes: 12 additions & 2 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -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 <net/dst.h>]])
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 <linux/skbuff.h>]])
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 <linux/skbuff.h>]],
[[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 <linux/skbuff.h>]])
if test $ac_cv_skb_linearize = yes; then
Expand Down
3 changes: 2 additions & 1 deletion elements/linuxmodule/anydevice.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion elements/linuxmodule/tohost.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 7 additions & 4 deletions linuxmodule/clickfs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
9 changes: 9 additions & 0 deletions linuxmodule/fixincludes.pl
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,15 @@ ($$)
1 while s<void \*\*pslot([^\}]*?)\{><void **____pslot$1\{char **pslot = (char **) ____pslot;>;
1 while s<pslot, void \*item([^\}]*?)\{><pslot, void *____item$1\{char *item = (char *) ____item;>;
}
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<struct\s+__raw_tickets\s+(\w+)\s*=\s*\{\s*tail:\s*(\S+?)\s*\};><struct __raw_tickets $1 = {}; $1.tail = $2;>;
}
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>) {
Expand Down
2 changes: 1 addition & 1 deletion linuxmodule/skbmgr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 1c53ca8

Please sign in to comment.