From owner-p4-projects@FreeBSD.ORG Wed Jun 9 03:06:51 2004 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 7F19816A4D2; Wed, 9 Jun 2004 03:06:51 +0000 (GMT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 522AC16A4CE for ; Wed, 9 Jun 2004 03:06:51 +0000 (GMT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4623A43D49 for ; Wed, 9 Jun 2004 03:06:51 +0000 (GMT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.11/8.12.11) with ESMTP id i5936poZ069283 for ; Wed, 9 Jun 2004 03:06:51 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.11/8.12.11/Submit) id i5936oqC069280 for perforce@freebsd.org; Wed, 9 Jun 2004 03:06:50 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Wed, 9 Jun 2004 03:06:50 GMT Message-Id: <200406090306.i5936oqC069280@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson To: Perforce Change Reviews Subject: PERFORCE change 54442 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Jun 2004 03:06:52 -0000 http://perforce.freebsd.org/chv.cgi?CH=54442 Change 54442 by rwatson@rwatson_tislabs on 2004/06/09 03:05:57 Integrate netperf_socket: Loop back rtsock+netisr changes so that rt_dispatch() defers delivering to raw sockets via a netisr avoiding lock order and recursion issues. Affected files ... .. //depot/projects/netperf_socket/sys/net/netisr.h#3 integrate .. //depot/projects/netperf_socket/sys/net/rtsock.c#9 integrate .. //depot/projects/netperf_socket/sys/sys/mbuf.h#12 integrate Differences ... ==== //depot/projects/netperf_socket/sys/net/netisr.h#3 (text+ko) ==== @@ -27,7 +27,7 @@ * SUCH DAMAGE. * * @(#)netisr.h 8.1 (Berkeley) 6/10/93 - * $FreeBSD: src/sys/net/netisr.h,v 1.31 2004/04/07 20:46:11 imp Exp $ + * $FreeBSD: src/sys/net/netisr.h,v 1.32 2004/06/09 02:48:23 rwatson Exp $ */ #ifndef _NET_NETISR_H_ @@ -50,6 +50,7 @@ */ #define NETISR_POLL 0 /* polling callback, must be first */ #define NETISR_IP 2 /* same as AF_INET */ +#define NETISR_ROUTE 14 /* routing socket */ #define NETISR_AARP 15 /* Appletalk ARP */ #define NETISR_ATALK2 16 /* Appletalk phase 2 */ #define NETISR_ATALK1 17 /* Appletalk phase 1 */ ==== //depot/projects/netperf_socket/sys/net/rtsock.c#9 (text+ko) ==== @@ -27,7 +27,7 @@ * SUCH DAMAGE. * * @(#)rtsock.c 8.7 (Berkeley) 10/12/95 - * $FreeBSD: src/sys/net/rtsock.c,v 1.110 2004/05/10 15:07:23 csjp Exp $ + * $FreeBSD: src/sys/net/rtsock.c,v 1.111 2004/06/09 02:48:23 rwatson Exp $ */ #include @@ -45,6 +45,7 @@ #include #include +#include #include #include @@ -71,6 +72,8 @@ #define RTSOCK_UNLOCK() mtx_unlock(&rtsock_mtx) #define RTSOCK_LOCK_ASSERT() mtx_assert(&rtsock_mtx, MA_OWNED) +static struct ifqueue rtsintrq; + struct walkarg { int w_tmemsize; int w_op, w_arg; @@ -78,6 +81,7 @@ struct sysctl_req *w_req; }; +static void rts_input(struct mbuf *m); static struct mbuf *rt_msg1(int type, struct rt_addrinfo *rtinfo); static int rt_msg2(int type, struct rt_addrinfo *rtinfo, caddr_t cp, struct walkarg *w); @@ -93,6 +97,35 @@ struct rt_metrics *out); static void rt_dispatch(struct mbuf *, const struct sockaddr *); +static void +rts_init(void) +{ + + rtsintrq.ifq_maxlen = IFQ_MAXLEN; + mtx_init(&rtsintrq.ifq_mtx, "rts_inq", NULL, MTX_DEF); + netisr_register(NETISR_ROUTE, rts_input, &rtsintrq, NETISR_MPSAFE); +} +SYSINIT(rtsock, SI_SUB_PROTO_DOMAIN, SI_ORDER_THIRD, rts_init, 0) + +static void +rts_input(struct mbuf *m) +{ + struct sockproto route_proto; + unsigned short *family; + struct m_tag *tag; + + route_proto.sp_family = PF_ROUTE; + tag = m_tag_find(m, PACKET_TAG_RTSOCKFAM, NULL); + if (tag != NULL) { + family = (unsigned short *)(tag + 1); + route_proto.sp_protocol = *family; + m_tag_delete(m, tag); + } else + route_proto.sp_protocol = 0; + + raw_input(m, &route_proto, &route_src, &route_dst); +} + /* * It really doesn't make any sense at all for this code to share much * with raw_usrreq.c, since its functionality is so restricted. XXX @@ -919,11 +952,26 @@ static void rt_dispatch(struct mbuf *m, const struct sockaddr *sa) { - struct sockproto route_proto; + unsigned short *family; + struct m_tag *tag; - route_proto.sp_family = PF_ROUTE; - route_proto.sp_protocol = sa ? sa->sa_family : 0; - raw_input(m, &route_proto, &route_src, &route_dst); + /* + * Preserve the family from the sockaddr, if any, in an m_tag for + * use when injecting the mbuf into the routing socket buffer from + * the netisr. + */ + if (sa != NULL) { + tag = m_tag_get(PACKET_TAG_RTSOCKFAM, sizeof(unsigned short), + M_NOWAIT); + if (tag == NULL) { + m_freem(m); + return; + } + family = (unsigned short *)(tag + 1); + *family = sa ? sa->sa_family : 0; + m_tag_prepend(m, tag); + } + netisr_queue(NETISR_ROUTE, m); } /* ==== //depot/projects/netperf_socket/sys/sys/mbuf.h#12 (text+ko) ==== @@ -27,7 +27,7 @@ * SUCH DAMAGE. * * @(#)mbuf.h 8.5 (Berkeley) 2/19/95 - * $FreeBSD: src/sys/sys/mbuf.h,v 1.148 2004/05/31 21:46:05 bmilekic Exp $ + * $FreeBSD: src/sys/sys/mbuf.h,v 1.149 2004/06/09 02:48:23 rwatson Exp $ */ #ifndef _SYS_MBUF_H_ @@ -631,6 +631,7 @@ #define PACKET_TAG_PF_FRAGCACHE 22 /* PF fragment cached */ #define PACKET_TAG_PF_QID 23 /* PF ALTQ queue id */ #define PACKET_TAG_PF_TAG 24 /* PF tagged */ +#define PACKET_TAG_RTSOCKFAM 25 /* rtsock sa family */ /* Packet tag routines. */ struct m_tag *m_tag_alloc(u_int32_t, int, int, int);