From owner-svn-src-head@FreeBSD.ORG Thu May 21 09:45:47 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 B702E106566B; Thu, 21 May 2009 09:45:47 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A5A938FC19; Thu, 21 May 2009 09:45:47 +0000 (UTC) (envelope-from rwatson@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 n4L9jl1E061244; Thu, 21 May 2009 09:45:47 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4L9jlwv061243; Thu, 21 May 2009 09:45:47 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <200905210945.n4L9jlwv061243@svn.freebsd.org> From: Robert Watson Date: Thu, 21 May 2009 09:45:47 +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: r192528 - 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: Thu, 21 May 2009 09:45:48 -0000 Author: rwatson Date: Thu May 21 09:45:47 2009 New Revision: 192528 URL: http://svn.freebsd.org/changeset/base/192528 Log: Consolidate and clean up the first section of ip_output.c in light of the last year or two's work on routing: - Combine iproute initialization and flowtable lookup blocks, eliminating unnecessary tests for known-zero'd iproute fields. - Add a comment indicating (a) why the route entry returned by the flowtable is considered stable and (b) that the flowtable lookup must occur after the setup of the mbuf flow ID. - Assert the inpcb lock before any use of inpcb fields. Reviewed by: kmacy Modified: head/sys/netinet/ip_output.c Modified: head/sys/netinet/ip_output.c ============================================================================== --- head/sys/netinet/ip_output.c Thu May 21 07:55:25 2009 (r192527) +++ head/sys/netinet/ip_output.c Thu May 21 09:45:47 2009 (r192528) @@ -150,20 +150,25 @@ ip_output(struct mbuf *m, struct mbuf *o #endif M_ASSERTPKTHDR(m); - if (ro == NULL) { - ro = &iproute; - bzero(ro, sizeof (*ro)); - } - if (inp != NULL) { - M_SETFIB(m, inp->inp_inc.inc_fibnum); INP_LOCK_ASSERT(inp); + M_SETFIB(m, inp->inp_inc.inc_fibnum); if (inp->inp_flags & (INP_HW_FLOWID|INP_SW_FLOWID)) { m->m_pkthdr.flowid = inp->inp_flowid; m->m_flags |= M_FLOWID; } } - if ((ro == &iproute) && (ro->ro_rt == NULL) && (ro->ro_lle == NULL)) { + + if (ro == NULL) { + ro = &iproute; + bzero(ro, sizeof (*ro)); + + /* + * The flow table returns route entries valid for up to 30 + * seconds; we rely on the remainder of ip_output() taking no + * longer than that long for the stability of ro_rt. The + * flow ID assignment must have happened before this point. + */ if (flowtable_lookup(ip_ft, m, ro) == 0) nortfree = 1; }