Date: Wed, 3 Sep 2014 18:03:35 GMT From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r273571 - soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw Message-ID: <201409031803.s83I3ZV0050971@socsvn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dpl Date: Wed Sep 3 18:03:34 2014 New Revision: 273571 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=273571 Log: Added the needed stuff to have a complete bitcode. Modified: soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw_rules.c Modified: soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw_rules.c ============================================================================== --- soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw_rules.c Wed Sep 3 18:01:56 2014 (r273570) +++ soc2014/dpl/netmap-ipfwjit/sys/netpfil/ipfw/ip_fw_rules.c Wed Sep 3 18:03:34 2014 (r273571) @@ -1,5 +1,6 @@ #include <sys/param.h> #include <sys/ucred.h> + #include <netinet/in.h> #define IPFW_RULES_INLINE __unused #include "ip_fw_rules.h" @@ -7,6 +8,71 @@ // The real function will be compiled and inserted by the JIT. int ipfw_chk_jit(struct ip_fw_args *args, struct ip_fw_chain *chain); +void crfree(struct ucred *); +time_t time_uptime = 0; + +/* XXX Function defined at ip_fw_sockopt.c + * Find the smallest rule >= key, id. + * We could use bsearch but it is so simple that we code it directly + */ +int +ipfw_find_rule(struct ip_fw_chain *chain, uint32_t key, uint32_t id) +{ + int i, lo, hi; + struct ip_fw *r; + + for (lo = 0, hi = chain->n_rules - 1; lo < hi;) { + i = (lo + hi) / 2; + r = chain->map[i]; + if (r->rulenum < key) + lo = i + 1; /* continue from the next one */ + else if (r->rulenum > key) + hi = i; /* this might be good */ + else if (r->id < id) + lo = i + 1; /* continue from the next one */ + else /* r->id >= id */ + hi = i; /* this might be good */ + }; + return hi; +} + +/* Defined at extra/missing.c */ +struct tags_freelist tags_freelist; +int tags_minlen = 64; +int tags_freelist_count = 0; +static int tags_freelist_max = 0; + +struct mbuf *mbuf_freelist; + +void +m_freem(struct mbuf *m) +{ + struct m_tag *t; + + /* free the m_tag chain */ + while ( (t = SLIST_FIRST(&m->m_pkthdr.tags) ) ) { + ND("free tag %p", &m->m_pkthdr.tags); + SLIST_REMOVE_HEAD(&m->m_pkthdr.tags, m_tag_link); + SLIST_INSERT_HEAD(&tags_freelist, t, m_tag_link); + tags_freelist_count++; + if (tags_freelist_count > tags_freelist_max) { + static int pr=0; + if ((pr++ % 1000) == 0) + D("new max %d", tags_freelist_count); + tags_freelist_max = tags_freelist_count; + } + } + if (m->m_flags & M_STACK) { + ND("free invalid mbuf %p", m); + return; + } + /* free the mbuf */ + ND("free(m = %p, M_IPFW);", m); + m->m_next = mbuf_freelist; + mbuf_freelist = m; +}; + + // Declarations of some needed structs. struct mbuf; struct ifnet; @@ -26,14 +92,6 @@ struct ucred; #endif -// Functions used by JIT, external. -int printf(const char * restrict format, ...); -int ipfw_find_rule(struct ip_fw_chain *chain, uint32_t key, uint32_t id); -void crfree(struct ucred *); - -// As done at netmap-ipfw -time_t time_uptime = 0; - // This functions only forces the compiler to store the stubs of the functions // so that they can be used by the JIT-compiled code instead. // this functions is not to be called anywhere. @@ -42,6 +100,7 @@ { struct ip_fw_args arguments; struct ip_fw_chain chainss; + uint32_t thing; #ifndef __FreeBSD__ struct bsd_ucred user_creds; @@ -68,5 +127,8 @@ crfree(ucreds); #endif + + thing = htonl(thing); + thing = ntohl(thing); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201409031803.s83I3ZV0050971>
