diff --git a/buildrun.cxx b/buildrun.cxx
index 3c26d50..cfb3ae0 100644
--- a/buildrun.cxx
+++ b/buildrun.cxx
@@ -1,5 +1,5 @@
// build/run probes
-// Copyright (C) 2005-2013 Red Hat Inc.
+// Copyright (C) 2005-2014 Red Hat Inc.
//
// This file is part of systemtap, and is free software. You can
// redistribute it and/or modify it under the terms of the GNU General
@@ -378,6 +378,7 @@ compile_pass (systemtap_session& s)
output_autoconf(s, o, "autoconf-relay-umode_t.c", "STAPCONF_RELAY_UMODE_T", NULL);
output_autoconf(s, o, "autoconf-fs_supers-hlist.c", "STAPCONF_FS_SUPERS_HLIST", NULL);
output_autoconf(s, o, "autoconf-compat_sigaction.c", "STAPCONF_COMPAT_SIGACTION", NULL);
+ output_autoconf(s, o, "autoconf-netfilter.c", "STAPCONF_NETFILTER_V313", NULL);
// used by tapset/timestamp_monotonic.stp
output_exportconf(s, o, "cpu_clock", "STAPCONF_CPU_CLOCK");
diff --git a/man/stapprobes.3stap b/man/stapprobes.3stap
index 4bc99fc..2229c9c 100644
--- a/man/stapprobes.3stap
+++ b/man/stapprobes.3stap
@@ -1043,6 +1043,9 @@ the C code generated by systemtap.
The netfilter probe points define the following context variables:
.TP
+.IR $hooknum
+The hook number.
+.TP
.IR $skb
The address of the sk_buff struct representing the packet. See
<linux/skbuff.h> for details on how to use this struct, or
diff --git a/runtime/linux/autoconf-netfilter.c b/runtime/linux/autoconf-netfilter.c
new file mode 100644
index 0000000..f122664
--- /dev/null
+++ b/runtime/linux/autoconf-netfilter.c
@@ -0,0 +1,16 @@
+#include <linux/netfilter.h>
+
+unsigned int
+new_style_hook(const struct nf_hook_ops *ops, /* not: unsigned int hook; */
+ struct sk_buff *skb,
+ const struct net_device *in, const struct net_device *out,
+ int (*okfn)(struct sk_buff *))
+{
+ (void) ops; (void) skb; (void) in; (void) out; (void) okfn;
+ return 0;
+}
+
+struct nf_hook_ops netfilter_ops = {
+ .hook = new_style_hook
+};
+
diff --git a/tapset-netfilter.cxx b/tapset-netfilter.cxx
index f20b569..eec7e31 100644
--- a/tapset-netfilter.cxx
+++ b/tapset-netfilter.cxx
@@ -1,5 +1,5 @@
// tapset for netfilter hooks
-// Copyright (C) 2012 Red Hat Inc.
+// Copyright (C) 2012-2014 Red Hat Inc.
//
// This file is part of systemtap, and is free software. You can
// redistribute it and/or modify it under the terms of the GNU General
@@ -267,7 +267,13 @@ netfilter_derived_probe_group::emit_module_decls (systemtap_session& s)
// Previous to kernel 2.6.22, the hookfunction definition takes a struct sk_buff **skb,
// whereas currently it uses a *skb. We need emit the right version so this will
// compile on RHEL5, for example.
- s.op->newline() << "#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,22)";
+ s.op->newline() << "#ifdef STAPCONF_NETFILTER_V313";
+
+ s.op->newline() << "(const struct nf_hook_ops *nf_ops, struct sk_buff *nf_skb, const struct net_device *nf_in, const struct net_device *nf_out, int (*nf_okfn)(struct sk_buff *))";
+ s.op->newline() << "{";
+
+ s.op->newline() << "#elif LINUX_VERSION_CODE > KERNEL_VERSION(2,6,22)";
+
s.op->newline() << "(unsigned int nf_hooknum, struct sk_buff *nf_skb, const struct net_device *nf_in, const struct net_device *nf_out, int (*nf_okfn)(struct sk_buff *))";
s.op->newline() << "{";
@@ -280,6 +286,9 @@ netfilter_derived_probe_group::emit_module_decls (systemtap_session& s)
s.op->newline(-1) << "#endif";
s.op->newline(1) << "const struct stap_probe * const stp = & stap_probes[" << np->session_index << "];";
s.op->newline() << "int nf_verdict = NF_ACCEPT;"; // default NF_ACCEPT, to be used by $verdict context var
+ s.op->newline() << "#ifdef STAPCONF_NETFILTER_V313";
+ s.op->newline() << "unsigned int nf_hooknum = nf_ops->hooknum;";
+ s.op->newline() << "#endif";
common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING", "stp",
"stp_probe_type_netfilter",
false);