Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 19 Oct 2004 18:21:54 GMT
From:      Robert Watson <rwatson@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 63368 for review
Message-ID:  <200410191821.i9JILsKd085683@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=63368

Change 63368 by rwatson@rwatson_zoo on 2004/10/19 18:21:38

	Integ netperf_socket:
	
	- Pluggable IP protocols
	- IFF_LOCKGIANT() around if_ioctl

Affected files ...

.. //depot/projects/netperf_socket/sys/kern/uipc_domain.c#6 integrate
.. //depot/projects/netperf_socket/sys/kern/uipc_socket2.c#23 integrate
.. //depot/projects/netperf_socket/sys/net/if.c#22 integrate
.. //depot/projects/netperf_socket/sys/net/if_var.h#20 integrate
.. //depot/projects/netperf_socket/sys/netinet/in_pcb.h#8 integrate
.. //depot/projects/netperf_socket/sys/netinet/in_proto.c#7 integrate
.. //depot/projects/netperf_socket/sys/netinet/ip_fastfwd.c#12 integrate
.. //depot/projects/netperf_socket/sys/netinet/ip_input.c#26 integrate
.. //depot/projects/netperf_socket/sys/netinet/ip_var.h#11 integrate
.. //depot/projects/netperf_socket/sys/netinet6/ip6_input.c#12 integrate
.. //depot/projects/netperf_socket/sys/pci/if_vr.c#14 integrate
.. //depot/projects/netperf_socket/sys/sys/protosw.h#3 integrate

Differences ...

==== //depot/projects/netperf_socket/sys/kern/uipc_domain.c#6 (text+ko) ====

@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/uipc_domain.c,v 1.36 2004/04/05 21:03:36 imp Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/uipc_domain.c,v 1.37 2004/10/19 15:13:30 andre Exp $");
 
 #include <sys/param.h>
 #include <sys/socket.h>
@@ -70,8 +70,22 @@
 MTX_SYSINIT(domain, &dom_mtx, "domain list", MTX_DEF);
 
 /*
+ * Dummy protocol specific user requests function pointer array.
+ * All functions return EOPNOTSUPP.
+ */
+struct pr_usrreqs nousrreqs = {
+        pru_abort_notsupp, pru_accept_notsupp, pru_attach_notsupp,
+        pru_bind_notsupp, pru_connect_notsupp, pru_connect2_notsupp,
+        pru_control_notsupp, pru_detach_notsupp, pru_disconnect_notsupp,
+        pru_listen_notsupp, pru_peeraddr_notsupp, pru_rcvd_notsupp,
+        pru_rcvoob_notsupp, pru_send_notsupp, pru_sense_null,
+        pru_shutdown_notsupp, pru_sockaddr_notsupp, pru_sosend_notsupp,
+        pru_soreceive_notsupp, pru_sopoll_notsupp, pru_sosetlabel_null
+};
+
+/*
  * Add a new protocol domain to the list of supported domains
- * Note: you cant unload it again because  a socket may be using it.
+ * Note: you cant unload it again because a socket may be using it.
  * XXX can't fail at this time.
  */
 static void
@@ -98,7 +112,7 @@
 
 /*
  * Add a new protocol domain to the list of supported domains
- * Note: you cant unload it again because  a socket may be using it.
+ * Note: you cant unload it again because a socket may be using it.
  * XXX can't fail at this time.
  */
 void
@@ -190,6 +204,126 @@
 	return (maybe);
 }
 
