From owner-svn-src-all@FreeBSD.ORG Sun Apr 19 04:44:06 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 31644106566C; Sun, 19 Apr 2009 04:44:06 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 210118FC15; Sun, 19 Apr 2009 04:44:06 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n3J4i6OM098365; Sun, 19 Apr 2009 04:44:06 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n3J4i5wF098362; Sun, 19 Apr 2009 04:44:05 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200904190444.n3J4i5wF098362@svn.freebsd.org> From: Kip Macy Date: Sun, 19 Apr 2009 04:44:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r191259 - head/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Apr 2009 04:44:06 -0000 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 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;