From owner-svn-src-user@FreeBSD.ORG Mon Jan 4 10:25:01 2010
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
Delivered-To: svn-src-user@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
by hub.freebsd.org (Postfix) with ESMTP id 044F4106568F;
Mon, 4 Jan 2010 10:25:01 +0000 (UTC)
(envelope-from luigi@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
by mx1.freebsd.org (Postfix) with ESMTP id E82D78FC29;
Mon, 4 Jan 2010 10:25:00 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o04AP05S028412;
Mon, 4 Jan 2010 10:25:00 GMT (envelope-from luigi@svn.freebsd.org)
Received: (from luigi@localhost)
by svn.freebsd.org (8.14.3/8.14.3/Submit) id o04AP09P028409;
Mon, 4 Jan 2010 10:25:00 GMT (envelope-from luigi@svn.freebsd.org)
Message-Id: <201001041025.o04AP09P028409@svn.freebsd.org>
From: Luigi Rizzo <luigi@FreeBSD.org>
Date: Mon, 4 Jan 2010 10:25:00 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-user@freebsd.org
X-SVN-Group: user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc:
Subject: svn commit: r201483 - user/luigi/ipfw3-head/sys/netinet/ipfw
X-BeenThere: svn-src-user@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the experimental " user"
src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Mon, 04 Jan 2010 10:25:01 -0000
Author: luigi
Date: Mon Jan 4 10:25:00 2010
New Revision: 201483
URL: http://svn.freebsd.org/changeset/base/201483
Log:
complete work on tag cleanup.
Modified:
user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c
user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_pfil.c
Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c Mon Jan 4 09:59:18 2010 (r201482)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c Mon Jan 4 10:25:00 2010 (r201483)
@@ -968,17 +968,21 @@ dummynet_send(struct mbuf *m)
for (; m != NULL; m = n) {
struct ifnet *ifp;
int dst;
+ struct m_tag *tag;
n = m->m_nextpkt;
m->m_nextpkt = NULL;
- if (m_tag_first(m) == NULL) {
+ tag = m_tag_first(m);
+ if (tag == NULL) {
dst = DIR_DROP;
} else {
struct dn_pkt_tag *pkt = dn_tag_get(m);
/* extract the dummynet info, rename the tag */
dst = pkt->dn_dir;
ifp = pkt->ifp;
- // XXX rename the tag
+ /* rename the tag so it carries reinject info */
+ tag->m_tag_cookie = MTAG_IPFW_RULE;
+ tag->m_tag_id = 0;
}
switch (dst) {
Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_pfil.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_pfil.c Mon Jan 4 09:59:18 2010 (r201482)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_fw_pfil.c Mon Jan 4 10:25:00 2010 (r201483)
@@ -81,7 +81,7 @@ ip_divert_packet_t *ip_divert_ptr = NULL
ng_ipfw_input_t *ng_ipfw_input_p = NULL;
/* Forward declarations. */
-static void ipfw_divert(struct mbuf **, int, int);
+static int ipfw_divert(struct mbuf **, int, struct ipfw_rule_ref *, int);
#ifdef SYSCTL_NODE
SYSCTL_DECL(_net_inet_ip_fw);
@@ -205,17 +205,9 @@ again:
ret = EACCES;
break; /* i.e. drop */
}
- tag = m_tag_alloc(MTAG_IPFW_RULE, 0,
- sizeof(struct ipfw_rule_ref), M_NOWAIT);
- if (tag == NULL) {
- ret = EACCES;
- break; /* i.e. drop */
- }
- *((struct ipfw_rule_ref *)(tag+1)) = args.rule;
- m_tag_prepend(*m0, tag);
-
- ipfw_divert(m0, dir, (ipfw == IP_FW_TEE) ? 1 : 0);
- /* continue processing for the original packet (tee) */
+ ret = ipfw_divert(m0, dir, &args.rule,
+ (ipfw == IP_FW_TEE) ? 1 : 0);
+ /* continue processing for the original packet (tee). */
if (*m0)
goto again;
break;
@@ -250,8 +242,10 @@ again:
return ret;
}
-static void
-ipfw_divert(struct mbuf **m0, int incoming, int tee)
+/* do the divert, return 1 on error 0 on success */
+static int
+ipfw_divert(struct mbuf **m0, int incoming, struct ipfw_rule_ref *rule,
+ int tee)
{
/*
* ipfw_chk() has already tagged the packet with the divert tag.
@@ -260,6 +254,7 @@ ipfw_divert(struct mbuf **m0, int incomi
*/
struct mbuf *clone;
struct ip *ip;
+ struct m_tag *tag;
/* Cloning needed for tee? */
if (tee == 0) {
@@ -271,7 +266,7 @@ ipfw_divert(struct mbuf **m0, int incomi
* chain and continue with the tee-ed packet.
*/
if (clone == NULL)
- return;
+ return 1;
}
/*
@@ -290,7 +285,7 @@ ipfw_divert(struct mbuf **m0, int incomi
SET_HOST_IPLEN(ip); /* ip_reass wants host order */
reass = ip_reass(clone); /* Reassemble packet. */
if (reass == NULL)
- return;
+ return 0; /* not an error */
/* if reass = NULL then it was consumed by ip_reass */
/*
* IP header checksum fixup after reassembly and leave header
@@ -306,9 +301,19 @@ ipfw_divert(struct mbuf **m0, int incomi
ip->ip_sum = in_cksum(reass, hlen);
clone = reass;
}
+ /* attach a tag to the packet with the reinject info */
+ tag = m_tag_alloc(MTAG_IPFW_RULE, 0,
+ sizeof(struct ipfw_rule_ref), M_NOWAIT);
+ if (tag == NULL) {
+ FREE_PKT(clone);
+ return 1;
+ }
+ *((struct ipfw_rule_ref *)(tag+1)) = *rule;
+ m_tag_prepend(clone, tag);
/* Do the dirty job... */
ip_divert_ptr(clone, incoming);
+ return 0;
}
/*