+/*
+ * The caller must make sure that the new protocol is fully set up and ready to
+ * accept requests before it is registered.
+ */
+int
+pf_proto_register(family, npr)
+	int family;
+	struct protosw *npr;
+{
+	struct domain *dp;
+	struct protosw *pr, *fpr;
+
+	/* Sanity checks. */
+	if (family == 0)
+		return (EPFNOSUPPORT);
+	if (npr->pr_type == 0)
+		return (EPROTOTYPE);
+	if (npr->pr_protocol == 0)
+		return (EPROTONOSUPPORT);
+	if (npr->pr_usrreqs == NULL)
+		return (ENXIO);
+
+	/* Try to find the specified domain based on the family. */
+	for (dp = domains; dp; dp = dp->dom_next)
+		if (dp->dom_family == family)
+			goto found;
+	return (EPFNOSUPPORT);
+
+found:
+	/* Initialize backpointer to struct domain. */
+	npr->pr_domain = dp;
+	fpr = NULL;
+
+	/* The new protocol must not yet exist. */
+	for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) {
+		if ((pr->pr_type == npr->pr_type) &&
+		    (pr->pr_protocol == npr->pr_protocol))
+			return (EEXIST);	/* XXX: Check only protocol? */
+		/* While here, remember the first free spacer. */
+		if ((fpr == NULL) && (pr->pr_protocol == PROTO_SPACER))
+			fpr = pr;
+	}
+
+	/* If no free spacer is found we can't add the new protocol. */
+	if (fpr == NULL)
+		return (ENOMEM);
+
+	/* Copy the new struct protosw over the spacer. */
+	bcopy(npr, fpr, sizeof(*fpr));
+
+	/* Initialize and activate the protocol. */
+	if (fpr->pr_init)
+		(fpr->pr_init)();
+
+	return (0);
+}
+
+/*
+ * The caller must make sure the protocol and its functions correctly shut down
+ * all sockets and release all locks and memory references.
+ */
+int
+pf_proto_unregister(family, protocol, type)
+	int family;
+	int protocol;
+	int type;
+{
+	struct domain *dp;
+	struct protosw *pr, *dpr;
+
+	/* Sanity checks. */
+	if (family == 0)
+		return (EPFNOSUPPORT);
+	if (protocol == 0)
+		return (EPROTONOSUPPORT);
+	if (type == 0)
+		return (EPROTOTYPE);
+
+	/* Try to find the specified domain based on the family type. */
+	for (dp = domains; dp; dp = dp->dom_next)
+		if (dp->dom_family == family)
+			goto found;
+	return (EPFNOSUPPORT);
+
+found:
+	dpr = NULL;
+
+	/* The protocol must exist and only once. */
+	for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) {
+		if ((pr->pr_type == type) && (pr->pr_protocol == protocol)) {
+			if (dpr != NULL)
+				return (EMLINK);   /* Should not happen! */
+			else
+				dpr = pr;
+		}
+	}
+
+	/* Protocol does not exist. */
+	if (dpr == NULL)
+		return (EPROTONOSUPPORT);
+
+	/* De-orbit the protocol and make the slot available again. */
+	dpr->pr_type = 0;
+	dpr->pr_domain = dp;
+	dpr->pr_protocol = PROTO_SPACER;
+	dpr->pr_flags = 0;
+	dpr->pr_input = NULL;
+	dpr->pr_output = NULL;
+	dpr->pr_ctlinput = NULL;
+	dpr->pr_ctloutput = NULL;
+	dpr->pr_ousrreq = NULL;
+	dpr->pr_init = NULL;
+	dpr->pr_fasttimo = NULL;
+	dpr->pr_slowtimo = NULL;
+	dpr->pr_drain = NULL;
+	dpr->pr_usrreqs = &nousrreqs;
+
+	return (0);
+}
+
 void
 pfctlinput(cmd, sa)
 	int cmd;

==== //depot/projects/netperf_socket/sys/kern/uipc_socket2.c#23 (text+ko) ====

@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/uipc_socket2.c,v 1.137 2004/08/15 06:24:41 jmg Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/uipc_socket2.c,v 1.138 2004/10/19 15:13:30 andre Exp $");
 
 #include "opt_mac.h"
 #include "opt_param.h"
@@ -1339,12 +1339,30 @@
  * supported by a protocol.  Fill in as needed.
  */
 int
+pru_abort_notsupp(struct socket *so)
+{
+	return EOPNOTSUPP;
+}
+
+int
 pru_accept_notsupp(struct socket *so, struct sockaddr **nam)
 {
 	return EOPNOTSUPP;
 }
 
 int
+pru_attach_notsupp(struct socket *so, int proto, struct thread *td)
+{
+	return EOPNOTSUPP;
+}
+
+int
+pru_bind_notsupp(struct socket *so, struct sockaddr *nam, struct thread *td)
+{
+	return EOPNOTSUPP;
+}
+
+int
 pru_connect_notsupp(struct socket *so, struct sockaddr *nam, struct thread *td)
 {
 	return EOPNOTSUPP;
@@ -1358,7 +1376,19 @@
 
 int
 pru_control_notsupp(struct socket *so, u_long cmd, caddr_t data,
-		    struct ifnet *ifp, struct thread *td)
+	struct ifnet *ifp, struct thread *td)
+{
+	return EOPNOTSUPP;
+}
+
+int
+pru_detach_notsupp(struct socket *so)
+{
+	return EOPNOTSUPP;
+}
+
+int
+pru_disconnect_notsupp(struct socket *so)
 {
 	return EOPNOTSUPP;
 }
