Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 27 Jul 2008 10:53:58 GMT
From:      Gleb Kurtsou <gk@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 146034 for review
Message-ID:  <200807271053.m6RArwnW079205@repoman.freebsd.org>

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

Change 146034 by gk@gk_h1 on 2008/07/27 10:53:10

	ifc

Affected files ...

.. //depot/projects/soc2008/gk_l2filter/sbin-ipfw/ipfw.8#3 integrate
.. //depot/projects/soc2008/gk_l2filter/sys-net/bpf.c#3 integrate
.. //depot/projects/soc2008/gk_l2filter/sys-net/bpf_buffer.c#2 integrate
.. //depot/projects/soc2008/gk_l2filter/sys-net/if_gre.c#3 integrate
.. //depot/projects/soc2008/gk_l2filter/sys-net/if_vlan.c#2 integrate
.. //depot/projects/soc2008/gk_l2filter/sys-net/route.c#2 integrate
.. //depot/projects/soc2008/gk_l2filter/sys-netinet/accf_dns.c#1 branch
.. //depot/projects/soc2008/gk_l2filter/sys-netinet/in_pcb.c#3 integrate
.. //depot/projects/soc2008/gk_l2filter/sys-netinet/in_pcb.h#3 integrate
.. //depot/projects/soc2008/gk_l2filter/sys-netinet/ip_carp.c#3 integrate
.. //depot/projects/soc2008/gk_l2filter/sys-netinet/raw_ip.c#3 integrate
.. //depot/projects/soc2008/gk_l2filter/sys-netinet/tcp_offload.c#2 integrate
.. //depot/projects/soc2008/gk_l2filter/sys-netinet/tcp_offload.h#2 integrate
.. //depot/projects/soc2008/gk_l2filter/sys-netinet/tcp_output.c#2 integrate
.. //depot/projects/soc2008/gk_l2filter/sys-netinet/tcp_syncache.c#3 integrate
.. //depot/projects/soc2008/gk_l2filter/sys-netinet/tcp_syncache.h#2 integrate
.. //depot/projects/soc2008/gk_l2filter/sys-netinet/tcp_timer.c#3 integrate
.. //depot/projects/soc2008/gk_l2filter/sys-netinet/toedev.h#2 integrate
.. //depot/projects/soc2008/gk_l2filter/sys-netinet/udp_usrreq.c#4 integrate
.. //depot/projects/soc2008/gk_l2filter/sys-pf/net/pf_ioctl.c#4 integrate

Differences ...

==== //depot/projects/soc2008/gk_l2filter/sbin-ipfw/ipfw.8#3 (text+ko) ====

@@ -1,5 +1,5 @@
 .\"
-.\" $FreeBSD: src/sbin/ipfw/ipfw.8,v 1.212 2008/05/09 23:02:54 julian Exp $
+.\" $FreeBSD: src/sbin/ipfw/ipfw.8,v 1.213 2008/07/24 18:39:36 julian Exp $
 .\"
 .Dd November 26, 2007
 .Dt IPFW 8
@@ -877,7 +877,8 @@
 .Ar fibnum
 in any subsequent forwarding decisions. Initially this is
 limited to the values  0 through 15. See 
-.Xr setfib 8
+.Xr setfib 8 .
+Processing continues at the next rule.
 .El
 .Ss RULE BODY
 The body of a rule contains zero or more patterns (such as

==== //depot/projects/soc2008/gk_l2filter/sys-net/bpf.c#3 (text+ko) ====

@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/net/bpf.c,v 1.197 2008/07/07 09:25:49 dwmalone Exp $");
+__FBSDID("$FreeBSD: src/sys/net/bpf.c,v 1.198 2008/07/14 22:41:48 jkim Exp $");
 
 #include "opt_bpf.h"
 #include "opt_mac.h"
@@ -443,13 +443,19 @@
 	if (len - hlen > ifp->if_mtu)
 		return (EMSGSIZE);
 
-	if ((unsigned)len > MCLBYTES)
+	if ((unsigned)len > MJUM16BYTES)
 		return (EIO);
 
-	if (len > MHLEN)
+	if (len <= MHLEN)
+		MGETHDR(m, M_WAIT, MT_DATA);
+	else if (len <= MCLBYTES)
 		m = m_getcl(M_WAIT, MT_DATA, M_PKTHDR);
 	else
-		MGETHDR(m, M_WAIT, MT_DATA);
+		m = m_getjcl(M_WAIT, MT_DATA, M_PKTHDR,
+#if (MJUMPAGESIZE > MCLBYTES)
+		    len <= MJUMPAGESIZE ? MJUMPAGESIZE :
+#endif
+		    (len <= MJUM9BYTES ? MJUM9BYTES : MJUM16BYTES));
 	m->m_pkthdr.len = m->m_len = len;
 	m->m_pkthdr.rcvif = NULL;
 	*mp = m;

==== //depot/projects/soc2008/gk_l2filter/sys-net/bpf_buffer.c#2 (text+ko) ====

@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/net/bpf_buffer.c,v 1.2 2008/03/24 22:21:32 jkim Exp $");
+__FBSDID("$FreeBSD: src/sys/net/bpf_buffer.c,v 1.3 2008/07/25 23:58:09 trhodes Exp $");
 
 #include "opt_bpf.h"
 
@@ -89,10 +89,10 @@
 
 static int bpf_bufsize = 4096;
 SYSCTL_INT(_net_bpf, OID_AUTO, bufsize, CTLFLAG_RW,
-    &bpf_bufsize, 0, "");
+    &bpf_bufsize, 0, "Maximum capture buffer size in bytes");
 static int bpf_maxbufsize = BPF_MAXBUFSIZE;
 SYSCTL_INT(_net_bpf, OID_AUTO, maxbufsize, CTLFLAG_RW,
-    &bpf_maxbufsize, 0, "");
+    &bpf_maxbufsize, 0, "Default capture buffer in bytes");
 
 void
 bpf_buffer_alloc(struct bpf_d *d)

