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

dpl at FreeBSD.org dpl at FreeBSD.org
Wed Jul 30 17:40:56 UTC 2014


Author: dpl
Date: Wed Jul 30 17:40:55 2014
New Revision: 271612
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=271612

Log:
  Substitute function calls for stub loading.

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	Wed Jul 30 16:08:16 2014	(r271611)
+++ soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/jit.cc	Wed Jul 30 17:40:55 2014	(r271612)
@@ -53,6 +53,48 @@
 		int
 		loadStub(std::string funcname)
 		{
+			/*
+			// Get the stub (prototype) for the cell function
+			F = Mod->getFunction("cell");
+			// Set it to have private linkage, so that it can be removed after being
+			// inlined.
+			F->setLinkage(GlobalValue::PrivateLinkage);
+
+			// Add an entry basic block to this function and set it
+			BasicBlock *entry = BasicBlock::Create(C, "entry", F);
+			B.SetInsertPoint(entry);
+			// Cache the type of registers
+			regTy = Type::getInt16Ty(C);
+
+			// Collect the function parameters
+			auto args = F->arg_begin();
+			oldGrid = args++;
+			newGrid = args++;
+			width = args++;
+			height = args++;
+			x = args++;
+			y = args++;
+
+			// Create space on the stack for the local registers
+			for (int i=0 ; i<10 ; i++)
+			{
+				a[i] = B.CreateAlloca(regTy);
+			}
+
+			// Create a space on the stack for the current value.  This can be
+			// assigned to, and will be returned at the end.  Store the value passed
+			// as a parameter in this.
+			v = B.CreateAlloca(regTy);
+			B.CreateStore(args++, v);
+
+			// Create a load of pointers to the global registers.
+			Value *gArg = args;
+			for (int i=0 ; i<10 ; i++)
+			{
+				B.CreateStore(ConstantInt::get(regTy, 0), a[i]);
+				g[i] = B.CreateConstGEP1_32(gArg, i);
+			}
+			*/
 			return (0);
 		}
 