@@ -1370,6 +1400,12 @@
 }
 
 int
+pru_peeraddr_notsupp(struct socket *so, struct sockaddr **nam)
+{
+	return EOPNOTSUPP;
+}
+
+int
 pru_rcvd_notsupp(struct socket *so, int flags)
 {
 	return EOPNOTSUPP;
@@ -1381,6 +1417,13 @@
 	return EOPNOTSUPP;
 }
 
+int
+pru_send_notsupp(struct socket *so, int flags, struct mbuf *m,
+	struct sockaddr *addr, struct mbuf *control, struct thread *td)
+{
+	return EOPNOTSUPP;
+}
+
 /*
  * This isn't really a ``null'' operation, but it's the default one
  * and doesn't do anything destructive.
@@ -1392,6 +1435,40 @@
 	return 0;
 }
 
+int
+pru_shutdown_notsupp(struct socket *so)
+{
+	return EOPNOTSUPP;
+}
+
+int
+pru_sockaddr_notsupp(struct socket *so, struct sockaddr **nam)
+{
+	return EOPNOTSUPP;
+}
+
+int
+pru_sosend_notsupp(struct socket *so, struct sockaddr *addr, struct uio *uio,
+	struct mbuf *top, struct mbuf *control, int flags, struct thread *td)
+{
+	return EOPNOTSUPP;
+}
+
+int
+pru_soreceive_notsupp(struct socket *so, struct sockaddr **paddr,
+	struct uio *uio, struct mbuf **mp0, struct mbuf **controlp,
+	int *flagsp)
+{
+	return EOPNOTSUPP;
+}
+
+int
+pru_sopoll_notsupp(struct socket *so, int events, struct ucred *cred,
+	struct thread *td)
+{
+	return EOPNOTSUPP;
+}
+
 /*
  * For protocol types that don't keep cached copies of labels in their
  * pcbs, provide a null sosetlabel that does a NOOP.

==== //depot/projects/netperf_socket/sys/net/if.c#22 (text+ko) ====

@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)if.c	8.5 (Berkeley) 1/9/95
- * $FreeBSD: src/sys/net/if.c,v 1.209 2004/09/22 12:53:27 green Exp $
+ * $FreeBSD: src/sys/net/if.c,v 1.210 2004/10/19 18:11:55 rwatson Exp $
  */
 
 #include "opt_compat.h"
@@ -1122,8 +1122,11 @@
 		} else if (ifp->if_pcount == 0) {
 			ifp->if_flags &= ~IFF_PROMISC;
 		}
-		if (ifp->if_ioctl)
+		if (ifp->if_ioctl) {
+			IFF_LOCKGIANT(ifp);
 			(void) (*ifp->if_ioctl)(ifp, cmd, data);
+			IFF_UNLOCKGIANT(ifp);
+		}
 		getmicrotime(&ifp->if_lastchange);
 		break;
 
@@ -1135,7 +1138,9 @@
 			return (EOPNOTSUPP);
 		if (ifr->ifr_reqcap & ~ifp->if_capabilities)
 			return (EINVAL);
+		IFF_LOCKGIANT(ifp);
 		error = (*ifp->if_ioctl)(ifp, cmd, data);
+		IFF_UNLOCKGIANT(ifp);
 		if (error == 0)
 			getmicrotime(&ifp->if_lastchange);
 		break;
@@ -1207,7 +1212,9 @@
 			return (error);
 		if (ifp->if_ioctl == NULL)
 			return (EOPNOTSUPP);
+		IFF_LOCKGIANT(ifp);
 		error = (*ifp->if_ioctl)(ifp, cmd, data);
+		IFF_UNLOCKGIANT(ifp);
 		if (error == 0)
 			getmicrotime(&ifp->if_lastchange);
 		break;
@@ -1223,7 +1230,9 @@
 			return (EINVAL);
 		if (ifp->if_ioctl == NULL)
 			return (EOPNOTSUPP);
+		IFF_LOCKGIANT(ifp);
 		error = (*ifp->if_ioctl)(ifp, cmd, data);