==== //depot/projects/soc2008/gk_l2filter/sys-net/if_gre.c#3 (text+ko) ====

@@ -250,6 +250,7 @@
 	u_int16_t etype = 0;
 	struct mobile_h mob_h;
 	u_int32_t af;
+	int extra = 0;
 
 	/*
 	 * gre may cause infinite recursion calls when misconfigured.
@@ -365,7 +366,12 @@
 			ip = mtod(m, struct ip *);
 			gre_ip_tos = ip->ip_tos;
 			gre_ip_id = ip->ip_id;
-			etype = ETHERTYPE_IP;
+			if (sc->wccp_ver == WCCP_V2) {
+				extra = sizeof(uint32_t);
+				etype =  WCCP_PROTOCOL_TYPE;
+			} else {
+				etype = ETHERTYPE_IP;
+			}
 			break;
 #ifdef INET6
 		case AF_INET6:
@@ -386,7 +392,7 @@
 		}
 			
 		/* Reserve space for GRE header + optional GRE key */
-		int hdrlen = sizeof(struct greip);
+		int hdrlen = sizeof(struct greip) + extra;
 		if (sc->key)
 			hdrlen += sizeof(uint32_t);
 		M_PREPEND(m, hdrlen, M_DONTWAIT);
@@ -409,7 +415,7 @@
 	if (sc->g_proto == IPPROTO_GRE) {
 		uint32_t *options = gh->gi_options;
 
-		memset((void *)gh, 0, sizeof(struct greip));
+		memset((void *)gh, 0, sizeof(struct greip) + extra);
 		gh->gi_ptype = htons(etype);
 		gh->gi_flags = 0;
 

==== //depot/projects/soc2008/gk_l2filter/sys-net/if_vlan.c#2 (text+ko) ====

@@ -26,7 +26,7 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/net/if_vlan.c,v 1.125 2007/10/18 21:22:15 thompsa Exp $
+ * $FreeBSD: src/sys/net/if_vlan.c,v 1.126 2008/07/14 18:40:21 jfv Exp $
  */
 
 /*
@@ -1062,6 +1062,8 @@
 	ifp->if_drv_flags |= IFF_DRV_RUNNING;
 done:
 	TRUNK_UNLOCK(trunk);
+	if (error == 0)
+		EVENTHANDLER_INVOKE(vlan_config, p, ifv->ifv_tag);
 	VLAN_UNLOCK();
 
 	return (error);
@@ -1084,12 +1086,14 @@
 	struct ifvlantrunk *trunk;
 	struct vlan_mc_entry *mc;
 	struct ifvlan *ifv;
+	struct ifnet  *parent;
 	int error;
 
 	VLAN_LOCK_ASSERT();
 
 	ifv = ifp->if_softc;
 	trunk = ifv->ifv_trunk;
+	parent = PARENT(ifv);
 
 	if (trunk) {
 		struct sockaddr_dl sdl;
@@ -1153,6 +1157,8 @@
 	ifp->if_link_state = LINK_STATE_UNKNOWN;
 	ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
 
+	EVENTHANDLER_INVOKE(vlan_unconfig, parent, ifv->ifv_tag);
+
 	return (0);
 }
 

==== //depot/projects/soc2008/gk_l2filter/sys-net/route.c#2 (text+ko) ====

@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)route.c	8.3.1.1 (Berkeley) 2/23/95
- * $FreeBSD: src/sys/net/route.c,v 1.131 2008/05/10 04:32:58 julian Exp $
+ * $FreeBSD: src/sys/net/route.c,v 1.132 2008/07/27 01:29:28 julian Exp $
  */
 /************************************************************************
  * Note: In this file a 'fib' is a "forwarding information base"	*
@@ -84,9 +84,25 @@
 
 u_int rt_numfibs = RT_NUMFIBS;
 SYSCTL_INT(_net, OID_AUTO, fibs, CTLFLAG_RD, &rt_numfibs, 0, "");
-/* Eventually this will be a tunable */
+/*
+ * Allow the boot code to allow LESS than RT_MAXFIBS to be used.
+ * We can't do more because storage is statically allocated for now.
+ * (for compatibility reasons.. this will change).
+ */
 TUNABLE_INT("net.fibs", &rt_numfibs);
 
+/*
+ * By default add routes to all fibs for new interfaces.
+ * Once this is set to 0 then only allocate routes on interface
+ * changes for the FIB of the caller when adding a new set of addresses
+ * to an interface.  XXX this is a shotgun aproach to a problem that needs
+ * a more fine grained solution.. that will come.
+ */
+u_int rt_add_addr_allfibs = 1;
+SYSCTL_INT(_net, OID_AUTO, add_addr_allfibs, CTLFLAG_RW,
+    &rt_add_addr_allfibs, 0, "");
+TUNABLE_INT("net.add_addr_allfibs", &rt_add_addr_allfibs);
+
 static struct rtstat rtstat;
 
 /* by default only the first 'row' of tables will be accessed. */
@@ -1453,8 +1469,12 @@
 	if ( dst->sa_family != AF_INET)
 		fibnum = 0;
 	if (fibnum == -1) {
-		startfib = 0;
-		endfib = rt_numfibs - 1;
+		if (rt_add_addr_allfibs == 0 && cmd == (int)RTM_ADD) {
+			startfib = endfib = curthread->td_proc->p_fibnum;
+		} else {
+			startfib = 0;
+			endfib = rt_numfibs - 1;
+		}
 	} else {
 		KASSERT((fibnum < rt_numfibs), ("rtinit1: bad fibnum"));
 		startfib = fibnum;

==== //depot/projects/soc2008/gk_l2filter/sys-netinet/in_pcb.c#3 (text+ko) ====

@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/netinet/in_pcb.c,v 1.209 2008/07/10 13:31:11 bz Exp $");
+__FBSDID("$FreeBSD: src/sys/netinet/in_pcb.c,v 1.214 2008/07/22 04:23:57 avatar Exp $");
 
 #include "opt_ddb.h"
 #include "opt_ipsec.h"
@@ -598,7 +598,7 @@
 			    &in_ifaddrhead)->ia_broadaddr)->sin_addr;
 	}
 	if (laddr.s_addr == INADDR_ANY) {
-		ia = (struct in_ifaddr *)0;
+		ia = NULL;
 		/*
 		 * If route is known our src addr is taken from the i/f,
 		 * else punt.
@@ -615,16 +615,16 @@
 		 * network and try to find a corresponding interface to take
 		 * the source address from.
 		 */
-		if (ia == 0) {
+		if (ia == NULL) {
 			bzero(&sa, sizeof(sa));
 			sa.sin_addr = faddr;
 			sa.sin_len = sizeof(sa);
 			sa.sin_family = AF_INET;
 
 			ia = ifatoia(ifa_ifwithdstaddr(sintosa(&sa)));
-			if (ia == 0)
+			if (ia == NULL)
 				ia = ifatoia(ifa_ifwithnet(sintosa(&sa)));
-			if (ia == 0)
+			if (ia == NULL)
 				return (ENETUNREACH);
 		}
 		/*
@@ -643,7 +643,7 @@
 				TAILQ_FOREACH(ia, &in_ifaddrhead, ia_link)
 					if (ia->ia_ifp == ifp)
 						break;
-				if (ia == 0)
+				if (ia == NULL)
 					return (EADDRNOTAVAIL);
 			}
 		}
@@ -1254,6 +1254,76 @@
 }
 #endif
 
+void
+inp_apply_all(void (*func)(struct inpcb *, void *), void *arg)
+{
+	struct inpcb *inp;
+
+	INP_INFO_RLOCK(&tcbinfo);
+	LIST_FOREACH(inp, tcbinfo.ipi_listhead, inp_list) {
+		INP_WLOCK(inp);
+		func(inp, arg);
+		INP_WUNLOCK(inp);
+	}
+	INP_INFO_RUNLOCK(&tcbinfo);
+}
+
+struct socket *
+inp_inpcbtosocket(struct inpcb *inp)
+{
+
+	INP_WLOCK_ASSERT(inp);
+	return (inp->inp_socket);
+}
+
+struct tcpcb *
+inp_inpcbtotcpcb(struct inpcb *inp)
+{
+
+	INP_WLOCK_ASSERT(inp);
+	return ((struct tcpcb *)inp->inp_ppcb);
+}
+
+int
+inp_ip_tos_get(const struct inpcb *inp)
+{
+
+	return (inp->inp_ip_tos);
+}
+
+void
+inp_ip_tos_set(struct inpcb *inp, int val)
+{
+
+	inp->inp_ip_tos = val;
+}
+
+void
+inp_4tuple_get(struct inpcb *inp, uint32_t *laddr, uint16_t *lp,
+    uint32_t *faddr, uint16_t *fp)
+{
+
+	INP_LOCK_ASSERT(inp);
+	*laddr = inp->inp_laddr.s_addr;
+	*faddr = inp->inp_faddr.s_addr;
+	*lp = inp->inp_lport;
+	*fp = inp->inp_fport;
+}
+
+struct inpcb *
+so_sotoinpcb(struct socket *so)
+{
+
+	return (sotoinpcb(so));
+}
+
+struct tcpcb *
+so_sototcpcb(struct socket *so)
+{
+
+	return (sototcpcb(so));
+}
+
 #ifdef DDB
 static void
 db_print_indent(int indent)

==== //depot/projects/soc2008/gk_l2filter/sys-netinet/in_pcb.h#3 (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.109 2008/07/10 13:31:11 bz Exp $
+ * $FreeBSD: src/sys/netinet/in_pcb.h,v 1.113 2008/07/22 04:23:57 avatar Exp $
  */
 
 #ifndef _NETINET_IN_PCB_H_
@@ -315,6 +315,8 @@
 #define INP_LOCK_DESTROY(inp)	rw_destroy(&(inp)->inp_lock)
 #define INP_RLOCK(inp)		rw_rlock(&(inp)->inp_lock)
 #define INP_WLOCK(inp)		rw_wlock(&(inp)->inp_lock)
+#define INP_TRY_RLOCK(inp)	rw_try_rlock(&(inp)->inp_lock)
+#define INP_TRY_WLOCK(inp)	rw_try_wlock(&(inp)->inp_lock)
 #define INP_RUNLOCK(inp)	rw_runlock(&(inp)->inp_lock)
 #define INP_WUNLOCK(inp)	rw_wunlock(&(inp)->inp_lock)
 #define INP_LOCK_ASSERT(inp)	rw_assert(&(inp)->inp_lock, RA_LOCKED)
@@ -348,6 +350,17 @@
 }
 
 #endif
+
+void	inp_apply_all(void (*func)(struct inpcb *, void *), void *arg);
+int 	inp_ip_tos_get(const struct inpcb *inp);
+void 	inp_ip_tos_set(struct inpcb *inp, int val);
+struct socket *
+	inp_inpcbtosocket(struct inpcb *inp);
+struct tcpcb *
+	inp_inpcbtotcpcb(struct inpcb *inp);
+void 	inp_4tuple_get(struct inpcb *inp, uint32_t *laddr, uint16_t *lp, 
+		uint32_t *faddr, uint16_t *fp);
+
 #endif /* _KERNEL */
 
 
@@ -356,6 +369,8 @@
 #define INP_INFO_LOCK_DESTROY(ipi)  rw_destroy(&(ipi)->ipi_lock)
 #define INP_INFO_RLOCK(ipi)	rw_rlock(&(ipi)->ipi_lock)
 #define INP_INFO_WLOCK(ipi)	rw_wlock(&(ipi)->ipi_lock)
+#define INP_INFO_TRY_RLOCK(ipi)	rw_try_rlock(&(ipi)->ipi_lock)
+#define INP_INFO_TRY_WLOCK(ipi)	rw_try_wlock(&(ipi)->ipi_lock)
 #define INP_INFO_RUNLOCK(ipi)	rw_runlock(&(ipi)->ipi_lock)
 #define INP_INFO_WUNLOCK(ipi)	rw_wunlock(&(ipi)->ipi_lock)
 #define	INP_INFO_LOCK_ASSERT(ipi)	rw_assert(&(ipi)->ipi_lock, RA_LOCKED)

==== //depot/projects/soc2008/gk_l2filter/sys-netinet/ip_carp.c#3 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/netinet/ip_carp.c,v 1.54 2008/06/02 18:58:07 mlaier Exp $");
+__FBSDID("$FreeBSD: src/sys/netinet/ip_carp.c,v 1.55 2008/07/14 20:11:51 eri Exp $");
 
 #include "opt_carp.h"
 #include "opt_bpf.h"
@@ -1464,7 +1464,11 @@
 			carp_set_state(sc, INIT);
 		if (sc->sc_naddrs)
 			SC2IFP(sc)->if_flags |= IFF_UP;
+		if (sc->sc_carpdev)
+			CARP_SCLOCK(sc);
 		carp_setrun(sc, 0);
+		if (sc->sc_carpdev)
+			CARP_SCUNLOCK(sc);
 		return (0);
 	}
 
