From owner-svn-soc-all@FreeBSD.ORG Wed Jul 30 14:25:30 2014 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2A32FB7A for ; Wed, 30 Jul 2014 14:25:30 +0000 (UTC) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 16D4725B1 for ; Wed, 30 Jul 2014 14:25:30 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id s6UEPTqZ075472 for ; Wed, 30 Jul 2014 14:25:29 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id s6UEPTEF075468 for svn-soc-all@FreeBSD.org; Wed, 30 Jul 2014 14:25:29 GMT (envelope-from dpl@FreeBSD.org) Date: Wed, 30 Jul 2014 14:25:29 GMT Message-Id: <201407301425.s6UEPTEF075468@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r271602 - soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Jul 2014 14:25:30 -0000 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 #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");