From owner-svn-soc-all@FreeBSD.ORG Mon Aug 11 13:25:54 2014 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 1D9DD94E for ; Mon, 11 Aug 2014 13:25:54 +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 0A32C2765 for ; Mon, 11 Aug 2014 13:25:54 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id s7BDPrJv094996 for ; Mon, 11 Aug 2014 13:25:53 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id s7BDPrXC094994 for svn-soc-all@FreeBSD.org; Mon, 11 Aug 2014 13:25:53 GMT (envelope-from dpl@FreeBSD.org) Date: Mon, 11 Aug 2014 13:25:53 GMT Message-Id: <201408111325.s7BDPrXC094994@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: r272204 - 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: Mon, 11 Aug 2014 13:25:54 -0000 Author: dpl Date: Mon Aug 11 13:25:53 2014 New Revision: 272204 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=272204 Log: Improved comments, added struct types to be used by the compiler, and removed the __inline attribute of auxiliary functions. Modified: soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw_rules.h Modified: soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw_rules.h ============================================================================== --- soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw_rules.h Mon Aug 11 12:59:55 2014 (r272203) +++ soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw_rules.h Mon Aug 11 13:25:53 2014 (r272204) @@ -1,4 +1,3 @@ -/* Includes dpl XXX -- we have to clean them up*/ #include __FBSDID("$FreeBSD: head/sys/netpfil/ipfw/ip_fw2.c 243711 2012-11-30 19:36:55Z melifaro $"); @@ -30,8 +29,7 @@ #include /* XXX for in_cksum */ -// dpl XXX. The real function will be inserted by the JIT. -// dpl XXX. For now, we put the chain there, that could change, tough. +// The real function will be inserted by the JIT. int ipfw_chk_jit(struct ip_fw_args *args, struct ip_fw_chain *chain); // Functions used by JIT, external to our code. @@ -40,10 +38,21 @@ // Declarations of some needed structs. struct mbuf; +struct ifnet; +struct in_addr; +struct ip; struct ip_fw_args; struct ip_fw_chain; struct ip_fw; struct ipfw_insn; +ipfw_insn_if; +ipfw_dyn_rule; + +#ifndef __FreeBSD__ + struct bsd_ucred; +#else + struct ucred; +#endif /* * Some macros used in the various matching options. @@ -60,13 +69,31 @@ /* This macro needs the calling function to have a tablearg argument */ #define IP_FW_ARG_TABLEARG(a) (((a) == IP_FW_TABLEARG) ? tablearg : (a)) +/* + * PULLUP_TO(len, p, T) makes sure that len + sizeof(T) is contiguous, + * then it sets p to point at the offset "len" in the mbuf. WARNING: the + * pointer might become stale after other pullups (but we never use it + * this way). + */ +#define PULLUP_TO(_len, p, T) PULLUP_LEN(_len, p, sizeof(T)) +#define PULLUP_LEN(_len, p, T) \ +do { \ + int x = (_len) + T; \ + if ((m)->m_len < x) { \ + args->m = m = m_pullup(m, x); \ + if (m == NULL) \ + goto pullup_failed; \ + } \ + p = (mtod(m, char *) + (_len)); \ +} while (0) + /* Needed vars defined at ip_fw2.c */ VNET_DECLARE(int, V_ipfw_vnet_ready); /* * Auxiliar functions. */ -static __inline int +static int icmptype_match(struct icmphdr *icmp, ipfw_insn_u32 *cmd) { int type = icmp->icmp_type; @@ -316,7 +343,7 @@ /* * ipv6 specific aux funtions here... */ -static __inline int +static int icmp6type_match (int type, ipfw_insn_u32 *cmd) { return (type <= ICMP6_MAXTYPE && (cmd->d[type/32] & (1<<(type%32)) ) ); @@ -1134,12 +1161,7 @@ static IPFW_RULES_INLINE int rule_tcpopts(int *match, u_int hlen, void *ulp, uint8_t proto, u_short offset, ipfw_insn *cmd, struct mbuf *m, struct ip_fw_args *args) { - /* - * PULLUP_TO(len, p, T) makes sure that len + sizeof(T) is contiguous, - * then it sets p to point at the offset "len" in the mbuf. WARNING: the - * pointer might become stale after other pullups (but we never use it - * this way). - */ + /* Modified PULLUP_TO, returns 1 if error */ do { int x = (hlen) + (TCP(ulp)->th_off << 2); if ((m)->m_len < x) { @@ -1278,7 +1300,6 @@ verify_path(*src_ip, NULL, args->f_id.fib))); } -/* dpl XXX We could pass pointers to struct in_addr at in_localaddr() */ static IPFW_RULES_INLINE void rule_antispoof(int *match, struct ifnet *oif, u_int hlen, int is_ipv4, int is_ipv6, struct in_addr *src_ip, struct ip_fw_args *args, struct mbuf *m) {