@@ -128,248 +170,247 @@
 
 			switch (cmd->opcode) {
 			case O_NOP:
-				rule_nop(&match);
+				comp.loadStub("nop");
 				break;
 
 			case O_FORWARD_MAC:
-				rule_forward_mac(cmd->opcode);
+				comp.loadStub("forward_mac");
 				break;
 
 			case O_GID:
 			case O_UID:
 			case O_JAIL:
-				rule_jail(&match, offset, proto, cmd, args, ucred_lookup, ucred_cache);
+				comp.loadStub("jail");
 				break;
 
 			case O_RECV:
-				rule_recv(&match, cmd, m, chain, &tablearg);
+				comp.loadStub("recv");
 				break;
 
 			case O_XMIT:
-				rule_xmit(&match, oif, cmd, chain, &tablearg);
+				comp.loadStub("xmit");
 				break;
 
 			case O_VIA:
-				rule_via(&match, oif, m, cmd, chain, &tablearg);
+				comp.loadStub("via");
 				break;
 
 			case O_MACADDR2:
-				rule_macaddr2(&match, args, cmd);
+				comp.loadStub("macaddr2");
 				break;
 
 			case O_MAC_TYPE:
-				rule_mac_type(&match, args, cmd, cmdlen, etype);
+				comp.loadStub("mac_type");
 				break;
 
 			case O_FRAG:
-				rule_frag(&match, offset);
+				comp.loadStub("frag");
 				break;
 
 			case O_IN:
-				rule_in(&match, oif);
+				comp.loadStub("in");
 				break;
 
 			case O_LAYER2:
-				rule_layer2(&match, args);
+				comp.loadStub("layer2");
 				break;
 
 			case O_DIVERTED:
-				rule_diverted(&match, args, cmd);
+				comp.loadStub("diverted");
 				break;
 
 			case O_PROTO:
-				rule_proto(&match, proto, cmd);
+				comp.loadStub("proto");
 				break;
 
 			case O_IP_SRC:
-				rule_ip_src(&match, is_ipv4, cmd, &src_ip);
+				comp.loadStub("ip_src");
 				break;
 
 			case O_IP_SRC_LOOKUP:
 			case O_IP_DST_LOOKUP:
-				rule_ip_dst_lookup(&match, cmd, cmdlen, args, &tablearg, is_ipv4, is_ipv6, ip, &dst_ip, &src_ip, dst_port, src_port, offset, proto, ucred_lookup, ucred_cache, chain);
+				comp.loadStub("ip_dst_lookup");
 				break;
 
 			case O_IP_SRC_MASK:
 			case O_IP_DST_MASK:
-				rule_ip_dst_mask(&match, is_ipv4, cmd, cmdlen, &dst_ip, &src_ip);
+				comp.loadStub("ip_dst_mask");
 				break;
 
 			case O_IP_SRC_ME:
-				rule_ip_src_me(&match, is_ipv4, is_ipv6, &src_ip, args);
+				comp.loadStub("ip_src_me");
 #ifdef INET6
 				/* FALLTHROUGH */
 			case O_IP6_SRC_ME:
-				rule_ip6_src_me(&match, is_ipv6, args);
+				comp.loadStub("ip6_src_me");
 #endif
 				break;
 
 			case O_IP_DST_SET:
 			case O_IP_SRC_SET:
-				rule_ip_src_set(&match, is_ipv4, cmd, args);
+				comp.loadStub("ip_src_set");
 				break;
 
 			case O_IP_DST:
-				rule_ip_dst(&match, is_ipv4, cmd, &dst_ip);
+				comp.loadStub("ip_dst");
 				break;
 
 			case O_IP_DST_ME:
-				rule_ip_dst_me(&match, args, is_ipv4, is_ipv6, &dst_ip);
+				comp.loadStub("ip_dst_me");
 				
 #ifdef INET6
 				/* FALLTHROUGH */
 			case O_IP6_DST_ME:
-				rule_ip6_dst_me(&match, args, is_ipv6);
+				comp.loadStub("ip6_dst_me");
 #endif
 				break;
 
 
 			case O_IP_SRCPORT:
 			case O_IP_DSTPORT:
-				rule_ip_dstport(&match, proto, offset, cmd, cmdlen, dst_port, src_port);
+				comp.loadStub("ip_dstport");
 				break;
 
 			case O_ICMPTYPE:
-				rule_icmptype(&match, offset, proto, ulp, cmd);
+				comp.loadStub("icmptype");
 				break;
 
 #ifdef INET6
 			case O_ICMP6TYPE:
-				rule_icmp6type(&match, offset, is_ipv6, proto, ulp, cmd);
+				comp.loadStub("icmp6type");
 				break;
 #endif /* INET6 */
 
 			case O_IPOPT:
-				rule_ipopt(&match, is_ipv4, ip, cmd);
+				comp.loadStub("ipopt");
 				break;
 
 			case O_IPVER:
-				rule_ipver(&match, is_ipv4, cmd, ip);
+				comp.loadStub("ipver");
 				break;
 
 			case O_IPID:
 			case O_IPLEN:
 			case O_IPTTL:
-				rule_ipttl(&match, is_ipv4, cmd, cmdlen, ip, iplen);
+				comp.loadStub("ipttl");
 				break;
 
 			case O_IPPRECEDENCE:
-				rule_ipprecedence(&match, is_ipv4, cmd, ip);
+				comp.loadStub("ipprecedence");
 				break;
 
 			case O_IPTOS:
-				rule_iptos(&match, is_ipv4, cmd, ip);
+				comp.loadStub("iptos");
 				break;
 
 			case O_DSCP:
-				rule_dscp(&match, is_ipv4, is_ipv6, cmd, ip);
+				comp.loadStub("dscp");
 				break;
 
 			case O_TCPDATALEN:
-				rule_tcpdatalen(&match, proto, offset, ulp, iplen, cmdlen, cmd, ip);
+				comp.loadStub("tcpdatalen");
 				break;
 
 			case O_TCPFLAGS:
-				rule_tcpflags(&match, proto, offset, cmd, ulp);
+				comp.loadStub("tcpflags");
 				break;
 
 			case O_TCPOPTS:
-				if (rule_tcpopts(&match, hlen, ulp, proto, offset, cmd, m, args))
-					goto pullup_failed;
+				comp.loadStub("tcpopts");
 				break;
 
 			case O_TCPSEQ:
-				rule_tcpseq(&match, proto, offset, cmd, ulp);
+				comp.loadStub("tcpseq");
 				break;
 
 			case O_TCPACK:
-				rule_tcpack(&match, proto, offset, cmd, ulp);
+				comp.loadStub("tcpack");
 				break;
 
 			case O_TCPWIN:
-				rule_tcpwin(&match, proto, offset, cmd, cmdlen, ulp);
+				comp.loadStub("tcpwin");
 				break;
 
 			case O_ESTAB:
-				rule_estab(&match, proto, offset, ulp);
+				comp.loadStub("estab");
 				break;
 
 			case O_ALTQ:
-				rule_altq(&match, cmd, m, ip);
+				comp.loadStub("altq");
 				break;
 
 			case O_LOG:
-				rule_log(&match, f, hlen, args, m, oif, offset, ip6f_mf, tablearg, ip);
+				comp.loadStub("log");
 				break;
 
 			case O_PROB:
-				rule_prob(&match, cmd);
+				comp.loadStub("prob");
 				break;
 
 			case O_VERREVPATH:
-				rule_verrevpath(&match, oif, m, is_ipv6, args, &src_ip);
+				comp.loadStub("verrevpath");
 				break;
 
 			case O_VERSRCREACH:
-				rule_versrcreach(&match, hlen, oif, is_ipv6, args, &src_ip);
+				comp.loadStub("versrcreach");
 				break;
 
 			case O_ANTISPOOF:
-				rule_antispoof(&match, oif, hlen, is_ipv4, is_ipv6, &src_ip, args, m);
+				comp.loadStub("antispoof");
 				break;
 
 			case O_IPSEC:
 #ifdef IPSEC
-				rule_ipsec(&match, m);
+				comp.loadStub("ipsec");
 #endif
 				/* otherwise no match */
 				break;
 
 #ifdef INET6
 			case O_IP6_SRC:
-				rule_ip6_src(&match, is_ipv6, args, cmd);
+				comp.loadStub("ip6_src");
 				break;
 
 			case O_IP6_DST:
-				rule_ip6_dst(&match, is_ipv6, args, cmd);
+				comp.loadStub("ip6_dst");
 				break;
 
 			case O_IP6_SRC_MASK:
 			case O_IP6_DST_MASK:
-				rule_ip6_dst_mask(&match, args, cmd, cmdlen, is_ipv6);
+				comp.loadStub("ip6_dst_mask");
 				break;
 
 			case O_FLOW6ID:
-				rule_flow6id(&match, is_ipv6, args, cmd);
+				comp.loadStub("flow6id");
 				break;
 
 			case O_EXT_HDR:
-				rule_ext_hdr(&match, is_ipv6, ext_hd, cmd);
+				comp.loadStub("ext_hdr");
 				break;
 
 			case O_IP6:
-				rule_ip6(&match, is_ipv6);
+				comp.loadStub("ip6");
 				break;
 #endif
 
 			case O_IP4:
-				rule_ip4(&match, is_ipv4);
+				comp.loadStub("ip4");
 				break;
 
 			case O_TAG: 
-				rule_tag(&match, cmd, m, tablearg);
+				comp.loadStub("tag");
 				break;
 
 			case O_FIB: /* try match the specified fib */
-				rule_fib(&match, args, cmd);
+				comp.loadStub("fib");
 				break;
 
 			case O_SOCKARG:
-				rule_sockarg(&match, is_ipv6, proto, &dst_ip, &src_ip, dst_port, src_port, args, &tablearg);
+				comp.loadStub("sockarg");
 				break;
 
 			case O_TAGGED:
-				rule_tagged(&match, cmd, cmdlen, m, tablearg);
+				comp.loadStub("tagged");
 				break;
 				
 			/*
@@ -415,83 +456,83 @@
 			 */
 			case O_LIMIT:
 			case O_KEEP_STATE:
-				rule_keep_state(&match, f, cmd, args, tablearg, &retval, &l, &done);
+				comp.loadStub("keep_state");
 				break;
 
 			case O_PROBE_STATE:
 			case O_CHECK_STATE:
-				rule_check_state(&match, &dyn_dir, q, args, proto, ulp, pktlen, f, &f_pos, chain, cmd, &cmdlen, &l);
+				comp.loadStub("check_state");
 				break;
 
 			case O_ACCEPT:
-				rule_accept(&retval, &l, &done);
+				comp.loadStub("accept");
 				break;
 
 			case O_PIPE:
 			case O_QUEUE:
-				rule_queue(args, f_pos, chain, cmd, tablearg, &retval, &l, &done);
+				comp.loadStub("queue");
 				break;
 
 			case O_DIVERT:
 			case O_TEE:
-				rule_tee(&l, &done, &retval, cmd, args, f_pos, tablearg, chain);
+				comp.loadStub("tee");
 				break;
 
 			case O_COUNT:
-				rule_count(&l, f, pktlen);
+				comp.loadStub("count");
 				break;
 
 			case O_SKIPTO:
-				rule_skipto(&match, &l, cmd, &cmdlen, &skip_or, &f_pos, f, pktlen, chain, tablearg);
+				comp.loadStub("skipto");
 			    continue;
 			    break;	/* NOTREACHED */
 
 			case O_CALLRETURN:
-				rule_callreturn(cmd, m, f, chain, tablearg, pktlen, &skip_or, &cmdlen, &f_pos, &l);
+				comp.loadStub("callreturn");
 				continue;
 				break;	/* NOTREACHED */
 
 			case O_REJECT:
-				rule_reject(hlen, is_ipv4, offset, proto, ulp, m, &dst_ip, args, cmd, iplen, ip);
+				comp.loadStub("reject");
 				/* FALLTHROUGH */
 #ifdef INET6
 			case O_UNREACH6:
-				rule_unreach6(hlen, is_ipv6, offset, proto, icmp6_type, m, args, cmd, ip);
+				comp.loadStub("unreach6");
 				/* FALLTHROUGH */
 #endif
 			case O_DENY:
-				rule_deny(&l, &done, &retval);
+				comp.loadStub("deny");
 				break;
 
 			case O_FORWARD_IP:
-				rule_forward_ip(args, q, f, dyn_dir, cmd, tablearg, &retval, &l, &done);
+				comp.loadStub("forward_ip");
 				break;
 
 #ifdef INET6
 			case O_FORWARD_IP6:
-				rule_forward_ip6(args, q, f, dyn_dir, cmd, &retval, &l, &done);
+				comp.loadStub("forward_ip6");
 				break;
 #endif
 
 			case O_NETGRAPH:
 			case O_NGTEE:
-				rule_ngtee(args, f_pos, chain, cmd, tablearg, &retval, &l, &done);
+				comp.loadStub("ngtee");
 				break;
 
 			case O_SETFIB:
-				rule_setfib(f, pktlen, tablearg, cmd, m, args, &l);
+				comp.loadStub("setfib");
 				break;
 
 			case O_SETDSCP:
-				rule_setdscp(cmd, ip, is_ipv4, is_ipv6, tablearg, f, pktlen, &l);
+				comp.loadStub("setdscp");
 				break;
 
 			case O_NAT:
-				rule_nat(args, f_pos, chain, cmd, m, tablearg, &retval, &done, &l);
+				comp.loadStub("nat");
 				break;
 
 			case O_REASS:
-				rule_reass(f, f_pos, chain, pktlen, ip, args, m, &retval, &done, &l);
+				comp.loadStub("reass");
 				break;
 
 			default:
@@ -513,7 +554,6 @@
 			}
 
 		}	/* end of inner loop, scan opcodes */
