PERFORCE change 107997 for review
Paolo Pisati
piso at FreeBSD.org
Mon Oct 16 13:14:00 PDT 2006
http://perforce.freebsd.org/chv.cgi?CH=107997
Change 107997 by piso at piso_newluxor on 2006/10/16 20:13:08
Move the helper function m_megapullup from ng_nat.c & ipfw2.c
to alias.c and alias.h.
Affected files ...
.. //depot/projects/soc2005/libalias/sys/netgraph/ng_nat.c#3 edit
.. //depot/projects/soc2005/libalias/sys/netinet/ip_fw2.c#19 edit
.. //depot/projects/soc2005/libalias/sys/netinet/libalias/alias.c#16 edit
.. //depot/projects/soc2005/libalias/sys/netinet/libalias/alias.h#6 edit
Differences ...
==== //depot/projects/soc2005/libalias/sys/netgraph/ng_nat.c#3 (text+ko) ====
@@ -56,8 +56,6 @@
static ng_rcvdata_t ng_nat_rcvdata;
static ng_disconnect_t ng_nat_disconnect;
-static struct mbuf * m_megapullup(struct mbuf *, int);
-
/* List of commands and how to convert arguments to/from ASCII. */
static const struct ng_cmdlist ng_nat_cmdlist[] = {
{
@@ -327,36 +325,3 @@
return (0);
}
-/*
- * m_megapullup() function is a big hack.
- *
- * It allocates an mbuf with cluster and copies the whole
- * chain into cluster, so that it is all contigous and the
- * whole packet can be accessed via char pointer.
- *
- * This is required, because libalias doesn't have idea
- * about mbufs.
- */
-static struct mbuf *
-m_megapullup(struct mbuf *m, int len)
-{
- struct mbuf *mcl;
- caddr_t cp;
-
- if (len > MCLBYTES)
- goto bad;
-
- if ((mcl = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR)) == NULL)
- goto bad;
-
- cp = mtod(mcl, caddr_t);
- m_copydata(m, 0, len, cp);
- m_move_pkthdr(mcl, m);
- mcl->m_len = mcl->m_pkthdr.len;
- m_freem(m);
-
- return (mcl);
-bad:
- m_freem(m);
- return (NULL);
-}
==== //depot/projects/soc2005/libalias/sys/netinet/ip_fw2.c#19 (text+ko) ====
@@ -2046,42 +2046,6 @@
return match;
}
-/*
- * m_megapullup() function (from ng_nat.c) is a big hack.
- *
- * It allocates an mbuf with cluster and copies the whole
- * chain into cluster, so that it is all contigous and the
- * whole packet can be accessed via char pointer.
- * This is required, because libalias doesn't have idea
- * about mbufs.
- *
- * On success, m_megapullup returns an mbuf with cluster
- * containing the input packet, on failure NULL.
- * In both cases, the input packet is consumed.
- */
-static struct mbuf *
-m_megapullup(struct mbuf *m, int len) {
- struct mbuf *mcl;
- caddr_t cp;
-
- if (len > MCLBYTES)
- goto bad;
-
- if ((mcl = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR)) == NULL)
- goto bad;
-
- cp = mtod(mcl, caddr_t);
- m_copydata(m, 0, len, cp);
- m_move_pkthdr(mcl, m);
- mcl->m_len = mcl->m_pkthdr.len;
- m_freem(m);
-
- return (mcl);
-bad:
- m_freem(m);
- return (NULL);
-}
-
static void
flush_nat_ptrs(const int i) {
struct ip_fw *rule;
==== //depot/projects/soc2005/libalias/sys/netinet/libalias/alias.c#16 (text+ko) ====
@@ -113,6 +113,8 @@
#ifdef _KERNEL
#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/mbuf.h>
#else
#include <sys/types.h>
#include <stdlib.h>
@@ -1574,3 +1576,41 @@
}
#endif
+
+#ifdef _KERNEL
+/*
+ * m_megapullup() function is a big hack (only used in ng_nat and ipfw+nat).
+ *
+ * It allocates an mbuf with cluster and copies the whole
+ * chain into cluster, so that it is all contigous and the
+ * whole packet can be accessed via char pointer.
+ * This is required, because libalias doesn't have idea
+ * about mbufs.
+ *
+ * On success, m_megapullup returns an mbuf with cluster
+ * containing the input packet, on failure NULL.
+ * In both cases, the input packet is consumed.
+ */
+struct mbuf *
+m_megapullup(struct mbuf *m, int len) {
+ struct mbuf *mcl;
+ caddr_t cp;
+
+ if (len > MCLBYTES)
+ goto bad;
+
+ if ((mcl = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR)) == NULL)
+ goto bad;
+
+ cp = mtod(mcl, caddr_t);
+ m_copydata(m, 0, len, cp);
+ m_move_pkthdr(mcl, m);
+ mcl->m_len = mcl->m_pkthdr.len;
+ m_freem(m);
+
+ return (mcl);
+bad:
+ m_freem(m);
+ return (NULL);
+}
+#endif
==== //depot/projects/soc2005/libalias/sys/netinet/libalias/alias.h#6 (text+ko) ====
@@ -189,6 +189,9 @@
int LibAliasUnLoadAllModule(void);
int LibAliasRefreshModules(void);
+/* Mbuf helper function. */
+struct mbuf *m_megapullup(struct mbuf *, int);
+
/*
* Mode flags and other constants.
*/
More information about the p4-projects
mailing list