Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 28 Oct 2008 21:05:09 +0000 (UTC)
From:      Kip Macy <kmacy@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r184424 - user/kmacy/HEAD_fast_xmit/sys/netinet
Message-ID:  <200810282105.m9SL59RE003950@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kmacy
Date: Tue Oct 28 21:05:09 2008
New Revision: 184424
URL: http://svn.freebsd.org/changeset/base/184424

Log:
  hook flowtable in to ip forwarding path

Modified:
  user/kmacy/HEAD_fast_xmit/sys/netinet/ip_input.c

Modified: user/kmacy/HEAD_fast_xmit/sys/netinet/ip_input.c
==============================================================================
--- user/kmacy/HEAD_fast_xmit/sys/netinet/ip_input.c	Tue Oct 28 21:04:37 2008	(r184423)
+++ user/kmacy/HEAD_fast_xmit/sys/netinet/ip_input.c	Tue Oct 28 21:05:09 2008	(r184424)
@@ -213,6 +213,7 @@ ip_fw_chk_t *ip_fw_chk_ptr = NULL;
 ip_dn_io_t *ip_dn_io_ptr = NULL;
 int fw_one_pass = 1;
 struct flowtable *ipv4_ft;
+struct flowtable *ipv4_forward_ft;
 
 static void	ip_freef(struct ipqhead *, struct ipq *);
 
@@ -281,6 +282,12 @@ ip_init(void)
 	netisr_register(NETISR_IP, ip_input, &ipintrq, 0);
 	
 	ipv4_ft = flowtable_alloc(2048, FL_PCPU);
+#ifdef RADIX_MPATH
+	ipv4_forward_ft = flowtable_alloc(128*1024, FL_HASH_PORTS);
+#else
+	ipv4_forward_ft = flowtable_alloc(16*1024, 0);
+#endif	
+	
 }
 
 void
@@ -1289,8 +1296,8 @@ ip_forward(struct mbuf *m, int srcrt)
 	struct in_ifaddr *ia = NULL;
 	struct mbuf *mcopy;
 	struct in_addr dest;
-	struct route ro;
-	int error, type = 0, code = 0, mtu = 0, cached = 0;
+	struct rtentry_info ri;
+	int error, type = 0, code = 0, mtu = 0;
 
 	if (m->m_flags & (M_BCAST|M_MCAST) || in_canforward(ip->ip_dst) == 0) {
 		V_ipstat.ips_cantforward++;
@@ -1309,29 +1316,16 @@ ip_forward(struct mbuf *m, int srcrt)
 	}
 #endif
 
-	bzero(&ro, sizeof(ro));
-#ifdef RADIX_MPATH
-	hash = ipv4_flow_alloc(m, &ro);
+	error = flowtable_lookup(ipv4_forward_ft, m, &ri);
 	
-	if (ro.ro_rt == NULL) 
-		rtalloc_mpath_fib(&ro, hash, M_GETFIB(m));
-	else
-		cached = 1;
-
-	if (ro->ro_rt != NULL)
-		ia = ifatoia(ro.ro_rt->rt_ifa);
-#else	
-	/*
-	 * I love how we go to all the trouble to look up the
-	 * route and then throw it away KMM
-	 */
-	ia = ip_rtaddr(ip->ip_dst, M_GETFIB(m));
-#endif	
-	if (!srcrt && ia == NULL) {
+	if (!srcrt && error) {
 		icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_HOST, 0, 0);
 		return;
-	}
+	} else if (error)
+		return;
+#define	RIA(ri)	((struct in_ifaddr *)((ri)->ri_ifa))
 
+	ia = RIA(&ri);
 	/*
 	 * Save the IP header and at most 8 bytes of the payload,
 	 * in case we need to generate an ICMP message to the src.
@@ -1381,54 +1375,42 @@ ip_forward(struct mbuf *m, int srcrt)
 	 * Also, don't send redirect if forwarding using a default route
 	 * or a route modified by a redirect.
 	 */
+
+	/*
+	 * XXX check that this actually still works
+	 *
+	 */
 	dest.s_addr = 0;
 	if (!srcrt && V_ipsendredirects && ia->ia_ifp == m->m_pkthdr.rcvif) {
 		struct sockaddr_in *sin;
-		struct rtentry *rt;
 
-		sin = (struct sockaddr_in *)&ro.ro_dst;
+		sin = (struct sockaddr_in *)&ri.ri_dst;
 		sin->sin_family = AF_INET;
 		sin->sin_len = sizeof(*sin);
 		sin->sin_addr = ip->ip_dst;
-		in_rtalloc_ign(&ro, RTF_CLONING, M_GETFIB(m));
 
-		rt = ro.ro_rt;
-
-		if (rt && (rt->rt_flags & (RTF_DYNAMIC|RTF_MODIFIED)) == 0 &&
-		    satosin(rt_key(rt))->sin_addr.s_addr != 0) {
-#define	RTA(rt)	((struct in_ifaddr *)(rt->rt_ifa))
+		if ((ri.ri_flags & (RTF_DYNAMIC|RTF_MODIFIED)) == 0 &&
+		    sin->sin_addr.s_addr != 0) {
 			u_long src = ntohl(ip->ip_src.s_addr);
 
-			if (RTA(rt) &&
-			    (src & RTA(rt)->ia_subnetmask) == RTA(rt)->ia_subnet) {
-				if (rt->rt_flags & RTF_GATEWAY)
-					dest.s_addr = satosin(rt->rt_gateway)->sin_addr.s_addr;
-				else
-					dest.s_addr = ip->ip_dst.s_addr;
+			if (RIA(&ri) &&
+			    (src & RIA(&ri)->ia_subnetmask) == RIA(&ri)->ia_subnet) {
 				/* Router requirements says to only send host redirects */
 				type = ICMP_REDIRECT;
 				code = ICMP_REDIRECT_HOST;
 			}
 		}
-		if (rt && (cached == 0))
-			RTFREE(rt);
 	}
 
 	/*
 	 * Try to cache the route MTU from ip_output so we can consider it for
 	 * the ICMP_UNREACH_NEEDFRAG "Next-Hop MTU" field described in RFC1191.
 	 */
-	error = ip_output(m, NULL, &ro, IP_FORWARDING, NULL, NULL);
-
-#ifdef RADIX_MPATH
-	if (cached)
-		ipv4_flow_free(hash);
-#endif	
-	if (error == EMSGSIZE && ro.ro_rt)
-		mtu = ro.ro_rt->rt_rmx.rmx_mtu;
-	if (ro.ro_rt && (cached == 0))
-		RTFREE(ro.ro_rt);
+	error = ip_output(m, NULL, (struct route *)&ri, IP_FORWARDING|IP_RTINFO,
+	    NULL, NULL);
 
+	if (error == EMSGSIZE)
+		mtu = ri.ri_mtu;
 	if (error)
 		V_ipstat.ips_cantforward++;
 	else {



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