socsvn commit: r271602 - soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw
dpl at FreeBSD.org
dpl at FreeBSD.org
Wed Jul 30 14:25:30 UTC 2014
Author: dpl
Date: Wed Jul 30 14:25:28 2014
New Revision: 271602
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=271602
Log:
Sorted out how to lock and unlock correctly
Modified:
soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw2.c
soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw_rules.h
soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.cc
Modified: soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw2.c
==============================================================================
--- soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw2.c Wed Jul 30 12:39:49 2014 (r271601)
+++ soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw2.c Wed Jul 30 14:25:28 2014 (r271602)
@@ -264,12 +264,16 @@
int
ipfw_chk(struct ip_fw_args *args)
{
- if (compiledfuncptr == 0)
+ if (compiledfuncptr == 0) {
+ IPFW_PF_RLOCK(chain);
+ if (! V_ipfw_vnet_ready) { /* shutting down, leave NOW. */
+ IPFW_PF_RUNLOCK(chain);
+ return (IP_FW_PASS); /* accept */
+ }
compiledfuncptr = compile_code(args);
-
- if ((int)compiledfuncptr != 0) {
+ IPFW_PF_RUNLOCK(chain);
+ } else
return compiledfuncptr();
- }
/*
* Local variables holding state while processing a packet:
@@ -654,9 +658,11 @@
args->f_id.dst_port = dst_port = ntohs(dst_port);
}
- /* Returns -1 on error */
- if (lockcheckvnet(chain))
- return (IP_FW_PASS);
+ IPFW_PF_RLOCK(chain);
+ if (! V_ipfw_vnet_ready) { /* shutting down, leave NOW. */
+ IPFW_PF_RUNLOCK(chain);
+ return (IP_FW_PASS); /* accept */
+ }
getfpos(args, chain, &f_pos);
/*
@@ -1125,7 +1131,7 @@
retval = IP_FW_DENY;
printf("ipfw: ouch!, skip past end of rules, denying packet\n");
}
- unlockvnet(chain);
+ IPFW_PF_RUNLOCK(chain);
#ifdef __FreeBSD__
if (ucred_cache != NULL)
crfree(ucred_cache);
Modified: soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw_rules.h
==============================================================================
--- soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw_rules.h Wed Jul 30 12:39:49 2014 (r271601)
+++ soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw_rules.h Wed Jul 30 14:25:28 2014 (r271602)
@@ -1926,27 +1926,6 @@
}
/*
- * From here on, there's ip_fw2 code, so that
- * we can add this to our jit compiled code.
- */
-static IPFW_RULES_INLINE int
-lockcheckvnet(struct ip_fw_chain *chain)
-{
- IPFW_PF_RLOCK(chain);
- if (! V_ipfw_vnet_ready) { /* shutting down, leave NOW. */
- IPFW_PF_RUNLOCK(chain);
- return (-1); /* accept */
- }
- return 0;
-}
-
-static IPFW_RULES_INLINE void
-unlockvnet(struct ip_fw_chain *chain)
-{
- IPFW_PF_RUNLOCK(chain);
-}
-
-/*
* Function to be called just after
* lockcheckvnet();
*/
@@ -1968,4 +1947,5 @@
} else {
*f_pos = 0;
}
+ return (*f_pos);
}
Modified: soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.cc
==============================================================================
--- soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.cc Wed Jul 30 12:39:49 2014 (r271601)
+++ soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.cc Wed Jul 30 14:25:28 2014 (r271602)
@@ -14,9 +14,9 @@
#include <llvm/Support/ErrorOr.h>
#include "ip_fw_private.h"
-#include "ip_fw_private.h"
typedef int (*funcptr)();
+
using namespace llvm;
class jitCompiler {
@@ -67,13 +67,8 @@
// XXX Now I have to load the stubs of the loaded rules.
// For that, I need a table: RULE, "functname", #args
- lockcheckvnet(chain);
-
// Iterate through the rules.
- /* When we're done, or if there's an error. */
- unlockvnet(chain);
-
/*
// Get the stub (prototype) for the cell function
F = Mod->getFunction("cell");
More information about the svn-soc-all
mailing list