From owner-svn-src-head@FreeBSD.ORG Sun Apr 19 09:19:28 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0F250106566B; Sun, 19 Apr 2009 09:19:28 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id BCC4E8FC16; Sun, 19 Apr 2009 09:19:27 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from fledge.watson.org (fledge.watson.org [65.122.17.41]) by cyrus.watson.org (Postfix) with ESMTPS id 6D9BA46B5C; Sun, 19 Apr 2009 05:19:27 -0400 (EDT) Date: Sun, 19 Apr 2009 10:19:27 +0100 (BST) From: Robert Watson X-X-Sender: robert@fledge.watson.org To: Kip Macy In-Reply-To: <200904190444.n3J4i5wF098362@svn.freebsd.org> Message-ID: References: <200904190444.n3J4i5wF098362@svn.freebsd.org> User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r191259 - head/sys/netinet X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Apr 2009 09:19:28 -0000 On Sun, 19 Apr 2009, Kip Macy wrote: > Author: kmacy > Date: Sun Apr 19 04:44:05 2009 > New Revision: 191259 > URL: http://svn.freebsd.org/changeset/base/191259 > > Log: > - Allocate a small flowtable in ip_input.c (changeable by tuneable) > - Use for accelerating ip_output If you anticipate the flowtable being used with many types, I wonder if the flowtable sysctl to enable/disable it by policy should be on the consumer side, rather than the producer side? That way you could say "use the flowtable for ipv4 and ipv6 but not ipx", which might well be helpful for debugging when adding flowtable support for those protocols. Also, is it the case that when the flowtable is disabled, it isn't allocated, or is the basic table always allocated regardless of policy? Robert N M Watson Computer Laboratory University of Cambridge > > Modified: > head/sys/netinet/ip_input.c > head/sys/netinet/ip_output.c > head/sys/netinet/vinet.h > > Modified: head/sys/netinet/ip_input.c > ============================================================================== > --- head/sys/netinet/ip_input.c Sun Apr 19 04:39:42 2009 (r191258) > +++ head/sys/netinet/ip_input.c Sun Apr 19 04:44:05 2009 (r191259) > @@ -64,6 +64,7 @@ __FBSDID("$FreeBSD$"); > #include > #include > #include > +#include > > #include > #include > @@ -211,6 +212,11 @@ SYSCTL_INT(_net_inet_ip, IPCTL_DEFMTU, m > SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_ip, OID_AUTO, stealth, CTLFLAG_RW, > ipstealth, 0, "IP stealth mode, no TTL decrementation on forwarding"); > #endif > +static int ip_output_flowtable_size = 2048; > +TUNABLE_INT("net.inet.ip.output_flowtable_size", &ip_output_flowtable_size); > +SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_ip, OID_AUTO, output_flowtable_size, > + CTLFLAG_RDTUN, ip_output_flowtable_size, 2048, > + "number of entries in the per-cpu output flow caches"); > > /* > * ipfw_ether and ipfw_bridge hooks. > @@ -221,6 +227,7 @@ ip_dn_io_t *ip_dn_io_ptr = NULL; > #ifdef VIMAGE_GLOBALS > int fw_one_pass; > #endif > +struct flowtable *ip_ft; > > static void ip_freef(struct ipqhead *, struct ipq *); > > @@ -342,6 +349,8 @@ ip_init(void) > ipintrq.ifq_maxlen = ipqmaxlen; > mtx_init(&ipintrq.ifq_mtx, "ip_inq", NULL, MTX_DEF); > netisr_register(NETISR_IP, ip_input, &ipintrq, 0); > + > + ip_ft = flowtable_alloc(ip_output_flowtable_size, FL_PCPU); > } > > void > > Modified: head/sys/netinet/ip_output.c > ============================================================================== > --- head/sys/netinet/ip_output.c Sun Apr 19 04:39:42 2009 (r191258) > +++ head/sys/netinet/ip_output.c Sun Apr 19 04:44:05 2009 (r191259) > @@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$"); > #include > #include > #include > +#include > #ifdef RADIX_MPATH > #include > #endif > @@ -135,6 +136,7 @@ ip_output(struct mbuf *m, struct mbuf *o > int hlen = sizeof (struct ip); > int mtu; > int len, error = 0; > + int nortfree = 0; > struct sockaddr_in *dst = NULL; /* keep compiler happy */ > struct in_ifaddr *ia = NULL; > int isbroadcast, sw_csum; > @@ -158,6 +160,10 @@ ip_output(struct mbuf *m, struct mbuf *o > m->m_flags |= M_FLOWID; > } > } > + if ((ro == &iproute) && (ro->ro_rt == NULL) && (ro->ro_lle == NULL)) { > + if (flowtable_lookup(ip_ft, m, ro) == 0) > + nortfree = 1; > + } > > if (opt) { > len = 0; > @@ -199,7 +205,8 @@ again: > if (ro->ro_rt && ((ro->ro_rt->rt_flags & RTF_UP) == 0 || > dst->sin_family != AF_INET || > dst->sin_addr.s_addr != ip->ip_dst.s_addr)) { > - RTFREE(ro->ro_rt); > + if (!nortfree) > + RTFREE(ro->ro_rt); > ro->ro_rt = (struct rtentry *)NULL; > } > #ifdef IPFIREWALL_FORWARD > @@ -638,7 +645,7 @@ passout: > IPSTAT_INC(ips_fragmented); > > done: > - if (ro == &iproute && ro->ro_rt) { > + if (ro == &iproute && ro->ro_rt && !nortfree) { > RTFREE(ro->ro_rt); > } > return (error); > > Modified: head/sys/netinet/vinet.h > ============================================================================== > --- head/sys/netinet/vinet.h Sun Apr 19 04:39:42 2009 (r191258) > +++ head/sys/netinet/vinet.h Sun Apr 19 04:44:05 2009 (r191259) > @@ -72,6 +72,7 @@ struct vnet_inet { > int _ip_sendsourcequench; > int _ip_do_randomid; > int _ip_checkinterface; > + int _ip_output_flowtable_size; > u_short _ip_id; > > uma_zone_t _ipq_zone; >