From e5d90c37a787231e9a7d6cc34dfd71a678147f53 Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Sat, 20 Sep 2008 04:36:51 +0000 Subject: [PATCH] Instead of rejecting the eligible packet back into the correct cpu, dummynet(4) now reinjects the eligible packet back into correct network thread. --- sys/net/dummynet/ip_dummynet.h | 6 ++++-- sys/net/dummynet/ip_dummynet_glue.c | 15 +++------------ sys/net/ipfw/ip_fw2.c | 8 ++++++-- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/sys/net/dummynet/ip_dummynet.h b/sys/net/dummynet/ip_dummynet.h index 4340879871..64b4c4e591 100644 --- a/sys/net/dummynet/ip_dummynet.h +++ b/sys/net/dummynet/ip_dummynet.h @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/netinet/ip_dummynet.h,v 1.10.2.9 2003/05/13 09:31:06 maxim Exp $ - * $DragonFly: src/sys/net/dummynet/ip_dummynet.h,v 1.18 2007/11/18 13:00:28 sephe Exp $ + * $DragonFly: src/sys/net/dummynet/ip_dummynet.h,v 1.19 2008/09/20 04:36:51 sephe Exp $ */ #ifndef _IP_DUMMYNET_H @@ -114,6 +114,7 @@ struct dn_flow_id { }; typedef void (*ip_dn_unref_priv_t)(void *); +struct lwkt_port; /* * struct dn_pkt identifies a packet in the dummynet queue, but is also used @@ -148,7 +149,8 @@ struct dn_pkt { u_short pad; struct dn_flow_id id; /* flow id */ - int cpuid; /* target cpu, for IP_OUT/ETH_DEMUX/ETH_OUT */ + int cpuid; /* target cpuid, for assertion */ + struct lwkt_port *msgport; /* target msgport */ }; TAILQ_HEAD(dn_pkt_queue, dn_pkt); diff --git a/sys/net/dummynet/ip_dummynet_glue.c b/sys/net/dummynet/ip_dummynet_glue.c index eccab0df7f..a2cdd6aadf 100644 --- a/sys/net/dummynet/ip_dummynet_glue.c +++ b/sys/net/dummynet/ip_dummynet_glue.c @@ -31,7 +31,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sys/net/dummynet/ip_dummynet_glue.c,v 1.10 2008/09/06 14:07:30 sephe Exp $ + * $DragonFly: src/sys/net/dummynet/ip_dummynet_glue.c,v 1.11 2008/09/20 04:36:51 sephe Exp $ */ #include @@ -102,25 +102,18 @@ void ip_dn_packet_free(struct dn_pkt *pkt) { struct netmsg_packet *nmp; - lwkt_port_t port; struct mbuf *m = pkt->dn_m; M_ASSERTPKTHDR(m); KASSERT(m->m_pkthdr.fw_flags & DUMMYNET_MBUF_TAGGED, ("mbuf is not tagged for dummynet!\n")); - if (pkt->cpuid == mycpuid) { - ip_dn_freepkt(pkt); - return; - } - nmp = &m->m_hdr.mh_netmsg; netmsg_init(&nmp->nm_netmsg, &netisr_apanic_rport, 0, ip_dn_freepkt_dispatch); nmp->nm_packet = m; - port = cpu_portfn(pkt->cpuid); - lwkt_sendmsg(port, &nmp->nm_netmsg.nm_lmsg); + lwkt_sendmsg(pkt->msgport, &nmp->nm_netmsg.nm_lmsg); } void @@ -136,7 +129,6 @@ ip_dn_packet_redispatch(struct dn_pkt *pkt) struct netmsg_packet *nmp; struct mbuf *m; netisr_fn_t dispatch; - lwkt_port_t port; int dir; dir = (pkt->dn_flags & DN_FLAGS_DIR_MASK); @@ -156,8 +148,7 @@ ip_dn_packet_redispatch(struct dn_pkt *pkt) netmsg_init(&nmp->nm_netmsg, &netisr_apanic_rport, 0, dispatch); nmp->nm_packet = m; - port = cpu_portfn(pkt->cpuid); - lwkt_sendmsg(port, &nmp->nm_netmsg.nm_lmsg); + lwkt_sendmsg(pkt->msgport, &nmp->nm_netmsg.nm_lmsg); } int diff --git a/sys/net/ipfw/ip_fw2.c b/sys/net/ipfw/ip_fw2.c index 378992084e..0c9846eed7 100644 --- a/sys/net/ipfw/ip_fw2.c +++ b/sys/net/ipfw/ip_fw2.c @@ -23,7 +23,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/netinet/ip_fw2.c,v 1.6.2.12 2003/04/08 10:42:32 maxim Exp $ - * $DragonFly: src/sys/net/ipfw/ip_fw2.c,v 1.94 2008/09/19 12:23:56 sephe Exp $ + * $DragonFly: src/sys/net/ipfw/ip_fw2.c,v 1.95 2008/09/20 04:36:51 sephe Exp $ */ /* @@ -2476,9 +2476,13 @@ ipfw_dummynet_io(struct mbuf *m, int pipe_nr, int dir, struct ip_fw_args *fwa) pkt->dn_m = m; pkt->dn_flags = (dir & DN_FLAGS_DIR_MASK); pkt->ifp = fwa->oif; - pkt->cpuid = mycpuid; pkt->pipe_nr = pipe_nr; + KASSERT(curthread->td_flags & TDF_NETWORK, + ("not in network thread!\n")); + pkt->msgport = &curthread->td_msgport; + pkt->cpuid = mycpuid; + id = &fwa->f_id; fid = &pkt->id; fid->fid_dst_ip = id->dst_ip; -- 2.41.0