@@ -1625,7 +1629,11 @@
 			carp_set_state(sc, INIT);
 		if (sc->sc_naddrs6)
 			SC2IFP(sc)->if_flags |= IFF_UP;
+		if (sc->sc_carpdev)
+			CARP_SCLOCK(sc);
 		carp_setrun(sc, 0);
+		if (sc->sc_carpdev)
+			CARP_SCUNLOCK(sc);
 		return (0);
 	}
 

==== //depot/projects/soc2008/gk_l2filter/sys-netinet/raw_ip.c#3 (text+ko) ====

@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/netinet/raw_ip.c,v 1.187 2008/07/05 18:55:03 rwatson Exp $");
+__FBSDID("$FreeBSD: src/sys/netinet/raw_ip.c,v 1.190 2008/07/26 21:12:00 mav Exp $");
 
 #include "opt_inet6.h"
 #include "opt_ipsec.h"
@@ -109,6 +109,41 @@
 void (*ip_rsvp_force_done)(struct socket *);
 
 /*
+ * Hash functions
+ */
+
+#define INP_PCBHASH_RAW_SIZE	256
+#define INP_PCBHASH_RAW(proto, laddr, faddr, mask) \
+        (((proto) + (laddr) + (faddr)) % (mask) + 1)
+
+static void
+rip_inshash(struct inpcb *inp)
+{
+	struct inpcbinfo *pcbinfo = inp->inp_pcbinfo;
+	struct inpcbhead *pcbhash;
+	int hash;
+
+	INP_INFO_WLOCK_ASSERT(pcbinfo);
+	INP_WLOCK_ASSERT(inp);
+	
+	if (inp->inp_ip_p && inp->inp_laddr.s_addr && inp->inp_faddr.s_addr) {
+		hash = INP_PCBHASH_RAW(inp->inp_ip_p, inp->inp_laddr.s_addr,
+		    inp->inp_faddr.s_addr, pcbinfo->ipi_hashmask);
+	} else {
+		hash = 0;
+	}
+	pcbhash = &pcbinfo->ipi_hashbase[hash];
+	LIST_INSERT_HEAD(pcbhash, inp, inp_hash);
+}
+
+static void
+rip_delhash(struct inpcb *inp)
+{
+	INP_WLOCK_ASSERT(inp);
+	LIST_REMOVE(inp, inp_hash);
+}
+
+/*
  * Raw interface to IP protocol.
  */
 
