Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 11 Aug 2014 13:25:53 GMT
From:      dpl@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r272204 - soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw
Message-ID:  <201408111325.s7BDPrXC094994@socsvn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 <sys/cdefs.h>
 __FBSDID("$FreeBSD: head/sys/netpfil/ipfw/ip_fw2.c 243711 2012-11-30 19:36:55Z melifaro $");
 
@@ -30,8 +29,7 @@
 
 #include <machine/in_cksum.h>	/* 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)
 {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201408111325.s7BDPrXC094994>