-#undef PULLUP_LEN
 
 		if (done)
 			break;
@@ -531,46 +571,5 @@
 		printf("ipfw: ouch!, skip past end of rules, denying packet\n");
 	}
 
-	/*
-	// Get the stub (prototype) for the cell function
-	F = Mod->getFunction("cell");
-	// Set it to have private linkage, so that it can be removed after being
-	// inlined.
-	F->setLinkage(GlobalValue::PrivateLinkage);
-	// Add an entry basic block to this function and set it
-	BasicBlock *entry = BasicBlock::Create(C, "entry", F);
-	B.SetInsertPoint(entry);
-	// Cache the type of registers
-	regTy = Type::getInt16Ty(C);
-
-	// Collect the function parameters
-	auto args = F->arg_begin();
-	oldGrid = args++;
-	newGrid = args++;
-	width = args++;
-	height = args++;
-	x = args++;
-	y = args++;
-
-	// Create space on the stack for the local registers
-	for (int i=0 ; i<10 ; i++)
-	{
-		a[i] = B.CreateAlloca(regTy);
-	}
-	// Create a space on the stack for the current value.  This can be
-	// assigned to, and will be returned at the end.  Store the value passed
-	// as a parameter in this.
-	v = B.CreateAlloca(regTy);
-	B.CreateStore(args++, v);
-
-	// Create a load of pointers to the global registers.
-	Value *gArg = args;
-	for (int i=0 ; i<10 ; i++)
-	{
-		B.CreateStore(ConstantInt::get(regTy, 0), a[i]);
-		g[i] = B.CreateConstGEP1_32(gArg, i);
-	}
-
-	*/
 	return (0);
 }


More information about the svn-soc-all mailing list