@@ -138,12 +173,8 @@
 	INP_INFO_LOCK_INIT(&ripcbinfo, "rip");
 	LIST_INIT(&ripcb);
 	ripcbinfo.ipi_listhead = &ripcb;
-	/*
-	 * XXX We don't use the hash list for raw IP, but it's easier to
-	 * allocate a one entry hash list than it is to check all over the
-	 * place for hashbase == NULL.
-	 */
-	ripcbinfo.ipi_hashbase = hashinit(1, M_PCB, &ripcbinfo.ipi_hashmask);
+	ripcbinfo.ipi_hashbase = hashinit(INP_PCBHASH_RAW_SIZE, M_PCB,
+	    &ripcbinfo.ipi_hashmask);
 	ripcbinfo.ipi_porthashbase = hashinit(1, M_PCB,
 	    &ripcbinfo.ipi_porthashmask);
 	ripcbinfo.ipi_zone = uma_zcreate("ripcb", sizeof(struct inpcb),
@@ -153,10 +184,9 @@
 	    EVENTHANDLER_PRI_ANY);
 }
 
-static struct	sockaddr_in ripsrc = { sizeof(ripsrc), AF_INET };
-
 static int
-rip_append(struct inpcb *last, struct ip *ip, struct mbuf *n)
+rip_append(struct inpcb *last, struct ip *ip, struct mbuf *n,
+    struct sockaddr_in *ripsrc)
 {
 	int policyfail = 0;
 
@@ -185,7 +215,7 @@
 			ip_savecontrol(last, &opts, ip, n);
 		SOCKBUF_LOCK(&so->so_rcv);
 		if (sbappendaddr_locked(&so->so_rcv,
-		    (struct sockaddr *)&ripsrc, n, opts) == 0) {
+		    (struct sockaddr *)ripsrc, n, opts) == 0) {
 			/* should notify about lost packet */
 			m_freem(n);
 			if (opts)
@@ -208,44 +238,80 @@
 	struct ip *ip = mtod(m, struct ip *);
 	int proto = ip->ip_p;
 	struct inpcb *inp, *last;
+	struct sockaddr_in ripsrc;
+	int hash;
 
-	INP_INFO_RLOCK(&ripcbinfo);
+	bzero(&ripsrc, sizeof(ripsrc));
+	ripsrc.sin_len = sizeof(ripsrc);
+	ripsrc.sin_family = AF_INET;
 	ripsrc.sin_addr = ip->ip_src;
 	last = NULL;
-	LIST_FOREACH(inp, &ripcb, inp_list) {
+	hash = INP_PCBHASH_RAW(proto, ip->ip_src.s_addr,
+	    ip->ip_dst.s_addr, ripcbinfo.ipi_hashmask);
+	INP_INFO_RLOCK(&ripcbinfo);
+	LIST_FOREACH(inp, &ripcbinfo.ipi_hashbase[hash], inp_hash) {
+		if (inp->inp_ip_p != proto)
+			continue;
+#ifdef INET6
+		if ((inp->inp_vflag & INP_IPV4) == 0)
+			continue;
+#endif
+		if (inp->inp_laddr.s_addr != ip->ip_dst.s_addr)
+			continue;
+		if (inp->inp_faddr.s_addr != ip->ip_src.s_addr)
+			continue;
 		INP_RLOCK(inp);
-		if (inp->inp_ip_p && inp->inp_ip_p != proto) {
-	docontinue:
+		if (jailed(inp->inp_socket->so_cred) &&
+		    (htonl(prison_getip(inp->inp_socket->so_cred)) !=
+		    ip->ip_dst.s_addr)) {
 			INP_RUNLOCK(inp);
 			continue;
 		}
+		if (last) {
+			struct mbuf *n;
+
+			n = m_copy(m, 0, (int)M_COPYALL);
+			if (n != NULL)
+		    	    (void) rip_append(last, ip, n, &ripsrc);
+			/* XXX count dropped packet */
+			INP_RUNLOCK(last);
+		}
+		last = inp;
+	}
+	LIST_FOREACH(inp, &ripcbinfo.ipi_hashbase[0], inp_hash) {
+		if (inp->inp_ip_p && inp->inp_ip_p != proto)
+			continue;
 #ifdef INET6
 		if ((inp->inp_vflag & INP_IPV4) == 0)
-			goto docontinue;
+			continue;
 #endif
 		if (inp->inp_laddr.s_addr &&
 		    inp->inp_laddr.s_addr != ip->ip_dst.s_addr)
-			goto docontinue;
+			continue;
 		if (inp->inp_faddr.s_addr &&
 		    inp->inp_faddr.s_addr != ip->ip_src.s_addr)
-			goto docontinue;
-		if (jailed(inp->inp_socket->so_cred))
-			if (htonl(prison_getip(inp->inp_socket->so_cred)) !=
-			    ip->ip_dst.s_addr)
-				goto docontinue;
+			continue;
+		INP_RLOCK(inp);
+		if (jailed(inp->inp_socket->so_cred) &&
+		    (htonl(prison_getip(inp->inp_socket->so_cred)) !=
+		    ip->ip_dst.s_addr)) {
+			INP_RUNLOCK(inp);
+			continue;
+		}
 		if (last) {
 			struct mbuf *n;
 
 			n = m_copy(m, 0, (int)M_COPYALL);
 			if (n != NULL)
-				(void) rip_append(last, ip, n);
+				(void) rip_append(last, ip, n, &ripsrc);
 			/* XXX count dropped packet */
 			INP_RUNLOCK(last);
 		}
 		last = inp;
 	}
+	INP_INFO_RUNLOCK(&ripcbinfo);
 	if (last != NULL) {
-		if (rip_append(last, ip, m) != 0)
+		if (rip_append(last, ip, m, &ripsrc) != 0)
 			ipstat.ips_delivered--;
 		INP_RUNLOCK(last);
 	} else {
@@ -253,7 +319,6 @@
 		ipstat.ips_noproto++;
 		ipstat.ips_delivered--;
 	}
-	INP_INFO_RUNLOCK(&ripcbinfo);
 }
 
 /*
@@ -607,10 +672,11 @@
 		return (error);
 	}
 	inp = (struct inpcb *)so->so_pcb;
-	INP_INFO_WUNLOCK(&ripcbinfo);
 	inp->inp_vflag |= INP_IPV4;
 	inp->inp_ip_p = proto;
 	inp->inp_ip_ttl = ip_defttl;
+	rip_inshash(inp);
+	INP_INFO_WUNLOCK(&ripcbinfo);
 	INP_WUNLOCK(inp);
 	return (0);
 }
@@ -627,6 +693,7 @@
 
 	INP_INFO_WLOCK(&ripcbinfo);
 	INP_WLOCK(inp);
+	rip_delhash(inp);
 	if (so == ip_mrouter && ip_mrouter_done)
 		ip_mrouter_done();
 	if (ip_rsvp_force_done)
@@ -641,10 +708,11 @@
 static void
 rip_dodisconnect(struct socket *so, struct inpcb *inp)
 {
-
 	INP_WLOCK_ASSERT(inp);
 
+	rip_delhash(inp);
 	inp->inp_faddr.s_addr = INADDR_ANY;
+	rip_inshash(inp);
 	SOCK_LOCK(so);
 	so->so_state &= ~SS_ISCONNECTED;
 	SOCK_UNLOCK(so);
@@ -727,7 +795,9 @@
 
 	INP_INFO_WLOCK(&ripcbinfo);
 	INP_WLOCK(inp);
+	rip_delhash(inp);
 	inp->inp_laddr = addr->sin_addr;
+	rip_inshash(inp);
 	INP_WUNLOCK(inp);
 	INP_INFO_WUNLOCK(&ripcbinfo);
 	return (0);
@@ -751,7 +821,9 @@
 
 	INP_INFO_WLOCK(&ripcbinfo);
 	INP_WLOCK(inp);
+	rip_delhash(inp);
 	inp->inp_faddr = addr->sin_addr;
+	rip_inshash(inp);
 	soisconnected(so);
 	INP_WUNLOCK(inp);
 	INP_INFO_WUNLOCK(&ripcbinfo);

==== //depot/projects/soc2008/gk_l2filter/sys-netinet/tcp_offload.c#2 (text+ko) ====

@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/netinet/tcp_offload.c,v 1.2 2007/12/19 05:17:40 kmacy Exp $");
+__FBSDID("$FreeBSD: src/sys/netinet/tcp_offload.c,v 1.4 2008/07/21 21:22:56 kmacy Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -50,7 +50,6 @@
 #include <netinet/tcp_offload.h>
 #include <netinet/toedev.h>
 
-
 int
 tcp_offload_connect(struct socket *so, struct sockaddr *nam)
 {
@@ -92,3 +91,48 @@
 	RTFREE(rt);
 	return (error);
 }
+
+
+/*
+ * This file contains code as a short-term staging area before it is moved in 
+ * to sys/netinet/tcp_offload.c
+ */
+
+void
+tcp_offload_twstart(struct tcpcb *tp)
+{
+
+	INP_INFO_WLOCK(&tcbinfo);
+	INP_WLOCK(tp->t_inpcb);
+	tcp_twstart(tp);
+	INP_INFO_WUNLOCK(&tcbinfo);
+}
+
+struct tcpcb *
+tcp_offload_close(struct tcpcb *tp)
+{
+	
+	INP_INFO_WLOCK(&tcbinfo);
+	INP_WLOCK(tp->t_inpcb);
+	tp = tcp_close(tp);
+	INP_INFO_WUNLOCK(&tcbinfo);
+	if (tp)
+		INP_WUNLOCK(tp->t_inpcb);
+
+	return (tp);
+}
+
+struct tcpcb *
+tcp_offload_drop(struct tcpcb *tp, int error)
+{
+	
+	INP_INFO_WLOCK(&tcbinfo);
+	INP_WLOCK(tp->t_inpcb);
+	tp = tcp_drop(tp, error);
+	INP_INFO_WUNLOCK(&tcbinfo);
+	if (tp)
+		INP_WUNLOCK(tp->t_inpcb);
+
+	return (tp);
+}
+

==== //depot/projects/soc2008/gk_l2filter/sys-netinet/tcp_offload.h#2 (text+ko) ====

@@ -24,7 +24,7 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/netinet/tcp_offload.h,v 1.3 2008/04/19 03:22:43 kmacy Exp $
+ * $FreeBSD: src/sys/netinet/tcp_offload.h,v 1.5 2008/07/21 21:22:56 kmacy Exp $
  */
 
 #ifndef _NETINET_TCP_OFFLOAD_H_
@@ -333,4 +333,9 @@
 #undef SO_OFFLOADABLE
 #endif /* _SYS_SOCKETVAR_H_ */
 #undef tp_offload
+
+void tcp_offload_twstart(struct tcpcb *tp);
+struct tcpcb *tcp_offload_close(struct tcpcb *tp);
+struct tcpcb *tcp_offload_drop(struct tcpcb *tp, int error);
+
 #endif /* _NETINET_TCP_OFFLOAD_H_ */

==== //depot/projects/soc2008/gk_l2filter/sys-netinet/tcp_output.c#2 (text+ko) ====

@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/netinet/tcp_output.c,v 1.150 2008/04/17 21:38:16 rwatson Exp $");
+__FBSDID("$FreeBSD: src/sys/netinet/tcp_output.c,v 1.151 2008/07/15 10:32:35 rpaulo Exp $");
 
 #include "opt_inet.h"
 #include "opt_inet6.h"
@@ -934,7 +934,7 @@
 	 * a 0 window.  This may cause the remote transmitter to stall.  This
 	 * flag tells soreceive() to disable delayed acknowledgements when
 	 * draining the buffer.  This can occur if the receiver is attempting
-	 * to read more data then can be buffered prior to transmitting on
+	 * to read more data than can be buffered prior to transmitting on
 	 * the connection.
 	 */
 	if (recwin == 0)

==== //depot/projects/soc2008/gk_l2filter/sys-netinet/tcp_syncache.c#3 (text+ko) ====

@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/netinet/tcp_syncache.c,v 1.147 2008/06/16 20:08:22 ups Exp $");
+__FBSDID("$FreeBSD: src/sys/netinet/tcp_syncache.c,v 1.148 2008/07/21 02:11:06 kmacy Exp $");
 
 #include "opt_inet.h"
 #include "opt_inet6.h"
@@ -959,6 +959,19 @@
 	return (0);
 }
 
+int
+tcp_offload_syncache_expand(struct in_conninfo *inc, struct tcpopt *to,
+    struct tcphdr *th, struct socket **lsop, struct mbuf *m)
+{
+	int rc;
+	
+	INP_INFO_WLOCK(&tcbinfo);
+	rc = syncache_expand(inc, to, th, lsop, m);
+	INP_INFO_WUNLOCK(&tcbinfo);
+
+	return (rc);
+}
+
 /*
  * Given a LISTEN socket and an inbound SYN request, add
  * this to the syn cache, and send back a segment:
@@ -1426,7 +1439,7 @@
 }
 
 void
-syncache_offload_add(struct in_conninfo *inc, struct tcpopt *to,
+tcp_offload_syncache_add(struct in_conninfo *inc, struct tcpopt *to,
     struct tcphdr *th, struct inpcb *inp, struct socket **lsop,
     struct toe_usrreqs *tu, void *toepcb)
 {

==== //depot/projects/soc2008/gk_l2filter/sys-netinet/tcp_syncache.h#2 (text+ko) ====

@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)tcp_var.h	8.4 (Berkeley) 5/24/95
- * $FreeBSD: src/sys/netinet/tcp_syncache.h,v 1.2 2007/12/12 20:35:59 kmacy Exp $
+ * $FreeBSD: src/sys/netinet/tcp_syncache.h,v 1.3 2008/07/21 02:11:06 kmacy Exp $
  */
 
 #ifndef _NETINET_TCP_SYNCACHE_H_
@@ -38,11 +38,14 @@
 void	 syncache_unreach(struct in_conninfo *, struct tcphdr *);
 int	 syncache_expand(struct in_conninfo *, struct tcpopt *,
 	     struct tcphdr *, struct socket **, struct mbuf *);
+int	 tcp_offload_syncache_expand(struct in_conninfo *inc, struct tcpopt *to,
+             struct tcphdr *th, struct socket **lsop, struct mbuf *m);
 void	 syncache_add(struct in_conninfo *, struct tcpopt *,
 	     struct tcphdr *, struct inpcb *, struct socket **, struct mbuf *);
-void	 syncache_offload_add(struct in_conninfo *, struct tcpopt *,
+void	 tcp_offload_syncache_add(struct in_conninfo *, struct tcpopt *,
              struct tcphdr *, struct inpcb *, struct socket **,
              struct toe_usrreqs *tu, void *toepcb);
+
 void	 syncache_chkrst(struct in_conninfo *, struct tcphdr *);
 void	 syncache_badack(struct in_conninfo *);
 int	 syncache_pcbcount(void);

==== //depot/projects/soc2008/gk_l2filter/sys-netinet/tcp_timer.c#3 (text+ko) ====

@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/netinet/tcp_timer.c,v 1.101 2008/06/02 14:20:26 rwatson Exp $");
+__FBSDID("$FreeBSD: src/sys/netinet/tcp_timer.c,v 1.102 2008/07/20 15:29:58 trhodes Exp $");
 
 #include "opt_inet6.h"
 #include "opt_tcpdebug.h"
@@ -66,15 +66,15 @@
 
 int	tcp_keepinit;
 SYSCTL_PROC(_net_inet_tcp, TCPCTL_KEEPINIT, keepinit, CTLTYPE_INT|CTLFLAG_RW,
-    &tcp_keepinit, 0, sysctl_msec_to_ticks, "I", "");
+    &tcp_keepinit, 0, sysctl_msec_to_ticks, "I", "time to establish connection");
 
 int	tcp_keepidle;
 SYSCTL_PROC(_net_inet_tcp, TCPCTL_KEEPIDLE, keepidle, CTLTYPE_INT|CTLFLAG_RW,
-    &tcp_keepidle, 0, sysctl_msec_to_ticks, "I", "");
+    &tcp_keepidle, 0, sysctl_msec_to_ticks, "I", "time before keepalive probes begin");
 
 int	tcp_keepintvl;
 SYSCTL_PROC(_net_inet_tcp, TCPCTL_KEEPINTVL, keepintvl, CTLTYPE_INT|CTLFLAG_RW,
-    &tcp_keepintvl, 0, sysctl_msec_to_ticks, "I", "");
+    &tcp_keepintvl, 0, sysctl_msec_to_ticks, "I", "time between keepalive probes");
 
 int	tcp_delacktime;
 SYSCTL_PROC(_net_inet_tcp, TCPCTL_DELACKTIME, delacktime, CTLTYPE_INT|CTLFLAG_RW,

==== //depot/projects/soc2008/gk_l2filter/sys-netinet/toedev.h#2 (text+ko) ====

@@ -24,7 +24,7 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/netinet/toedev.h,v 1.4 2007/12/16 05:30:21 kmacy Exp $
+ * $FreeBSD: src/sys/netinet/toedev.h,v 1.5 2008/07/20 02:02:50 kmacy Exp $
  */
 
 #ifndef _NETINET_TOEDEV_H_
@@ -78,15 +78,35 @@
 	struct ifnet 	*tod_lldev;   		/* first interface */
 	const struct tom_info *tod_offload_mod; /* TCP offload module */
 
-	int	(*tod_open)(struct toedev *dev);
-	int	(*tod_close)(struct toedev *dev);
+	/*
+	 * This TOE device is capable of offloading the connection for socket so
+	 */
 	int	(*tod_can_offload)(struct toedev *dev, struct socket *so);
+
+	/*
+	 * Establish a connection to nam using the TOE device dev
+	 */
 	int	(*tod_connect)(struct toedev *dev, struct socket *so,
 	        struct rtentry *rt, struct sockaddr *nam);
+	/*
+	 * Send an mbuf down to the toe device 
+	 */
 	int	(*tod_send)(struct toedev *dev, struct mbuf *m);
+	/*
+	 * Receive an array of mbufs from the TOE device dev 
+	 */
 	int	(*tod_recv)(struct toedev *dev, struct mbuf **m, int n);
+	/*
+	 * Device specific ioctl interface
+	 */
 	int	(*tod_ctl)(struct toedev *dev, unsigned int req, void *data);
+	/*
+	 * Update L2 entry in toedev 
+	 */
 	void	(*tod_arp_update)(struct toedev *dev, struct rtentry *neigh);
+	/*
+	 * Failover from one toe device to another
+	 */
 	void	(*tod_failover)(struct toedev *dev, struct ifnet *bond_ifp,
 			 struct ifnet *ndev, int event);
 	void	*tod_priv;			/* driver private data */

==== //depot/projects/soc2008/gk_l2filter/sys-netinet/udp_usrreq.c#4 (text+ko) ====

@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/netinet/udp_usrreq.c,v 1.230 2008/07/10 16:20:18 rwatson Exp $");
+__FBSDID("$FreeBSD: src/sys/netinet/udp_usrreq.c,v 1.234 2008/07/26 23:07:34 mav Exp $");
 
 #include "opt_ipfw.h"
 #include "opt_inet6.h"
@@ -102,7 +102,7 @@
  */
 static int	udp_cksum = 1;
 SYSCTL_INT(_net_inet_udp, UDPCTL_CHECKSUM, checksum, CTLFLAG_RW, &udp_cksum,
-    0, "");
+    0, "compute udp checksum");
 
 int	udp_log_in_vain = 0;
 SYSCTL_INT(_net_inet_udp, OID_AUTO, log_in_vain, CTLFLAG_RW,
@@ -132,7 +132,7 @@
 struct inpcbinfo	udbinfo;
 
 #ifndef UDBHASHSIZE
-#define	UDBHASHSIZE	16
+#define	UDBHASHSIZE	128
 #endif
 
 struct udpstat	udpstat;	/* from udp_var.h */

>>> TRUNCATED FOR MAIL (1000 lines) <<<



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