+		IFF_UNLOCKGIANT(ifp);
 		if (error == 0) {
 			getmicrotime(&ifp->if_lastchange);
 			rt_ifmsg(ifp);
@@ -1276,7 +1285,9 @@
 			return (error);
 		if (ifp->if_ioctl == NULL)
 			return (EOPNOTSUPP);
+		IFF_LOCKGIANT(ifp);
 		error = (*ifp->if_ioctl)(ifp, cmd, data);
+		IFF_UNLOCKGIANT(ifp);
 		if (error == 0)
 			getmicrotime(&ifp->if_lastchange);
 		break;
@@ -1292,7 +1303,9 @@
 	case SIOCGIFGENERIC:
 		if (ifp->if_ioctl == NULL)
 			return (EOPNOTSUPP);
+		IFF_LOCKGIANT(ifp);
 		error = (*ifp->if_ioctl)(ifp, cmd, data);
+		IFF_UNLOCKGIANT(ifp);
 		break;
 
 	case SIOCSIFLLADDR:
@@ -1459,7 +1472,9 @@
 	}
 	ifr.ifr_flags = ifp->if_flags & 0xffff;
 	ifr.ifr_flagshigh = ifp->if_flags >> 16;
+	IFF_LOCKGIANT(ifp);
 	error = (*ifp->if_ioctl)(ifp, SIOCSIFFLAGS, (caddr_t)&ifr);
+	IFF_UNLOCKGIANT(ifp);
 	if (error == 0) {
 		log(LOG_INFO, "%s: promiscuous mode %s\n",
 		    ifp->if_xname,
@@ -1585,7 +1600,9 @@
 			ifp->if_flags |= IFF_ALLMULTI;
 			ifr.ifr_flags = ifp->if_flags & 0xffff;
 			ifr.ifr_flagshigh = ifp->if_flags >> 16;
+			IFF_LOCKGIANT(ifp);
 			error = ifp->if_ioctl(ifp, SIOCSIFFLAGS, (caddr_t)&ifr);
+			IFF_UNLOCKGIANT(ifp);
 		}
 	} else {
 		if (ifp->if_amcount > 1) {
@@ -1595,7 +1612,9 @@
 			ifp->if_flags &= ~IFF_ALLMULTI;
 			ifr.ifr_flags = ifp->if_flags & 0xffff;;
 			ifr.ifr_flagshigh = ifp->if_flags >> 16;
+			IFF_LOCKGIANT(ifp);
 			error = ifp->if_ioctl(ifp, SIOCSIFFLAGS, (caddr_t)&ifr);
+			IFF_UNLOCKGIANT(ifp);
 		}
 	}
 	splx(s);
@@ -1690,7 +1709,9 @@
 	 * interface to let them know about it.
 	 */
 	s = splimp();
+	IFF_LOCKGIANT(ifp);
 	ifp->if_ioctl(ifp, SIOCADDMULTI, 0);
+	IFF_UNLOCKGIANT(ifp);
 	splx(s);
 
 	return 0;
@@ -1725,8 +1746,11 @@
 	 * Make sure the interface driver is notified
 	 * in the case of a link layer mcast group being left.
 	 */
-	if (ifma->ifma_addr->sa_family == AF_LINK && sa == 0)
+	if (ifma->ifma_addr->sa_family == AF_LINK && sa == 0) {
+		IFF_LOCKGIANT(ifp);
 		ifp->if_ioctl(ifp, SIOCDELMULTI, 0);
+		IFF_UNLOCKGIANT(ifp);
+	}
 	splx(s);
 	free(ifma->ifma_addr, M_IFMADDR);
 	free(ifma, M_IFMADDR);
@@ -1757,7 +1781,9 @@
 
 	s = splimp();
 	TAILQ_REMOVE(&ifp->if_multiaddrs, ifma, ifma_link);
+	IFF_LOCKGIANT(ifp);
 	ifp->if_ioctl(ifp, SIOCDELMULTI, 0);
+	IFF_UNLOCKGIANT(ifp);
 	splx(s);
 	free(ifma->ifma_addr, M_IFMADDR);
 	free(sa, M_IFMADDR);
