socsvn commit: r273321 - soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw

dpl at FreeBSD.org dpl at FreeBSD.org
Fri Aug 29 12:16:15 UTC 2014


Author: dpl
Date: Fri Aug 29 12:16:14 2014
New Revision: 273321
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=273321

Log:
  Delete unneeded calls in userspace, and codegen rule_xmit.

Modified:
  soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.cc

Modified: soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.cc
==============================================================================
--- soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.cc	Fri Aug 29 12:13:49 2014	(r273320)
+++ soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.cc	Fri Aug 29 12:16:14 2014	(r273321)
@@ -135,14 +135,12 @@
 	Function *send_reject6;
 #endif /* INET6 */
 	Function *send_reject;
-	Function *check_uidgid;
 	Function *set_match;
 	Function *jump_fast;
 
 	// Not pkg-filtering related funcs.
 	Function *printfFunc;
 	Function *ipfw_find_rule;
-	Function *crfree;
 
 	// Used structs.
 	StructType *ifnetTy;
@@ -270,16 +268,12 @@
 #endif /* INET6 */
 
 		send_reject = mod->getFunction("send_reject");
-		check_uidgid = mod->getFunction("check_uidgid");
 		set_match = mod->getFunction("set_match");
 		jump_fast = mod->getFunction("jump_fast");
 
 		// Functions declared at bitcode.
 		printfFunc = mod->getFunction("printf");
 		ipfw_find_rule = mod->getFunction("ipfw_find_rule");
-#ifdef __FreeBSD__
-		crfree = mod->getFunction("crfree");
-#endif
 	}
 
 	// Allocate and initialize LLVM vars.
@@ -310,7 +304,7 @@
 
 		// m = args->m (idx: 0)
 		m = irb.CreateAlloca(mbufPtrTy);
-		irb.CreateStore(irb.CreateStructGEP(args, 0), m);
+		irb.CreateStore(irb.CreateLoad(irb.CreateStructGEP(args, 0)), m);
 
 		// ip = (struct ip *)((m)->m_data) (idx: 2)
 		ip = irb.CreateAlloca(ipPtrTy);
@@ -725,8 +719,6 @@
 			irb.CreateCondBr(irb.CreateICmpNE(ucred_cache, ConstantPointerNull::get(ucredPtrTy)), cache_nnull, ret);
 
 			irb.SetInsertPoint(cache_nnull);
-			// 		crfree(ucred_cache);
-			irb.CreateCall(crfree, ucred_cache);
 			irb.CreateBr(ret);
 		}
 #endif
@@ -750,7 +742,6 @@
 			i = BasicBlock::Create(con, "rule", func);
 		}
 
-
 		// Create static BasicBlocks.
 		// The entry basic block contains all the initialization 
 		// and allocation of resources, and a basic check done 
@@ -891,6 +882,7 @@
 		printf("Compilation continues.\n");
 	}
 
+	// check_uidgid() returns 0 on userspace.
 	void
 	emit_jail()
 	{
@@ -900,18 +892,10 @@
 		//  * packet with the ports info.
 		//  */
 		// if (offset != 0)
-		// 	return;
+		//		return;
 		// if (proto == IPPROTO_TCP ||
 		// 	proto == IPPROTO_UDP)
-		// 	*match = check_uidgid(
-		// 			(ipfw_insn_u32 *)cmd,
-		// 			args, &ucred_lookup,
-		// #ifdef __FreeBSD__
-		// 			//(struct bsd_ucred **)&ucred_cache);
-		// 			(struct ucred **)&ucred_cache);
-		// #else
-		// 			(void *)&ucred_cache);
-		// #endif
+		//		*match = 0;
 
 	}
 
@@ -928,8 +912,10 @@
 	void
 	emit_xmit()
 	{
-		// XXX Check correctness.
 		//*match = iface_match(oif, (ipfw_insn_if *)cmd, chain, tablearg);
+
+		Value *cmdc = irb.CreateBitCast(cmd, ipfw_insn_ifPtrTy);
+		irb.CreateStore(irb.CreateCall4(iface_match, oif, cmdc, chain, tablearg), match);
 	}
 
 };


More information about the svn-soc-all mailing list