@@ -1812,6 +1838,7 @@
 	 * address filter.
 	 */
 	if ((ifp->if_flags & IFF_UP) != 0) {
+		IFF_LOCKGIANT(ifp);
 		ifp->if_flags &= ~IFF_UP;
 		ifr.ifr_flags = ifp->if_flags & 0xffff;
 		ifr.ifr_flagshigh = ifp->if_flags >> 16;
@@ -1820,6 +1847,7 @@
 		ifr.ifr_flags = ifp->if_flags & 0xffff;
 		ifr.ifr_flagshigh = ifp->if_flags >> 16;
 		(*ifp->if_ioctl)(ifp, SIOCSIFFLAGS, (caddr_t)&ifr);
+		IFF_UNLOCKGIANT(ifp);
 #ifdef INET
 		/*
 		 * Also send gratuitous ARPs to notify other nodes about

==== //depot/projects/netperf_socket/sys/net/if_var.h#20 (text+ko) ====

@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  *
  *	From: @(#)if.h	8.1 (Berkeley) 6/10/93
- * $FreeBSD: src/sys/net/if_var.h,v 1.84 2004/08/15 06:24:42 jmg Exp $
+ * $FreeBSD: src/sys/net/if_var.h,v 1.85 2004/10/19 18:11:55 rwatson Exp $
  */
 
 #ifndef	_NET_IF_VAR_H_
@@ -327,6 +327,16 @@
 #define	IF_AFDATA_UNLOCK(ifp)	mtx_unlock(&(ifp)->if_afdata_mtx)
 #define	IF_AFDATA_DESTROY(ifp)	mtx_destroy(&(ifp)->if_afdata_mtx)
 
+#define	IFF_LOCKGIANT(ifp) do {						\
+	if ((ifp)->if_flags & IFF_NEEDSGIANT)				\
+		mtx_lock(&Giant);					\
+} while (0)
+
+#define	IFF_UNLOCKGIANT(ifp) do {					\
+	if ((ifp)->if_flags & IFF_NEEDSGIANT)				\
+		mtx_unlock(&Giant);					\
+} while (0)
+
 #define	IF_HANDOFF(ifq, m, ifp)			\
 	if_handoff((struct ifqueue *)ifq, m, ifp, 0)
 #define	IF_HANDOFF_ADJ(ifq, m, ifp, adj)	\

==== //depot/projects/netperf_socket/sys/netinet/in_pcb.h#8 (text+ko) ====

@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)in_pcb.h	8.1 (Berkeley) 6/10/93
- * $FreeBSD: src/sys/netinet/in_pcb.h,v 1.76 2004/08/16 18:32:07 rwatson Exp $
+ * $FreeBSD: src/sys/netinet/in_pcb.h,v 1.77 2004/10/19 14:34:13 andre Exp $
  */
 
 #ifndef _NETINET_IN_PCB_H_
@@ -250,6 +250,7 @@
 
 #define INP_INFO_LOCK_INIT(ipi, d) \
 	mtx_init(&(ipi)->ipi_mtx, (d), NULL, MTX_DEF | MTX_RECURSE)
+#define INP_INFO_LOCK_DESTROY(ipi)  mtx_destroy(&(ipi)->ipi_mtx)
 #define INP_INFO_RLOCK(ipi)	mtx_lock(&(ipi)->ipi_mtx)
 #define INP_INFO_WLOCK(ipi)	mtx_lock(&(ipi)->ipi_mtx)
 #define INP_INFO_RUNLOCK(ipi)	mtx_unlock(&(ipi)->ipi_mtx)

==== //depot/projects/netperf_socket/sys/netinet/in_proto.c#7 (text+ko) ====

@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)in_proto.c	8.2 (Berkeley) 2/9/95
- * $FreeBSD: src/sys/netinet/in_proto.c,v 1.73 2004/08/16 18:32:07 rwatson Exp $
+ * $FreeBSD: src/sys/netinet/in_proto.c,v 1.74 2004/10/19 15:58:22 andre Exp $
  */
 
 #include "opt_ipdivert.h"
@@ -93,7 +93,15 @@
 #endif
 
 extern	struct domain inetdomain;
-static	struct pr_usrreqs nousrreqs;
+
+/* Spacer for loadable protocols. */
+#define IPPROTOSPACER   \
+{ 0,		&inetdomain,	PROTO_SPACER,	0,	\
+  NULL,		NULL,		NULL,		NULL,	\
+  NULL,							\
+  NULL,		NULL,		NULL,		NULL,	\
+  &nousrreqs						\
+}
 
 struct protosw inetsw[] = {
 { 0,		&inetdomain,	0,		0,
@@ -239,7 +247,16 @@
   &rip_usrreqs
 },
 #endif	/* DEV_PFSYNC */
-	/* raw wildcard */
+/* Spacer n-times for loadable protocols. */
+IPPROTOSPACER,
+IPPROTOSPACER,
+IPPROTOSPACER,
+IPPROTOSPACER,
+IPPROTOSPACER,
+IPPROTOSPACER,
+IPPROTOSPACER,
+IPPROTOSPACER,
+/* raw wildcard */
 { SOCK_RAW,	&inetdomain,	0,		PR_ATOMIC|PR_ADDR,
   rip_input,	0,		0,		rip_ctloutput,
   0,

==== //depot/projects/netperf_socket/sys/netinet/ip_fastfwd.c#12 (text+ko) ====

@@ -26,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/netinet/ip_fastfwd.c,v 1.21 2004/09/29 04:54:33 mlaier Exp $
+ * $FreeBSD: src/sys/netinet/ip_fastfwd.c,v 1.22 2004/10/19 14:31:56 andre Exp $
  */
 
 /*
@@ -241,6 +241,10 @@
 		ipstat.ips_badsum++;
 		goto drop;
 	}
+
+	/*
+	 * Remeber that we have checked the IP header and found it valid.
+	 */
 	m->m_pkthdr.csum_flags |= (CSUM_IP_CHECKED | CSUM_IP_VALID);
 
 	ip_len = ntohs(ip->ip_len);
@@ -408,8 +412,9 @@
 	}
 
 	/*
-	 * Decrement the TTL and incrementally change the checksum.
-	 * Don't bother doing this with hw checksum offloading.
+	 * Decrement the TTL and incrementally change the IP header checksum.
+	 * Don't bother doing this with hw checksum offloading, it's faster
+	 * doing it right here.
 	 */
 	ip->ip_ttl -= IPTTLDEC;
 	if (ip->ip_sum >= (u_int16_t) ~htons(IPTTLDEC << 8))
@@ -462,7 +467,7 @@
 #ifndef IPFIREWALL_FORWARD
 		if (in_localip(dest)) {
 #else
-		if (in_localip(dest) || m->m_flags & M_FASTFWD_OURS) {
+		if (m->m_flags & M_FASTFWD_OURS || in_localip(dest)) {
 #endif /* IPFIREWALL_FORWARD */
 forwardlocal:
 			/*

==== //depot/projects/netperf_socket/sys/netinet/ip_input.c#26 (text+ko) ====

@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)ip_input.c	8.2 (Berkeley) 1/4/94
- * $FreeBSD: src/sys/netinet/ip_input.c,v 1.291 2004/09/29 04:54:33 mlaier Exp $
+ * $FreeBSD: src/sys/netinet/ip_input.c,v 1.292 2004/10/19 15:45:57 andre Exp $
  */
 
 #include "opt_bootp.h"
@@ -261,7 +261,7 @@
 		if (pr->pr_domain->dom_family == PF_INET &&
 		    pr->pr_protocol && pr->pr_protocol != IPPROTO_RAW) {
 			/* Be careful to only index valid IP protocols. */
-			if (pr->pr_protocol && pr->pr_protocol < IPPROTO_MAX)
+			if (pr->pr_protocol <= IPPROTO_MAX)
 				ip_protox[pr->pr_protocol] = pr - inetsw;
 		}
 
@@ -1145,6 +1145,67 @@
 }
 
 /*
+ * The protocol to be inserted into ip_protox[] must be already registered
+ * in inetsw[], either statically or through pf_proto_register().
+ */
+int
+ipproto_register(u_char ipproto)
+{
+	struct protosw *pr;
+
+	/* Sanity checks. */
+	if (ipproto == 0)
+		return (EPROTONOSUPPORT);
+
+	/*
+	 * The protocol slot must not be occupied by another protocol
+	 * already.  An index pointing to IPPROTO_RAW is unused.
+	 */
+	pr = pffindproto(PF_INET, IPPROTO_RAW, SOCK_RAW);
+	if (pr == NULL)
+		return (EPFNOSUPPORT);
+	if (ip_protox[ipproto] != pr - inetsw)	/* IPPROTO_RAW */
+		return (EEXIST);
+
+	/* Find the protocol position in inetsw[] and set the index. */
+	for (pr = inetdomain.dom_protosw;
+	     pr < inetdomain.dom_protoswNPROTOSW; pr++) {
+		if (pr->pr_domain->dom_family == PF_INET &&
+		    pr->pr_protocol && pr->pr_protocol == ipproto) {
+			/* Be careful to only index valid IP protocols. */
+			if (pr->pr_protocol <= IPPROTO_MAX) {
+				ip_protox[pr->pr_protocol] = pr - inetsw;
+				return (0);
+			} else
+				return (EINVAL);
+		}
+	}
+	return (EPROTONOSUPPORT);
+}
+
+int
+ipproto_unregister(u_char ipproto)
+{
+	struct protosw *pr;
+
+	/* Sanity checks. */
+	if (ipproto == 0)
+		return (EPROTONOSUPPORT);
+
+	/* Check if the protocol was indeed registered. */
+	pr = pffindproto(PF_INET, IPPROTO_RAW, SOCK_RAW);
+	if (pr == NULL)
+		return (EPFNOSUPPORT);
+	if (ip_protox[ipproto] == pr - inetsw)  /* IPPROTO_RAW */
+		return (ENOENT);
+
+	/* Reset the protocol slot to IPPROTO_RAW. */
+	ip_protox[ipproto] = pr - inetsw;
+	return (0);
+}
+
+
+/*
  * Do option processing on a datagram,
  * possibly discarding it if bad options are encountered,
  * or forwarding it if source-routed.

==== //depot/projects/netperf_socket/sys/netinet/ip_var.h#11 (text+ko) ====

@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)ip_var.h	8.2 (Berkeley) 1/9/95
- * $FreeBSD: src/sys/netinet/ip_var.h,v 1.91 2004/09/15 20:13:26 andre Exp $
+ * $FreeBSD: src/sys/netinet/ip_var.h,v 1.92 2004/10/19 15:45:57 andre Exp $
  */
 
 #ifndef _NETINET_IP_VAR_H_
@@ -168,6 +168,8 @@
 int	 ip_output(struct mbuf *,
 	    struct mbuf *, struct route *, int, struct ip_moptions *,
 	    struct inpcb *);
+int	 ipproto_register(u_char);
+int	 ipproto_unregister(u_char);
 struct mbuf *
 	 ip_reass(struct mbuf *);
 struct in_ifaddr *

==== //depot/projects/netperf_socket/sys/netinet6/ip6_input.c#12 (text+ko) ====

@@ -1,4 +1,4 @@
-/*	$FreeBSD: src/sys/netinet6/ip6_input.c,v 1.78 2004/09/29 04:54:33 mlaier Exp $	*/
+/*	$FreeBSD: src/sys/netinet6/ip6_input.c,v 1.79 2004/10/19 14:26:44 andre Exp $	*/
 /*	$KAME: ip6_input.c,v 1.259 2002/01/21 04:58:09 jinmei Exp $	*/
 
 /*
@@ -169,13 +169,22 @@
 	pr = (struct ip6protosw *)pffindproto(PF_INET6, IPPROTO_RAW, SOCK_RAW);
 	if (pr == 0)
 		panic("ip6_init");
+
+	/* Initialize the entire ip_protox[] array to IPPROTO_RAW. */
 	for (i = 0; i < IPPROTO_MAX; i++)
 		ip6_protox[i] = pr - inet6sw;
+	/*
+	 * Cycle through IP protocols and put them into the appropriate place
+	 * in ip6_protox[].
+	 */
 	for (pr = (struct ip6protosw *)inet6domain.dom_protosw;
 	    pr < (struct ip6protosw *)inet6domain.dom_protoswNPROTOSW; pr++)
 		if (pr->pr_domain->dom_family == PF_INET6 &&
-		    pr->pr_protocol && pr->pr_protocol != IPPROTO_RAW)
-			ip6_protox[pr->pr_protocol] = pr - inet6sw;
+		    pr->pr_protocol && pr->pr_protocol != IPPROTO_RAW) {
+			/* Be careful to only index valid IP protocols. */
+			if (pr->pr_protocol <= IPPROTO_MAX)
+				ip6_protox[pr->pr_protocol] = pr - inet6sw;
+		}
 
 	/* Initialize packet filter hooks. */
 	inet6_pfil_hook.ph_type = PFIL_TYPE_AF;

==== //depot/projects/netperf_socket/sys/pci/if_vr.c#14 (text+ko) ====

@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/pci/if_vr.c,v 1.94 2004/08/11 04:30:49 scottl Exp $");
+__FBSDID("$FreeBSD: src/sys/pci/if_vr.c,v 1.96 2004/10/19 16:47:53 bms Exp $");
 
 /*
  * VIA Rhine fast ethernet PCI NIC driver
@@ -1692,7 +1692,5 @@
 {
 	struct vr_softc		*sc = device_get_softc(dev);
 
-	VR_LOCK(sc);
-	vr_stop(sc);
-	VR_UNLOCK(sc);
+	vr_detach(dev);
 }

==== //depot/projects/netperf_socket/sys/sys/protosw.h#3 (text+ko) ====

@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)protosw.h	8.1 (Berkeley) 6/2/93
- * $FreeBSD: src/sys/sys/protosw.h,v 1.43 2004/04/07 04:19:49 imp Exp $
+ * $FreeBSD: src/sys/sys/protosw.h,v 1.44 2004/10/19 15:13:29 andre Exp $
  */
 
 #ifndef _SYS_PROTOSW_H_
@@ -105,6 +105,12 @@
 #define	PR_FASTHZ	5		/* 5 fast timeouts per second */
 
 /*
+ * This number should be defined again within each protocol family to avoid
+ * confusion.
+ */
+#define	PROTO_SPACER	32767		/* spacer for loadable protocols */
+
+/*
  * Values for pr_flags.
  * PR_ADDR requires PR_ATOMIC;
  * PR_ADDR and PR_CONNREQUIRED are mutually exclusive.
@@ -231,16 +237,41 @@
 	void	(*pru_sosetlabel)(struct socket *so);
 };
 
+/*
+ * The dummy protocol specific user requests function pointer array is
+ * initialized to the functions below.  All functions return EOPNOTSUPP.
+ */
+extern	struct pr_usrreqs nousrreqs;
+
+int	pru_abort_notsupp(struct socket *so);
 int	pru_accept_notsupp(struct socket *so, struct sockaddr **nam);
+int	pru_attach_notsupp(struct socket *so, int proto, struct thread *td);
+int	pru_bind_notsupp(struct socket *so, struct sockaddr *nam,
+	    struct thread *td);
 int	pru_connect_notsupp(struct socket *so, struct sockaddr *nam,
 	    struct thread *td);
 int	pru_connect2_notsupp(struct socket *so1, struct socket *so2);
 int	pru_control_notsupp(struct socket *so, u_long cmd, caddr_t data,
 	    struct ifnet *ifp, struct thread *td);
+int	pru_detach_notsupp(struct socket *so);
+int	pru_disconnect_notsupp(struct socket *so);
 int	pru_listen_notsupp(struct socket *so, struct thread *td);
+int	pru_peeraddr_notsupp(struct socket *so, struct sockaddr **nam);
 int	pru_rcvd_notsupp(struct socket *so, int flags);
 int	pru_rcvoob_notsupp(struct socket *so, struct mbuf *m, int flags);
+int	pru_send_notsupp(struct socket *so, int flags, struct mbuf *m,
+	    struct sockaddr *addr, struct mbuf *control, struct thread *td);
 int	pru_sense_null(struct socket *so, struct stat *sb);
+int	pru_shutdown_notsupp(struct socket *so);
+int	pru_sockaddr_notsupp(struct socket *so, struct sockaddr **nam);
+int	pru_sosend_notsupp(struct socket *so, struct sockaddr *addr,
+	    struct uio *uio, struct mbuf *top, struct mbuf *control, int flags,
+	    struct thread *td);
+int	pru_soreceive_notsupp(struct socket *so, struct sockaddr **paddr,
+	    struct uio *uio, struct mbuf **mp0, struct mbuf **controlp,
+	    int *flagsp);
+int	pru_sopoll_notsupp(struct socket *so, int events, struct ucred *cred,
+	    struct thread *td);
 void	pru_sosetlabel_null(struct socket *so);
 
 #endif /* _KERNEL */
@@ -319,6 +350,8 @@
 void	pfctlinput2(int, struct sockaddr *, void *);
 struct protosw *pffindproto(int family, int protocol, int type);
 struct protosw *pffindtype(int family, int type);
+int	pf_proto_register(int family, struct protosw *npr);
+int	pf_proto_unregister(int family, int protocol, int type);
 #endif
 
 #endif



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200410191821.i9JILsKd085683>