From owner-svn-src-user@FreeBSD.ORG Sun Dec 28 14:37:09 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9F129106564A; Sun, 28 Dec 2008 14:37:09 +0000 (UTC) (envelope-from piso@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 716578FC08; Sun, 28 Dec 2008 14:37:09 +0000 (UTC) (envelope-from piso@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 mBSEb9lL015945; Sun, 28 Dec 2008 14:37:09 GMT (envelope-from piso@svn.freebsd.org) Received: (from piso@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBSEb9rL015944; Sun, 28 Dec 2008 14:37:09 GMT (envelope-from piso@svn.freebsd.org) Message-Id: <200812281437.mBSEb9rL015944@svn.freebsd.org> From: Paolo Pisati Date: Sun, 28 Dec 2008 14:37:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186542 - user/piso X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Dec 2008 14:37:09 -0000 Author: piso Date: Sun Dec 28 14:37:09 2008 New Revision: 186542 URL: http://svn.freebsd.org/changeset/base/186542 Log: Create my own branch. Added: user/piso/ (props changed) - copied from r186541, head/ From owner-svn-src-user@FreeBSD.ORG Sun Dec 28 14:42:24 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D10BC106564A; Sun, 28 Dec 2008 14:42:24 +0000 (UTC) (envelope-from mat.macy@gmail.com) Received: from rv-out-0506.google.com (rv-out-0506.google.com [209.85.198.225]) by mx1.freebsd.org (Postfix) with ESMTP id 978A18FC1A; Sun, 28 Dec 2008 14:42:24 +0000 (UTC) (envelope-from mat.macy@gmail.com) Received: by rv-out-0506.google.com with SMTP id b25so5629265rvf.43 for ; Sun, 28 Dec 2008 06:42:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender :to:subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references :x-google-sender-auth; bh=/LHK+w/cwMmWrjE9iZrnw9JGtnCGtM8lYkJYRs7c+x0=; b=MhwaAjUFOC5EgN0IB9V62Ofc5mBk1K9XqNPNTfInmXS/q0weJ+FhV6fVEHozdZUPh/ QpPooMMdX7GLWqqHYnKq8CxGyVEgH1Y2uMKFwFktCLxpUF/dOJkAqvJhogmr1a4OGRgH gL/+rH3nBI3M2f7OFWgjl8/M7oLMbQ8uBeXxA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references:x-google-sender-auth; b=HB8+fk5ynjHmmmVRTWyq39WwZuEYEmNELWLug24IVEs5U7aqhmEhVyGwGskULqCpIS f7kRf5kxG6Btm1NSK36/Gpj97+ZE9t1QF5BIrwdA7DzERnL0G17zUB1iUhi9VGm9F+ZH F77ijU+RyYP4cA/Nj58WnQzBChUfbSG/21inQ= Received: by 10.141.40.7 with SMTP id s7mr6223440rvj.268.1230475344414; Sun, 28 Dec 2008 06:42:24 -0800 (PST) Received: by 10.141.37.17 with HTTP; Sun, 28 Dec 2008 06:42:24 -0800 (PST) Message-ID: <3c1674c90812280642i32c59e67i93ab5f38bac2c09b@mail.gmail.com> Date: Sun, 28 Dec 2008 06:42:24 -0800 From: "Kip Macy" Sender: mat.macy@gmail.com To: "Paolo Pisati" In-Reply-To: <200812281437.mBSEb9rL015944@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <200812281437.mBSEb9rL015944@svn.freebsd.org> X-Google-Sender-Auth: f7952aab0a51edfb Cc: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: Re: svn commit: r186542 - user/piso X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Dec 2008 14:42:24 -0000 Most of us create branches under user/ rather than using it for a branch itself. You might wish to reconsider as you'll almost certainly want to have more than one personal branch at a time. On Sun, Dec 28, 2008 at 6:37 AM, Paolo Pisati wrote: > Author: piso > Date: Sun Dec 28 14:37:09 2008 > New Revision: 186542 > URL: http://svn.freebsd.org/changeset/base/186542 > > Log: > Create my own branch. > > Added: > user/piso/ (props changed) > - copied from r186541, head/ > -- Als die Nazis die Kommunisten holten, habe ich geschwiegen; ich war ja kein Kommunist. Als sie die Sozialdemokraten einsperrten, habe ich geschwiegen; ich war ja kein Sozialdemokrat. Als sie die Gewerkschafter holten, habe ich nicht protestiert; ich war ja kein Gewerkschafter. Als sie die Juden holten, habe ich geschwiegen; ich war ja kein Jude. Als sie mich holten, gab es keinen mehr, der protestieren konnte. From owner-svn-src-user@FreeBSD.ORG Sun Dec 28 16:08:18 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 54090106564A; Sun, 28 Dec 2008 16:08:18 +0000 (UTC) (envelope-from p.pisati@oltrelinux.com) Received: from joe.mail.tiscali.it (joe.mail.tiscali.it [213.205.33.54]) by mx1.freebsd.org (Postfix) with ESMTP id 0EAB48FC12; Sun, 28 Dec 2008 16:08:18 +0000 (UTC) (envelope-from p.pisati@oltrelinux.com) Received: from newluxor.wired.org (94.36.85.105) by joe.mail.tiscali.it (8.0.022) id 494F82F40040AEC1; Sun, 28 Dec 2008 16:56:39 +0100 Message-ID: <4957A1B4.70009@oltrelinux.com> Date: Sun, 28 Dec 2008 16:56:36 +0100 From: Paolo Pisati User-Agent: Thunderbird 2.0.0.18 (X11/20081214) MIME-Version: 1.0 To: Kip Macy References: <200812281437.mBSEb9rL015944@svn.freebsd.org> <3c1674c90812280642i32c59e67i93ab5f38bac2c09b@mail.gmail.com> In-Reply-To: <3c1674c90812280642i32c59e67i93ab5f38bac2c09b@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: src-committers@freebsd.org, Paolo Pisati , svn-src-user@freebsd.org Subject: Re: svn commit: r186542 - user/piso X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Dec 2008 16:08:18 -0000 Kip Macy wrote: > Most of us create branches under user/ rather than using it > for a branch itself. You might wish to reconsider as you'll almost > certainly want to have more than one personal branch at a time. > can i simply "svn mv" the stuff or shall i revert the previous commit? From owner-svn-src-user@FreeBSD.ORG Sun Dec 28 17:16:33 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 24B261065673; Sun, 28 Dec 2008 17:16:33 +0000 (UTC) (envelope-from piso@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 10E828FC08; Sun, 28 Dec 2008 17:16:33 +0000 (UTC) (envelope-from piso@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 mBSHGWNH018989; Sun, 28 Dec 2008 17:16:32 GMT (envelope-from piso@svn.freebsd.org) Received: (from piso@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBSHGWg8018977; Sun, 28 Dec 2008 17:16:32 GMT (envelope-from piso@svn.freebsd.org) Message-Id: <200812281716.mBSHGWg8018977@svn.freebsd.org> From: Paolo Pisati Date: Sun, 28 Dec 2008 17:16:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186543 - in user/piso: sbin/ipfw share/man/man8 sys/modules/libalias/libalias sys/netinet sys/netinet/libalias X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Dec 2008 17:16:33 -0000 Author: piso Date: Sun Dec 28 17:16:32 2008 New Revision: 186543 URL: http://svn.freebsd.org/changeset/base/186543 Log: Import sctp nat support in ipfw obtained from CAIA - http://caia.swin.edu.au. Added: user/piso/share/man/man8/alias_sctp.8 (contents, props changed) user/piso/sys/netinet/libalias/alias_sctp.c (contents, props changed) user/piso/sys/netinet/libalias/alias_sctp.h (contents, props changed) Modified: user/piso/sbin/ipfw/ipfw2.c user/piso/share/man/man8/Makefile user/piso/sys/modules/libalias/libalias/Makefile user/piso/sys/netinet/ip_fw_nat.c user/piso/sys/netinet/libalias/alias.c user/piso/sys/netinet/libalias/alias.h user/piso/sys/netinet/libalias/alias_db.c user/piso/sys/netinet/libalias/alias_local.h Modified: user/piso/sbin/ipfw/ipfw2.c ============================================================================== --- user/piso/sbin/ipfw/ipfw2.c Sun Dec 28 14:37:09 2008 (r186542) +++ user/piso/sbin/ipfw/ipfw2.c Sun Dec 28 17:16:32 2008 (r186543) @@ -48,6 +48,7 @@ #include #define IPFW_INTERNAL /* Access to protected structures in ip_fw.h. */ +#define _ALIAS_SCTP /*Using alias_sctp*/ #include #include @@ -3504,7 +3505,13 @@ StrToProto (const char* str) if (!strcmp (str, "udp")) return IPPROTO_UDP; +#ifdef _ALIAS_SCTP /*Using alias_sctp*/ + if (!strcmp (str, "sctp")) + return IPPROTO_SCTP; + errx (EX_DATAERR, "unknown protocol %s. Expected sctp, tcp or udp", str); +#else errx (EX_DATAERR, "unknown protocol %s. Expected tcp or udp", str); +#endif } static int @@ -3680,13 +3687,29 @@ setup_redir_port(char *spool_buf, int le strncpy(tmp_spool_buf, *av, strlen(*av)+1); lsnat = 1; } else { - if (StrToAddrAndPortRange (*av, &r->laddr, protoName, +#ifdef _ALIAS_SCTP /*Using alias_sctp*/ + /* + * The sctp nat does not allow the port numbers to be mapped to new port numbers + * Therefore, no ports are to be specified in the target port field + */ + if (r->proto == IPPROTO_SCTP) { + if (strchr (*av, ':')) + errx(EX_DATAERR, "redirect_port:" + "port numbers do not change in sctp, so do not specify them as part of the target"); + else + StrToAddr(*av, &r->laddr); + } else { +#endif /*Using alias_sctp*/ + if (StrToAddrAndPortRange (*av, &r->laddr, protoName, &portRange) != 0) errx(EX_DATAERR, "redirect_port:" "invalid local port range"); r->lport = GETLOPORT(portRange); numLocalPorts = GETNUMPORTS(portRange); +#ifdef _ALIAS_SCTP /*Using alias_sctp*/ + } +#endif /*Using alias_sctp*/ } INC_ARGCV(); @@ -3710,6 +3733,12 @@ setup_redir_port(char *spool_buf, int le } r->pport = GETLOPORT(portRange); +#ifdef _ALIAS_SCTP /*Using alias_sctp*/ + if (r->proto == IPPROTO_SCTP) { /* so the logic below still works */ + numLocalPorts = GETNUMPORTS(portRange); + r->lport = r->pport; + } +#endif /*Using alias_sctp*/ r->pport_cnt = GETNUMPORTS(portRange); INC_ARGCV(); @@ -3765,6 +3794,22 @@ setup_redir_port(char *spool_buf, int le goto nospace; len -= SOF_SPOOL; space += SOF_SPOOL; + +#ifdef _ALIAS_SCTP /*Using alias_sctp*/ + /* + * The sctp nat does not allow the port numbers to be mapped to new port numbers + * Therefore, no ports are to be specified in the target port field + */ + if (r->proto == IPPROTO_SCTP) { + if (strchr (sep, ':')) { + errx(EX_DATAERR, "redirect_port:" + "port numbers do not change in sctp, so do not specify them as part of the target"); + } else { + StrToAddr(sep, &tmp->addr); + tmp->port = r->pport; + } + } else { +#endif /*Using alias_sctp*/ if (StrToAddrAndPortRange(sep, &tmp->addr, protoName, &portRange) != 0) errx(EX_DATAERR, "redirect_port:" @@ -3773,6 +3818,9 @@ setup_redir_port(char *spool_buf, int le errx(EX_DATAERR, "redirect_port: local port" "must be single in this context"); tmp->port = GETLOPORT(portRange); +#ifdef _ALIAS_SCTP /*Using alias_sctp*/ + } +#endif /*Using alias_sctp*/ r->spool_cnt++; /* Point to the next possible cfg_spool. */ spool_buf = &spool_buf[SOF_SPOOL]; Modified: user/piso/share/man/man8/Makefile ============================================================================== --- user/piso/share/man/man8/Makefile Sun Dec 28 14:37:09 2008 (r186542) +++ user/piso/share/man/man8/Makefile Sun Dec 28 17:16:32 2008 (r186543) @@ -13,7 +13,8 @@ MAN= adding_user.8 \ rc.subr.8 \ rescue.8 \ sticky.8 \ - yp.8 + yp.8 \ + alias_sctp.8 MLINKS= rc.8 rc.atm.8 \ rc.8 rc.d.8 \ Added: user/piso/share/man/man8/alias_sctp.8 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/piso/share/man/man8/alias_sctp.8 Sun Dec 28 17:16:32 2008 (r186543) @@ -0,0 +1,241 @@ +.\" * Copyright (c) 2008, Centre for Advanced Internet Architectures +.\" * Swinburne University of Technology, Melbourne, Australia +.\" * (CRICOS number 00111D). +.\" * +.\" * Alias_sctp forms part of the libalias kernel module to handle +.\" * Network Address Translation (NAT) for the SCTP protocol. +.\" * +.\" * This software was developed by David A. Hayes and Jason But +.\" * +.\" * The design is outlined in CAIA technical report number 080618A +.\" * (D. Hayes and J. But, "Alias_sctp Version 0.1: SCTP NAT implementation in IPFW") +.\" * +.\" * Development is part of the CAIA SONATA project, +.\" * proposed by Jason But and Grenville Armitage: +.\" * http://caia.swin.edu.au/urp/sonata/ +.\" * +.\" * +.\" * This project has been made possible in part by a grant from +.\" * the Cisco University Research Program Fund at Community +.\" * Foundation Silicon Valley. +.\" * +.\" * +.\" * +.\" * All rights reserved. +.\" * +.\" * Redistribution and use in source and binary forms, with or without +.\" * modification, are permitted provided that the following conditions +.\" * are met: +.\" * 1. Redistributions of source code must retain the above copyright +.\" * notice, this list of conditions and the following disclaimer. +.\" * 2. Redistributions in binary form must reproduce the above copyright +.\" * notice, this list of conditions and the following disclaimer in the +.\" * documentation and/or other materials provided with the distribution. +.\" * 3. The names of the authors, the "Centre for Advanced Internet Architectures" +.\" * and "Swinburne University of Technology" may not be used to endorse +.\" * or promote products derived from this software without specific +.\" * prior written permission. +.\" * +.\" * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS "AS IS" AND +.\" * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE +.\" * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" * SUCH DAMAGE. +.TH ALIAS_SCTP 8 "30 September 08" "version 0.2" +.SH NAME +alias_sctp - SCTP NAT functionality for libalias in FreeBSD +.SH SYNOPSIS +.B alias_sctp \- libalias enhancements to support SCTP NAT +.PP +.B ipfw \- Extensions to user-land tool to configure SCTP NAT +.PP +.B sysctl net.inet.ip.alias.sctp.* \- sysctl interface to alias_sctp +./"=========================================================================" +.SH DESCRIPTION +.B alias_sctp +is a kernel space addition to libalias that implements NAT for SCTP within the +.B ipfw2 +framework for FreeBSD. The +.B alias_sctp +implementation is based on the details provided in Internet Draft xxxxx and our +own ideas discovered during implementation. +.B alias_sctp +is a dynamically configurable NAT module that supports the following functionality: +.IP o +Optional support for tracking of Global IP Addresses (see Internet Draft xxxx) +.IP o +Dynamically configurable timeouts for various states within the NAT +.IP o +Dynamically configurable packet parsing limits (to protect against DoS attacks) +.IP o +Per port/IP-address forwarding of incoming associations +.IP o +Dynamically configurable hash table size and logging details +.IP o +NAT configured via user-land +.B ipfw +tool +.IP o +NAT statistics available via +.B ipfw +user-land command +./"=========================================================================" +.SH USING alias_sctp +.SS Configuring alias_sctp via ipfw +.B Alias_sctp +can be configured in a simillar manner to TCP through the ipfw command line tool +(see ipfw(8)). The main difference in configuring SCTP NAT rules, is that +.B alias_sctp +does not do port translation. Since the local and global side ports will be the +same, there is no need to specify both. Ports are redirected as follows: +.IP +.B ipfw nat +inst# +.B config if +nic +.B redirect_port sctp +ip-addr [,addr-list] {port | port-port] [,ports]} +./"=========================================================================" +.SH "sysctl" INTERFACE +Most +.B alias_sctp +configuration can be done in real-time through the +.B sysctl(8) +interface. All may be changed dynamically, though the hash_table size will only +change for new NAT instances. Default values are also listed below. + +.SS net.inet.ip.alias.sctp.hashtable_size (Default = 2003) +Size of hash tables used for NAT lookups (100 < prime_number > 1000001) +This value sets the hash table size for any _future_ created NAT +instance and therefore must be set prior to creating a NAT instance (ie +ipfw nat 100 config ...). +.PP +The table sizes my be changed to suit specific needs. If there will be few +concurrent associations, and memory is scarce, you may make these smaller. If +there will be many thousands (or millions) of concurrent associations, you +should make these larger. A prime number is best for the table size. The sysctl +update function will adjust your input value to the next highest prime number. + +.SS net.inet.ip.alias.sctp.error_on_ootb (Default = 1) +Defines when the NAT responds to any Out-of-the-Blue (OOTB) packets with ErrorM +packets. An OOTB packet is a packet that arrives with no existing association +registered in the NAT AND is not an INIT or ASCONF-AddIP packet: +.PP +.IP "0 \-" +ErrorM is never sent in response to OOTB packets +.IP "1 \-" +ErrorM is only sent to OOTB packets received on the local side +.IP "2 \-" +ErrorM is sent to the local side and on the global side ONLY if there is a +partial match (ports and vtags match but the source global IP does not). This +value is only useful if the NAT is tracking global IP addresses +.IP "3 \-" +ErrorM is sent in response to all OOTB packets on both the local and global side +(DoS risk) +.PP +At the moment the default is 0, since the ErrorM packet is not yet +supported by most SCTP stacks. When it is supported, and if not tracking +global addresses we recommend setting this value to 1 to allow +multi-homed local hosts to function with the NAT. If tracking global addresses +we recommend setting this value to 2 to allow global hosts to be informed when +they need to (re)send an ASCONF-AddIP. Value 3 should never be chosen (except +for debugging) as the NAT will respond to all OOTB global packets (a DoS risk). + +.SS net.inet.ip.alias.sctp.accept_global_ootb_addip (Default = 0) +Defines how the NAT responds to receipt of global OOTB ASCONF-AddIP: +.PP +.IP "0 \-" +No response (unless a partially matching association exists - +ports and vtags match but global address does not) +.IP "1 \-" +NAT will accept and process all OOTB global AddIP messages. +.PP +Option 1 should never be selected as this forms a security risk. An attacker can +establish multiple fake associations by sending AddIP messages. + +.SS net.inet.ip.alias.sctp.initialising_chunk_proc_limit (Default = 2) +Defines the maximum number of chunks in an SCTP packet that will be parsed when +no existing association exists that matches that packet. Ideally this packet +will only be an INIT or ASCONF-AddIP packet. A higher value may become a DoS +risk as malformed packets can consume processing resources. + +.SS net.inet.ip.alias.sctp.chunk_proc_limit (Default = 5) +Defines the maximum number of chunks in an SCTP packet that will be parsed for a +packet that matches an existing association. This value is enforced to be >= +(initialising_chunk_proc_limit). As for the previous parameter, a high value is +a DoS risk yet setting too low a value may result in important control chunks in +the packet not being located and parsed. + +.SS net.inet.ip.alias.sctp.param_proc_limit (Default = 25) +Defines the maximum number of parameters within a chunk that will be parsed in a +packet. As for other similar sysctl variables, larger values pose a DoS risk. + +.SS net.inet.ip.alias.sctp.track_global_addresses (Default = 0) +Enables/disables global IP address tracking within the NAT and places an +upper limit on the number of addresses tracked for each association: +.PP +.IP "0 \-" +Global tracking is disabled +.IP ">1 \-" +Enables tracking, the maximum number of addresses tracked for each +association is limited to this value +.PP +This variable is fully dynamic, the new value will be adopted for all newly +arriving associations, existing association are treated as they were previously. +Global tracking will decrease the number of collisions within the NAT at a cost +of increased processing load, memory usage, complexity, and possible NAT state +problems in complex networks with multiple NATs. We recommend not tracking +global IP addresses, this will still result in a fully functional NAT. + +.SS net.inet.ip.alias.sctp.init_timer (Default = 15) +Timeout value (s) while waiting for (INIT-ACK|AddIP-ACK). +This value cannot be 0. + +.SS net.inet.ip.alias.sctp.up_timer (Default = 300) +Timeout value (s) to keep an association up with no traffic. +This value cannot be 0. + +.SS net.inet.ip.alias.sctp.shutdown_time (Default = 15) +Timeout value (s) while waiting for SHUTDOWN-COMPLETE. +This value cannot be 0. + +.SS net.inet.ip.alias.sctp.holddown_time (Default = 0) +Hold association in table for this many seconds after receiving a +SHUTDOWN-COMPLETE. This allows endpoints to correct shutdown gracefully if a +shutdown_complete is lost and retransmissions are required. This +net.inet.ip.alias.sctp.log_level (Default = 0) Level of detail in the system log +messages (0 \- minimal, 1 \- event, 2 \- info, 3 \- detail, 4 \- debug, 5 \- max +debug) +.PP +May be a good option in high loss environments. + +.SH "SEE ALSO" +.BR ipfw (8), +.BR libalias (8), +.BR sysctl (8) +.SH AUTHOR +.B alias_sctp +has been developed and released by: + +The Centre for Advanced Internet Architectures (CAIA), Swinburne University, +Melbourne, Australia. +.IP +.I http://www.caia.swin.edu.au +.LP +The primary developers and maintainers of +.B alias_sctp +are David Hayes and Jason But. + +.B alias_sctp +can be downloaded from its website: +.IP +.I http://www.caia.swin.edu.au/urp/SONATA +.LP +This site contains the latest updates and further information on how to use and +.B alias_sctp Modified: user/piso/sys/modules/libalias/libalias/Makefile ============================================================================== --- user/piso/sys/modules/libalias/libalias/Makefile Sun Dec 28 14:37:09 2008 (r186542) +++ user/piso/sys/modules/libalias/libalias/Makefile Sun Dec 28 17:16:32 2008 (r186543) @@ -3,6 +3,6 @@ .PATH: ${.CURDIR}/../../../netinet/libalias KMOD= libalias -SRCS= alias.c alias_db.c alias_proxy.c alias_util.c alias_mod.c +SRCS= alias.c alias_db.c alias_proxy.c alias_util.c alias_mod.c alias_sctp.c .include Modified: user/piso/sys/netinet/ip_fw_nat.c ============================================================================== --- user/piso/sys/netinet/ip_fw_nat.c Sun Dec 28 14:37:09 2008 (r186542) +++ user/piso/sys/netinet/ip_fw_nat.c Sun Dec 28 17:16:32 2008 (r186543) @@ -326,6 +326,12 @@ ipfw_nat(struct ip_fw_args *args, struct else retval = LibAliasOut(t->lib, c, mcl->m_len + M_TRAILINGSPACE(mcl)); +#ifdef _ALIAS_SCTP + if (retval == PKT_ALIAS_RESPOND) { + m->m_flags |= M_SKIP_FIREWALL; + retval = PKT_ALIAS_OK; + } +#endif if (retval != PKT_ALIAS_OK && retval != PKT_ALIAS_FOUND_HEADER_FRAGMENT) { /* XXX - should i add some logging? */ @@ -401,6 +407,7 @@ ipfw_nat(struct ip_fw_args *args, struct } args->m = mcl; + return (IP_FW_NAT); } Modified: user/piso/sys/netinet/libalias/alias.c ============================================================================== --- user/piso/sys/netinet/libalias/alias.c Sun Dec 28 14:37:09 2008 (r186542) +++ user/piso/sys/netinet/libalias/alias.c Sun Dec 28 17:16:32 2008 (r186543) @@ -111,10 +111,18 @@ __FBSDID("$FreeBSD$"); See HISTORY file for additional revisions. */ +/** + * Modifications to add sctp functionality by David A. Hayes + * $Id: alias.c 122 2008-06-25 06:50:47Z dhayes $ + * All are inclosed in #ifdef _ALIAS_SCTP + * + */ + #ifdef _KERNEL #include #include #include +#include #else #include #include @@ -136,11 +144,28 @@ __FBSDID("$FreeBSD$"); #include #include #include +#ifdef _ALIAS_SCTP +#include +#endif #else #include #include "alias.h" #include "alias_local.h" #include "alias_mod.h" +#ifdef _ALIAS_SCTP +#include "alias_sctp.h" +#endif +#endif + +/* + * Define libalias SYSCTL Node + */ +#ifdef SYSCTL_NODE + +SYSCTL_DECL(_net_inet); +SYSCTL_DECL(_net_inet_ip); +SYSCTL_NODE(_net_inet_ip, OID_AUTO, alias, CTLFLAG_RW, NULL, "Libalias sysctl API"); + #endif static __inline int @@ -1335,6 +1360,11 @@ LibAliasInLocked(struct libalias *la, ch case IPPROTO_TCP: iresult = TcpAliasIn(la, pip); break; +#ifdef _ALIAS_SCTP + case IPPROTO_SCTP: + iresult = SctpAlias(la, pip, SN_TO_LOCAL); + break; +#endif case IPPROTO_GRE: { int error; struct alias_data ad = { @@ -1477,10 +1507,15 @@ LibAliasOutLocked(struct libalias *la, c case IPPROTO_UDP: iresult = UdpAliasOut(la, pip, maxpacketsize, create); break; - case IPPROTO_TCP: + case IPPROTO_TCP: iresult = TcpAliasOut(la, pip, maxpacketsize, create); break; - case IPPROTO_GRE: { + #ifdef _ALIAS_SCTP + case IPPROTO_SCTP: + iresult = SctpAlias(la, pip, SN_TO_GLOBAL); + break; +#endif + case IPPROTO_GRE: { int error; struct alias_data ad = { .lnk = NULL, Modified: user/piso/sys/netinet/libalias/alias.h ============================================================================== --- user/piso/sys/netinet/libalias/alias.h Sun Dec 28 14:37:09 2008 (r186542) +++ user/piso/sys/netinet/libalias/alias.h Sun Dec 28 17:16:32 2008 (r186543) @@ -36,6 +36,13 @@ * distribution. */ +/** + * Modifications to add sctp functionality by David A. Hayes + * $Id: alias.h 122 2008-06-25 06:50:47Z dhayes $ + * All are inclosed in #ifdef _ALIAS_SCTP + * + */ + #ifndef _ALIAS_H_ #define _ALIAS_H_ @@ -45,6 +52,11 @@ #define LIBALIAS_BUF_SIZE 128 #ifdef _KERNEL + +#ifndef _ALIAS_SCTP +#define _ALIAS_SCTP //if ALIAS_SCTP code is to be included +#endif + /* * The kernel version of libalias does not support these features. */ Modified: user/piso/sys/netinet/libalias/alias_db.c ============================================================================== --- user/piso/sys/netinet/libalias/alias_db.c Sun Dec 28 14:37:09 2008 (r186542) +++ user/piso/sys/netinet/libalias/alias_db.c Sun Dec 28 17:16:32 2008 (r186543) @@ -141,6 +141,13 @@ __FBSDID("$FreeBSD$"); See HISTORY file for additional revisions. */ +/** + * Modifications to add sctp functionality by David A. Hayes + * $Id: alias_db.c 177 2008-07-14 04:33:47Z dhayes $ + * All are inclosed in #ifdef _ALIAS_SCTP + * + */ + #ifdef _KERNEL #include @@ -166,6 +173,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#ifdef _ALIAS_SCTP +#include +#endif #include #else #include "alias.h" @@ -373,6 +383,7 @@ static moduledata_t alias_mod = { }; DECLARE_MODULE(alias, alias_mod, SI_SUB_DRIVERS, SI_ORDER_SECOND); + #endif /* Internal utility routines (used only in alias_db.c) @@ -410,6 +421,10 @@ static void ClearFWHole(struct alias_lin static void ShowAliasStats(struct libalias *); static int InitPacketAliasLog(struct libalias *); static void UninitPacketAliasLog(struct libalias *); +#ifdef _ALIAS_SCTP +struct in_addr FindSctpRedirectAddress(struct libalias *la, struct sctp_nat_msg *sm); +void SctpShowAliasStats(struct libalias *la); +#endif static u_int StartPointIn(struct in_addr alias_addr, @@ -489,15 +504,25 @@ ShowAliasStats(struct libalias *la) /* Used for debugging */ if (la->logDesc) { int tot = la->icmpLinkCount + la->udpLinkCount + +#ifdef _ALIAS_SCTP + (la->sctpLinkCount>>1) + /* sctp counts half associations */ +#endif la->tcpLinkCount + la->pptpLinkCount + la->protoLinkCount + la->fragmentIdLinkCount + la->fragmentPtrLinkCount; AliasLog(la->logDesc, +#ifdef _ALIAS_SCTP + "icmp=%u, udp=%u, tcp=%u, sctp=%u, pptp=%u, proto=%u, frag_id=%u frag_ptr=%u / tot=%u", +#else "icmp=%u, udp=%u, tcp=%u, pptp=%u, proto=%u, frag_id=%u frag_ptr=%u / tot=%u", +#endif la->icmpLinkCount, la->udpLinkCount, la->tcpLinkCount, +#ifdef _ALIAS_SCTP + la->sctpLinkCount>>1, /* sctp counts half associations */ +#endif la->pptpLinkCount, la->protoLinkCount, la->fragmentIdLinkCount, @@ -508,6 +533,13 @@ ShowAliasStats(struct libalias *la) } } +#ifdef _ALIAS_SCTP +void SctpShowAliasStats(struct libalias *la) +{ + ShowAliasStats(la); +} +#endif + /* Internal routines for finding, deleting and adding links Port Allocation: @@ -971,6 +1003,10 @@ AddLink(struct libalias *la, struct in_a case LINK_TCP: lnk->expire_time = TCP_EXPIRE_INITIAL; break; +#ifdef _ALIAS_SCTP + case LINK_SCTP: /* treat like LINK_ADDR */ + break; +#endif case LINK_PPTP: lnk->flags |= LINK_PERMANENT; /* no timeout. */ break; @@ -1031,6 +1067,10 @@ AddLink(struct libalias *la, struct in_a return (NULL); } break; +#ifdef _ALIAS_SCTP + case LINK_SCTP: /* treat like LINK_ADDR */ + break; +#endif case LINK_PPTP: la->pptpLinkCount++; break; @@ -1277,11 +1317,17 @@ _FindLinkIn(struct libalias *la, struct src_addr = lnk->src_addr; src_port = lnk->src_port; } - - lnk = ReLink(lnk, - src_addr, dst_addr, alias_addr, - src_port, dst_port, alias_port, - link_type); +#ifdef _ALIAS_SCTP + if(link_type == LINK_SCTP) { + lnk->src_addr = src_addr; + lnk->src_port = src_port; + return(lnk); + } +#endif + lnk = ReLink(lnk, + src_addr, dst_addr, alias_addr, + src_port, dst_port, alias_port, + link_type); } return (lnk); } @@ -2277,10 +2323,15 @@ LibAliasRedirectPort(struct libalias *la case IPPROTO_TCP: link_type = LINK_TCP; break; +#ifdef _ALIAS_SCTP + case IPPROTO_SCTP: + link_type = LINK_SCTP; + break; +#endif default: #ifdef LIBALIAS_DEBUG fprintf(stderr, "PacketAliasRedirectPort(): "); - fprintf(stderr, "only TCP and UDP protocols allowed\n"); + fprintf(stderr, "only SCTP, TCP and UDP protocols allowed\n"); #endif lnk = NULL; goto getout; @@ -2496,6 +2547,9 @@ LibAliasInit(struct libalias *la) LIST_INIT(&la->linkTableOut[i]); for (i = 0; i < LINK_TABLE_IN_SIZE; i++) LIST_INIT(&la->linkTableIn[i]); +#ifdef _ALIAS_SCTP + AliasSctpInit(la);//*** +#endif LIBALIAS_LOCK_INIT(la); LIBALIAS_LOCK(la); } else { @@ -2503,6 +2557,10 @@ LibAliasInit(struct libalias *la) la->deleteAllLinks = 1; CleanupAliasData(la); la->deleteAllLinks = 0; +#ifdef _ALIAS_SCTP + AliasSctpTerm(la); + AliasSctpInit(la); +#endif } la->aliasAddress.s_addr = INADDR_ANY; @@ -2511,6 +2569,9 @@ LibAliasInit(struct libalias *la) la->icmpLinkCount = 0; la->udpLinkCount = 0; la->tcpLinkCount = 0; +#ifdef _ALIAS_SCTP + la->sctpLinkCount = 0; +#endif la->pptpLinkCount = 0; la->protoLinkCount = 0; la->fragmentIdLinkCount = 0; @@ -2539,6 +2600,9 @@ LibAliasUninit(struct libalias *la) { LIBALIAS_LOCK(la); +#ifdef _ALIAS_SCTP + AliasSctpTerm(la); +#endif la->deleteAllLinks = 1; CleanupAliasData(la); la->deleteAllLinks = 0; @@ -2879,3 +2943,39 @@ LibAliasSetSkinnyPort(struct libalias *l la->skinnyPort = port; LIBALIAS_UNLOCK(la); } +#ifdef _ALIAS_SCTP +/** + * @brief Find the address to redirect incoming packets + * + * The function is located in alias_db.c due to calls to static functions + * + * + * @param la pointer to the libalias instance + * @param sm pointer to the incoming message + * + * @return address to redirect an incoming INIT to + */ +struct in_addr +FindSctpRedirectAddress(struct libalias *la, struct sctp_nat_msg *sm) +{ + struct alias_link *lnk; + struct in_addr redir; + + LIBALIAS_LOCK_ASSERT(la); + lnk = FindLinkIn(la, sm->ip_hdr->ip_src, sm->ip_hdr->ip_dst, + sm->sctp_hdr->dest_port,sm->sctp_hdr->dest_port, LINK_SCTP, 1); + if (lnk != NULL) { + return(lnk->src_addr); /* port redirect */ + } else { + redir = FindOriginalAddress(la,sm->ip_hdr->ip_dst); + if (redir.s_addr == la->aliasAddress.s_addr || + redir.s_addr == la->targetAddress.s_addr) { /* No address found */ + lnk = FindLinkIn(la, sm->ip_hdr->ip_src, sm->ip_hdr->ip_dst, + NO_DEST_PORT, 0, LINK_SCTP, 1); + if (lnk != NULL) + return(lnk->src_addr); /* redirect proto */ + } + return(redir); /* address redirect */ + } +} +#endif Modified: user/piso/sys/netinet/libalias/alias_local.h ============================================================================== --- user/piso/sys/netinet/libalias/alias_local.h Sun Dec 28 14:37:09 2008 (r186542) +++ user/piso/sys/netinet/libalias/alias_local.h Sun Dec 28 17:16:32 2008 (r186543) @@ -42,6 +42,12 @@ * * */ +/** + * Modifications to add sctp functionality by David A. Hayes + * $Id: alias_local.h 122 2008-06-25 06:50:47Z dhayes $ + * All are inclosed in #ifdef _ALIAS_SCTP + * + */ #ifndef _ALIAS_LOCAL_H_ #define _ALIAS_LOCAL_H_ @@ -50,6 +56,16 @@ #include #ifdef _KERNEL +/* if alias_sctp is not required, #define _ALIAS_SCTP should be commented out */ +#ifndef _ALIAS_SCTP +#define _ALIAS_SCTP +#endif +#ifdef _ALIAS_SCTP +#include +#endif +#endif + +#ifdef _KERNEL #include #include #include @@ -147,6 +163,32 @@ struct libalias { struct in_addr true_addr; /* in network byte order. */ u_short true_port; /* in host byte order. */ + /* + * + *alias_sctp code + */ +#ifdef _ALIAS_SCTP + /*counts associations that have progressed to UP and not yet removed */ + int sctpLinkCount; + /*Timing queue for keeping track of association timeouts */ + struct sctp_nat_timer sctpNatTimer; + + /* Size of hash table used in this instance*/ + u_int sctpNatTableSize; +/** + * @brief Local look up table + * + * lookup table of sctp_nat_assoc sorted by l_vtag/l_port + */ + LIST_HEAD(sctpNatTableL, sctp_nat_assoc) *sctpTableLocal; +/** + * @brief Global look up table + * + * lookup table of sctp_nat_assoc sorted by g_vtag/g_port + */ + LIST_HEAD(sctpNatTableG, sctp_nat_assoc) *sctpTableGlobal; +#endif + #ifdef _KERNEL /* * avoid races in libalias: every public function has to use it. @@ -198,6 +240,22 @@ struct libalias { /* Prototypes */ + /* + * + *alias_sctp code + */ +#ifdef _ALIAS_SCTP +/* + * SctpFunction prototypes + * + */ +void AliasSctpInit(struct libalias *la); +void AliasSctpTerm(struct libalias *la); + +int SctpAlias(struct libalias *la, struct ip *ip, int direction); +//int SctpAliasOut(struct libalias *la, struct ip *ip); +#endif + /* * We do not calculate TCP checksums when libalias is a kernel * module, since it has no idea about checksum offloading. Added: user/piso/sys/netinet/libalias/alias_sctp.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/piso/sys/netinet/libalias/alias_sctp.c Sun Dec 28 17:16:32 2008 (r186543) @@ -0,0 +1,2687 @@ +//* $Id$ */ +//#ifndef lint +//static char vcid[] = "$Id$"; +//#endif /* lint */ +/** + * @file alias_sctp.c + * Copyright (c) 2008, Centre for Advanced Internet Architectures + * Swinburne University of Technology, Melbourne, Australia + * (CRICOS number 00111D). + * + * Alias_sctp forms part of the libalias kernel module to handle + * Network Address Translation (NAT) for the SCTP protocol. + * + * This software was developed by David A. Hayes and Jason But + * + * The design is outlined in CAIA technical report number 080618A + * (D. Hayes and J. But, "Alias_sctp Version 0.1: SCTP NAT implementation in IPFW") + * + * Development is part of the CAIA SONATA project, + * proposed by Jason But and Grenville Armitage: + * http://caia.swin.edu.au/urp/sonata/ + * + * + * This project has been made possible in part by a grant from + * the Cisco University Research Program Fund at Community + * Foundation Silicon Valley. + * + * + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The names of the authors, the "Centre for Advanced Internet Architectures" + * and "Swinburne University of Technology" may not be used to endorse + * or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ +/** @mainpage + * Alias_sctp is part of the SONATA (http://caia.swin.edu.au/urp/sonata) project + * to develop and release a BSD licensed implementation of a Network Address + * Translation (NAT) module that supports the Stream Control Transmission + * Protocol (SCTP). + * + * Traditional address and port number look ups are inadequate for SCTP's + * operation due to both processing requirements and issues with multi-homing. + * Alias_sctp integrates with FreeBSD's ipfw/libalias NAT system. + * + * Version 0.2 features include: + * - Support for global multi-homing + * - Support for ASCONF modification from Internet Draft + * (draft-stewart-behave-sctpnat-04, R. Stewart and M. Tuexen, "Stream control + * transmission protocol (SCTP) network address translation," Jul. 2008) to + * provide support for multi-homed privately addressed hosts + * - Support for forwarding of T-flagged packets + * - Generation and delivery of AbortM/ErrorM packets upon detection of NAT + * collisions + * - Per-port forwarding rules + * - Dynamically controllable logging and statistics + * - Dynamic management of timers + * - Dynamic control of hash-table size + */ + +#ifdef _KERNEL +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#else +#include "alias_sctp.h" +#include +#include "alias.h" +#include "alias_local.h" +#include +#include +#endif //#ifdef _KERNEL + +/* ---------------------------------------------------------------------- + * FUNCTION PROTOTYPES + * ---------------------------------------------------------------------- + */ +/* Packet Parsing Functions */ +static int sctp_PktParser(struct libalias *la, int direction, struct ip *pip, + struct sctp_nat_msg *sm, struct sctp_nat_assoc **passoc); +static int GetAsconfVtags(struct libalias *la, struct sctp_nat_msg *sm, + uint32_t *l_vtag, uint32_t *g_vtag, int direction); +static int IsASCONFack(struct libalias *la, struct sctp_nat_msg *sm, int direction); + +static void AddGlobalIPAddresses(struct sctp_nat_msg *sm, struct sctp_nat_assoc *assoc, int direction); +static int Add_Global_Address_to_List(struct sctp_nat_assoc *assoc, struct sctp_GlobalAddress *G_addr); +static void RmGlobalIPAddresses(struct sctp_nat_msg *sm, struct sctp_nat_assoc *assoc, int direction); +static int IsADDorDEL(struct libalias *la, struct sctp_nat_msg *sm, int direction); + +/* State Machine Functions */ +static int ProcessSctpMsg(struct libalias *la, int direction, \ + struct sctp_nat_msg *sm, struct sctp_nat_assoc *assoc); + +static int ID_process(struct libalias *la, int direction,\ + struct sctp_nat_assoc *assoc, struct sctp_nat_msg *sm); +static int INi_process(struct libalias *la, int direction,\ + struct sctp_nat_assoc *assoc, struct sctp_nat_msg *sm); +static int INa_process(struct libalias *la, int direction,\ + struct sctp_nat_assoc *assoc, struct sctp_nat_msg *sm); +static int UP_process(struct libalias *la, int direction,\ + struct sctp_nat_assoc *assoc, struct sctp_nat_msg *sm); +static int CL_process(struct libalias *la, int direction,\ + struct sctp_nat_assoc *assoc, struct sctp_nat_msg *sm); +static void TxAbortErrorM(struct libalias *la, struct sctp_nat_msg *sm,\ + struct sctp_nat_assoc *assoc, int sndrply, int direction); + +/* Hash Table Functions */ +static struct sctp_nat_assoc* +FindSctpLocal(struct libalias *la, struct in_addr l_addr, struct in_addr g_addr, uint32_t l_vtag, uint16_t l_port, uint16_t g_port); +static struct sctp_nat_assoc* +FindSctpGlobal(struct libalias *la, struct in_addr g_addr, uint32_t g_vtag, uint16_t g_port, uint16_t l_port, int *partial_match); +static struct sctp_nat_assoc* +FindSctpGlobalClash(struct libalias *la, struct sctp_nat_assoc *Cassoc); +static struct sctp_nat_assoc* +FindSctpLocalT(struct libalias *la, struct in_addr g_addr, uint32_t l_vtag, uint16_t g_port, uint16_t l_port); +static struct sctp_nat_assoc* +FindSctpGlobalT(struct libalias *la, struct in_addr g_addr, uint32_t g_vtag, uint16_t l_port, uint16_t g_port); + +static int AddSctpAssocLocal(struct libalias *la, struct sctp_nat_assoc *assoc, struct in_addr g_addr); +static int AddSctpAssocGlobal(struct libalias *la, struct sctp_nat_assoc *assoc); +static void RmSctpAssoc(struct libalias *la, struct sctp_nat_assoc *assoc); +static void freeGlobalAddressList(struct sctp_nat_assoc *assoc); + +/* Timer Queue Functions */ +static void sctp_AddTimeOut(struct libalias *la, struct sctp_nat_assoc *assoc); +static void sctp_RmTimeOut(struct libalias *la, struct sctp_nat_assoc *assoc); +static void sctp_ResetTimeOut(struct libalias *la, struct sctp_nat_assoc *assoc, int newexp); +void sctp_CheckTimers(struct libalias *la); + + +/* Logging Functions */ +static void logsctperror(char* errormsg, uint32_t vtag, int error, int direction); +static void logsctpparse(int direction, struct sctp_nat_msg *sm); +static void logsctpassoc(struct sctp_nat_assoc *assoc, char *s); +static void logTimerQ(struct libalias *la); +static void logSctpGlobal(struct libalias *la); +static void logSctpLocal(struct libalias *la); +#ifdef _KERNEL +static void SctpAliasLog(const char *format, ...); +#endif + +/** @defgroup external External code changes and modifications + * + * Some changes have been made to files external to alias_sctp.(c|h). These + * changes are primarily due to code needing to call static functions within + * those files or to perform extra functionality that can only be performed + * within these files. + */ +/** @ingroup external + * @brief Log current statistics for the libalias instance + * + * This function is defined in alias_db.c, since it calls static functions in + * this file *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Mon Dec 29 21:50:51 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4DE5D1065692; Mon, 29 Dec 2008 21:50:51 +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 216878FC0C; Mon, 29 Dec 2008 21:50:51 +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 mBTLoooE067714; Mon, 29 Dec 2008 21:50:50 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBTLooUG067713; Mon, 29 Dec 2008 21:50:50 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200812292150.mBTLooUG067713@svn.freebsd.org> From: Kip Macy Date: Mon, 29 Dec 2008 21:50:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186572 - projects/HEAD_fast_net user/kmacy/HEAD_fast_net X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Dec 2008 21:50:51 -0000 Author: kmacy Date: Mon Dec 29 21:50:50 2008 New Revision: 186572 URL: http://svn.freebsd.org/changeset/base/186572 Log: move repo to personal directory Added: user/kmacy/HEAD_fast_net/ (props changed) - copied from r186571, projects/HEAD_fast_net/ Changes in other areas also in this revision: Deleted: projects/HEAD_fast_net/ From owner-svn-src-user@FreeBSD.ORG Mon Dec 29 22:07:19 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2DBA21065732; Mon, 29 Dec 2008 22:07:19 +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 19ED48FC0C; Mon, 29 Dec 2008 22:07:19 +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 mBTM7IGl068142; Mon, 29 Dec 2008 22:07:18 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBTM7INk068138; Mon, 29 Dec 2008 22:07:18 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200812292207.mBTM7INk068138@svn.freebsd.org> From: Kip Macy Date: Mon, 29 Dec 2008 22:07:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186573 - user/kmacy/HEAD_fast_net/sys/netinet X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Dec 2008 22:07:19 -0000 Author: kmacy Date: Mon Dec 29 22:07:18 2008 New Revision: 186573 URL: http://svn.freebsd.org/changeset/base/186573 Log: cache rtentry in inpcb for connected sockets Modified: user/kmacy/HEAD_fast_net/sys/netinet/in_pcb.c user/kmacy/HEAD_fast_net/sys/netinet/in_pcb.h user/kmacy/HEAD_fast_net/sys/netinet/ip_output.c user/kmacy/HEAD_fast_net/sys/netinet/tcp_usrreq.c Modified: user/kmacy/HEAD_fast_net/sys/netinet/in_pcb.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/netinet/in_pcb.c Mon Dec 29 21:50:50 2008 (r186572) +++ user/kmacy/HEAD_fast_net/sys/netinet/in_pcb.c Mon Dec 29 22:07:18 2008 (r186573) @@ -490,6 +490,39 @@ in_pcbbind_setup(struct inpcb *inp, stru return (0); } +void +in_pcbrtalloc(struct inpcb *inp, in_addr_t faddr, struct route *sro) +{ + struct sockaddr_in *sin; + + INP_WLOCK_ASSERT(inp); + bzero(sro, sizeof(*sro)); + sin = (struct sockaddr_in *)&sro->ro_dst; + sin->sin_family = AF_INET; + sin->sin_len = sizeof(struct sockaddr_in); + sin->sin_addr.s_addr = faddr; + /* + * If route is known our src addr is taken from the i/f, + * else punt. + * + * Find out route to destination. + */ + if ((inp->inp_socket->so_options & SO_DONTROUTE) == 0) { +#ifdef RADIX_MPATH + rtalloc_mpath_fib(sro, ntohl(faddr->s_addr), + inp->inp_inc.inc_fibnum); +#else + in_rtalloc_ign(sro, 0, inp->inp_inc.inc_fibnum); +#endif + } + + if (sro->ro_rt != NULL) { + inp->inp_rt = sro->ro_rt; + inp->inp_vflag |= INP_RT_VALID; + + } +} + /* * Connect from a socket to a specified address. * Both address and port must be specified in argument sin. @@ -502,6 +535,7 @@ in_pcbconnect(struct inpcb *inp, struct u_short lport, fport; in_addr_t laddr, faddr; int anonport, error; + struct route sro; INP_INFO_WLOCK_ASSERT(inp->inp_pcbinfo); INP_WLOCK_ASSERT(inp); @@ -525,6 +559,7 @@ in_pcbconnect(struct inpcb *inp, struct } } + in_pcbrtalloc(inp, faddr, &sro); /* Commit the remaining changes. */ inp->inp_lport = lport; inp->inp_laddr.s_addr = laddr; @@ -869,6 +904,12 @@ in_pcbdisconnect(struct inpcb *inp) INP_INFO_WLOCK_ASSERT(inp->inp_pcbinfo); INP_WLOCK_ASSERT(inp); + if (inp->inp_vflag & INP_RT_VALID) { + RTFREE(inp->inp_rt); + inp->inp_rt = NULL; + inp->inp_vflag &= ~INP_RT_VALID; + } + inp->inp_faddr.s_addr = INADDR_ANY; inp->inp_fport = 0; in_pcbrehash(inp); @@ -906,6 +947,12 @@ in_pcbfree_internal(struct inpcb *inp) INP_INFO_WLOCK_ASSERT(ipi); INP_WLOCK_ASSERT(inp); + if (inp->inp_vflag & INP_RT_VALID) { + RTFREE(inp->inp_rt); + inp->inp_rt = NULL; + inp->inp_vflag &= ~INP_RT_VALID; + } + #ifdef IPSEC if (inp->inp_sp != NULL) ipsec_delete_pcbpolicy(inp); Modified: user/kmacy/HEAD_fast_net/sys/netinet/in_pcb.h ============================================================================== --- user/kmacy/HEAD_fast_net/sys/netinet/in_pcb.h Mon Dec 29 21:50:50 2008 (r186572) +++ user/kmacy/HEAD_fast_net/sys/netinet/in_pcb.h Mon Dec 29 22:07:18 2008 (r186573) @@ -169,7 +169,8 @@ struct inpcb { u_char inp_ip_minttl; /* (i) minimum TTL or drop */ uint32_t inp_ispare1; /* (x) connection id / queue id */ u_int inp_refcount; /* (i) refcount */ - void *inp_pspare[2]; /* (x) rtentry / general use */ + void *inp_pspare[1]; /* L2 information */ + struct rtentry *inp_rt; /* L3 information */ /* Local and foreign ports, local and foreign addr. */ struct in_conninfo inp_inc; /* (i/p) list for PCB's local port */ @@ -324,6 +325,9 @@ struct inpcbinfo { #define INP_RLOCK_ASSERT(inp) rw_assert(&(inp)->inp_lock, RA_RLOCKED) #define INP_WLOCK_ASSERT(inp) rw_assert(&(inp)->inp_lock, RA_WLOCKED) #define INP_UNLOCK_ASSERT(inp) rw_assert(&(inp)->inp_lock, RA_UNLOCKED) +#define INP_TRY_UPGRADE(inp) rw_try_upgrade(&(inp)->inp_lock) +#define INP_DOWNGRADE(inp) rw_downgrade(&(inp)->inp_lock) +#define INP_WLOCKED(inp) rw_wowned(&(inp)->inp_lock) #ifdef _KERNEL /* @@ -395,6 +399,7 @@ void inp_4tuple_get(struct inpcb *inp, #define INP_ONESBCAST 0x10 /* send all-ones broadcast */ #define INP_DROPPED 0x20 /* protocol drop flag */ #define INP_SOCKREF 0x40 /* strong socket reference */ +#define INP_RT_VALID 0x80 /* rtentry is set */ /* * Flags for inp_flag. @@ -487,6 +492,7 @@ void in_pcbdisconnect(struct inpcb *); void in_pcbdrop(struct inpcb *); void in_pcbfree(struct inpcb *); int in_pcbinshash(struct inpcb *); +void in_pcbrtalloc(struct inpcb *inp, in_addr_t faddr, struct route *sro); struct inpcb * in_pcblookup_local(struct inpcbinfo *, struct in_addr, u_short, int, struct ucred *); Modified: user/kmacy/HEAD_fast_net/sys/netinet/ip_output.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/netinet/ip_output.c Mon Dec 29 21:50:50 2008 (r186572) +++ user/kmacy/HEAD_fast_net/sys/netinet/ip_output.c Mon Dec 29 22:07:18 2008 (r186573) @@ -121,11 +121,13 @@ ip_output(struct mbuf *m, struct mbuf *o int hlen = sizeof (struct ip); int mtu; int len, error = 0; + int neednewroute = 0; struct sockaddr_in *dst = NULL; /* keep compiler happy */ struct in_ifaddr *ia = NULL; int isbroadcast, sw_csum; struct route iproute; struct in_addr odst; + struct sockaddr_in *sin; #ifdef IPFIREWALL_FORWARD struct m_tag *fwd_tag = NULL; #endif @@ -139,6 +141,16 @@ ip_output(struct mbuf *m, struct mbuf *o if (inp != NULL) { M_SETFIB(m, inp->inp_inc.inc_fibnum); INP_LOCK_ASSERT(inp); + if ((ro == &iproute) && (inp->inp_vflag & INP_RT_VALID)) { + if (inp->inp_rt->rt_flags & RTF_UP) { + sin = (struct sockaddr_in *)&ro->ro_dst; + sin->sin_family = AF_INET; + sin->sin_len = sizeof(struct sockaddr_in); + sin->sin_addr.s_addr = inp->inp_faddr.s_addr; + ro->ro_rt = inp->inp_rt; + } else + neednewroute = 1; + } } if (opt) { @@ -181,7 +193,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 (inp == NULL || (ro->ro_rt != inp->inp_rt)) + RTFREE(ro->ro_rt); ro->ro_rt = (struct rtentry *)NULL; } #ifdef IPFIREWALL_FORWARD @@ -611,8 +624,20 @@ passout: V_ipstat.ips_fragmented++; done: - if (ro == &iproute && ro->ro_rt) { - RTFREE(ro->ro_rt); + if (ro == &iproute && ro->ro_rt != NULL) { + int wlocked; + + if (inp == NULL || (inp->inp_vflag & INP_RT_VALID) == 0) + RTFREE(ro->ro_rt); + else if (neednewroute && ro->ro_rt != inp->inp_rt) { + wlocked = INP_WLOCKED(inp); + if (!wlocked && INP_TRY_UPGRADE(inp) == 0) + return (error); + RTFREE(inp->inp_rt); + inp->inp_rt = ro->ro_rt; + if (!wlocked) + INP_DOWNGRADE(inp); + } } return (error); bad: Modified: user/kmacy/HEAD_fast_net/sys/netinet/tcp_usrreq.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/netinet/tcp_usrreq.c Mon Dec 29 21:50:50 2008 (r186572) +++ user/kmacy/HEAD_fast_net/sys/netinet/tcp_usrreq.c Mon Dec 29 22:07:18 2008 (r186573) @@ -1077,6 +1077,7 @@ tcp_connect(struct tcpcb *tp, struct soc struct socket *so = inp->inp_socket; INIT_VNET_INET(so->so_vnet); struct in_addr laddr; + struct route sro; u_short lport; int error; @@ -1105,6 +1106,7 @@ tcp_connect(struct tcpcb *tp, struct soc inp->inp_laddr = laddr; in_pcbrehash(inp); + in_pcbrtalloc(inp, inp->inp_faddr.s_addr, &sro); /* * Compute window scaling to request: * Scale to fit into sweet spot. See tcp_syncache.c. From owner-svn-src-user@FreeBSD.ORG Mon Dec 29 22:30:10 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5C28A106566B; Mon, 29 Dec 2008 22:30:10 +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 4614D8FC1D; Mon, 29 Dec 2008 22:30:10 +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 mBTMUADX068609; Mon, 29 Dec 2008 22:30:10 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBTMU84U068570; Mon, 29 Dec 2008 22:30:08 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200812292230.mBTMU84U068570@svn.freebsd.org> From: Kip Macy Date: Mon, 29 Dec 2008 22:30:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186574 - in user/kmacy/HEAD_fast_net/sys: contrib/ipfilter/netinet contrib/pf/net dev/iicbus dev/lmc dev/ppbus net net80211 netatalk netgraph netgraph/atm netinet netinet6 netipx netnatm X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Dec 2008 22:30:10 -0000 Author: kmacy Date: Mon Dec 29 22:30:08 2008 New Revision: 186574 URL: http://svn.freebsd.org/changeset/base/186574 Log: change if_output signature to allow passing cached lle down to L2 Modified: user/kmacy/HEAD_fast_net/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c user/kmacy/HEAD_fast_net/sys/contrib/pf/net/if_pflog.c user/kmacy/HEAD_fast_net/sys/contrib/pf/net/if_pfsync.c user/kmacy/HEAD_fast_net/sys/contrib/pf/net/pf.c user/kmacy/HEAD_fast_net/sys/dev/iicbus/if_ic.c user/kmacy/HEAD_fast_net/sys/dev/lmc/if_lmc.c user/kmacy/HEAD_fast_net/sys/dev/lmc/if_lmc.h user/kmacy/HEAD_fast_net/sys/dev/ppbus/if_plip.c user/kmacy/HEAD_fast_net/sys/net/bpf.c user/kmacy/HEAD_fast_net/sys/net/ethernet.h user/kmacy/HEAD_fast_net/sys/net/if_arc.h user/kmacy/HEAD_fast_net/sys/net/if_arcsubr.c user/kmacy/HEAD_fast_net/sys/net/if_atm.h user/kmacy/HEAD_fast_net/sys/net/if_atmsubr.c user/kmacy/HEAD_fast_net/sys/net/if_disc.c user/kmacy/HEAD_fast_net/sys/net/if_enc.c user/kmacy/HEAD_fast_net/sys/net/if_ethersubr.c user/kmacy/HEAD_fast_net/sys/net/if_faith.c user/kmacy/HEAD_fast_net/sys/net/if_fddisubr.c user/kmacy/HEAD_fast_net/sys/net/if_fwsubr.c user/kmacy/HEAD_fast_net/sys/net/if_gif.c user/kmacy/HEAD_fast_net/sys/net/if_gif.h user/kmacy/HEAD_fast_net/sys/net/if_gre.c user/kmacy/HEAD_fast_net/sys/net/if_iso88025subr.c user/kmacy/HEAD_fast_net/sys/net/if_lagg.c user/kmacy/HEAD_fast_net/sys/net/if_lagg.h user/kmacy/HEAD_fast_net/sys/net/if_loop.c user/kmacy/HEAD_fast_net/sys/net/if_spppsubr.c user/kmacy/HEAD_fast_net/sys/net/if_stf.c user/kmacy/HEAD_fast_net/sys/net/if_tun.c user/kmacy/HEAD_fast_net/sys/net/if_var.h user/kmacy/HEAD_fast_net/sys/net/iso88025.h user/kmacy/HEAD_fast_net/sys/net/route.h user/kmacy/HEAD_fast_net/sys/net80211/ieee80211.c user/kmacy/HEAD_fast_net/sys/net80211/ieee80211_output.c user/kmacy/HEAD_fast_net/sys/net80211/ieee80211_proto.h user/kmacy/HEAD_fast_net/sys/net80211/ieee80211_var.h user/kmacy/HEAD_fast_net/sys/netatalk/aarp.c user/kmacy/HEAD_fast_net/sys/netatalk/ddp_output.c user/kmacy/HEAD_fast_net/sys/netgraph/atm/ng_atm.c user/kmacy/HEAD_fast_net/sys/netgraph/ng_fec.c user/kmacy/HEAD_fast_net/sys/netgraph/ng_gif.c user/kmacy/HEAD_fast_net/sys/netgraph/ng_iface.c user/kmacy/HEAD_fast_net/sys/netinet/if_ether.c user/kmacy/HEAD_fast_net/sys/netinet/ip_carp.c user/kmacy/HEAD_fast_net/sys/netinet/ip_fastfwd.c user/kmacy/HEAD_fast_net/sys/netinet/ip_output.c user/kmacy/HEAD_fast_net/sys/netinet6/in6.h user/kmacy/HEAD_fast_net/sys/netinet6/ip6_mroute.c user/kmacy/HEAD_fast_net/sys/netinet6/nd6.c user/kmacy/HEAD_fast_net/sys/netipx/ipx_outputfl.c user/kmacy/HEAD_fast_net/sys/netnatm/natm.c Modified: user/kmacy/HEAD_fast_net/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c Mon Dec 29 22:07:18 2008 (r186573) +++ user/kmacy/HEAD_fast_net/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c Mon Dec 29 22:30:08 2008 (r186574) @@ -1045,8 +1045,8 @@ frdest_t *fdp; if (!ip->ip_sum) ip->ip_sum = in_cksum(m, hlen); - error = (*ifp->if_output)(ifp, m, (struct sockaddr *)dst, - ro->ro_rt); + bcopy(dst, &ro->ro_dst, sizeof(dst)); + error = (*ifp->if_output)(ifp, m, ro); goto done; } /* @@ -1122,12 +1122,12 @@ frdest_t *fdp; ip->ip_sum = 0; ip->ip_sum = in_cksum(m0, hlen); sendorfree: + bcopy(dst, &ro->ro_dst, sizeof(dst)); for (m = m0; m; m = m0) { m0 = m->m_act; m->m_act = 0; if (error == 0) - error = (*ifp->if_output)(ifp, m, - (struct sockaddr *)dst, ro->ro_rt); + error = (*ifp->if_output)(ifp, m, ro); else FREE_MB_T(m); } Modified: user/kmacy/HEAD_fast_net/sys/contrib/pf/net/if_pflog.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/contrib/pf/net/if_pflog.c Mon Dec 29 22:07:18 2008 (r186573) +++ user/kmacy/HEAD_fast_net/sys/contrib/pf/net/if_pflog.c Mon Dec 29 22:30:08 2008 (r186574) @@ -112,8 +112,7 @@ __FBSDID("$FreeBSD$"); #endif void pflogattach(int); -int pflogoutput(struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *); +int pflogoutput(struct ifnet *, struct mbuf *, struct route *); int pflogioctl(struct ifnet *, u_long, caddr_t); void pflogstart(struct ifnet *); #ifdef __FreeBSD__ @@ -286,8 +285,7 @@ pflogstart(struct ifnet *ifp) } int -pflogoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, - struct rtentry *rt) +pflogoutput(struct ifnet *ifp, struct mbuf *m, struct route *ro) { m_freem(m); return (0); Modified: user/kmacy/HEAD_fast_net/sys/contrib/pf/net/if_pfsync.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/contrib/pf/net/if_pfsync.c Mon Dec 29 22:07:18 2008 (r186573) +++ user/kmacy/HEAD_fast_net/sys/contrib/pf/net/if_pfsync.c Mon Dec 29 22:30:08 2008 (r186574) @@ -151,8 +151,7 @@ int pfsync_insert_net_state(struct pfsyn #ifdef PFSYNC_TDB void pfsync_update_net_tdb(struct pfsync_tdb *); #endif -int pfsyncoutput(struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *); +int pfsyncoutput(struct ifnet *, struct mbuf *, struct route *); int pfsyncioctl(struct ifnet *, u_long, caddr_t); void pfsyncstart(struct ifnet *); @@ -1082,8 +1081,7 @@ done: } int -pfsyncoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, - struct rtentry *rt) +pfsyncoutput(struct ifnet *ifp, struct mbuf *m, struct route *ro) { m_freem(m); return (0); Modified: user/kmacy/HEAD_fast_net/sys/contrib/pf/net/pf.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/contrib/pf/net/pf.c Mon Dec 29 22:07:18 2008 (r186573) +++ user/kmacy/HEAD_fast_net/sys/contrib/pf/net/pf.c Mon Dec 29 22:30:08 2008 (r186574) @@ -6244,8 +6244,9 @@ pf_route(struct mbuf **m, struct pf_rule ip->ip_sum = in_cksum(m0, ip->ip_hl << 2); } } + bcopy(dst, &ro->ro_dst, sizeof(*dst)); PF_UNLOCK(); - error = (*ifp->if_output)(ifp, m0, sintosa(dst), ro->ro_rt); + error = (*ifp->if_output)(ifp, m0, ro); PF_LOCK(); goto done; } @@ -6281,6 +6282,8 @@ pf_route(struct mbuf **m, struct pf_rule } if (ntohs(ip->ip_len) <= ifp->if_mtu) { + struct route ro; + if ((ifp->if_capabilities & IFCAP_CSUM_IPv4) && ifp->if_bridge == NULL) { m0->m_pkthdr.csum_flags |= M_IPV4_CSUM_OUT; @@ -6294,7 +6297,9 @@ pf_route(struct mbuf **m, struct pf_rule V_tcpstat.tcps_outhwcsum++; else if (m0->m_pkthdr.csum_flags & M_UDPV4_CSUM_OUT) V_udpstat.udps_outhwcsum++; - error = (*ifp->if_output)(ifp, m0, sintosa(dst), NULL); + + bcopy(dst, &ro->ro_dst, sizeof(*dst)); + error = (*ifp->if_output)(ifp, m0, ro); goto done; } #endif @@ -6345,9 +6350,11 @@ pf_route(struct mbuf **m, struct pf_rule m0->m_nextpkt = 0; #ifdef __FreeBSD__ if (error == 0) { + bcopy(dst, &ro->ro_dst, sizeof(*dst)); + ro->ro_lle = NULL; + ro->ro_rt = NULL; PF_UNLOCK(); - error = (*ifp->if_output)(ifp, m0, sintosa(dst), - NULL); + error = (*ifp->if_output)(ifp, m0, ro); PF_LOCK(); } else #else Modified: user/kmacy/HEAD_fast_net/sys/dev/iicbus/if_ic.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/dev/iicbus/if_ic.c Mon Dec 29 22:07:18 2008 (r186573) +++ user/kmacy/HEAD_fast_net/sys/dev/iicbus/if_ic.c Mon Dec 29 22:30:08 2008 (r186574) @@ -102,9 +102,7 @@ static int icprobe(device_t); static int icattach(device_t); static int icioctl(struct ifnet *, u_long, caddr_t); -static int icoutput(struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *); - +static int icoutput(struct ifnet *, struct mbuf *, struct route *); static void icintr(device_t, int, char *); static device_method_t ic_methods[] = { @@ -353,8 +351,7 @@ icintr(device_t dev, int event, char *pt * icoutput() */ static int -icoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, - struct rtentry *rt) +icoutput(struct ifnet *ifp, struct mbuf *m, struct route *ro) { struct ic_softc *sc = ifp->if_softc; device_t icdev = sc->ic_dev; @@ -363,6 +360,7 @@ icoutput(struct ifnet *ifp, struct mbuf struct mbuf *mm; u_char *cp; u_int32_t hdr; + struct sockaddr *dst = &ro->ro_dst; /* BPF writes need to be handled specially. */ if (dst->sa_family == AF_UNSPEC) Modified: user/kmacy/HEAD_fast_net/sys/dev/lmc/if_lmc.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/dev/lmc/if_lmc.c Mon Dec 29 22:07:18 2008 (r186573) +++ user/kmacy/HEAD_fast_net/sys/dev/lmc/if_lmc.c Mon Dec 29 22:30:08 2008 (r186574) @@ -114,6 +114,7 @@ # include # include # include +# include # include # include # include @@ -4582,8 +4583,7 @@ lmc_ifnet_start(struct ifnet *ifp) /* RAWIP mode is the only time this is used. */ /* Called from a syscall (user context; no spinlocks). */ static int -lmc_raw_output(struct ifnet *ifp, struct mbuf *m, - struct sockaddr *dst, struct rtentry *rt) +lmc_raw_output(struct ifnet *ifp, struct mbuf *m, struct route *ro) { softc_t *sc = IFP2SC(ifp); int error = 0; Modified: user/kmacy/HEAD_fast_net/sys/dev/lmc/if_lmc.h ============================================================================== --- user/kmacy/HEAD_fast_net/sys/dev/lmc/if_lmc.h Mon Dec 29 22:07:18 2008 (r186573) +++ user/kmacy/HEAD_fast_net/sys/dev/lmc/if_lmc.h Mon Dec 29 22:30:08 2008 (r186574) @@ -1594,8 +1594,7 @@ static void core_watchdog(softc_t *); static int lmc_raw_ioctl(struct ifnet *, u_long, caddr_t); static int lmc_ifnet_ioctl(struct ifnet *, u_long, caddr_t); static void lmc_ifnet_start(struct ifnet *); -static int lmc_raw_output(struct ifnet *, struct mbuf *, - struct sockaddr *, struct rtentry *); +static int lmc_raw_output(struct ifnet *, struct mbuf *, struct route *ro); static void lmc_ifnet_watchdog(struct ifnet *); # ifdef __OpenBSD__ static int ifmedia_change(struct ifnet *); Modified: user/kmacy/HEAD_fast_net/sys/dev/ppbus/if_plip.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/dev/ppbus/if_plip.c Mon Dec 29 22:07:18 2008 (r186573) +++ user/kmacy/HEAD_fast_net/sys/dev/ppbus/if_plip.c Mon Dec 29 22:30:08 2008 (r186574) @@ -99,6 +99,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -168,8 +169,7 @@ static u_char *ctxmith; /* Functions for the lp# interface */ static int lpinittables(void); static int lpioctl(struct ifnet *, u_long, caddr_t); -static int lpoutput(struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *); +static int lpoutput(struct ifnet *, struct mbuf *, struct route *); static void lp_intr(void *); #define DEVTOSOFTC(dev) \ @@ -596,8 +596,7 @@ lpoutbyte(u_char byte, int spin, device_ } static int -lpoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, - struct rtentry *rt) +lpoutput(struct ifnet *ifp, struct mbuf *m, struct route *ro) { struct lp_data *sc = ifp->if_softc; device_t dev = sc->sc_dev; Modified: user/kmacy/HEAD_fast_net/sys/net/bpf.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/bpf.c Mon Dec 29 22:07:18 2008 (r186573) +++ user/kmacy/HEAD_fast_net/sys/net/bpf.c Mon Dec 29 22:30:08 2008 (r186574) @@ -73,6 +73,7 @@ __FBSDID("$FreeBSD$"); #endif #include #include +#include #include #include @@ -822,7 +823,8 @@ bpfwrite(struct cdev *dev, struct uio *u struct mbuf *m, *mc; struct sockaddr dst; int error, hlen; - + struct route ro; + error = devfs_get_cdevpriv((void **)&d); if (error != 0) return (error); @@ -883,7 +885,10 @@ bpfwrite(struct cdev *dev, struct uio *u BPFD_UNLOCK(d); #endif - error = (*ifp->if_output)(ifp, m, &dst, NULL); + bcopy(&dst, &ro.ro_dst, sizeof(dst)); + ro.ro_rt = NULL; + ro.ro_lle = NULL; + error = (*ifp->if_output)(ifp, m, &ro); if (error) d->bd_wdcount++; Modified: user/kmacy/HEAD_fast_net/sys/net/ethernet.h ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/ethernet.h Mon Dec 29 22:07:18 2008 (r186573) +++ user/kmacy/HEAD_fast_net/sys/net/ethernet.h Mon Dec 29 22:30:08 2008 (r186574) @@ -368,6 +368,7 @@ struct mbuf; struct rtentry; struct sockaddr; struct bpf_if; +struct route; extern uint32_t ether_crc32_le(const uint8_t *, size_t); extern uint32_t ether_crc32_be(const uint8_t *, size_t); @@ -375,8 +376,7 @@ extern void ether_demux(struct ifnet *, extern void ether_ifattach(struct ifnet *, const u_int8_t *); extern void ether_ifdetach(struct ifnet *); extern int ether_ioctl(struct ifnet *, u_long, caddr_t); -extern int ether_output(struct ifnet *, - struct mbuf *, struct sockaddr *, struct rtentry *); +extern int ether_output(struct ifnet *, struct mbuf *, struct route *); extern int ether_output_frame(struct ifnet *, struct mbuf *); extern char *ether_sprintf(const u_int8_t *); void ether_vlan_mtap(struct bpf_if *, struct mbuf *, Modified: user/kmacy/HEAD_fast_net/sys/net/if_arc.h ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/if_arc.h Mon Dec 29 22:07:18 2008 (r186573) +++ user/kmacy/HEAD_fast_net/sys/net/if_arc.h Mon Dec 29 22:30:08 2008 (r186574) @@ -132,8 +132,7 @@ void arc_ifdetach(struct ifnet *); void arc_storelladdr(struct ifnet *, u_int8_t); int arc_isphds(u_int8_t); void arc_input(struct ifnet *, struct mbuf *); -int arc_output(struct ifnet *, struct mbuf *, - struct sockaddr *, struct rtentry *); +int arc_output(struct ifnet *, struct mbuf *, struct route *); int arc_ioctl(struct ifnet *, int, caddr_t); void arc_frag_init(struct ifnet *); Modified: user/kmacy/HEAD_fast_net/sys/net/if_arcsubr.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/if_arcsubr.c Mon Dec 29 22:07:18 2008 (r186573) +++ user/kmacy/HEAD_fast_net/sys/net/if_arcsubr.c Mon Dec 29 22:30:08 2008 (r186574) @@ -101,8 +101,7 @@ u_int8_t arcbroadcastaddr = 0; * Assumes that ifp is actually pointer to arccom structure. */ int -arc_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, - struct rtentry *rt0) +arc_output(struct ifnet *ifp, struct mbuf *m, struct route *ro) { struct arc_header *ah; int error; @@ -110,7 +109,9 @@ arc_output(struct ifnet *ifp, struct mbu int loop_copy = 0; int isphds; struct llentry *lle; - + struct sockaddr *dst = &ro->ro_dst; + struct rtentry *rt0 = ro->ro_rt; + if (!((ifp->if_flags & IFF_UP) && (ifp->if_drv_flags & IFF_DRV_RUNNING))) return(ENETDOWN); /* m, m1 aren't initialized yet */ Modified: user/kmacy/HEAD_fast_net/sys/net/if_atm.h ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/if_atm.h Mon Dec 29 22:07:18 2008 (r186573) +++ user/kmacy/HEAD_fast_net/sys/net/if_atm.h Mon Dec 29 22:30:08 2008 (r186574) @@ -292,8 +292,7 @@ void atm_ifattach(struct ifnet *); void atm_ifdetach(struct ifnet *); void atm_input(struct ifnet *, struct atm_pseudohdr *, struct mbuf *, void *); -int atm_output(struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *); +int atm_output(struct ifnet *, struct mbuf *, struct route *); struct atmio_vcctable *atm_getvccs(struct atmio_vcc **, u_int, u_int, struct mtx *, int); Modified: user/kmacy/HEAD_fast_net/sys/net/if_atmsubr.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/if_atmsubr.c Mon Dec 29 22:07:18 2008 (r186573) +++ user/kmacy/HEAD_fast_net/sys/net/if_atmsubr.c Mon Dec 29 22:30:08 2008 (r186574) @@ -122,8 +122,7 @@ MALLOC_DEFINE(M_IFATM, "ifatm", "atm int * rt0 must also be NULL. */ int -atm_output(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst, - struct rtentry *rt0) +atm_output(struct ifnet *ifp, struct mbuf *m0, struct route *ro) { u_int16_t etype = 0; /* if using LLC/SNAP */ int error = 0, sz; @@ -132,6 +131,8 @@ atm_output(struct ifnet *ifp, struct mbu struct atmllc *atmllc; struct atmllc *llc_hdr = NULL; u_int32_t atm_flags; + struct sockaddr *dst = &ro->ro_dst; + struct rtentry *rt0 = ro->ro_rt; #ifdef MAC error = mac_ifnet_check_transmit(ifp, m); Modified: user/kmacy/HEAD_fast_net/sys/net/if_disc.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/if_disc.c Mon Dec 29 22:07:18 2008 (r186573) +++ user/kmacy/HEAD_fast_net/sys/net/if_disc.c Mon Dec 29 22:30:08 2008 (r186574) @@ -65,8 +65,7 @@ struct disc_softc { struct ifnet *sc_ifp; }; -static int discoutput(struct ifnet *, struct mbuf *, - struct sockaddr *, struct rtentry *); +static int discoutput(struct ifnet *, struct mbuf *, struct route *); static void discrtrequest(int, struct rtentry *, struct rt_addrinfo *); static int discioctl(struct ifnet *, u_long, caddr_t); static int disc_clone_create(struct if_clone *, int, caddr_t); @@ -155,13 +154,13 @@ static moduledata_t disc_mod = { DECLARE_MODULE(if_disc, disc_mod, SI_SUB_PSEUDO, SI_ORDER_ANY); static int -discoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, - struct rtentry *rt) +discoutput(struct ifnet *ifp, struct mbuf *m, struct route *ro) { u_int32_t af; + struct sockaddr *dst = &ro->ro_dst; + M_ASSERTPKTHDR(m); - /* BPF writes need to be handled specially. */ if (dst->sa_family == AF_UNSPEC) { bcopy(dst->sa_data, &af, sizeof(af)); Modified: user/kmacy/HEAD_fast_net/sys/net/if_enc.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/if_enc.c Mon Dec 29 22:07:18 2008 (r186573) +++ user/kmacy/HEAD_fast_net/sys/net/if_enc.c Mon Dec 29 22:30:08 2008 (r186574) @@ -84,8 +84,7 @@ struct enc_softc { }; static int enc_ioctl(struct ifnet *, u_long, caddr_t); -static int enc_output(struct ifnet *ifp, struct mbuf *m, - struct sockaddr *dst, struct rtentry *rt); +static int enc_output(struct ifnet *ifp, struct mbuf *m, struct route *ro); static int enc_clone_create(struct if_clone *, int, caddr_t); static void enc_clone_destroy(struct ifnet *); @@ -184,8 +183,7 @@ static moduledata_t enc_mod = { DECLARE_MODULE(enc, enc_mod, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY); static int -enc_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, - struct rtentry *rt) +enc_output(struct ifnet *ifp, struct mbuf *m, struct route *ro) { m_freem(m); return (0); Modified: user/kmacy/HEAD_fast_net/sys/net/if_ethersubr.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/if_ethersubr.c Mon Dec 29 22:07:18 2008 (r186573) +++ user/kmacy/HEAD_fast_net/sys/net/if_ethersubr.c Mon Dec 29 22:30:08 2008 (r186574) @@ -161,8 +161,7 @@ static int ether_ipfw; * packet leaves a multiple of 512 bytes of data in remainder. */ int -ether_output(struct ifnet *ifp, struct mbuf *m, - struct sockaddr *dst, struct rtentry *rt0) +ether_output(struct ifnet *ifp, struct mbuf *m, struct route *ro) { short type; int error, hdrcmplt = 0; @@ -171,8 +170,11 @@ ether_output(struct ifnet *ifp, struct m struct ether_header *eh; struct pf_mtag *t; int loop_copy = 1; + struct sockaddr *dst = &ro->ro_dst; + struct rtentry *rt0 = ro->ro_rt; int hlen; /* link layer header length */ + #ifdef MAC error = mac_ifnet_check_transmit(ifp, m); if (error) Modified: user/kmacy/HEAD_fast_net/sys/net/if_faith.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/if_faith.c Mon Dec 29 22:07:18 2008 (r186573) +++ user/kmacy/HEAD_fast_net/sys/net/if_faith.c Mon Dec 29 22:30:08 2008 (r186574) @@ -87,8 +87,7 @@ struct faith_softc { }; static int faithioctl(struct ifnet *, u_long, caddr_t); -int faithoutput(struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *); +int faithoutput(struct ifnet *, struct mbuf *, struct route *); static void faithrtrequest(int, struct rtentry *, struct rt_addrinfo *); #ifdef INET6 static int faithprefix(struct in6_addr *); @@ -188,14 +187,15 @@ faith_clone_destroy(ifp) } int -faithoutput(ifp, m, dst, rt) +faithoutput(ifp, m, ro) struct ifnet *ifp; struct mbuf *m; - struct sockaddr *dst; - struct rtentry *rt; + struct route *ro; { int isr; u_int32_t af; + struct sockaddr *dst = &ro->ro_dst; + struct rtentry *rt = ro->ro_rt; M_ASSERTPKTHDR(m); Modified: user/kmacy/HEAD_fast_net/sys/net/if_fddisubr.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/if_fddisubr.c Mon Dec 29 22:07:18 2008 (r186573) +++ user/kmacy/HEAD_fast_net/sys/net/if_fddisubr.c Mon Dec 29 22:30:08 2008 (r186574) @@ -97,8 +97,7 @@ static const u_char fddibroadcastaddr[FD static int fddi_resolvemulti(struct ifnet *, struct sockaddr **, struct sockaddr *); -static int fddi_output(struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *); +static int fddi_output(struct ifnet *, struct mbuf *, struct route *); static void fddi_input(struct ifnet *ifp, struct mbuf *m); #define senderr(e) do { error = (e); goto bad; } while (0) @@ -111,17 +110,18 @@ static void fddi_input(struct ifnet *ifp * Assumes that ifp is actually pointer to arpcom structure. */ static int -fddi_output(ifp, m, dst, rt0) +fddi_output(ifp, m, ro) struct ifnet *ifp; struct mbuf *m; - struct sockaddr *dst; - struct rtentry *rt0; + struct route *ro; { u_int16_t type; int loop_copy = 0, error = 0, hdrcmplt = 0; u_char esrc[FDDI_ADDR_LEN], edst[FDDI_ADDR_LEN]; struct fddi_header *fh; struct llentry *lle; + struct sockaddr *dst = &ro->ro_dst; + struct rtentry *rt0 = ro->ro_rt; #ifdef MAC error = mac_ifnet_check_transmit(ifp, m); Modified: user/kmacy/HEAD_fast_net/sys/net/if_fwsubr.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/if_fwsubr.c Mon Dec 29 22:07:18 2008 (r186573) +++ user/kmacy/HEAD_fast_net/sys/net/if_fwsubr.c Mon Dec 29 22:30:08 2008 (r186574) @@ -76,8 +76,7 @@ struct fw_hwaddr firewire_broadcastaddr }; static int -firewire_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, - struct rtentry *rt0) +firewire_output(struct ifnet *ifp, struct mbuf *m, struct route *ro) { struct fw_com *fc = IFP2FWC(ifp); int error, type; @@ -89,8 +88,10 @@ firewire_output(struct ifnet *ifp, struc struct mbuf *mtail; int unicast, dgl, foff; static int next_dgl; - struct llentry *lle; - + struct llentry *lle = ro->ro_lle; + struct rtentry *rt0 = ro->ro_rt; + struct sockaddr *dst = &ro->ro_dst; + #ifdef MAC error = mac_ifnet_check_transmit(ifp, m); if (error) Modified: user/kmacy/HEAD_fast_net/sys/net/if_gif.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/if_gif.c Mon Dec 29 22:07:18 2008 (r186573) +++ user/kmacy/HEAD_fast_net/sys/net/if_gif.c Mon Dec 29 22:30:08 2008 (r186574) @@ -369,17 +369,19 @@ gif_start(struct ifnet *ifp) { struct gif_softc *sc; struct mbuf *m; + struct route ro; sc = ifp->if_softc; - + bcopy(sc->gif_pdst, &ro.ro_dst, sizeof(sc->gif_pdst)); + ro.ro_rt = NULL; + ro.ro_lle = NULL; ifp->if_drv_flags |= IFF_DRV_OACTIVE; for (;;) { IFQ_DEQUEUE(&ifp->if_snd, m); if (m == 0) break; - gif_output(ifp, m, sc->gif_pdst, NULL); - + gif_output(ifp, m, &ro); } ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; @@ -387,11 +389,10 @@ gif_start(struct ifnet *ifp) } int -gif_output(ifp, m, dst, rt) +gif_output(ifp, m, ro) struct ifnet *ifp; struct mbuf *m; - struct sockaddr *dst; - struct rtentry *rt; /* added in net2 */ + struct route *ro; { INIT_VNET_GIF(ifp->if_vnet); struct gif_softc *sc = ifp->if_softc; @@ -399,6 +400,7 @@ gif_output(ifp, m, dst, rt) int error = 0; int gif_called; u_int32_t af; + struct sockaddr *dst = &ro->ro_dst; #ifdef MAC error = mac_ifnet_check_transmit(ifp, m); Modified: user/kmacy/HEAD_fast_net/sys/net/if_gif.h ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/if_gif.h Mon Dec 29 22:07:18 2008 (r186573) +++ user/kmacy/HEAD_fast_net/sys/net/if_gif.h Mon Dec 29 22:30:08 2008 (r186574) @@ -103,8 +103,7 @@ struct etherip_header { /* Prototypes */ void gif_input(struct mbuf *, int, struct ifnet *); -int gif_output(struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *); +int gif_output(struct ifnet *, struct mbuf *, struct route *ro); int gif_ioctl(struct ifnet *, u_long, caddr_t); int gif_set_tunnel(struct ifnet *, struct sockaddr *, struct sockaddr *); void gif_delete_tunnel(struct ifnet *); Modified: user/kmacy/HEAD_fast_net/sys/net/if_gre.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/if_gre.c Mon Dec 29 22:07:18 2008 (r186573) +++ user/kmacy/HEAD_fast_net/sys/net/if_gre.c Mon Dec 29 22:30:08 2008 (r186574) @@ -109,8 +109,7 @@ struct gre_softc_head gre_softc_list; static int gre_clone_create(struct if_clone *, int, caddr_t); static void gre_clone_destroy(struct ifnet *); static int gre_ioctl(struct ifnet *, u_long, caddr_t); -static int gre_output(struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *rt); +static int gre_output(struct ifnet *, struct mbuf *, struct route *); IFC_SIMPLE_DECLARE(gre, 0); @@ -239,8 +238,7 @@ gre_clone_destroy(ifp) * given by sc->g_proto. See also RFC 1701 and RFC 2004 */ static int -gre_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, - struct rtentry *rt) +gre_output(struct ifnet *ifp, struct mbuf *m, struct route *ro) { #ifdef INET6 INIT_VNET_INET(ifp->if_vnet); @@ -255,6 +253,7 @@ gre_output(struct ifnet *ifp, struct mbu struct mobile_h mob_h; u_int32_t af; int extra = 0; + struct sockaddr *dst = &ro->ro_dst; /* * gre may cause infinite recursion calls when misconfigured. Modified: user/kmacy/HEAD_fast_net/sys/net/if_iso88025subr.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/if_iso88025subr.c Mon Dec 29 22:07:18 2008 (r186573) +++ user/kmacy/HEAD_fast_net/sys/net/if_iso88025subr.c Mon Dec 29 22:30:08 2008 (r186574) @@ -232,11 +232,10 @@ iso88025_ioctl(struct ifnet *ifp, int co * ISO88025 encapsulation */ int -iso88025_output(ifp, m, dst, rt0) +iso88025_output(ifp, m, ro) struct ifnet *ifp; struct mbuf *m; - struct sockaddr *dst; - struct rtentry *rt0; + struct route *ro; { u_int16_t snap_type = 0; int loop_copy = 0, error = 0, rif_len = 0; @@ -245,12 +244,16 @@ iso88025_output(ifp, m, dst, rt0) struct iso88025_header gen_th; struct sockaddr_dl *sdl = NULL; struct llentry *lle; + struct sockaddr *dst; + struct rtentry *rt0; #ifdef MAC error = mac_ifnet_check_transmit(ifp, m); if (error) senderr(error); #endif + rt0 = ro->ro_rt; + dst = &ro->ro_dst; if (ifp->if_flags & IFF_MONITOR) senderr(ENETDOWN); @@ -628,8 +631,9 @@ iso88025_input(ifp, m) case LLC_TEST: case LLC_TEST_P: { - struct sockaddr sa; + struct sockaddr *sa; struct arpcom *ac; + struct route ro; struct iso88025_sockaddr_data *th2; int i; u_char c; @@ -646,8 +650,9 @@ iso88025_input(ifp, m) bcopy((caddr_t)IF_LLADDR(ifp), (caddr_t)th->iso88025_dhost, ISO88025_ADDR_LEN); - sa.sa_family = AF_UNSPEC; - sa.sa_len = sizeof(sa); + sa = &ro.ro_dst; + sa->sa_family = AF_UNSPEC; + sa->sa_len = sizeof(*sa); th2 = (struct iso88025_sockaddr_data *)sa.sa_data; for (i = 0; i < ISO88025_ADDR_LEN; i++) { th2->ether_shost[i] = c = th->iso88025_dhost[i]; @@ -657,7 +662,7 @@ iso88025_input(ifp, m) } th2->ac = TR_AC; th2->fc = TR_LLC_FRAME; - ifp->if_output(ifp, m, &sa, NULL); + ifp->if_output(ifp, m, &ro); return; } default: Modified: user/kmacy/HEAD_fast_net/sys/net/if_lagg.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/if_lagg.c Mon Dec 29 22:07:18 2008 (r186573) +++ user/kmacy/HEAD_fast_net/sys/net/if_lagg.c Mon Dec 29 22:30:08 2008 (r186574) @@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #ifdef INET #include @@ -92,8 +93,7 @@ static struct mbuf *lagg_input(struct if static void lagg_linkstate(struct lagg_softc *); static void lagg_port_state(struct ifnet *, int); static int lagg_port_ioctl(struct ifnet *, u_long, caddr_t); -static int lagg_port_output(struct ifnet *, struct mbuf *, - struct sockaddr *, struct rtentry *); +static int lagg_port_output(struct ifnet *, struct mbuf *, struct route *ro); static void lagg_port_ifdetach(void *arg __unused, struct ifnet *); static int lagg_port_checkstacking(struct lagg_softc *); static void lagg_port2req(struct lagg_port *, struct lagg_reqport *); @@ -675,11 +675,11 @@ fallback: } static int -lagg_port_output(struct ifnet *ifp, struct mbuf *m, - struct sockaddr *dst, struct rtentry *rt0) +lagg_port_output(struct ifnet *ifp, struct mbuf *m, struct route *ro) { struct lagg_port *lp = ifp->if_lagg; struct ether_header *eh; + struct sockaddr *dst = &ro->ro_dst; short type = 0; switch (dst->sa_family) { @@ -696,7 +696,7 @@ lagg_port_output(struct ifnet *ifp, stru */ switch (ntohs(type)) { case ETHERTYPE_PAE: /* EAPOL PAE/802.1x */ - return ((*lp->lp_output)(ifp, m, dst, rt0)); + return ((*lp->lp_output)(ifp, m, ro)); } /* drop any other frames */ Modified: user/kmacy/HEAD_fast_net/sys/net/if_lagg.h ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/if_lagg.h Mon Dec 29 22:07:18 2008 (r186573) +++ user/kmacy/HEAD_fast_net/sys/net/if_lagg.h Mon Dec 29 22:30:08 2008 (r186574) @@ -217,8 +217,7 @@ struct lagg_port { /* Redirected callbacks */ int (*lp_ioctl)(struct ifnet *, u_long, caddr_t); - int (*lp_output)(struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *); + int (*lp_output)(struct ifnet *, struct mbuf *, struct route *); SLIST_ENTRY(lagg_port) lp_entries; }; Modified: user/kmacy/HEAD_fast_net/sys/net/if_loop.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/if_loop.c Mon Dec 29 22:07:18 2008 (r186573) +++ user/kmacy/HEAD_fast_net/sys/net/if_loop.c Mon Dec 29 22:30:08 2008 (r186574) @@ -92,8 +92,7 @@ int loioctl(struct ifnet *, u_long, caddr_t); static void lortrequest(int, struct rtentry *, struct rt_addrinfo *); -int looutput(struct ifnet *ifp, struct mbuf *m, - struct sockaddr *dst, struct rtentry *rt); +int looutput(struct ifnet *ifp, struct mbuf *m, struct route *ro); static int lo_clone_create(struct if_clone *, int, caddr_t); static void lo_clone_destroy(struct ifnet *); @@ -172,10 +171,11 @@ static moduledata_t loop_mod = { DECLARE_MODULE(loop, loop_mod, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY); int -looutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, - struct rtentry *rt) +looutput(struct ifnet *ifp, struct mbuf *m, struct route *ro) { u_int32_t af; + struct sockaddr *dst = &ro->ro_dst; + struct rtentry *rt = ro->ro_rt; M_ASSERTPKTHDR(m); /* check if we have the packet header */ Modified: user/kmacy/HEAD_fast_net/sys/net/if_spppsubr.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/if_spppsubr.c Mon Dec 29 22:07:18 2008 (r186573) +++ user/kmacy/HEAD_fast_net/sys/net/if_spppsubr.c Mon Dec 29 22:30:08 2008 (r186574) @@ -277,9 +277,7 @@ static const u_short interactive_ports[8 struct ifnet *ifp = SP2IFP(sp); \ int debug = ifp->if_flags & IFF_DEBUG -static int sppp_output(struct ifnet *ifp, struct mbuf *m, - struct sockaddr *dst, struct rtentry *rt); - +static int sppp_output(struct ifnet *ifp, struct mbuf *m, struct route *ro); static void sppp_cisco_send(struct sppp *sp, int type, long par1, long par2); static void sppp_cisco_input(struct sppp *sp, struct mbuf *m); @@ -800,8 +798,7 @@ sppp_ifstart(struct ifnet *ifp) * Enqueue transmit packet. */ static int -sppp_output(struct ifnet *ifp, struct mbuf *m, - struct sockaddr *dst, struct rtentry *rt) +sppp_output(struct ifnet *ifp, struct mbuf *m, struct route *ro) { struct sppp *sp = IFP2SP(ifp); struct ppp_header *h; @@ -811,6 +808,7 @@ sppp_output(struct ifnet *ifp, struct mb int ipproto = PPP_IP; #endif int debug = ifp->if_flags & IFF_DEBUG; + struct sockaddr *dst = &ro->ro_dst; s = splimp(); SPPP_LOCK(sp); Modified: user/kmacy/HEAD_fast_net/sys/net/if_stf.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/if_stf.c Mon Dec 29 22:07:18 2008 (r186573) +++ user/kmacy/HEAD_fast_net/sys/net/if_stf.c Mon Dec 29 22:30:08 2008 (r186574) @@ -177,8 +177,7 @@ static char *stfnames[] = {"stf0", "stf" static int stfmodevent(module_t, int, void *); static int stf_encapcheck(const struct mbuf *, int, int, void *); static struct in6_ifaddr *stf_getsrcifa6(struct ifnet *); -static int stf_output(struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *); +static int stf_output(struct ifnet *, struct mbuf *, struct route *); static int isrfc1918addr(struct in_addr *); static int stf_checkaddr4(struct stf_softc *, struct in_addr *, struct ifnet *); @@ -403,11 +402,10 @@ stf_getsrcifa6(ifp) } static int -stf_output(ifp, m, dst, rt) +stf_output(ifp, m, ro) struct ifnet *ifp; struct mbuf *m; - struct sockaddr *dst; - struct rtentry *rt; + struct route *ro; { struct stf_softc *sc; struct sockaddr_in6 *dst6; @@ -415,6 +413,7 @@ stf_output(ifp, m, dst, rt) struct in_addr in4; caddr_t ptr; struct sockaddr_in *dst4; + struct sockaddr *dst; u_int8_t tos; struct ip *ip; struct ip6_hdr *ip6; @@ -431,6 +430,7 @@ stf_output(ifp, m, dst, rt) #endif sc = ifp->if_softc; + dst = &ro->ro_dst; dst6 = (struct sockaddr_in6 *)dst; /* just in case */ Modified: user/kmacy/HEAD_fast_net/sys/net/if_tun.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/if_tun.c Mon Dec 29 22:07:18 2008 (r186573) +++ user/kmacy/HEAD_fast_net/sys/net/if_tun.c Mon Dec 29 22:30:08 2008 (r186574) @@ -128,8 +128,7 @@ static void tuncreate(const char *name, static int tunifioctl(struct ifnet *, u_long, caddr_t); static int tuninit(struct ifnet *); static int tunmodevent(module_t, int, void *); -static int tunoutput(struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *rt); +static int tunoutput(struct ifnet *, struct mbuf *, struct route *ro); static void tunstart(struct ifnet *); static int tun_clone_create(struct if_clone *, int, caddr_t); @@ -590,14 +589,14 @@ static int tunoutput( struct ifnet *ifp, struct mbuf *m0, - struct sockaddr *dst, - struct rtentry *rt) -{ + struct route *ro) +{ struct tun_softc *tp = ifp->if_softc; u_short cached_tun_flags; int error; u_int32_t af; - + struct sockaddr *dst = &ro->ro_dst; + TUNDEBUG (ifp, "tunoutput\n"); #ifdef MAC Modified: user/kmacy/HEAD_fast_net/sys/net/if_var.h ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/if_var.h Mon Dec 29 22:07:18 2008 (r186573) +++ user/kmacy/HEAD_fast_net/sys/net/if_var.h Mon Dec 29 22:30:08 2008 (r186574) @@ -70,6 +70,7 @@ struct socket; struct ether_header; struct carp_if; struct ifvlantrunk; +struct route; #endif #include /* get TAILQ macros */ @@ -148,8 +149,7 @@ struct ifnet { int if_amcount; /* number of all-multicast requests */ /* procedure handles */ int (*if_output) /* output routine (enqueue) */ - (struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *); + (struct ifnet *, struct mbuf *, struct route *); void (*if_input) /* input routine (from h/w driver) */ (struct ifnet *, struct mbuf *); void (*if_start) /* initiate output routine */ @@ -162,6 +162,10 @@ struct ifnet { (void *); int (*if_resolvemulti) /* validate/resolve multicast */ (struct ifnet *, struct sockaddr **, struct sockaddr *); + void (*if_qflush) /* flush any queues */ + (struct ifnet *); + int (*if_transmit) /* initiate output routine */ + (struct ifnet *, struct mbuf *); struct ifaddr *if_addr; /* pointer to link-level address */ void *if_llsoftc; /* link layer softc */ int if_drv_flags; /* driver-managed status flags */ @@ -188,10 +192,6 @@ struct ifnet { void *if_pf_kif; void *if_lagg; /* lagg glue */ void *if_pspare[8]; /* TOE 3; vimage 3; general use 4 */ - void (*if_qflush) /* flush any queues */ - (struct ifnet *); - int (*if_transmit) /* initiate output routine */ - (struct ifnet *, struct mbuf *); int if_ispare[2]; /* general use 2 */ }; Modified: user/kmacy/HEAD_fast_net/sys/net/iso88025.h ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/iso88025.h Mon Dec 29 22:07:18 2008 (r186573) +++ user/kmacy/HEAD_fast_net/sys/net/iso88025.h Mon Dec 29 22:30:08 2008 (r186574) @@ -165,8 +165,7 @@ struct iso88025_addr { void iso88025_ifattach (struct ifnet *, const u_int8_t *, int); void iso88025_ifdetach (struct ifnet *, int); int iso88025_ioctl (struct ifnet *, int , caddr_t ); -int iso88025_output (struct ifnet *, struct mbuf *, struct sockaddr *, - struct rtentry *); +int iso88025_output (struct ifnet *, struct mbuf *, struct route *ro); void iso88025_input (struct ifnet *, struct mbuf *); #endif Modified: user/kmacy/HEAD_fast_net/sys/net/route.h ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/route.h Mon Dec 29 22:07:18 2008 (r186573) +++ user/kmacy/HEAD_fast_net/sys/net/route.h Mon Dec 29 22:30:08 2008 (r186574) @@ -41,12 +41,14 @@ */ /* - * A route consists of a destination address and a reference - * to a routing entry. These are often held by protocols - * in their control blocks, e.g. inpcb. + * A route consists of a destination address, a reference + * to a routing entry, and a reference to an llentry. + * These are often held by protocols in their control + * blocks, e.g. inpcb. */ struct route { struct rtentry *ro_rt; + struct llentry *ro_lle; struct sockaddr ro_dst; }; Modified: user/kmacy/HEAD_fast_net/sys/net80211/ieee80211.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net80211/ieee80211.c Mon Dec 29 22:07:18 2008 (r186573) +++ user/kmacy/HEAD_fast_net/sys/net80211/ieee80211.c Mon Dec 29 22:30:08 2008 (r186574) @@ -190,8 +190,7 @@ null_update_promisc(struct ifnet *ifp) } static int -null_output(struct ifnet *ifp, struct mbuf *m, - struct sockaddr *dst, struct rtentry *rt0) +null_output(struct ifnet *ifp, struct mbuf *m, struct route *ro) { if_printf(ifp, "discard raw packet\n"); m_freem(m); Modified: user/kmacy/HEAD_fast_net/sys/net80211/ieee80211_output.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net80211/ieee80211_output.c Mon Dec 29 22:07:18 2008 (r186573) +++ user/kmacy/HEAD_fast_net/sys/net80211/ieee80211_output.c Mon Dec 29 22:30:08 2008 (r186574) @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -286,13 +287,13 @@ ieee80211_start(struct ifnet *ifp) * will go away when the virtual ap support comes in. */ int -ieee80211_output(struct ifnet *ifp, struct mbuf *m, - struct sockaddr *dst, struct rtentry *rt0) +ieee80211_output(struct ifnet *ifp, struct mbuf *m, struct route *ro) { #define senderr(e) do { error = (e); goto bad;} while (0) struct ieee80211_node *ni = NULL; struct ieee80211vap *vap; struct ieee80211_frame *wh; + struct sockaddr *dst = &ro->ro_dst; int error; if (ifp->if_drv_flags & IFF_DRV_OACTIVE) { @@ -313,7 +314,7 @@ ieee80211_output(struct ifnet *ifp, stru * a raw 802.11 frame. */ if (dst->sa_family != AF_IEEE80211) - return vap->iv_output(ifp, m, dst, rt0); + return vap->iv_output(ifp, m, ro); #ifdef MAC error = mac_check_ifnet_transmit(ifp, m); if (error) Modified: user/kmacy/HEAD_fast_net/sys/net80211/ieee80211_proto.h ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net80211/ieee80211_proto.h Mon Dec 29 22:07:18 2008 (r186573) +++ user/kmacy/HEAD_fast_net/sys/net80211/ieee80211_proto.h Mon Dec 29 22:30:08 2008 (r186574) @@ -69,8 +69,7 @@ int ieee80211_mgmt_output(struct ieee802 struct ieee80211_bpf_params *); int ieee80211_raw_xmit(struct ieee80211_node *, struct mbuf *, const struct ieee80211_bpf_params *); -int ieee80211_output(struct ifnet *, struct mbuf *, - struct sockaddr *, struct rtentry *); +int ieee80211_output(struct ifnet *, struct mbuf *, struct route *ro); void ieee80211_start(struct ifnet *); int ieee80211_send_nulldata(struct ieee80211_node *); int ieee80211_classify(struct ieee80211_node *, struct mbuf *m); Modified: user/kmacy/HEAD_fast_net/sys/net80211/ieee80211_var.h ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net80211/ieee80211_var.h Mon Dec 29 22:07:18 2008 (r186573) +++ user/kmacy/HEAD_fast_net/sys/net80211/ieee80211_var.h Mon Dec 29 22:30:08 2008 (r186574) @@ -418,7 +418,7 @@ struct ieee80211vap { enum ieee80211_state, int); /* 802.3 output method for raw frame xmit */ int (*iv_output)(struct ifnet *, struct mbuf *, - struct sockaddr *, struct rtentry *); + struct route *); }; MALLOC_DECLARE(M_80211_VAP); Modified: user/kmacy/HEAD_fast_net/sys/netatalk/aarp.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/netatalk/aarp.c Mon Dec 29 22:07:18 2008 (r186573) +++ user/kmacy/HEAD_fast_net/sys/netatalk/aarp.c Mon Dec 29 22:30:08 2008 (r186574) @@ -62,6 +62,7 @@ #include #include +#include #include #undef s_net @@ -170,8 +171,12 @@ aarpwhohas(struct ifnet *ifp, struct soc struct ether_aarp *ea; struct at_ifaddr *aa; struct llc *llc; - struct sockaddr sa; - + struct sockaddr *sa; + struct route ro; + sa = &ro.ro_dst; + *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Mon Dec 29 22:36:24 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7B9081065673; Mon, 29 Dec 2008 22:36:24 +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 68A068FC29; Mon, 29 Dec 2008 22:36:24 +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 mBTMaOXG068759; Mon, 29 Dec 2008 22:36:24 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBTMaOuS068756; Mon, 29 Dec 2008 22:36:24 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200812292236.mBTMaOuS068756@svn.freebsd.org> From: Kip Macy Date: Mon, 29 Dec 2008 22:36:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186575 - user/kmacy/HEAD_fast_net/sys/netinet X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Dec 2008 22:36:25 -0000 Author: kmacy Date: Mon Dec 29 22:36:23 2008 New Revision: 186575 URL: http://svn.freebsd.org/changeset/base/186575 Log: - add cached llentry to inpcb - reduce header pollution by removing net/route.h include from in_pcb.h Modified: user/kmacy/HEAD_fast_net/sys/netinet/in_pcb.h user/kmacy/HEAD_fast_net/sys/netinet/tcp_hostcache.c user/kmacy/HEAD_fast_net/sys/netinet/tcp_offload.c Modified: user/kmacy/HEAD_fast_net/sys/netinet/in_pcb.h ============================================================================== --- user/kmacy/HEAD_fast_net/sys/netinet/in_pcb.h Mon Dec 29 22:30:08 2008 (r186574) +++ user/kmacy/HEAD_fast_net/sys/netinet/in_pcb.h Mon Dec 29 22:36:23 2008 (r186575) @@ -39,8 +39,6 @@ #include #include -#include - #ifdef _KERNEL #include #endif @@ -49,6 +47,10 @@ #define in6p_sp inp_sp /* for KAME src sync over BSD*'s */ struct inpcbpolicy; +struct rtentry; +struct llentry; +struct route; + /* * struct inpcb is the common protocol control block structure used in most * IP transport protocols. @@ -169,8 +171,8 @@ struct inpcb { u_char inp_ip_minttl; /* (i) minimum TTL or drop */ uint32_t inp_ispare1; /* (x) connection id / queue id */ u_int inp_refcount; /* (i) refcount */ - void *inp_pspare[1]; /* L2 information */ - struct rtentry *inp_rt; /* L3 information */ + struct llentry *inp_lle; /* L2 information */ + struct rtentry *inp_rt; /* L3 information */ /* Local and foreign ports, local and foreign addr. */ struct in_conninfo inp_inc; /* (i/p) list for PCB's local port */ Modified: user/kmacy/HEAD_fast_net/sys/netinet/tcp_hostcache.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/netinet/tcp_hostcache.c Mon Dec 29 22:30:08 2008 (r186574) +++ user/kmacy/HEAD_fast_net/sys/netinet/tcp_hostcache.c Mon Dec 29 22:36:23 2008 (r186575) @@ -79,6 +79,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include Modified: user/kmacy/HEAD_fast_net/sys/netinet/tcp_offload.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/netinet/tcp_offload.c Mon Dec 29 22:30:08 2008 (r186574) +++ user/kmacy/HEAD_fast_net/sys/netinet/tcp_offload.c Mon Dec 29 22:36:23 2008 (r186575) @@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include From owner-svn-src-user@FreeBSD.ORG Mon Dec 29 23:31:05 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 73A4C106564A; Mon, 29 Dec 2008 23:31:05 +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 630A68FC14; Mon, 29 Dec 2008 23:31:05 +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 mBTNV558069764; Mon, 29 Dec 2008 23:31:05 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBTNV5gu069760; Mon, 29 Dec 2008 23:31:05 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200812292331.mBTNV5gu069760@svn.freebsd.org> From: Kip Macy Date: Mon, 29 Dec 2008 23:31:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186576 - user/kmacy/HEAD_fast_net/sys/netinet X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Dec 2008 23:31:05 -0000 Author: kmacy Date: Mon Dec 29 23:31:04 2008 New Revision: 186576 URL: http://svn.freebsd.org/changeset/base/186576 Log: install cached llentry in the inpcb and then pass down to ether_output in the struct route Modified: user/kmacy/HEAD_fast_net/sys/netinet/if_ether.c user/kmacy/HEAD_fast_net/sys/netinet/in_pcb.c user/kmacy/HEAD_fast_net/sys/netinet/in_pcb.h user/kmacy/HEAD_fast_net/sys/netinet/ip_output.c Modified: user/kmacy/HEAD_fast_net/sys/netinet/if_ether.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/netinet/if_ether.c Mon Dec 29 22:36:23 2008 (r186575) +++ user/kmacy/HEAD_fast_net/sys/netinet/if_ether.c Mon Dec 29 23:31:04 2008 (r186576) @@ -80,7 +80,6 @@ __FBSDID("$FreeBSD$"); #define SIN(s) ((struct sockaddr_in *)s) #define SDL(s) ((struct sockaddr_dl *)s) -#define LLTABLE(ifp) ((struct lltable *)(ifp)->if_afdata[AF_INET]) SYSCTL_DECL(_net_link_ether); SYSCTL_NODE(_net_link_ether, PF_INET, inet, CTLFLAG_RW, 0, ""); Modified: user/kmacy/HEAD_fast_net/sys/netinet/in_pcb.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/netinet/in_pcb.c Mon Dec 29 22:36:23 2008 (r186575) +++ user/kmacy/HEAD_fast_net/sys/netinet/in_pcb.c Mon Dec 29 23:31:04 2008 (r186576) @@ -62,6 +62,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -494,6 +495,11 @@ void in_pcbrtalloc(struct inpcb *inp, in_addr_t faddr, struct route *sro) { struct sockaddr_in *sin; + struct sockaddr *dst; + struct llentry *la; + struct rtentry *rt; + struct ifnet *ifp; + int flags = LLE_EXCLUSIVE; INP_WLOCK_ASSERT(inp); bzero(sro, sizeof(*sro)); @@ -516,11 +522,39 @@ in_pcbrtalloc(struct inpcb *inp, in_addr #endif } - if (sro->ro_rt != NULL) { - inp->inp_rt = sro->ro_rt; - inp->inp_vflag |= INP_RT_VALID; + rt = sro->ro_rt; + if (rt == NULL) + return; + + inp->inp_rt = rt; + inp->inp_vflag |= INP_RT_VALID; + if (rt->rt_ifp == NULL) + return; + + ifp = rt->rt_ifp; + dst = &sro->ro_dst; + if (rt->rt_flags & RTF_GATEWAY) + dst = rt->rt_gateway; + + IF_AFDATA_RLOCK(ifp); + la = lla_lookup(LLTABLE(ifp), flags, dst); + IF_AFDATA_RUNLOCK(ifp); + if ((la == NULL) && + (ifp->if_flags & (IFF_NOARP | IFF_STATICARP)) == 0) { + flags |= (LLE_CREATE | LLE_EXCLUSIVE); + IF_AFDATA_WLOCK(ifp); + la = lla_lookup(LLTABLE(ifp), flags, dst); + IF_AFDATA_WUNLOCK(ifp); } + if (la == NULL) + return; + + LLE_ADDREF(la); + LLE_WUNLOCK(la); + + inp->inp_lle = la; + inp->inp_flags |= INP_LLE_VALID; } /* @@ -905,9 +939,14 @@ in_pcbdisconnect(struct inpcb *inp) INP_WLOCK_ASSERT(inp); if (inp->inp_vflag & INP_RT_VALID) { + inp->inp_vflag &= ~INP_RT_VALID; RTFREE(inp->inp_rt); inp->inp_rt = NULL; - inp->inp_vflag &= ~INP_RT_VALID; + } + if (inp->inp_flags & INP_LLE_VALID) { + inp->inp_flags &= ~INP_LLE_VALID; + LLE_FREE(inp->inp_lle); + inp->inp_lle = NULL; } inp->inp_faddr.s_addr = INADDR_ANY; @@ -948,11 +987,16 @@ in_pcbfree_internal(struct inpcb *inp) INP_WLOCK_ASSERT(inp); if (inp->inp_vflag & INP_RT_VALID) { + inp->inp_vflag &= ~INP_RT_VALID; RTFREE(inp->inp_rt); inp->inp_rt = NULL; - inp->inp_vflag &= ~INP_RT_VALID; } - + if (inp->inp_flags & INP_LLE_VALID) { + inp->inp_flags &= ~INP_LLE_VALID; + LLE_FREE(inp->inp_lle); + inp->inp_lle = NULL; + } + #ifdef IPSEC if (inp->inp_sp != NULL) ipsec_delete_pcbpolicy(inp); Modified: user/kmacy/HEAD_fast_net/sys/netinet/in_pcb.h ============================================================================== --- user/kmacy/HEAD_fast_net/sys/netinet/in_pcb.h Mon Dec 29 22:36:23 2008 (r186575) +++ user/kmacy/HEAD_fast_net/sys/netinet/in_pcb.h Mon Dec 29 23:31:04 2008 (r186576) @@ -418,6 +418,7 @@ void inp_4tuple_get(struct inpcb *inp, #define INP_FAITH 0x200 /* accept FAITH'ed connections */ #define INP_RECVTTL 0x400 /* receive incoming IP TTL */ #define INP_DONTFRAG 0x800 /* don't fragment packet */ +#define INP_LLE_VALID 0x1000 /* L2 entry is set */ #define IN6P_IPV6_V6ONLY 0x008000 /* restrict AF_INET6 socket for v6 */ Modified: user/kmacy/HEAD_fast_net/sys/netinet/ip_output.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/netinet/ip_output.c Mon Dec 29 22:36:23 2008 (r186575) +++ user/kmacy/HEAD_fast_net/sys/netinet/ip_output.c Mon Dec 29 23:31:04 2008 (r186576) @@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -121,7 +122,7 @@ ip_output(struct mbuf *m, struct mbuf *o int hlen = sizeof (struct ip); int mtu; int len, error = 0; - int neednewroute = 0; + int neednewroute = 0, neednewlle = 0; struct sockaddr_in *dst = NULL; /* keep compiler happy */ struct in_ifaddr *ia = NULL; int isbroadcast, sw_csum; @@ -150,7 +151,13 @@ ip_output(struct mbuf *m, struct mbuf *o ro->ro_rt = inp->inp_rt; } else neednewroute = 1; - } + } + if ((ro == &iproute) && (inp->inp_flags & INP_LLE_VALID)) { + if (inp->inp_lle->la_flags & LLE_VALID) { + ro->ro_lle = inp->inp_lle; + } else + neednewlle = 1; + } } if (opt) { @@ -625,19 +632,44 @@ passout: done: if (ro == &iproute && ro->ro_rt != NULL) { int wlocked; - + struct llentry *la; + + wlocked = INP_WLOCKED(inp); if (inp == NULL || (inp->inp_vflag & INP_RT_VALID) == 0) - RTFREE(ro->ro_rt); + RTFREE(ro->ro_rt); else if (neednewroute && ro->ro_rt != inp->inp_rt) { - wlocked = INP_WLOCKED(inp); if (!wlocked && INP_TRY_UPGRADE(inp) == 0) return (error); RTFREE(inp->inp_rt); inp->inp_rt = ro->ro_rt; - if (!wlocked) - INP_DOWNGRADE(inp); + + } + if (neednewlle) { + if (!wlocked && INP_TRY_UPGRADE(inp) == 0) + return (error); + IF_AFDATA_RLOCK(ifp); + la = lla_lookup(LLTABLE(ifp), LLE_EXCLUSIVE, + (struct sockaddr *)dst); + IF_AFDATA_RUNLOCK(ifp); + if ((la == NULL) && + (ifp->if_flags & (IFF_NOARP | IFF_STATICARP)) == 0) { + IF_AFDATA_WLOCK(ifp); + la = lla_lookup(LLTABLE(ifp), + (LLE_CREATE | LLE_EXCLUSIVE), + (struct sockaddr *)dst); + IF_AFDATA_WUNLOCK(ifp); + } + if (la != NULL) { + LLE_FREE(inp->inp_lle); + LLE_ADDREF(la); + LLE_WUNLOCK(la); + inp->inp_lle = la; + } } + if (!wlocked) + INP_DOWNGRADE(inp); } + return (error); bad: m_freem(m); From owner-svn-src-user@FreeBSD.ORG Mon Dec 29 23:41:13 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 73054106566B; Mon, 29 Dec 2008 23:41:13 +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 62FC68FC16; Mon, 29 Dec 2008 23:41:13 +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 mBTNfDa2069988; Mon, 29 Dec 2008 23:41:13 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBTNfDfi069986; Mon, 29 Dec 2008 23:41:13 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200812292341.mBTNfDfi069986@svn.freebsd.org> From: Kip Macy Date: Mon, 29 Dec 2008 23:41:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186577 - user/kmacy/HEAD_fast_net/sys/net X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Dec 2008 23:41:13 -0000 Author: kmacy Date: Mon Dec 29 23:41:12 2008 New Revision: 186577 URL: http://svn.freebsd.org/changeset/base/186577 Log: use cached lle where possible Modified: user/kmacy/HEAD_fast_net/sys/net/if_ethersubr.c user/kmacy/HEAD_fast_net/sys/net/if_var.h Modified: user/kmacy/HEAD_fast_net/sys/net/if_ethersubr.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/if_ethersubr.c Mon Dec 29 23:31:04 2008 (r186576) +++ user/kmacy/HEAD_fast_net/sys/net/if_ethersubr.c Mon Dec 29 23:41:12 2008 (r186577) @@ -164,9 +164,9 @@ int ether_output(struct ifnet *ifp, struct mbuf *m, struct route *ro) { short type; - int error, hdrcmplt = 0; + int error = 0, hdrcmplt = 0; u_char esrc[ETHER_ADDR_LEN], edst[ETHER_ADDR_LEN]; - struct llentry *lle = NULL; + struct llentry *lle = ro->ro_lle; struct ether_header *eh; struct pf_mtag *t; int loop_copy = 1; @@ -192,7 +192,10 @@ ether_output(struct ifnet *ifp, struct m switch (dst->sa_family) { #ifdef INET case AF_INET: - error = arpresolve(ifp, rt0, m, dst, edst, &lle); + if (lle != NULL && (lle->la_flags & LLE_VALID)) + memcpy(edst, &lle->ll_addr.mac16, ETHER_ADDR_LEN); + else + error = arpresolve(ifp, rt0, m, dst, edst, &lle); if (error) return (error == EWOULDBLOCK ? 0 : error); type = htons(ETHERTYPE_IP); @@ -227,7 +230,10 @@ ether_output(struct ifnet *ifp, struct m #endif #ifdef INET6 case AF_INET6: - error = nd6_storelladdr(ifp, m, dst, (u_char *)edst, &lle); + if (lle != NULL && (lle->la_flags & LLE_VALID)) + memcpy(edst, &lle->ll_addr.mac16, ETHER_ADDR_LEN); + else + error = nd6_storelladdr(ifp, m, dst, (u_char *)edst, &lle); if (error) return error; type = htons(ETHERTYPE_IPV6); Modified: user/kmacy/HEAD_fast_net/sys/net/if_var.h ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/if_var.h Mon Dec 29 23:31:04 2008 (r186576) +++ user/kmacy/HEAD_fast_net/sys/net/if_var.h Mon Dec 29 23:41:12 2008 (r186577) @@ -664,6 +664,8 @@ struct ifmultiaddr { }; #ifdef _KERNEL +#define LLTABLE(ifp) ((struct lltable *)(ifp)->if_afdata[AF_INET]) + #define IFAFREE(ifa) \ do { \ IFA_LOCK(ifa); \ From owner-svn-src-user@FreeBSD.ORG Tue Dec 30 00:15:13 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 012D51065672; Tue, 30 Dec 2008 00:15:13 +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 E59518FC37; Tue, 30 Dec 2008 00:15:12 +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 mBU0FCmp070638; Tue, 30 Dec 2008 00:15:12 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBU0FCnO070637; Tue, 30 Dec 2008 00:15:12 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200812300015.mBU0FCnO070637@svn.freebsd.org> From: Kip Macy Date: Tue, 30 Dec 2008 00:15:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186578 - user/kmacy/HEAD_fast_net/sys/netinet X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Dec 2008 00:15:13 -0000 Author: kmacy Date: Tue Dec 30 00:15:12 2008 New Revision: 186578 URL: http://svn.freebsd.org/changeset/base/186578 Log: don't LLE_FREE if llentry is unchanged Modified: user/kmacy/HEAD_fast_net/sys/netinet/ip_output.c Modified: user/kmacy/HEAD_fast_net/sys/netinet/ip_output.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/netinet/ip_output.c Mon Dec 29 23:41:12 2008 (r186577) +++ user/kmacy/HEAD_fast_net/sys/netinet/ip_output.c Tue Dec 30 00:15:12 2008 (r186578) @@ -659,12 +659,13 @@ done: (struct sockaddr *)dst); IF_AFDATA_WUNLOCK(ifp); } - if (la != NULL) { + if (la != NULL && (inp->inp_lle != la)) { LLE_FREE(inp->inp_lle); LLE_ADDREF(la); LLE_WUNLOCK(la); inp->inp_lle = la; - } + } else if (la != NULL) + LLE_WUNLOCK(la); } if (!wlocked) INP_DOWNGRADE(inp); From owner-svn-src-user@FreeBSD.ORG Tue Dec 30 00:19:07 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 26DE91065672; Tue, 30 Dec 2008 00:19:07 +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 178BD8FC0C; Tue, 30 Dec 2008 00:19:07 +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 mBU0J6ft070739; Tue, 30 Dec 2008 00:19:06 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBU0J6V3070738; Tue, 30 Dec 2008 00:19:06 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200812300019.mBU0J6V3070738@svn.freebsd.org> From: Kip Macy Date: Tue, 30 Dec 2008 00:19:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186579 - user/kmacy/HEAD_fast_net/sys/netinet X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Dec 2008 00:19:07 -0000 Author: kmacy Date: Tue Dec 30 00:19:06 2008 New Revision: 186579 URL: http://svn.freebsd.org/changeset/base/186579 Log: cleanup upgrade / downgrade checks for route and lle Modified: user/kmacy/HEAD_fast_net/sys/netinet/ip_output.c Modified: user/kmacy/HEAD_fast_net/sys/netinet/ip_output.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/netinet/ip_output.c Tue Dec 30 00:15:12 2008 (r186578) +++ user/kmacy/HEAD_fast_net/sys/netinet/ip_output.c Tue Dec 30 00:19:06 2008 (r186579) @@ -635,18 +635,18 @@ done: struct llentry *la; wlocked = INP_WLOCKED(inp); + if ((neednewlle || neednewroute) && + !wlocked && INP_TRY_UPGRADE(inp) == 0) + return (error); + if (inp == NULL || (inp->inp_vflag & INP_RT_VALID) == 0) RTFREE(ro->ro_rt); else if (neednewroute && ro->ro_rt != inp->inp_rt) { - if (!wlocked && INP_TRY_UPGRADE(inp) == 0) - return (error); RTFREE(inp->inp_rt); inp->inp_rt = ro->ro_rt; } if (neednewlle) { - if (!wlocked && INP_TRY_UPGRADE(inp) == 0) - return (error); IF_AFDATA_RLOCK(ifp); la = lla_lookup(LLTABLE(ifp), LLE_EXCLUSIVE, (struct sockaddr *)dst); @@ -667,7 +667,7 @@ done: } else if (la != NULL) LLE_WUNLOCK(la); } - if (!wlocked) + if ((neednewlle || neednewroute) && !wlocked) INP_DOWNGRADE(inp); } From owner-svn-src-user@FreeBSD.ORG Tue Dec 30 00:50:25 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6BE231065680; Tue, 30 Dec 2008 00:50:25 +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 5CCC68FC18; Tue, 30 Dec 2008 00:50:25 +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 mBU0oPlC071403; Tue, 30 Dec 2008 00:50:25 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBU0oPKM071402; Tue, 30 Dec 2008 00:50:25 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200812300050.mBU0oPKM071402@svn.freebsd.org> From: Kip Macy Date: Tue, 30 Dec 2008 00:50:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186580 - user/kmacy/HEAD_fast_net/sys/netinet X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Dec 2008 00:50:25 -0000 Author: kmacy Date: Tue Dec 30 00:50:25 2008 New Revision: 186580 URL: http://svn.freebsd.org/changeset/base/186580 Log: don't check INP_WLOCKED if inp is NULL Modified: user/kmacy/HEAD_fast_net/sys/netinet/ip_output.c Modified: user/kmacy/HEAD_fast_net/sys/netinet/ip_output.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/netinet/ip_output.c Tue Dec 30 00:19:06 2008 (r186579) +++ user/kmacy/HEAD_fast_net/sys/netinet/ip_output.c Tue Dec 30 00:50:25 2008 (r186580) @@ -631,14 +631,15 @@ passout: done: if (ro == &iproute && ro->ro_rt != NULL) { - int wlocked; + int wlocked = 0; struct llentry *la; - wlocked = INP_WLOCKED(inp); - if ((neednewlle || neednewroute) && - !wlocked && INP_TRY_UPGRADE(inp) == 0) - return (error); - + if (neednewlle || neednewroute) { + wlocked = INP_WLOCKED(inp); + if (!wlocked && INP_TRY_UPGRADE(inp) == 0) + return (error); + } + if (inp == NULL || (inp->inp_vflag & INP_RT_VALID) == 0) RTFREE(ro->ro_rt); else if (neednewroute && ro->ro_rt != inp->inp_rt) { From owner-svn-src-user@FreeBSD.ORG Tue Dec 30 04:20:07 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 247691065670; Tue, 30 Dec 2008 04:20:07 +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 127A88FC08; Tue, 30 Dec 2008 04:20:07 +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 mBU4K7UF075645; Tue, 30 Dec 2008 04:20:07 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBU4K6bC075639; Tue, 30 Dec 2008 04:20:06 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200812300420.mBU4K6bC075639@svn.freebsd.org> From: Kip Macy Date: Tue, 30 Dec 2008 04:20:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186583 - in user/kmacy/HEAD_fast_net/sys: conf net netinet X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Dec 2008 04:20:07 -0000 Author: kmacy Date: Tue Dec 30 04:20:06 2008 New Revision: 186583 URL: http://svn.freebsd.org/changeset/base/186583 Log: import updated flowtable for use by forwarding and unconnected sockets Added: user/kmacy/HEAD_fast_net/sys/net/flowtable.c (contents, props changed) user/kmacy/HEAD_fast_net/sys/net/flowtable.h (contents, props changed) Modified: user/kmacy/HEAD_fast_net/sys/conf/files user/kmacy/HEAD_fast_net/sys/netinet/ip_input.c user/kmacy/HEAD_fast_net/sys/netinet/ip_output.c user/kmacy/HEAD_fast_net/sys/netinet/vinet.h Modified: user/kmacy/HEAD_fast_net/sys/conf/files ============================================================================== --- user/kmacy/HEAD_fast_net/sys/conf/files Tue Dec 30 01:33:15 2008 (r186582) +++ user/kmacy/HEAD_fast_net/sys/conf/files Tue Dec 30 04:20:06 2008 (r186583) @@ -2154,6 +2154,7 @@ net/bpf_filter.c optional bpf | netgrap net/bpf_zerocopy.c optional bpf net/bridgestp.c optional bridge | if_bridge net/bsd_comp.c optional ppp_bsdcomp +net/flowtable.c standard net/ieee8023ad_lacp.c optional lagg net/if.c standard net/if_arcsubr.c optional arcnet Added: user/kmacy/HEAD_fast_net/sys/net/flowtable.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kmacy/HEAD_fast_net/sys/net/flowtable.c Tue Dec 30 04:20:06 2008 (r186583) @@ -0,0 +1,747 @@ +#include "opt_mpath.h" + +#include +#include +#include +#include +#include +#include +#include + + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#define calloc(count, size) malloc((count)*(size), M_DEVBUF, M_WAITOK|M_ZERO) + +/* + * Taken from http://burtleburtle.net/bob/c/lookup3.c + */ + +#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k)))) + +/* +------------------------------------------------------------------------------- +mix -- mix 3 32-bit values reversibly. + +This is reversible, so any information in (a,b,c) before mix() is +still in (a,b,c) after mix(). + +If four pairs of (a,b,c) inputs are run through mix(), or through +mix() in reverse, there are at least 32 bits of the output that +are sometimes the same for one pair and different for another pair. +This was tested for: +* pairs that differed by one bit, by two bits, in any combination + of top bits of (a,b,c), or in any combination of bottom bits of + (a,b,c). +* "differ" is defined as +, -, ^, or ~^. For + and -, I transformed + the output delta to a Gray code (a^(a>>1)) so a string of 1's (as + is commonly produced by subtraction) look like a single 1-bit + difference. +* the base values were pseudorandom, all zero but one bit set, or + all zero plus a counter that starts at zero. + +Some k values for my "a-=c; a^=rot(c,k); c+=b;" arrangement that +satisfy this are + 4 6 8 16 19 4 + 9 15 3 18 27 15 + 14 9 3 7 17 3 +Well, "9 15 3 18 27 15" didn't quite get 32 bits diffing +for "differ" defined as + with a one-bit base and a two-bit delta. I +used http://burtleburtle.net/bob/hash/avalanche.html to choose +the operations, constants, and arrangements of the variables. + +This does not achieve avalanche. There are input bits of (a,b,c) +that fail to affect some output bits of (a,b,c), especially of a. The +most thoroughly mixed value is c, but it doesn't really even achieve +avalanche in c. + +This allows some parallelism. Read-after-writes are good at doubling +the number of bits affected, so the goal of mixing pulls in the opposite +direction as the goal of parallelism. I did what I could. Rotates +seem to cost as much as shifts on every machine I could lay my hands +on, and rotates are much kinder to the top and bottom bits, so I used +rotates. +------------------------------------------------------------------------------- +*/ +#define mix(a,b,c) \ +{ \ + a -= c; a ^= rot(c, 4); c += b; \ + b -= a; b ^= rot(a, 6); a += c; \ + c -= b; c ^= rot(b, 8); b += a; \ + a -= c; a ^= rot(c,16); c += b; \ + b -= a; b ^= rot(a,19); a += c; \ + c -= b; c ^= rot(b, 4); b += a; \ +} + +/* +------------------------------------------------------------------------------- +final -- final mixing of 3 32-bit values (a,b,c) into c + +Pairs of (a,b,c) values differing in only a few bits will usually +produce values of c that look totally different. This was tested for +* pairs that differed by one bit, by two bits, in any combination + of top bits of (a,b,c), or in any combination of bottom bits of + (a,b,c). +* "differ" is defined as +, -, ^, or ~^. For + and -, I transformed + the output delta to a Gray code (a^(a>>1)) so a string of 1's (as + is commonly produced by subtraction) look like a single 1-bit + difference. +* the base values were pseudorandom, all zero but one bit set, or + all zero plus a counter that starts at zero. + +These constants passed: + 14 11 25 16 4 14 24 + 12 14 25 16 4 14 24 +and these came close: + 4 8 15 26 3 22 24 + 10 8 15 26 3 22 24 + 11 8 15 26 3 22 24 +------------------------------------------------------------------------------- +*/ +#define final(a,b,c) \ +{ \ + c ^= b; c -= rot(b,14); \ + a ^= c; a -= rot(c,11); \ + b ^= a; b -= rot(a,25); \ + c ^= b; c -= rot(b,16); \ + a ^= c; a -= rot(c,4); \ + b ^= a; b -= rot(a,14); \ + c ^= b; c -= rot(b,24); \ +} + +/* +-------------------------------------------------------------------- + This works on all machines. To be useful, it requires + -- that the key be an array of uint32_t's, and + -- that the length be the number of uint32_t's in the key + + The function hashword() is identical to hashlittle() on little-endian + machines, and identical to hashbig() on big-endian machines, + except that the length has to be measured in uint32_ts rather than in + bytes. hashlittle() is more complicated than hashword() only because + hashlittle() has to dance around fitting the key bytes into registers. +-------------------------------------------------------------------- +*/ +static uint32_t hashword( +const uint32_t *k, /* the key, an array of uint32_t values */ +size_t length, /* the length of the key, in uint32_ts */ +uint32_t initval) /* the previous hash, or an arbitrary value */ +{ + uint32_t a,b,c; + + /* Set up the internal state */ + a = b = c = 0xdeadbeef + (((uint32_t)length)<<2) + initval; + + /*------------------------------------------------- handle most of the key */ + while (length > 3) + { + a += k[0]; + b += k[1]; + c += k[2]; + mix(a,b,c); + length -= 3; + k += 3; + } + + /*------------------------------------------- handle the last 3 uint32_t's */ + switch(length) /* all the case statements fall through */ + { + case 3 : c+=k[2]; + case 2 : b+=k[1]; + case 1 : a+=k[0]; + final(a,b,c); + case 0: /* case 0: nothing left to add */ + break; + } + /*------------------------------------------------------ report the result */ + return c; +} + + +struct ipv4_tuple { + uint16_t ip_sport; /* source port */ + uint16_t ip_dport; /* destination port */ + in_addr_t ip_saddr; /* source address */ + in_addr_t ip_daddr; /* destination address */ +}; + +union ipv4_flow { + struct ipv4_tuple ipf_ipt; + uint32_t ipf_key[3]; +}; + +struct ipv6_tuple { + uint16_t ip_sport; /* source port */ + uint16_t ip_dport; /* destination port */ + struct in6_addr ip_saddr; /* source address */ + struct in6_addr ip_daddr; /* destination address */ +}; + +union ipv6_flow { + struct ipv6_tuple ipf_ipt; + uint32_t ipf_key[9]; +}; + +struct flentry { + volatile uint32_t f_fhash; /* hash flowing forward */ + uint16_t f_flags; /* flow flags */ + uint8_t f_pad; + uint8_t f_proto; /* protocol */ + uint32_t f_uptime; + volatile struct rtentry *f_rt; /* rtentry for flow */ + volatile struct llentry *f_lle; /* llentry for flow */ +}; + +struct flentry_v4 { + struct flentry fl_entry; + union ipv4_flow fl_flow; +}; + +struct flentry_v6 { + struct flentry fl_entry; + union ipv6_flow fl_flow; +}; + +#define fl_fhash fl_entry.fl_fhash +#define fl_flags fl_entry.fl_flags +#define fl_proto fl_entry.fl_proto +#define fl_uptime fl_entry.fl_uptime +#define fl_rt fl_entry.fl_rt +#define fl_lle fl_entry.fl_lle + +#define SECS_PER_HOUR 3600 +#define SECS_PER_DAY (24*SECS_PER_HOUR) + +#define SYN_IDLE 300 +#define UDP_IDLE 300 +#define FIN_WAIT_IDLE 600 +#define TCP_IDLE SECS_PER_DAY + + +typedef void fl_lock_t(struct flowtable *, uint32_t); +typedef void fl_rtalloc_t(struct route *, uint32_t, u_int); + +union flentryp { + struct flentry_v4 *v4; + struct flentry_v6 *v6; + struct flentry_v4 *v4_pcpu[MAXCPU]; + struct flentry_v6 *v6_pcpu[MAXCPU]; +}; + +struct flowtable { + union flentryp ft_table; + int ft_size; + bitstr_t *ft_masks[MAXCPU]; + struct mtx *ft_locks; + int ft_lock_count; + uint32_t ft_flags; + uint32_t ft_collisions; + uint32_t ft_allocated; + uint64_t ft_hits; + + uint32_t ft_udp_idle; + uint32_t ft_fin_wait_idle; + uint32_t ft_syn_idle; + uint32_t ft_tcp_idle; + + fl_lock_t *ft_lock; + fl_lock_t *ft_unlock; + fl_rtalloc_t *ft_rtalloc; + +}; + +static uint32_t hashjitter; + +SYSCTL_NODE(_net_inet, OID_AUTO, flowtable, CTLFLAG_RD, NULL, "flowtable"); + +int flowtable_enable = 1; +SYSCTL_INT(_net_inet_flowtable, OID_AUTO, enable, CTLFLAG_RW, + &flowtable_enable, 0, "enable flowtable caching."); + + +#ifndef RADIX_MPATH +static void +in_rtalloc_ign_wrapper(struct route *ro, uint32_t hash, u_int fib) +{ + + in_rtalloc_ign(ro, 0, fib); +} +#endif + +static void +flowtable_global_lock(struct flowtable *table, uint32_t hash) +{ + int lock_index = (hash)&(table->ft_lock_count - 1); + + mtx_lock(&table->ft_locks[lock_index]); +} + +static void +flowtable_global_unlock(struct flowtable *table, uint32_t hash) +{ + int lock_index = (hash)&(table->ft_lock_count - 1); + + mtx_unlock(&table->ft_locks[lock_index]); +} + +static void +flowtable_pcpu_lock(struct flowtable *table, uint32_t hash) +{ + + critical_enter(); +} + +static void +flowtable_pcpu_unlock(struct flowtable *table, uint32_t hash) +{ + + mb(); + critical_exit(); +} + +#define FL_ENTRY_INDEX(table, hash)((hash) % (table)->ft_size) +#define FL_ENTRY(table, hash) flowtable_entry((table), (hash)) +#define FL_ENTRY_LOCK(table, hash) (table)->ft_lock((table), (hash)) +#define FL_ENTRY_UNLOCK(table, hash) (table)->ft_unlock((table), (hash)) + +#define FL_STALE (1<<8) + +static uint32_t +ipv4_flow_lookup_hash_internal(struct mbuf *m, struct route *ro, + uint32_t *key, uint16_t *flags, uint8_t *protop) +{ + uint16_t sport = 0, dport = 0; + struct ip *ip = mtod(m, struct ip *); + uint8_t proto = ip->ip_p; + int iphlen = ip->ip_hl << 2; + uint32_t hash; + struct sockaddr_in *sin; + struct tcphdr *th; + struct udphdr *uh; + struct sctphdr *sh; + + key[0] = 0; + key[1] = ip->ip_src.s_addr; + key[2] = ip->ip_dst.s_addr; + + sin = (struct sockaddr_in *)&ro->ro_dst; + sin->sin_family = AF_INET; + sin->sin_len = sizeof(*sin); + sin->sin_addr = ip->ip_dst; + + if (flowtable_enable == 0) + return (0); + + switch (proto) { + case IPPROTO_TCP: + th = (struct tcphdr *)((caddr_t)ip + iphlen); + sport = ntohs(th->th_sport); + dport = ntohs(th->th_dport); + *flags |= th->th_flags; + if (*flags & TH_RST) + *flags |= FL_STALE; + break; + case IPPROTO_UDP: + uh = (struct udphdr *)((caddr_t)ip + iphlen); + sport = uh->uh_sport; + dport = uh->uh_dport; + break; + case IPPROTO_SCTP: + sh = (struct sctphdr *)((caddr_t)ip + iphlen); + sport = sh->src_port; + dport = sh->dest_port; + break; + default: + if (*flags & FL_HASH_PORTS) + goto noop; + /* no port - hence not a protocol we care about */ + break;; + + } + *protop = proto; + + /* + * If this is a transmit route cache then + * hash all flows to a given destination to + * the same bucket + */ + if ((*flags & FL_HASH_PORTS) == 0) + proto = sport = dport = 0; + + ((uint16_t *)key)[0] = sport; + ((uint16_t *)key)[1] = dport; + + hash = hashword(key, 3, hashjitter + proto); + if (m->m_pkthdr.flowid == 0) + m->m_pkthdr.flowid = hash; + + CTR5(KTR_SPARE3, "proto=%d hash=%x key[0]=%x sport=%d dport=%d\n", proto, hash, key[0], sport, dport); + + return (hash); +noop: + *protop = proto; + return (0); +} + +static bitstr_t * +flowtable_mask(struct flowtable *ft) +{ + bitstr_t *mask; + + if (ft->ft_flags & FL_PCPU) + mask = ft->ft_masks[curcpu]; + else + mask = ft->ft_masks[0]; + + return (mask); +} + +static struct flentry * +flowtable_entry(struct flowtable *ft, uint32_t hash) +{ + struct flentry *fle; + int index = (hash % ft->ft_size); + + + if ((ft->ft_flags & FL_IPV6) == 0) { + if (ft->ft_flags & FL_PCPU) { + fle = (struct flentry *) + &ft->ft_table.v4_pcpu[curcpu][index]; + } else + fle = (struct flentry *)&ft->ft_table.v4[index]; + } else { + if (ft->ft_flags & FL_PCPU) + fle = (struct flentry *) + &ft->ft_table.v6_pcpu[curcpu][index]; + else + fle = (struct flentry *)&ft->ft_table.v6[index]; + } + + return (fle); +} + +static int +flow_stale(struct flowtable *ft, struct flentry *fle) +{ + time_t idle_time; + + if ((fle->f_fhash == 0) + || ((fle->f_rt->rt_flags & RTF_HOST) && + ((fle->f_rt->rt_flags & (RTF_UP)) + != (RTF_UP))) + || (fle->f_rt->rt_ifp == NULL)) + return (1); + + idle_time = time_uptime - fle->f_uptime; + + if ((fle->f_flags & FL_STALE) || + ((fle->f_flags & (TH_SYN|TH_ACK|TH_FIN)) == 0 + && (idle_time > ft->ft_udp_idle)) || + ((fle->f_flags & TH_FIN) + && (idle_time > ft->ft_fin_wait_idle)) || + ((fle->f_flags & (TH_SYN|TH_ACK)) == TH_SYN + && (idle_time > ft->ft_syn_idle)) || + ((fle->f_flags & (TH_SYN|TH_ACK)) == (TH_SYN|TH_ACK) + && (idle_time > ft->ft_tcp_idle)) || + ((fle->f_rt->rt_flags & RTF_UP) == 0 || + (fle->f_rt->rt_ifp == NULL))) + return (1); + + return (0); +} + +static void +flowtable_set_hashkey(struct flowtable *ft, struct flentry *fle, uint32_t *key) +{ + uint32_t *hashkey; + int i, nwords; + + if (ft->ft_flags & FL_IPV6) { + nwords = 9; + hashkey = ((struct flentry_v4 *)fle)->fl_flow.ipf_key; + } else { + nwords = 3; + hashkey = ((struct flentry_v6 *)fle)->fl_flow.ipf_key; + } + + for (i = 0; i < nwords; i++) + hashkey[i] = key[i]; +} + +static int +flowtable_insert(struct flowtable *ft, uint32_t hash, uint32_t *key, + uint8_t proto, struct route *ro, uint16_t flags) +{ + struct flentry *fle; + volatile struct rtentry *rt0 = NULL; + struct rtentry *rt1; + int stale; + bitstr_t *mask; + +retry: + FL_ENTRY_LOCK(ft, hash); + mask = flowtable_mask(ft); + fle = flowtable_entry(ft, hash); + if (fle->f_fhash) { + if ((stale = flow_stale(ft, fle)) != 0) { + fle->f_fhash = 0; + rt0 = fle->f_rt; + fle->f_rt = NULL; + bit_clear(mask, FL_ENTRY_INDEX(ft, hash)); + } + FL_ENTRY_UNLOCK(ft, hash); + if (!stale) + return (ENOSPC); + + rt1 = __DEVOLATILE(struct rtentry *, rt0); + RTFREE(rt1); + /* + * We might end up on a different cpu + */ + goto retry; + + } + flowtable_set_hashkey(ft, fle, key); + bit_set(mask, FL_ENTRY_INDEX(ft, hash)); + + fle->f_proto = proto; + fle->f_rt = ro->ro_rt; + fle->f_lle = ro->ro_lle; + fle->f_fhash = hash; + fle->f_uptime = time_uptime; + FL_ENTRY_UNLOCK(ft, hash); + return (0); +} + +static int +flowtable_key_equal(struct flentry *fle, uint32_t *key, int flags) +{ + uint32_t *hashkey; + int i, nwords; + + if (flags & FL_IPV6) { + nwords = 9; + hashkey = ((struct flentry_v4 *)fle)->fl_flow.ipf_key; + } else { + nwords = 3; + hashkey = ((struct flentry_v6 *)fle)->fl_flow.ipf_key; + } + + for (i = 0; i < nwords; i++) + if (hashkey[i] != key[i]) + return (0); + + return (1); +} + +int +flowtable_lookup(struct flowtable *ft, struct mbuf *m, struct route *ro) +{ + uint32_t key[9], hash; + struct flentry *fle; + uint16_t flags; + uint8_t proto = 0; + int cache = 1, error = 0; + struct rtentry *rt; + struct llentry *lle; + + flags = ft ? ft->ft_flags : 0; + ro->ro_rt = NULL; + ro->ro_lle = NULL; + + /* + * The internal hash lookup is the only IPv4 specific bit + * remaining + */ + hash = ipv4_flow_lookup_hash_internal(m, ro, key, + &flags, &proto); + + /* + * Ports are zero and this isn't a transmit cache + * - thus not a protocol for which we need to keep + * statex + * FL_HASH_PORTS => key[0] != 0 for TCP || UDP || SCTP + */ + if (hash == 0 || (key[0] == 0 && (ft->ft_flags & FL_HASH_PORTS))) { + cache = 0; + goto uncached; + } + FL_ENTRY_LOCK(ft, hash); + fle = FL_ENTRY(ft, hash); + rt = __DEVOLATILE(struct rtentry *, fle->f_rt); + lle = __DEVOLATILE(struct llentry *, fle->f_lle); + if ((rt != NULL) + && fle->f_fhash == hash + && flowtable_key_equal(fle, key, flags) + && (proto == fle->f_proto) + && (rt->rt_flags & RTF_UP) + && (rt->rt_ifp != NULL)) { + fle->f_uptime = time_uptime; + fle->f_flags |= flags; + ro->ro_rt = rt; + ro->ro_lle = lle; + FL_ENTRY_UNLOCK(ft, hash); + return (0); + } + FL_ENTRY_UNLOCK(ft, hash); + +uncached: + /* + * This bit of code ends up locking the + * same route 3 times (just like ip_output + ether_output) + * - at lookup + * - in rt_check when called by arpresolve + * - dropping the refcount for the rtentry + * + * This could be consolidated to one if we wrote a variant + * of arpresolve with an rt_check variant that expected to + * receive the route locked + */ + ft->ft_rtalloc(ro, hash, M_GETFIB(m)); + if (ro->ro_rt == NULL) + error = ENETUNREACH; + else { + int finsert; + struct llentry *lle = NULL; + struct sockaddr *l3addr; + struct rtentry *rt = ro->ro_rt; + struct ifnet *ifp = rt->rt_ifp; + + if (rt->rt_flags & RTF_GATEWAY) + l3addr = rt->rt_gateway; + else + l3addr = &ro->ro_dst; + IF_AFDATA_RLOCK(ifp); + lle = lla_lookup(LLTABLE(ifp), LLE_EXCLUSIVE, l3addr); + IF_AFDATA_RUNLOCK(ifp); + if ((lle == NULL) && + (ifp->if_flags & (IFF_NOARP | IFF_STATICARP)) == 0) { + IF_AFDATA_WLOCK(ifp); + lle = lla_lookup(LLTABLE(ifp), + (LLE_CREATE | LLE_EXCLUSIVE), l3addr); + IF_AFDATA_WUNLOCK(ifp); + } + if (lle != NULL) { + LLE_ADDREF(lle); + LLE_WUNLOCK(lle); + } + ro->ro_lle = lle; + finsert = ((lle != NULL) && cache); + if (finsert) + error = flowtable_insert(ft, hash, key, proto, + ro, flags); + + if (error || !finsert) { + RTFREE(rt); + if (lle != NULL) + LLE_FREE(lle); + } + error = 0; + } + + return (error); +} + +#ifdef notyet +static __inline int +bit_fns(bitstr_t *name, int nbits, int lastbit) +{ + int lastbit_start = lastbit & ~0x7; + bitstr_t *bitstr_start = &name[lastbit_start]; + int value = 0; + + while (value <= lastbit && value != 1) + bit_ffs(bitstr_start, nbits, &value); + + return (value); +} +#endif + +struct flowtable * +flowtable_alloc(int nentry, int flags) +{ + struct flowtable *ft; + int i; + + if (hashjitter == 0) + hashjitter = arc4random(); + + ft = malloc(sizeof(struct flowtable), + M_RTABLE, M_WAITOK | M_ZERO); + + ft->ft_flags = flags; + ft->ft_size = nentry; +#ifdef RADIX_MPATH + ft->ft_rtalloc = rtalloc_mpath_fib; +#else + ft->ft_rtalloc = in_rtalloc_ign_wrapper; +#endif + if (flags & FL_PCPU) { + ft->ft_lock = flowtable_pcpu_lock; + ft->ft_unlock = flowtable_pcpu_unlock; + + for (i = 0; i < mp_ncpus; i++) { + ft->ft_table.v4_pcpu[i] = + malloc(nentry*sizeof(struct flentry_v4), + M_RTABLE, M_WAITOK | M_ZERO); + ft->ft_masks[i] = bit_alloc(nentry); + } + } else { + ft->ft_lock_count = 2*(powerof2(mp_ncpus) ? mp_ncpus : + (fls(mp_ncpus) << 1)); + + ft->ft_lock = flowtable_global_lock; + ft->ft_unlock = flowtable_global_unlock; + ft->ft_table.v4 = + malloc(nentry*sizeof(struct flentry_v4), + M_RTABLE, M_WAITOK | M_ZERO); + ft->ft_locks = malloc(ft->ft_lock_count*sizeof(struct mtx), + M_RTABLE, M_WAITOK | M_ZERO); + for (i = 0; i < ft->ft_lock_count; i++) + mtx_init(&ft->ft_locks[i], "flow", NULL, MTX_DEF|MTX_DUPOK); + + ft->ft_masks[0] = bit_alloc(nentry); + } + + /* + * In the local transmit case the table truly is + * just a cache - so everything is eligible for + * replacement after 5s of non-use + */ + if (flags & FL_HASH_PORTS) { + ft->ft_udp_idle = UDP_IDLE; + ft->ft_syn_idle = SYN_IDLE; + ft->ft_fin_wait_idle = FIN_WAIT_IDLE; + ft->ft_tcp_idle = TCP_IDLE; + } else { + ft->ft_udp_idle = ft->ft_fin_wait_idle = + ft->ft_syn_idle = ft->ft_tcp_idle = 30; + + } + + + return (ft); +} + Added: user/kmacy/HEAD_fast_net/sys/net/flowtable.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kmacy/HEAD_fast_net/sys/net/flowtable.h Tue Dec 30 04:20:06 2008 (r186583) @@ -0,0 +1,24 @@ +#ifndef _NET_FLOWTABLE_H_ +#define _NET_FLOWTABLE_H_ + +#ifdef _KERNEL +#include +#include + +#define FL_HASH_PORTS (1<<0) /* hash 4-tuple + protocol */ +#define FL_PCPU (1<<1) /* pcpu cache */ +#define FL_IPV6 (1<<2) /* IPv6 table */ + +struct flowtable; +struct flowtable *flowtable_alloc(int nentry, int flags); + +/* + * Given a flow table, look up the L3 and L2 information and + * return it in the route + * + */ +int flowtable_lookup(struct flowtable *ft, struct mbuf *m, + struct route *ro); + +#endif +#endif Modified: user/kmacy/HEAD_fast_net/sys/netinet/ip_input.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/netinet/ip_input.c Tue Dec 30 01:33:15 2008 (r186582) +++ user/kmacy/HEAD_fast_net/sys/netinet/ip_input.c Tue Dec 30 04:20:06 2008 (r186583) @@ -56,6 +56,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -210,6 +211,21 @@ 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_pcpu_flowtable_size = 2048; +TUNABLE_INT("net.inet.ip.pcpu_flowtable_size", &ip_pcpu_flowtable_size); +SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_ip, OID_AUTO, pcpu_flowtable_size, + CTLFLAG_RDTUN, ip_pcpu_flowtable_size, 0, + "number of entries in the per cpu flow caches"); + +#ifdef RADIX_MPATH +static int ip_global_flowtable_size = 128*1024; +#else +static int ip_global_flowtable_size = 16*1024; +#endif +TUNABLE_INT("net.inet.ip.global_flowtable_size", &ip_global_flowtable_size); +SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_ip, OID_AUTO, global_flowtable_size, + CTLFLAG_RDTUN, ip_global_flowtable_size, 0, + "number of entries in the global flow cache"); /* * ipfw_ether and ipfw_bridge hooks. @@ -220,6 +236,8 @@ ip_dn_io_t *ip_dn_io_ptr = NULL; #ifdef VIMAGE_GLOBALS int fw_one_pass; #endif +struct flowtable *ipv4_ft; +struct flowtable *ipv4_forward_ft; static void ip_freef(struct ipqhead *, struct ipq *); @@ -319,6 +337,9 @@ 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); + + ipv4_ft = flowtable_alloc(ip_pcpu_flowtable_size, FL_PCPU); + ipv4_forward_ft = flowtable_alloc(ip_global_flowtable_size, FL_HASH_PORTS); } void Modified: user/kmacy/HEAD_fast_net/sys/netinet/ip_output.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/netinet/ip_output.c Tue Dec 30 01:33:15 2008 (r186582) +++ user/kmacy/HEAD_fast_net/sys/netinet/ip_output.c Tue Dec 30 04:20:06 2008 (r186583) @@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -101,6 +102,7 @@ static void ip_mloopback extern struct protosw inetsw[]; +extern struct flowtable *ipv4_ft; /* * IP output. The packet in mbuf chain m contains a skeletal IP @@ -122,7 +124,7 @@ ip_output(struct mbuf *m, struct mbuf *o int hlen = sizeof (struct ip); int mtu; int len, error = 0; - int neednewroute = 0, neednewlle = 0; + int neednewroute = 0, neednewlle = 0, nortfree = 0; struct sockaddr_in *dst = NULL; /* keep compiler happy */ struct in_ifaddr *ia = NULL; int isbroadcast, sw_csum; @@ -159,6 +161,11 @@ ip_output(struct mbuf *m, struct mbuf *o neednewlle = 1; } } + if ((ro == &iproute) && (ro->ro_rt == NULL) && (ro->ro_lle == NULL)) { + if (flowtable_lookup(ipv4_ft, m, ro) == 0) + nortfree = 1; + } + if (opt) { len = 0; @@ -200,7 +207,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)) { - if (inp == NULL || (ro->ro_rt != inp->inp_rt)) + if ((nortfree == 0) && + (inp == NULL || (ro->ro_rt != inp->inp_rt))) RTFREE(ro->ro_rt); ro->ro_rt = (struct rtentry *)NULL; } @@ -640,12 +648,12 @@ done: return (error); } - if (inp == NULL || (inp->inp_vflag & INP_RT_VALID) == 0) + if ((nortfree == 0) && + (inp == NULL || (inp->inp_vflag & INP_RT_VALID) == 0)) RTFREE(ro->ro_rt); else if (neednewroute && ro->ro_rt != inp->inp_rt) { RTFREE(inp->inp_rt); inp->inp_rt = ro->ro_rt; - } if (neednewlle) { IF_AFDATA_RLOCK(ifp); Modified: user/kmacy/HEAD_fast_net/sys/netinet/vinet.h ============================================================================== --- user/kmacy/HEAD_fast_net/sys/netinet/vinet.h Tue Dec 30 01:33:15 2008 (r186582) +++ user/kmacy/HEAD_fast_net/sys/netinet/vinet.h Tue Dec 30 04:20:06 2008 (r186583) @@ -75,6 +75,8 @@ struct vnet_inet { int _ip_sendsourcequench; int _ip_do_randomid; int _ip_checkinterface; + int _ip_pcpu_flowtable_size; + int _ip_global_flowtable_size; u_short _ip_id; uma_zone_t _ipq_zone; From owner-svn-src-user@FreeBSD.ORG Tue Dec 30 04:22:48 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4B462106566B; Tue, 30 Dec 2008 04:22:48 +0000 (UTC) (envelope-from ps@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3AAA48FC19; Tue, 30 Dec 2008 04:22:48 +0000 (UTC) (envelope-from ps@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 mBU4Mmp5075802; Tue, 30 Dec 2008 04:22:48 GMT (envelope-from ps@svn.freebsd.org) Received: (from ps@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBU4Mm8W075800; Tue, 30 Dec 2008 04:22:48 GMT (envelope-from ps@svn.freebsd.org) Message-Id: <200812300422.mBU4Mm8W075800@svn.freebsd.org> From: Paul Saab Date: Tue, 30 Dec 2008 04:22:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186584 - user/kmacy/HEAD_fast_net/sys/dev/e1000 X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Dec 2008 04:22:48 -0000 Author: ps Date: Tue Dec 30 04:22:47 2008 New Revision: 186584 URL: http://svn.freebsd.org/changeset/base/186584 Log: Bring in if_transmit support for if_em and also fix a use after free bug that was fixed in r185621 Modified: user/kmacy/HEAD_fast_net/sys/dev/e1000/if_em.c user/kmacy/HEAD_fast_net/sys/dev/e1000/if_em.h Modified: user/kmacy/HEAD_fast_net/sys/dev/e1000/if_em.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/dev/e1000/if_em.c Tue Dec 30 04:20:06 2008 (r186583) +++ user/kmacy/HEAD_fast_net/sys/dev/e1000/if_em.c Tue Dec 30 04:22:47 2008 (r186584) @@ -39,6 +39,7 @@ #include #include +#include #include #include #include @@ -889,6 +890,7 @@ em_detach(device_t dev) em_free_pci_resources(adapter); bus_generic_detach(dev); if_free(ifp); + drbr_free(adapter->br, M_DEVBUF); em_free_transmit_structures(adapter); em_free_receive_structures(adapter); @@ -984,6 +986,81 @@ em_resume(device_t dev) * the packet is requeued. **********************************************************************/ +#ifdef IFNET_MULTIQUEUE +static int +em_transmit_locked(struct ifnet *ifp, struct mbuf *m) +{ + struct adapter *adapter = ifp->if_softc; + int error; + + EM_TX_LOCK_ASSERT(adapter); + if (((ifp->if_drv_flags & (IFF_DRV_RUNNING|IFF_DRV_OACTIVE)) != + IFF_DRV_RUNNING) + || (!adapter->link_active)) { + error = drbr_enqueue(ifp, adapter->br, m); + return (error); + } + + if (buf_ring_empty(adapter->br) && + (adapter->num_tx_desc_avail > EM_TX_OP_THRESHOLD)) { + if (em_xmit(adapter, &m)) { + if (m && (error = drbr_enqueue(ifp, adapter->br, m)) != 0) { + return (error); + } + } else{ + /* Send a copy of the frame to the BPF listener */ + ETHER_BPF_MTAP(ifp, m); + } + } else if ((error = drbr_enqueue(ifp, adapter->br, m)) != 0) + return (error); + + if (!buf_ring_empty(adapter->br)) + em_start_locked(ifp); + + return (0); +} + +static void +em_start_locked(struct ifnet *ifp) +{ + struct adapter *adapter = ifp->if_softc; + struct mbuf *m_head; + + EM_TX_LOCK_ASSERT(adapter); + + if ((ifp->if_drv_flags & (IFF_DRV_RUNNING|IFF_DRV_OACTIVE)) != + IFF_DRV_RUNNING) + return; + if (!adapter->link_active) + return; + + while ((adapter->num_tx_desc_avail > EM_TX_OP_THRESHOLD) + && (!buf_ring_empty(adapter->br))) { + + m_head = buf_ring_dequeue_sc(adapter->br); + if (m_head == NULL) + break; + /* + * Encapsulation can modify our pointer, and or make it + * NULL on failure. In that event, we can't requeue. + */ + if (em_xmit(adapter, &m_head)) { + if (m_head == NULL) + break; + break; + } + + /* Send a copy of the frame to the BPF listener */ + ETHER_BPF_MTAP(ifp, m_head); + + /* Set timeout in case hardware has problems transmitting. */ + adapter->watchdog_timer = EM_TX_TIMEOUT; + } + if ((adapter->num_tx_desc_avail <= EM_TX_OP_THRESHOLD)) + ifp->if_drv_flags |= IFF_DRV_OACTIVE; + +} +#else static void em_start_locked(struct ifnet *ifp) { @@ -1022,6 +1099,7 @@ em_start_locked(struct ifnet *ifp) adapter->watchdog_timer = EM_TX_TIMEOUT; } } +#endif static void em_start(struct ifnet *ifp) @@ -1034,6 +1112,23 @@ em_start(struct ifnet *ifp) EM_TX_UNLOCK(adapter); } +static int +em_transmit(struct ifnet *ifp, struct mbuf *m) +{ + + struct adapter *adapter = ifp->if_softc; + int error = 0; + + if(EM_TX_TRYLOCK(adapter)) { + if (ifp->if_drv_flags & IFF_DRV_RUNNING) + error = em_transmit_locked(ifp, m); + EM_TX_UNLOCK(adapter); + } else + error = drbr_enqueue(ifp, adapter->br, m); + + return (error); +} + /********************************************************************* * Ioctl entry point * @@ -1597,7 +1692,11 @@ em_poll(struct ifnet *ifp, enum poll_cmd EM_TX_LOCK(adapter); em_txeof(adapter); +#ifdef IFNET_MULTIQUEUE + if (!buf_ring_empty(adapter->br)) +#else if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) +#endif em_start_locked(ifp); EM_TX_UNLOCK(adapter); } @@ -1665,8 +1764,15 @@ em_intr(void *arg) } EM_CORE_UNLOCK(adapter); + if (ifp->if_drv_flags & IFF_DRV_RUNNING && - !IFQ_DRV_IS_EMPTY(&ifp->if_snd)) +#ifdef IFNET_MULTIQUEUE + !buf_ring_empty(adapter->br) +#else + !IFQ_DRV_IS_EMPTY(&ifp->if_snd) +#endif + ) + em_start(ifp); } @@ -1705,7 +1811,11 @@ em_handle_rxtx(void *context, int pendin EM_TX_LOCK(adapter); em_txeof(adapter); +#ifdef IFNET_MULTIQUEUE + if (!buf_ring_empty(adapter->br)) +#else if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) +#endif em_start_locked(ifp); EM_TX_UNLOCK(adapter); } @@ -1732,9 +1842,19 @@ em_handle_tx(void *context, int pending) struct ifnet *ifp = adapter->ifp; if (ifp->if_drv_flags & IFF_DRV_RUNNING) { +#ifdef IFNET_MULTIQUEUE + if (!EM_TX_TRYLOCK(adapter)) + return; +#else EM_TX_LOCK(adapter); +#endif + em_txeof(adapter); +#ifdef IFNET_MULTIQUEUE + if (!buf_ring_empty(adapter->br)) +#else if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) +#endif em_start_locked(ifp); EM_TX_UNLOCK(adapter); } @@ -2083,22 +2203,14 @@ em_xmit(struct adapter *adapter, struct error = bus_dmamap_load_mbuf_sg(adapter->txtag, map, *m_headp, segs, &nsegs, BUS_DMA_NOWAIT); - if (error == ENOMEM) { - adapter->no_tx_dma_setup++; - return (error); - } else if (error != 0) { + if (error) { adapter->no_tx_dma_setup++; m_freem(*m_headp); *m_headp = NULL; return (error); } - } else if (error == ENOMEM) { - adapter->no_tx_dma_setup++; - return (error); } else if (error != 0) { adapter->no_tx_dma_setup++; - m_freem(*m_headp); - *m_headp = NULL; return (error); } @@ -2531,7 +2643,8 @@ em_local_timer(void *arg) struct ifnet *ifp = adapter->ifp; EM_CORE_LOCK_ASSERT(adapter); - + taskqueue_enqueue(adapter->tq, + &adapter->rxtx_task); em_update_link_status(adapter); em_update_stats_counters(adapter); @@ -3125,7 +3238,11 @@ em_setup_interface(device_t dev, struct ether_ifattach(ifp, adapter->hw.mac.addr); ifp->if_capabilities = ifp->if_capenable = 0; - +#ifdef IFNET_MULTIQUEUE + ifp->if_transmit = em_transmit; + adapter->br = buf_ring_alloc(2048, M_DEVBUF, M_WAITOK, &adapter->tx_mtx); +#endif + if (adapter->hw.mac.type >= e1000_82543) { int version_cap; #if __FreeBSD_version < 700000 Modified: user/kmacy/HEAD_fast_net/sys/dev/e1000/if_em.h ============================================================================== --- user/kmacy/HEAD_fast_net/sys/dev/e1000/if_em.h Tue Dec 30 04:20:06 2008 (r186583) +++ user/kmacy/HEAD_fast_net/sys/dev/e1000/if_em.h Tue Dec 30 04:22:47 2008 (r186584) @@ -36,6 +36,7 @@ #ifndef _EM_H_DEFINED_ #define _EM_H_DEFINED_ +#define IFNET_MULTIQUEUE /* Tunables */ /* @@ -301,6 +302,9 @@ struct em_dma_alloc { /* Our adapter structure */ struct adapter { struct ifnet *ifp; +#ifdef IFNET_MULTIQUEUE + struct buf_ring *br; +#endif struct e1000_hw hw; /* FreeBSD operating-system-specific structures. */ @@ -482,6 +486,7 @@ typedef struct _DESCRIPTOR_PAIR #define EM_RX_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->rx_mtx) #define EM_CORE_LOCK(_sc) mtx_lock(&(_sc)->core_mtx) #define EM_TX_LOCK(_sc) mtx_lock(&(_sc)->tx_mtx) +#define EM_TX_TRYLOCK(_sc) mtx_trylock(&(_sc)->tx_mtx) #define EM_RX_LOCK(_sc) mtx_lock(&(_sc)->rx_mtx) #define EM_CORE_UNLOCK(_sc) mtx_unlock(&(_sc)->core_mtx) #define EM_TX_UNLOCK(_sc) mtx_unlock(&(_sc)->tx_mtx) From owner-svn-src-user@FreeBSD.ORG Tue Dec 30 04:38:40 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3FC53106566B; Tue, 30 Dec 2008 04:38:40 +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 2F4BF8FC1F; Tue, 30 Dec 2008 04:38:40 +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 mBU4ceF5076136; Tue, 30 Dec 2008 04:38:40 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBU4ceDK076135; Tue, 30 Dec 2008 04:38:40 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200812300438.mBU4ceDK076135@svn.freebsd.org> From: Kip Macy Date: Tue, 30 Dec 2008 04:38:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186585 - user/kmacy/HEAD_fast_net/sys/netinet X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Dec 2008 04:38:40 -0000 Author: kmacy Date: Tue Dec 30 04:38:39 2008 New Revision: 186585 URL: http://svn.freebsd.org/changeset/base/186585 Log: make ipv4 forwarding flowtable aware Modified: user/kmacy/HEAD_fast_net/sys/netinet/ip_input.c Modified: user/kmacy/HEAD_fast_net/sys/netinet/ip_input.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/netinet/ip_input.c Tue Dec 30 04:22:47 2008 (r186584) +++ user/kmacy/HEAD_fast_net/sys/netinet/ip_input.c Tue Dec 30 04:38:39 2008 (r186585) @@ -1350,6 +1350,7 @@ ip_forward(struct mbuf *m, int srcrt) struct in_addr dest; struct route ro; int error, type = 0, code = 0, mtu = 0; + int flerror; if (m->m_flags & (M_BCAST|M_MCAST) || in_canforward(ip->ip_dst) == 0) { V_ipstat.ips_cantforward++; @@ -1367,8 +1368,12 @@ ip_forward(struct mbuf *m, int srcrt) #ifdef IPSTEALTH } #endif + flerror = flowtable_lookup(ipv4_forward_ft, m, &ro); + if (flerror == 0) + ia = ifatoia(ro.ro_rt->rt_ifa); + else + ia = ip_rtaddr(ip->ip_dst, M_GETFIB(m)); - ia = ip_rtaddr(ip->ip_dst, M_GETFIB(m)); if (!srcrt && ia == NULL) { icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_HOST, 0, 0); return; @@ -1428,13 +1433,16 @@ ip_forward(struct mbuf *m, int srcrt) struct sockaddr_in *sin; struct rtentry *rt; - bzero(&ro, sizeof(ro)); - sin = (struct sockaddr_in *)&ro.ro_dst; - sin->sin_family = AF_INET; - sin->sin_len = sizeof(*sin); - sin->sin_addr = ip->ip_dst; - in_rtalloc_ign(&ro, 0, M_GETFIB(m)); - + if (flerror != 0) { + + bzero(&ro, sizeof(ro)); + sin = (struct sockaddr_in *)&ro.ro_dst; + sin->sin_family = AF_INET; + sin->sin_len = sizeof(*sin); + sin->sin_addr = ip->ip_dst; + in_rtalloc_ign(&ro, 0, M_GETFIB(m)); + } + rt = ro.ro_rt; if (rt && (rt->rt_flags & (RTF_DYNAMIC|RTF_MODIFIED)) == 0 && @@ -1453,7 +1461,7 @@ ip_forward(struct mbuf *m, int srcrt) code = ICMP_REDIRECT_HOST; } } - if (rt) + if (rt && (flerror != 0)) RTFREE(rt); } @@ -1461,13 +1469,14 @@ ip_forward(struct mbuf *m, int srcrt) * 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. */ - bzero(&ro, sizeof(ro)); + if (flerror != 0) + bzero(&ro, sizeof(ro)); error = ip_output(m, NULL, &ro, IP_FORWARDING, NULL, NULL); if (error == EMSGSIZE && ro.ro_rt) mtu = ro.ro_rt->rt_rmx.rmx_mtu; - if (ro.ro_rt) + if (ro.ro_rt && flerror != 0) RTFREE(ro.ro_rt); if (error) From owner-svn-src-user@FreeBSD.ORG Tue Dec 30 05:00:11 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 00B031065673; Tue, 30 Dec 2008 05:00:11 +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 E2C948FC16; Tue, 30 Dec 2008 05:00:10 +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 mBU50A0E076759; Tue, 30 Dec 2008 05:00:10 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBU50A1Z076754; Tue, 30 Dec 2008 05:00:10 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200812300500.mBU50A1Z076754@svn.freebsd.org> From: Kip Macy Date: Tue, 30 Dec 2008 05:00:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186588 - in user/kmacy/HEAD_fast_net/sys: net netinet sys X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Dec 2008 05:00:11 -0000 Author: kmacy Date: Tue Dec 30 05:00:10 2008 New Revision: 186588 URL: http://svn.freebsd.org/changeset/base/186588 Log: enabled flowid usage for supporting multiple transmit queues Modified: user/kmacy/HEAD_fast_net/sys/net/flowtable.c user/kmacy/HEAD_fast_net/sys/netinet/in_pcb.h user/kmacy/HEAD_fast_net/sys/netinet/ip_output.c user/kmacy/HEAD_fast_net/sys/netinet/tcp_input.c user/kmacy/HEAD_fast_net/sys/sys/mbuf.h Modified: user/kmacy/HEAD_fast_net/sys/net/flowtable.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/flowtable.c Tue Dec 30 04:48:59 2008 (r186587) +++ user/kmacy/HEAD_fast_net/sys/net/flowtable.c Tue Dec 30 05:00:10 2008 (r186588) @@ -394,7 +394,7 @@ ipv4_flow_lookup_hash_internal(struct mb ((uint16_t *)key)[1] = dport; hash = hashword(key, 3, hashjitter + proto); - if (m->m_pkthdr.flowid == 0) + if ((m->m_flags & M_FLOWID) == 0) m->m_pkthdr.flowid = hash; CTR5(KTR_SPARE3, "proto=%d hash=%x key[0]=%x sport=%d dport=%d\n", proto, hash, key[0], sport, dport); Modified: user/kmacy/HEAD_fast_net/sys/netinet/in_pcb.h ============================================================================== --- user/kmacy/HEAD_fast_net/sys/netinet/in_pcb.h Tue Dec 30 04:48:59 2008 (r186587) +++ user/kmacy/HEAD_fast_net/sys/netinet/in_pcb.h Tue Dec 30 05:00:10 2008 (r186588) @@ -169,7 +169,7 @@ struct inpcb { u_char inp_ip_ttl; /* (i) time to live proto */ u_char inp_ip_p; /* (c) protocol proto */ u_char inp_ip_minttl; /* (i) minimum TTL or drop */ - uint32_t inp_ispare1; /* (x) connection id / queue id */ + uint32_t inp_flowid; /* (x) flow id / queue id */ u_int inp_refcount; /* (i) refcount */ struct llentry *inp_lle; /* L2 information */ struct rtentry *inp_rt; /* L3 information */ @@ -419,6 +419,8 @@ void inp_4tuple_get(struct inpcb *inp, #define INP_RECVTTL 0x400 /* receive incoming IP TTL */ #define INP_DONTFRAG 0x800 /* don't fragment packet */ #define INP_LLE_VALID 0x1000 /* L2 entry is set */ +#define INP_SW_FLOWID 0x2000 /* software generated flow id */ +#define INP_HW_FLOWID 0x4000 /* hardware generated flow id */ #define IN6P_IPV6_V6ONLY 0x008000 /* restrict AF_INET6 socket for v6 */ Modified: user/kmacy/HEAD_fast_net/sys/netinet/ip_output.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/netinet/ip_output.c Tue Dec 30 04:48:59 2008 (r186587) +++ user/kmacy/HEAD_fast_net/sys/netinet/ip_output.c Tue Dec 30 05:00:10 2008 (r186588) @@ -144,6 +144,10 @@ ip_output(struct mbuf *m, struct mbuf *o if (inp != NULL) { M_SETFIB(m, inp->inp_inc.inc_fibnum); INP_LOCK_ASSERT(inp); + 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) && (inp->inp_vflag & INP_RT_VALID)) { if (inp->inp_rt->rt_flags & RTF_UP) { sin = (struct sockaddr_in *)&ro->ro_dst; Modified: user/kmacy/HEAD_fast_net/sys/netinet/tcp_input.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/netinet/tcp_input.c Tue Dec 30 04:48:59 2008 (r186587) +++ user/kmacy/HEAD_fast_net/sys/netinet/tcp_input.c Tue Dec 30 05:00:10 2008 (r186588) @@ -585,7 +585,13 @@ findpcb: goto dropwithreset; } INP_WLOCK(inp); - + if (!(so->so_options & SO_ACCEPTCONN) + && !(inp->inp_flags & INP_HW_FLOWID) + && (m->m_flags & M_FLOWID)) { + inp->inp_flags |= INP_HW_FLOWID; + inp->inp_flags &= ~INP_SW_FLOWID; + inp->inp_flowid = m->m_pkthdr.flowid; + } #ifdef IPSEC #ifdef INET6 if (isipv6 && ipsec6_in_reject(m, inp)) { Modified: user/kmacy/HEAD_fast_net/sys/sys/mbuf.h ============================================================================== --- user/kmacy/HEAD_fast_net/sys/sys/mbuf.h Tue Dec 30 04:48:59 2008 (r186587) +++ user/kmacy/HEAD_fast_net/sys/sys/mbuf.h Tue Dec 30 05:00:10 2008 (r186588) @@ -195,6 +195,7 @@ struct mbuf { #define M_PROTO6 0x00080000 /* protocol-specific */ #define M_PROTO7 0x00100000 /* protocol-specific */ #define M_PROTO8 0x00200000 /* protocol-specific */ +#define M_FLOWID 0x00400000 /* flowid is valid */ /* * For RELENG_{6,7} steal these flags for limited multiple routing table * support. In RELENG_8 and beyond, use just one flag and a tag. From owner-svn-src-user@FreeBSD.ORG Tue Dec 30 05:29:43 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C1D9D1065672; Tue, 30 Dec 2008 05:29:43 +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 AF4ED8FC14; Tue, 30 Dec 2008 05:29:43 +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 mBU5Thga077865; Tue, 30 Dec 2008 05:29:43 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBU5Thao077864; Tue, 30 Dec 2008 05:29:43 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200812300529.mBU5Thao077864@svn.freebsd.org> From: Kip Macy Date: Tue, 30 Dec 2008 05:29:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186591 - user/kmacy/HEAD_fast_net/sys/netinet X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Dec 2008 05:29:44 -0000 Author: kmacy Date: Tue Dec 30 05:29:43 2008 New Revision: 186591 URL: http://svn.freebsd.org/changeset/base/186591 Log: validate so before checking options in tcp_input Modified: user/kmacy/HEAD_fast_net/sys/netinet/tcp_input.c Modified: user/kmacy/HEAD_fast_net/sys/netinet/tcp_input.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/netinet/tcp_input.c Tue Dec 30 05:08:05 2008 (r186590) +++ user/kmacy/HEAD_fast_net/sys/netinet/tcp_input.c Tue Dec 30 05:29:43 2008 (r186591) @@ -585,9 +585,9 @@ findpcb: goto dropwithreset; } INP_WLOCK(inp); - if (!(so->so_options & SO_ACCEPTCONN) - && !(inp->inp_flags & INP_HW_FLOWID) - && (m->m_flags & M_FLOWID)) { + if (!(inp->inp_flags & INP_HW_FLOWID) + && (m->m_flags & M_FLOWID) && + ((so == NULL) || !(so->so_options & SO_ACCEPTCONN))) { inp->inp_flags |= INP_HW_FLOWID; inp->inp_flags &= ~INP_SW_FLOWID; inp->inp_flowid = m->m_pkthdr.flowid; From owner-svn-src-user@FreeBSD.ORG Tue Dec 30 05:35:28 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 27DC01065670; Tue, 30 Dec 2008 05:35:28 +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 159828FC12; Tue, 30 Dec 2008 05:35:28 +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 mBU5ZRGj078271; Tue, 30 Dec 2008 05:35:27 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBU5ZRd6078270; Tue, 30 Dec 2008 05:35:27 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200812300535.mBU5ZRd6078270@svn.freebsd.org> From: Kip Macy Date: Tue, 30 Dec 2008 05:35:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186592 - user/kmacy/HEAD_fast_net/sys/netinet X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Dec 2008 05:35:28 -0000 Author: kmacy Date: Tue Dec 30 05:35:27 2008 New Revision: 186592 URL: http://svn.freebsd.org/changeset/base/186592 Log: so isn't set yet, reference inp_socket Modified: user/kmacy/HEAD_fast_net/sys/netinet/tcp_input.c Modified: user/kmacy/HEAD_fast_net/sys/netinet/tcp_input.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/netinet/tcp_input.c Tue Dec 30 05:29:43 2008 (r186591) +++ user/kmacy/HEAD_fast_net/sys/netinet/tcp_input.c Tue Dec 30 05:35:27 2008 (r186592) @@ -586,8 +586,9 @@ findpcb: } INP_WLOCK(inp); if (!(inp->inp_flags & INP_HW_FLOWID) - && (m->m_flags & M_FLOWID) && - ((so == NULL) || !(so->so_options & SO_ACCEPTCONN))) { + && (m->m_flags & M_FLOWID) + && ((inp->inp_socket == NULL) + || !(inp->inp_socket->so_options & SO_ACCEPTCONN))) { inp->inp_flags |= INP_HW_FLOWID; inp->inp_flags &= ~INP_SW_FLOWID; inp->inp_flowid = m->m_pkthdr.flowid; From owner-svn-src-user@FreeBSD.ORG Tue Dec 30 05:35:54 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 589251065675; Tue, 30 Dec 2008 05:35:54 +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 454298FC19; Tue, 30 Dec 2008 05:35:54 +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 mBU5ZsZT078348; Tue, 30 Dec 2008 05:35:54 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBU5ZsA9078346; Tue, 30 Dec 2008 05:35:54 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200812300535.mBU5ZsA9078346@svn.freebsd.org> From: Kip Macy Date: Tue, 30 Dec 2008 05:35:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186593 - user/kmacy/HEAD_fast_net/sys/dev/mxge X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Dec 2008 05:35:54 -0000 Author: kmacy Date: Tue Dec 30 05:35:54 2008 New Revision: 186593 URL: http://svn.freebsd.org/changeset/base/186593 Log: import multiple tx queue support from HEAD_fast_multi_xmit Modified: user/kmacy/HEAD_fast_net/sys/dev/mxge/if_mxge.c user/kmacy/HEAD_fast_net/sys/dev/mxge/if_mxge_var.h Modified: user/kmacy/HEAD_fast_net/sys/dev/mxge/if_mxge.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/dev/mxge/if_mxge.c Tue Dec 30 05:35:27 2008 (r186592) +++ user/kmacy/HEAD_fast_net/sys/dev/mxge/if_mxge.c Tue Dec 30 05:35:54 2008 (r186593) @@ -30,6 +30,8 @@ POSSIBILITY OF SUCH DAMAGE. #include __FBSDID("$FreeBSD$"); +#define IFNET_MULTIQUEUE + #include #include #include @@ -66,6 +68,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#ifdef IFNET_MULTIQUEUE +#include +#endif #include #include #include @@ -1207,6 +1212,9 @@ mxge_reset(mxge_softc_t *sc, int interru */ cmd.data0 = sc->num_slices; cmd.data1 = MXGEFW_SLICE_INTR_MODE_ONE_PER_SLICE; +#ifdef IFNET_MULTIQUEUE + cmd.data1 |= MXGEFW_SLICE_ENABLE_MULTIPLE_TX_QUEUES; +#endif status = mxge_send_cmd(sc, MXGEFW_CMD_ENABLE_RSS_QUEUES, &cmd); if (status != 0) { @@ -1266,6 +1274,9 @@ mxge_reset(mxge_softc_t *sc, int interru ss->tx.req = 0; ss->tx.done = 0; ss->tx.pkt_done = 0; + ss->tx.queue_active = 0; + ss->tx.activate = 0; + ss->tx.deactivate = 0; ss->tx.wake = 0; ss->tx.defrag = 0; ss->tx.stall = 0; @@ -1598,10 +1609,6 @@ mxge_add_sysctls(mxge_softc_t *sc) "rx_big_cnt", CTLFLAG_RD, &ss->rx_big.cnt, 0, "rx_small_cnt"); - SYSCTL_ADD_INT(ctx, children, OID_AUTO, - "tx_req", - CTLFLAG_RD, &ss->tx.req, - 0, "tx_req"); SYSCTL_ADD_INT(ctx, children, OID_AUTO, "lro_flushed", CTLFLAG_RD, &ss->lro_flushed, 0, "number of lro merge queues flushed"); @@ -1611,9 +1618,15 @@ mxge_add_sysctls(mxge_softc_t *sc) 0, "number of frames appended to lro merge" "queues"); +#ifndef IFNET_MULTIQUEUE /* only transmit from slice 0 for now */ if (slice > 0) continue; +#endif + SYSCTL_ADD_INT(ctx, children, OID_AUTO, + "tx_req", + CTLFLAG_RD, &ss->tx.req, + 0, "tx_req"); SYSCTL_ADD_INT(ctx, children, OID_AUTO, "tx_done", @@ -1635,6 +1648,18 @@ mxge_add_sysctls(mxge_softc_t *sc) "tx_defrag", CTLFLAG_RD, &ss->tx.defrag, 0, "tx_defrag"); + SYSCTL_ADD_INT(ctx, children, OID_AUTO, + "tx_queue_active", + CTLFLAG_RD, &ss->tx.queue_active, + 0, "tx_queue_active"); + SYSCTL_ADD_INT(ctx, children, OID_AUTO, + "tx_activate", + CTLFLAG_RD, &ss->tx.activate, + 0, "tx_activate"); + SYSCTL_ADD_INT(ctx, children, OID_AUTO, + "tx_deactivate", + CTLFLAG_RD, &ss->tx.deactivate, + 0, "tx_deactivate"); } } @@ -1857,12 +1882,21 @@ mxge_encap_tso(struct mxge_slice_state * tx->info[((cnt - 1) + tx->req) & tx->mask].flag = 1; mxge_submit_req(tx, tx->req_list, cnt); +#ifdef IFNET_MULTIQUEUE + if ((ss->sc->num_slices > 1) && tx->queue_active == 0) { + /* tell the NIC to start polling this slice */ + *tx->send_go = 1; + tx->queue_active = 1; + tx->activate++; + wmb(); + } +#endif return; drop: bus_dmamap_unload(tx->dmat, tx->info[tx->req & tx->mask].map); m_freem(m); - ss->sc->ifp->if_oerrors++; + ss->oerrors++; if (!once) { printf("tx->max_desc exceeded via TSO!\n"); printf("mss = %d, %ld, %d!\n", mss, @@ -2059,16 +2093,114 @@ mxge_encap(struct mxge_slice_state *ss, #endif tx->info[((cnt - 1) + tx->req) & tx->mask].flag = 1; mxge_submit_req(tx, tx->req_list, cnt); +#ifdef IFNET_MULTIQUEUE + if ((ss->sc->num_slices > 1) && tx->queue_active == 0) { + /* tell the NIC to start polling this slice */ + *tx->send_go = 1; + tx->queue_active = 1; + tx->activate++; + wmb(); + } +#endif return; drop: m_freem(m); - ifp->if_oerrors++; + ss->oerrors++; return; } +#ifdef IFNET_MULTIQUEUE +static inline void +mxge_start_locked(struct mxge_slice_state *ss) +{ + mxge_softc_t *sc; + struct mbuf *m; + struct ifnet *ifp; + mxge_tx_ring_t *tx; + + sc = ss->sc; + ifp = sc->ifp; + tx = &ss->tx; + + while (((tx->mask - (tx->req - tx->done)) > tx->max_desc) + && (!buf_ring_empty(tx->br))) { + m = buf_ring_dequeue_sc(tx->br); + if (m == NULL) { + return; + } + /* let BPF see it */ + BPF_MTAP(ifp, m); + + /* give it to the nic */ + mxge_encap(ss, m); + } + /* ran out of transmit slots */ + if (((ss->if_drv_flags & IFF_DRV_OACTIVE) == 0) + && (!buf_ring_empty(tx->br))) { + ss->if_drv_flags |= IFF_DRV_OACTIVE; + tx->stall++; + } +} + +static int +mxge_transmit_locked(struct mxge_slice_state *ss, struct mbuf *m) +{ + mxge_softc_t *sc; + struct ifnet *ifp; + mxge_tx_ring_t *tx; + int err; + + sc = ss->sc; + ifp = sc->ifp; + tx = &ss->tx; + + if ((ss->if_drv_flags & (IFF_DRV_RUNNING|IFF_DRV_OACTIVE)) != + IFF_DRV_RUNNING) { + err = drbr_enqueue(ifp, tx->br, m); + return (err); + } + + if (buf_ring_empty(tx->br) && + ((tx->mask - (tx->req - tx->done)) > tx->max_desc)) { + /* let BPF see it */ + BPF_MTAP(ifp, m); + /* give it to the nic */ + mxge_encap(ss, m); + } else if ((err = drbr_enqueue(ifp, tx->br, m)) != 0) { + return (err); + } + if (!buf_ring_empty(tx->br)) + mxge_start_locked(ss); + return (0); +} + +static int +mxge_transmit(struct ifnet *ifp, struct mbuf *m) +{ + mxge_softc_t *sc = ifp->if_softc; + struct mxge_slice_state *ss; + mxge_tx_ring_t *tx; + int err = 0; + int slice; + + slice = m->m_pkthdr.flowid; + + slice &= (sc->num_slices - 1); /* num_slices always power of 2 */ + ss = &sc->ss[slice]; + tx = &ss->tx; + if (mtx_trylock(&tx->mtx)) { + err = mxge_transmit_locked(ss, m); + mtx_unlock(&tx->mtx); + } else { + err = drbr_enqueue(ifp, tx->br, m); + } + return (err); +} + +#else static inline void mxge_start_locked(struct mxge_slice_state *ss) @@ -2098,7 +2230,7 @@ mxge_start_locked(struct mxge_slice_stat tx->stall++; } } - +#endif static void mxge_start(struct ifnet *ifp) { @@ -2349,6 +2481,7 @@ mxge_rx_done_big(struct mxge_slice_state m->m_data += MXGEFW_PAD; m->m_pkthdr.rcvif = ifp; + m->m_pkthdr.flowid = ss - sc->ss; m->m_len = m->m_pkthdr.len = len; ss->ipackets++; eh = mtod(m, struct ether_header *); @@ -2409,6 +2542,7 @@ mxge_rx_done_small(struct mxge_slice_sta m->m_data += MXGEFW_PAD; m->m_pkthdr.rcvif = ifp; + m->m_pkthdr.flowid = ss - sc->ss; m->m_len = m->m_pkthdr.len = len; ss->ipackets++; eh = mtod(m, struct ether_header *); @@ -2470,6 +2604,7 @@ mxge_tx_done(struct mxge_slice_state *ss struct mbuf *m; bus_dmamap_t map; int idx; + int *flags; tx = &ss->tx; ifp = ss->sc->ifp; @@ -2480,7 +2615,12 @@ mxge_tx_done(struct mxge_slice_state *ss /* mbuf and DMA map only attached to the first segment per-mbuf */ if (m != NULL) { - ifp->if_opackets++; +#ifdef IFNET_MULTIQUEUE + ss->obytes += m->m_pkthdr.len; + if (m->m_flags & M_MCAST) + ss->omcasts++; +#endif + ss->opackets++; tx->info[idx].m = NULL; map = tx->info[idx].map; bus_dmamap_unload(tx->dmat, map); @@ -2494,15 +2634,33 @@ mxge_tx_done(struct mxge_slice_state *ss /* If we have space, clear IFF_OACTIVE to tell the stack that its OK to send packets */ - - if (ifp->if_drv_flags & IFF_DRV_OACTIVE && +#ifdef IFNET_MULTIQUEUE + flags = &ss->if_drv_flags; +#else + flags = &ifp->if_drv_flags; +#endif + mtx_lock(&ss->tx.mtx); + if ((*flags) & IFF_DRV_OACTIVE && tx->req - tx->done < (tx->mask + 1)/4) { - mtx_lock(&ss->tx.mtx); - ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; + *(flags) &= ~IFF_DRV_OACTIVE; ss->tx.wake++; mxge_start_locked(ss); - mtx_unlock(&ss->tx.mtx); } +#ifdef IFNET_MULTIQUEUE + if ((ss->sc->num_slices > 1) && (tx->req == tx->done)) { + /* let the NIC stop polling this queue, since there + * are no more transmits pending */ + if (tx->req == tx->done) { + *tx->send_stop = 1; + tx->queue_active = 0; + tx->deactivate++; + wmb(); + } + } + mtx_unlock(&ss->tx.mtx); + +#endif + } static struct mxge_media_type mxge_media_types[] = @@ -2653,6 +2811,7 @@ mxge_intr(void *arg) uint8_t valid; +#ifndef IFNET_MULTIQUEUE /* an interrupt on a non-zero slice is implicitly valid since MSI-X irqs are not shared */ if (ss != sc->ss) { @@ -2660,6 +2819,7 @@ mxge_intr(void *arg) *ss->irq_claim = be32toh(3); return; } +#endif /* make sure the DMA has finished */ if (!stats->valid) { @@ -2683,7 +2843,8 @@ mxge_intr(void *arg) send_done_count = be32toh(stats->send_done_count); while ((send_done_count != tx->pkt_done) || (rx_done->entry[rx_done->idx].length != 0)) { - mxge_tx_done(ss, (int)send_done_count); + if (send_done_count != tx->pkt_done) + mxge_tx_done(ss, (int)send_done_count); mxge_clean_rx_done(ss); send_done_count = be32toh(stats->send_done_count); } @@ -2691,7 +2852,8 @@ mxge_intr(void *arg) wmb(); } while (*((volatile uint8_t *) &stats->valid)); - if (__predict_false(stats->stats_updated)) { + /* fw stats meaningful only on the first slice */ + if (__predict_false((ss == sc->ss) && stats->stats_updated)) { if (sc->link_state != stats->link_up) { sc->link_state = stats->link_up; if (sc->link_state) { @@ -2980,11 +3142,11 @@ mxge_alloc_slice_rings(struct mxge_slice } /* now allocate TX resouces */ - +#ifndef IFNET_MULTIQUEUE /* only use a single TX ring for now */ if (ss != ss->sc->ss) return 0; - +#endif ss->tx.mask = tx_ring_entries - 1; ss->tx.max_desc = MIN(MXGE_MAX_SEND_DESC, tx_ring_entries / 4); @@ -3149,13 +3311,21 @@ mxge_slice_open(struct mxge_slice_state /* get the lanai pointers to the send and receive rings */ err = 0; +#ifndef IFNET_MULTIQUEUE /* We currently only send from the first slice */ if (slice == 0) { +#endif cmd.data0 = slice; err = mxge_send_cmd(sc, MXGEFW_CMD_GET_SEND_OFFSET, &cmd); ss->tx.lanai = (volatile mcp_kreq_ether_send_t *)(sc->sram + cmd.data0); + ss->tx.send_go = (volatile uint32_t *) + (sc->sram + MXGEFW_ETH_SEND_GO + 64 * slice); + ss->tx.send_stop = (volatile uint32_t *) + (sc->sram + MXGEFW_ETH_SEND_STOP + 64 * slice); +#ifndef IFNET_MULTIQUEUE } +#endif cmd.data0 = slice; err |= mxge_send_cmd(sc, MXGEFW_CMD_GET_SMALL_RX_OFFSET, &cmd); @@ -3207,6 +3377,7 @@ mxge_open(mxge_softc_t *sc) int err, big_bytes, nbufs, slice, cl_size, i; bus_addr_t bus; volatile uint8_t *itable; + struct mxge_slice_state *ss; /* Copy the MAC address in case it was overridden */ bcopy(IF_LLADDR(sc->ifp), sc->mac_addr, ETHER_ADDR_LEN); @@ -3276,10 +3447,22 @@ mxge_open(mxge_softc_t *sc) } /* Now give him the pointer to the stats block */ - cmd.data0 = MXGE_LOWPART_TO_U32(sc->ss->fw_stats_dma.bus_addr); - cmd.data1 = MXGE_HIGHPART_TO_U32(sc->ss->fw_stats_dma.bus_addr); - cmd.data2 = sizeof(struct mcp_irq_data); - err = mxge_send_cmd(sc, MXGEFW_CMD_SET_STATS_DMA_V2, &cmd); + for (slice = 0; +#ifdef IFNET_MULTIQUEUE + slice < sc->num_slices; +#else + slice < 1; +#endif + slice++) { + ss = &sc->ss[slice]; + cmd.data0 = + MXGE_LOWPART_TO_U32(ss->fw_stats_dma.bus_addr); + cmd.data1 = + MXGE_HIGHPART_TO_U32(ss->fw_stats_dma.bus_addr); + cmd.data2 = sizeof(struct mcp_irq_data); + cmd.data2 |= (slice << 16); + err |= mxge_send_cmd(sc, MXGEFW_CMD_SET_STATS_DMA_V2, &cmd); + } if (err != 0) { bus = sc->ss->fw_stats_dma.bus_addr; @@ -3315,8 +3498,16 @@ mxge_open(mxge_softc_t *sc) device_printf(sc->dev, "Couldn't bring up link\n"); goto abort; } +#ifdef IFNET_MULTIQUEUE + for (slice = 0; slice < sc->num_slices; slice++) { + ss = &sc->ss[slice]; + ss->if_drv_flags |= IFF_DRV_RUNNING; + ss->if_drv_flags &= ~IFF_DRV_OACTIVE; + } +#endif sc->ifp->if_drv_flags |= IFF_DRV_RUNNING; sc->ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; + callout_reset(&sc->co_hdl, mxge_ticks, mxge_tick, sc); return 0; @@ -3333,8 +3524,18 @@ mxge_close(mxge_softc_t *sc) { mxge_cmd_t cmd; int err, old_down_cnt; +#ifdef IFNET_MULTIQUEUE + struct mxge_slice_state *ss; + int slice; +#endif callout_stop(&sc->co_hdl); +#ifdef IFNET_MULTIQUEUE + for (slice = 0; slice < sc->num_slices; slice++) { + ss = &sc->ss[slice]; + ss->if_drv_flags &= ~IFF_DRV_RUNNING; + } +#endif sc->ifp->if_drv_flags &= ~IFF_DRV_RUNNING; old_down_cnt = sc->down_cnt; wmb(); @@ -3400,9 +3601,10 @@ mxge_read_reboot(mxge_softc_t *sc) } static int -mxge_watchdog_reset(mxge_softc_t *sc) +mxge_watchdog_reset(mxge_softc_t *sc, int slice) { struct pci_devinfo *dinfo; + mxge_tx_ring_t *tx; int err; uint32_t reboot; uint16_t cmd; @@ -3449,11 +3651,17 @@ mxge_watchdog_reset(mxge_softc_t *sc) err = mxge_open(sc); } } else { - device_printf(sc->dev, "NIC did not reboot, ring state:\n"); - device_printf(sc->dev, "tx.req=%d tx.done=%d\n", - sc->ss->tx.req, sc->ss->tx.done); + tx = &sc->ss[slice].tx; + device_printf(sc->dev, + "NIC did not reboot, slice %d ring state:\n", + slice); + device_printf(sc->dev, + "tx.req=%d tx.done=%d, tx.queue_active=%d\n", + tx->req, tx->done, tx->queue_active); + device_printf(sc->dev, "tx.activate=%d tx.deactivate=%d\n", + tx->activate, tx->deactivate); device_printf(sc->dev, "pkt_done=%d fw=%d\n", - sc->ss->tx.pkt_done, + tx->pkt_done, be32toh(sc->ss->fw_stats->send_done_count)); device_printf(sc->dev, "not resetting\n"); } @@ -3463,26 +3671,35 @@ mxge_watchdog_reset(mxge_softc_t *sc) static int mxge_watchdog(mxge_softc_t *sc) { - mxge_tx_ring_t *tx = &sc->ss->tx; + mxge_tx_ring_t *tx; uint32_t rx_pause = be32toh(sc->ss->fw_stats->dropped_pause); - int err = 0; + int i, err = 0; /* see if we have outstanding transmits, which have been pending for more than mxge_ticks */ - if (tx->req != tx->done && - tx->watchdog_req != tx->watchdog_done && - tx->done == tx->watchdog_done) { - /* check for pause blocking before resetting */ - if (tx->watchdog_rx_pause == rx_pause) - err = mxge_watchdog_reset(sc); - else - device_printf(sc->dev, "Flow control blocking " - "xmits, check link partner\n"); - } + for (i = 0; +#ifdef IFNET_MULTIQUEUE + (i < sc->num_slices) && (err == 0); +#else + (i < 1) && (err == 0); +#endif + i++) { + tx = &sc->ss[i].tx; + if (tx->req != tx->done && + tx->watchdog_req != tx->watchdog_done && + tx->done == tx->watchdog_done) { + /* check for pause blocking before resetting */ + if (tx->watchdog_rx_pause == rx_pause) + err = mxge_watchdog_reset(sc, i); + else + device_printf(sc->dev, "Flow control blocking " + "xmits, check link partner\n"); + } - tx->watchdog_req = tx->req; - tx->watchdog_done = tx->done; - tx->watchdog_rx_pause = rx_pause; + tx->watchdog_req = tx->req; + tx->watchdog_done = tx->done; + tx->watchdog_rx_pause = rx_pause; + } if (sc->need_media_probe) mxge_media_probe(sc); @@ -3494,15 +3711,36 @@ mxge_update_stats(mxge_softc_t *sc) { struct mxge_slice_state *ss; u_long ipackets = 0; + u_long opackets = 0; +#ifdef IFNET_MULTIQUEUE + u_long obytes = 0; + u_long omcasts = 0; + u_long odrops = 0; +#endif + u_long oerrors = 0; int slice; - for(slice = 0; slice < sc->num_slices; slice++) { + for (slice = 0; slice < sc->num_slices; slice++) { ss = &sc->ss[slice]; ipackets += ss->ipackets; + opackets += ss->opackets; +#ifdef IFNET_MULTIQUEUE + obytes += ss->obytes; + omcasts += ss->omcasts; + odrops += ss->tx.br->br_drops; +#endif + oerrors += ss->oerrors; } sc->ifp->if_ipackets = ipackets; - + sc->ifp->if_opackets = opackets; +#ifdef IFNET_MULTIQUEUE + sc->ifp->if_obytes = obytes; + sc->ifp->if_omcasts = omcasts; + sc->ifp->if_snd.ifq_drops = odrops; +#endif + sc->ifp->if_oerrors = oerrors; } + static void mxge_tick(void *arg) { @@ -3724,6 +3962,12 @@ mxge_free_slices(mxge_softc_t *sc) if (ss->fw_stats != NULL) { mxge_dma_free(&ss->fw_stats_dma); ss->fw_stats = NULL; +#ifdef IFNET_MULTIQUEUE + if (ss->tx.br != NULL) { + drbr_free(ss->tx.br, M_DEVBUF); + ss->tx.br = NULL; + } +#endif mtx_destroy(&ss->tx.mtx); } if (ss->rx_done.entry != NULL) { @@ -3774,9 +4018,10 @@ mxge_alloc_slices(mxge_softc_t *sc) * (including tx) are used used only on the first * slice for now */ +#ifndef IFNET_MULTIQUEUE if (i > 0) continue; - +#endif bytes = sizeof (*ss->fw_stats); err = mxge_dma_alloc(sc, &ss->fw_stats_dma, sizeof (*ss->fw_stats), 64); @@ -3786,6 +4031,11 @@ mxge_alloc_slices(mxge_softc_t *sc) snprintf(ss->tx.mtx_name, sizeof(ss->tx.mtx_name), "%s:tx(%d)", device_get_nameunit(sc->dev), i); mtx_init(&ss->tx.mtx, ss->tx.mtx_name, NULL, MTX_DEF); +#ifdef IFNET_MULTIQUEUE + ss->tx.br = buf_ring_alloc(2048, M_DEVBUF, M_WAITOK, + &ss->tx.mtx); +#endif + } return (0); @@ -4259,6 +4509,9 @@ mxge_attach(device_t dev) ifp->if_mtu = 9000; mxge_add_sysctls(sc); +#ifdef IFNET_MULTIQUEUE + ifp->if_transmit = mxge_transmit; +#endif return 0; abort_with_rings: Modified: user/kmacy/HEAD_fast_net/sys/dev/mxge/if_mxge_var.h ============================================================================== --- user/kmacy/HEAD_fast_net/sys/dev/mxge/if_mxge_var.h Tue Dec 30 05:35:27 2008 (r186592) +++ user/kmacy/HEAD_fast_net/sys/dev/mxge/if_mxge_var.h Tue Dec 30 05:35:54 2008 (r186593) @@ -125,7 +125,12 @@ typedef struct typedef struct { struct mtx mtx; +#ifdef IFNET_MULTIQUEUE + struct buf_ring *br; +#endif volatile mcp_kreq_ether_send_t *lanai; /* lanai ptr for sendq */ + volatile uint32_t *send_go; /* doorbell for sendq */ + volatile uint32_t *send_stop; /* doorbell for sendq */ mcp_kreq_ether_send_t *req_list; /* host shadow of sendq */ char *req_bytes; bus_dma_segment_t *seg_list; @@ -136,6 +141,9 @@ typedef struct int done; /* transmits completed */ int pkt_done; /* packets completed */ int max_desc; /* max descriptors per xmit */ + int queue_active; /* fw currently polling this queue*/ + int activate; + int deactivate; int stall; /* #times hw queue exhausted */ int wake; /* #times irq re-enabled xmit */ int watchdog_req; /* cache of req */ @@ -182,6 +190,11 @@ struct mxge_slice_state { mcp_irq_data_t *fw_stats; volatile uint32_t *irq_claim; u_long ipackets; + u_long opackets; + u_long obytes; + u_long omcasts; + u_long oerrors; + int if_drv_flags; struct lro_head lro_active; struct lro_head lro_free; int lro_queued; From owner-svn-src-user@FreeBSD.ORG Tue Dec 30 05:36:14 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4C1381065674; Tue, 30 Dec 2008 05:36:14 +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 3996D8FC1B; Tue, 30 Dec 2008 05:36:14 +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 mBU5aEY9078408; Tue, 30 Dec 2008 05:36:14 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBU5aE1t078407; Tue, 30 Dec 2008 05:36:14 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200812300536.mBU5aE1t078407@svn.freebsd.org> From: Kip Macy Date: Tue, 30 Dec 2008 05:36:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186594 - user/kmacy/HEAD_fast_net/sys/dev/cxgb X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Dec 2008 05:36:14 -0000 Author: kmacy Date: Tue Dec 30 05:36:13 2008 New Revision: 186594 URL: http://svn.freebsd.org/changeset/base/186594 Log: set flowid valid flag Modified: user/kmacy/HEAD_fast_net/sys/dev/cxgb/cxgb_sge.c Modified: user/kmacy/HEAD_fast_net/sys/dev/cxgb/cxgb_sge.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/dev/cxgb/cxgb_sge.c Tue Dec 30 05:35:54 2008 (r186593) +++ user/kmacy/HEAD_fast_net/sys/dev/cxgb/cxgb_sge.c Tue Dec 30 05:36:13 2008 (r186594) @@ -2879,6 +2879,7 @@ process_responses(adapter_t *adap, struc eop = get_packet(adap, drop_thresh, qs, &rspq->rspq_mbuf, r); #endif #ifdef IFNET_MULTIQUEUE + rspq->rspq_mh.mh_head->m_flags |= M_FLOWID; rspq->rspq_mh.mh_head->m_pkthdr.flowid = rss_hash; #endif ethpad = 2; From owner-svn-src-user@FreeBSD.ORG Tue Dec 30 17:00:53 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6A353106564A; Tue, 30 Dec 2008 17:00:53 +0000 (UTC) (envelope-from bms@FreeBSD.org) Received: from out1.smtp.messagingengine.com (out1.smtp.messagingengine.com [66.111.4.25]) by mx1.freebsd.org (Postfix) with ESMTP id 390668FC08; Tue, 30 Dec 2008 17:00:52 +0000 (UTC) (envelope-from bms@FreeBSD.org) Received: from compute1.internal (compute1.internal [10.202.2.41]) by out1.messagingengine.com (Postfix) with ESMTP id 9C7FD1FCC28; Tue, 30 Dec 2008 11:41:13 -0500 (EST) Received: from heartbeat1.messagingengine.com ([10.202.2.160]) by compute1.internal (MEProxy); Tue, 30 Dec 2008 11:41:13 -0500 X-Sasl-enc: UiUjpERGp4AdrN1OM1lQwlHCkYO36k+WLlGFddYyGrpJ 1230655273 Received: from empiric.lon.incunabulum.net (unknown [81.168.51.182]) by mail.messagingengine.com (Postfix) with ESMTPSA id C7DE12D676; Tue, 30 Dec 2008 11:41:12 -0500 (EST) Message-ID: <495A4F27.1050502@FreeBSD.org> Date: Tue, 30 Dec 2008 16:41:11 +0000 From: "Bruce M. Simpson" User-Agent: Thunderbird 2.0.0.18 (X11/20081205) MIME-Version: 1.0 To: Kip Macy References: <200812300438.mBU4ceDK076135@svn.freebsd.org> In-Reply-To: <200812300438.mBU4ceDK076135@svn.freebsd.org> X-Enigmail-Version: 0.95.6 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: Re: svn commit: r186585 - user/kmacy/HEAD_fast_net/sys/netinet X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Dec 2008 17:00:53 -0000 Kip Macy wrote: > Author: kmacy > Date: Tue Dec 30 04:38:39 2008 > New Revision: 186585 > URL: http://svn.freebsd.org/changeset/base/186585 > > Log: > make ipv4 forwarding flowtable aware > This is so that we continue to use the same IPv4 next-hop consistently in an ECMP enabled kernel for sockets, right? cheers BMS From owner-svn-src-user@FreeBSD.ORG Wed Dec 31 01:42:25 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 29965106564A; Wed, 31 Dec 2008 01:42:25 +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 15C008FC18; Wed, 31 Dec 2008 01:42:25 +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 mBV1gOVJ011169; Wed, 31 Dec 2008 01:42:24 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBV1gOkL011168; Wed, 31 Dec 2008 01:42:24 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200812310142.mBV1gOkL011168@svn.freebsd.org> From: Kip Macy Date: Wed, 31 Dec 2008 01:42:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186620 - user/kmacy/HEAD_fast_net/sys/netinet X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Dec 2008 01:42:25 -0000 Author: kmacy Date: Wed Dec 31 01:42:24 2008 New Revision: 186620 URL: http://svn.freebsd.org/changeset/base/186620 Log: Add ip_output_fast for handling ip transmit in the common case Modified: user/kmacy/HEAD_fast_net/sys/netinet/ip_output.c Modified: user/kmacy/HEAD_fast_net/sys/netinet/ip_output.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/netinet/ip_output.c Tue Dec 30 23:49:54 2008 (r186619) +++ user/kmacy/HEAD_fast_net/sys/netinet/ip_output.c Wed Dec 31 01:42:24 2008 (r186620) @@ -104,6 +104,92 @@ static void ip_mloopback extern struct protosw inetsw[]; extern struct flowtable *ipv4_ft; +static int +ip_output_fast(struct mbuf *m, struct route *ro, int flags, int hlen, + struct inpcb *inp) +{ + struct ifnet *ifp = NULL; /* keep compiler happy */ + struct ip *ip; + struct in_ifaddr *ia = NULL; + int sw_csum; + + ia = ifatoia(ro->ro_rt->rt_ifa); + ifp = ro->ro_rt->rt_ifp; + ro->ro_rt->rt_rmx.rmx_pksent++; + + if (ro->ro_rt->rt_flags & RTF_GATEWAY) + bcopy(ro->ro_rt->rt_gateway, &ro->ro_dst, + sizeof(struct sockaddr)); + + ip = mtod(m, struct ip *); + /* + * If the source address is not specified yet, use the address + * of the outoing interface. + */ + if (ip->ip_src.s_addr == INADDR_ANY) { + /* Interface may have no addresses. */ + if (ia != NULL) { + ip->ip_src = IA_SIN(ia)->sin_addr; + } + } + +#ifdef IPSEC + switch(ip_ipsec_output(&m, inp, &flags, &error, &ro, &iproute, &dst, &ia, &ifp)) { + case 1: + m_freem(m); + return (0); + case -1: + return (0); + case 0: + default: + break; /* Continue with packet processing. */ + } + /* Update variables that are affected by ipsec4_output(). */ + ip = mtod(m, struct ip *); + hlen = ip->ip_hl << 2; +#endif /* IPSEC */ + + m->m_pkthdr.csum_flags |= CSUM_IP; + sw_csum = m->m_pkthdr.csum_flags & ~ifp->if_hwassist; + if (sw_csum & CSUM_DELAY_DATA) { + in_delayed_cksum(m); + sw_csum &= ~CSUM_DELAY_DATA; + } + m->m_pkthdr.csum_flags &= ifp->if_hwassist; + + ip->ip_len = htons(ip->ip_len); + ip->ip_off = htons(ip->ip_off); + ip->ip_sum = 0; + if (sw_csum & CSUM_DELAY_IP) + ip->ip_sum = in_cksum(m, hlen); + + /* + * Record statistics for this interface address. + * With CSUM_TSO the byte/packet count will be slightly + * incorrect because we count the IP+TCP headers only + * once instead of for every generated packet. + */ + if (!(flags & IP_FORWARDING) && ia) { + if (m->m_pkthdr.csum_flags & CSUM_TSO) + ia->ia_ifa.if_opackets += + m->m_pkthdr.len / m->m_pkthdr.tso_segsz; + else + ia->ia_ifa.if_opackets++; + ia->ia_ifa.if_obytes += m->m_pkthdr.len; + } +#ifdef MBUF_STRESS_TEST + if (mbuf_frag_size && m->m_pkthdr.len > mbuf_frag_size) + m = m_fragment(m, M_DONTWAIT, mbuf_frag_size); +#endif + /* + * Reset layer specific mbuf flags + * to avoid confusing lower layers. + */ + m->m_flags &= ~(M_PROTOFLAGS); + + return ((*ifp->if_output)(ifp, m, ro)); +} + /* * IP output. The packet in mbuf chain m contains a skeletal IP * header (with len, off, ttl, proto, tos, src, dst). @@ -121,16 +207,15 @@ ip_output(struct mbuf *m, struct mbuf *o struct ip *ip; struct ifnet *ifp = NULL; /* keep compiler happy */ struct mbuf *m0; + struct in_ifaddr *ia = NULL; int hlen = sizeof (struct ip); int mtu; int len, error = 0; int neednewroute = 0, neednewlle = 0, nortfree = 0; struct sockaddr_in *dst = NULL; /* keep compiler happy */ - struct in_ifaddr *ia = NULL; int isbroadcast, sw_csum; struct route iproute; struct in_addr odst; - struct sockaddr_in *sin; #ifdef IPFIREWALL_FORWARD struct m_tag *fwd_tag = NULL; #endif @@ -144,33 +229,8 @@ ip_output(struct mbuf *m, struct mbuf *o if (inp != NULL) { M_SETFIB(m, inp->inp_inc.inc_fibnum); INP_LOCK_ASSERT(inp); - 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) && (inp->inp_vflag & INP_RT_VALID)) { - if (inp->inp_rt->rt_flags & RTF_UP) { - sin = (struct sockaddr_in *)&ro->ro_dst; - sin->sin_family = AF_INET; - sin->sin_len = sizeof(struct sockaddr_in); - sin->sin_addr.s_addr = inp->inp_faddr.s_addr; - ro->ro_rt = inp->inp_rt; - } else - neednewroute = 1; - } - if ((ro == &iproute) && (inp->inp_flags & INP_LLE_VALID)) { - if (inp->inp_lle->la_flags & LLE_VALID) { - ro->ro_lle = inp->inp_lle; - } else - neednewlle = 1; - } - } - if ((ro == &iproute) && (ro->ro_rt == NULL) && (ro->ro_lle == NULL)) { - if (flowtable_lookup(ipv4_ft, m, ro) == 0) - nortfree = 1; } - if (opt) { len = 0; m = ip_insertoptions(m, opt, &len); @@ -208,13 +268,16 @@ again: * The address family should also be checked in case of sharing the * cache with IPv6. */ - if (ro->ro_rt && ((ro->ro_rt->rt_flags & RTF_UP) == 0 || + if (ro->ro_rt != NULL && ((ro->ro_rt->rt_flags & RTF_UP) == 0 || dst->sin_family != AF_INET || dst->sin_addr.s_addr != ip->ip_dst.s_addr)) { - if ((nortfree == 0) && - (inp == NULL || (ro->ro_rt != inp->inp_rt))) - RTFREE(ro->ro_rt); - ro->ro_rt = (struct rtentry *)NULL; + /* + * XXX need to check that ro->ro_rt isn't coming from a flow + * lookup in ip_forward ... perhaps pass in a new flag + * + */ + RTFREE(ro->ro_rt); + ro->ro_rt = NULL; } #ifdef IPFIREWALL_FORWARD if (ro->ro_rt == NULL && fwd_tag == NULL) { @@ -226,6 +289,65 @@ again: dst->sin_len = sizeof(*dst); dst->sin_addr = ip->ip_dst; } + if (ro != &iproute) + goto skipcachecheck; + if (inp != NULL) { + if (inp->inp_flags & (INP_HW_FLOWID|INP_SW_FLOWID)) { + m->m_pkthdr.flowid = inp->inp_flowid; + m->m_flags |= M_FLOWID; + } + if (inp->inp_vflag & INP_RT_VALID) { + if (inp->inp_rt->rt_flags & RTF_UP) { + ro->ro_rt = inp->inp_rt; + } else + neednewroute = 1; + } + if (inp->inp_flags & INP_LLE_VALID) { + if (inp->inp_lle->la_flags & LLE_VALID) { + ro->ro_lle = inp->inp_lle; + } else + neednewlle = 1; + } + } + if ((ro->ro_rt == NULL) && (ro->ro_lle == NULL)) { + if (flowtable_lookup(ipv4_ft, m, ro) == 0) + nortfree = 1; + } +skipcachecheck: + + /* + * Check if we can take a huge shortcut + */ + if (ro->ro_rt != NULL && (ro->ro_rt->rt_flags & RTF_UP) && + ro->ro_lle != NULL && (ro->ro_lle->la_flags & LLE_VALID) && + (flags & (IP_SENDONES|IP_ROUTETOIF)) == 0 && + !PFIL_HOOKED(&inet_pfil_hook) && + !IN_MULTICAST(ntohl(ip->ip_dst.s_addr))) { + ifp = ro->ro_rt->rt_ifp; + + if (ro->ro_rt->rt_flags & (RTF_UP|RTF_HOST)) { + if (ro->ro_rt->rt_rmx.rmx_mtu > ifp->if_mtu) + ro->ro_rt->rt_rmx.rmx_mtu = ifp->if_mtu; + mtu = ro->ro_rt->rt_rmx.rmx_mtu; + } else + mtu = ifp->if_mtu; + + if (ro->ro_rt->rt_flags & RTF_GATEWAY) + dst = (struct sockaddr_in *)ro->ro_rt->rt_gateway; + else + dst = (struct sockaddr_in *)&ro->ro_dst; + if (ro->ro_rt->rt_flags & RTF_HOST) + isbroadcast = (ro->ro_rt->rt_flags & RTF_BROADCAST); + else + isbroadcast = in_broadcast(dst->sin_addr, ifp); + + if (!isbroadcast && (ip->ip_len <= mtu || + (m->m_pkthdr.csum_flags & ifp->if_hwassist & CSUM_TSO) != 0 + || ((ip->ip_off & IP_DF) == 0 + && (ifp->if_hwassist & CSUM_FRAGMENT)))) + return (ip_output_fast(m, ro, flags, hlen, inp)); + } + /* * If routing to interface only, short circuit routing lookup. * The use of an all-ones broadcast address implies this; an From owner-svn-src-user@FreeBSD.ORG Wed Dec 31 01:51:07 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B661D1065676; Wed, 31 Dec 2008 01:51:07 +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 A2C798FC19; Wed, 31 Dec 2008 01:51:07 +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 mBV1p7l7011369; Wed, 31 Dec 2008 01:51:07 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBV1p7Sl011368; Wed, 31 Dec 2008 01:51:07 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200812310151.mBV1p7Sl011368@svn.freebsd.org> From: Kip Macy Date: Wed, 31 Dec 2008 01:51:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186621 - user/kmacy/HEAD_fast_net/sys/netinet X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Dec 2008 01:51:08 -0000 Author: kmacy Date: Wed Dec 31 01:51:07 2008 New Revision: 186621 URL: http://svn.freebsd.org/changeset/base/186621 Log: initialize ro_dst at the beginning of ip_forward Modified: user/kmacy/HEAD_fast_net/sys/netinet/ip_input.c Modified: user/kmacy/HEAD_fast_net/sys/netinet/ip_input.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/netinet/ip_input.c Wed Dec 31 01:42:24 2008 (r186620) +++ user/kmacy/HEAD_fast_net/sys/netinet/ip_input.c Wed Dec 31 01:51:07 2008 (r186621) @@ -1348,6 +1348,7 @@ ip_forward(struct mbuf *m, int srcrt) struct in_ifaddr *ia = NULL; struct mbuf *mcopy; struct in_addr dest; + struct sockaddr_in *sin; struct route ro; int error, type = 0, code = 0, mtu = 0; int flerror; @@ -1368,6 +1369,12 @@ ip_forward(struct mbuf *m, int srcrt) #ifdef IPSTEALTH } #endif + bzero(&ro, sizeof(ro)); + sin = (struct sockaddr_in *)&ro.ro_dst; + sin->sin_family = AF_INET; + sin->sin_len = sizeof(*sin); + sin->sin_addr = ip->ip_dst; + flerror = flowtable_lookup(ipv4_forward_ft, m, &ro); if (flerror == 0) ia = ifatoia(ro.ro_rt->rt_ifa); @@ -1430,22 +1437,15 @@ ip_forward(struct mbuf *m, int srcrt) */ dest.s_addr = 0; if (!srcrt && V_ipsendredirects && ia->ia_ifp == m->m_pkthdr.rcvif) { - struct sockaddr_in *sin; struct rtentry *rt; - if (flerror != 0) { - - bzero(&ro, sizeof(ro)); - sin = (struct sockaddr_in *)&ro.ro_dst; - sin->sin_family = AF_INET; - sin->sin_len = sizeof(*sin); - sin->sin_addr = ip->ip_dst; + if (flerror != 0) in_rtalloc_ign(&ro, 0, M_GETFIB(m)); - } - + rt = ro.ro_rt; - if (rt && (rt->rt_flags & (RTF_DYNAMIC|RTF_MODIFIED)) == 0 && + if (rt != NULL && + (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)) u_long src = ntohl(ip->ip_src.s_addr); From owner-svn-src-user@FreeBSD.ORG Wed Dec 31 02:23:32 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2EC9D1065672; Wed, 31 Dec 2008 02:23:32 +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 1ADDA8FC12; Wed, 31 Dec 2008 02:23:32 +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 mBV2NWax012020; Wed, 31 Dec 2008 02:23:32 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBV2NWra012019; Wed, 31 Dec 2008 02:23:32 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200812310223.mBV2NWra012019@svn.freebsd.org> From: Kip Macy Date: Wed, 31 Dec 2008 02:23:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186622 - user/kmacy/HEAD_fast_net/sys/net X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Dec 2008 02:23:32 -0000 Author: kmacy Date: Wed Dec 31 02:23:31 2008 New Revision: 186622 URL: http://svn.freebsd.org/changeset/base/186622 Log: add shortcut for off-host ipv4 or ipv6 packets in ether_output Modified: user/kmacy/HEAD_fast_net/sys/net/if_ethersubr.c Modified: user/kmacy/HEAD_fast_net/sys/net/if_ethersubr.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/if_ethersubr.c Wed Dec 31 01:51:07 2008 (r186621) +++ user/kmacy/HEAD_fast_net/sys/net/if_ethersubr.c Wed Dec 31 02:23:31 2008 (r186622) @@ -163,7 +163,7 @@ static int ether_ipfw; int ether_output(struct ifnet *ifp, struct mbuf *m, struct route *ro) { - short type; + short type = 0; int error = 0, hdrcmplt = 0; u_char esrc[ETHER_ADDR_LEN], edst[ETHER_ADDR_LEN]; struct llentry *lle = ro->ro_lle; @@ -174,13 +174,11 @@ ether_output(struct ifnet *ifp, struct m struct rtentry *rt0 = ro->ro_rt; int hlen; /* link layer header length */ - #ifdef MAC error = mac_ifnet_check_transmit(ifp, m); if (error) senderr(error); #endif - M_PROFILE(m); if (ifp->if_flags & IFF_MONITOR) senderr(ENETDOWN); @@ -189,6 +187,50 @@ ether_output(struct ifnet *ifp, struct m senderr(ENETDOWN); hlen = ETHER_HDR_LEN; + + /* + * First try to see if we can shortcut most of ether_output + * 1) do we have a valid lle? + * 2) is this not a bridge? + * 3) is carp disabled? + * 4) is netgraph disabled for this device? + * 5) is this not loopback? + */ + t = pf_find_mtag(m); + if (lle != NULL && (lle->la_flags & LLE_VALID) && + ifp->if_bridge == NULL && ifp->if_carp == NULL && + IFP2AC(ifp)->ac_netgraph == NULL && + (t == NULL || t->routed)) { + + switch (dst->sa_family) { + case AF_INET: + type = htons(ETHERTYPE_IP); + break; + case AF_INET6: + type = htons(ETHERTYPE_IPV6); + break; + } + if (type != 0) { + M_PREPEND(m, ETHER_HDR_LEN, M_DONTWAIT); + if (m == NULL) + senderr(ENOBUFS); + eh = mtod(m, struct ether_header *); + (void)memcpy(&eh->ether_type, &type, + sizeof(eh->ether_type)); + (void)memcpy(eh->ether_dhost, &lle->ll_addr.mac16, + sizeof (edst)); + (void)memcpy(eh->ether_shost, IF_LLADDR(ifp), + sizeof(eh->ether_shost)); + + } + /* Continue with link-layer output */ + return ether_output_frame(ifp, m); + } + + /* + * The shortcut failed, use default path + * + */ switch (dst->sa_family) { #ifdef INET case AF_INET: @@ -340,7 +382,7 @@ ether_output(struct ifnet *ifp, struct m * reasons and compatibility with the original behavior. */ if ((ifp->if_flags & IFF_SIMPLEX) && loop_copy && - ((t = pf_find_mtag(m)) == NULL || !t->routed)) { + (t == NULL || !t->routed)) { int csum_flags = 0; if (m->m_pkthdr.csum_flags & CSUM_IP) From owner-svn-src-user@FreeBSD.ORG Wed Dec 31 02:27:31 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B98D21065704; Wed, 31 Dec 2008 02:27:31 +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 A60848FC19; Wed, 31 Dec 2008 02:27:31 +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 mBV2RV6m012124; Wed, 31 Dec 2008 02:27:31 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBV2RV0R012123; Wed, 31 Dec 2008 02:27:31 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200812310227.mBV2RV0R012123@svn.freebsd.org> From: Kip Macy Date: Wed, 31 Dec 2008 02:27:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186623 - user/kmacy/HEAD_fast_net/sys/net X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Dec 2008 02:27:32 -0000 Author: kmacy Date: Wed Dec 31 02:27:31 2008 New Revision: 186623 URL: http://svn.freebsd.org/changeset/base/186623 Log: don't lookup rule unless ipfw is enabled Modified: user/kmacy/HEAD_fast_net/sys/net/if_ethersubr.c Modified: user/kmacy/HEAD_fast_net/sys/net/if_ethersubr.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/if_ethersubr.c Wed Dec 31 02:23:31 2008 (r186622) +++ user/kmacy/HEAD_fast_net/sys/net/if_ethersubr.c Wed Dec 31 02:27:31 2008 (r186623) @@ -464,9 +464,10 @@ ether_output_frame(struct ifnet *ifp, st { #if defined(INET) || defined(INET6) INIT_VNET_NET(ifp->if_vnet); - struct ip_fw *rule = ip_dn_claim_rule(m); + struct ip_fw *rule; if (IPFW_LOADED && V_ether_ipfw != 0) { + rule = ip_dn_claim_rule(m); if (ether_ipfw_chk(&m, ifp, &rule, 0) == 0) { if (m) { m_freem(m); From owner-svn-src-user@FreeBSD.ORG Wed Dec 31 03:03:00 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 67217106564A; Wed, 31 Dec 2008 03:03:00 +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 53C478FC08; Wed, 31 Dec 2008 03:03:00 +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 mBV330LG012866; Wed, 31 Dec 2008 03:03:00 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBV330B6012865; Wed, 31 Dec 2008 03:03:00 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200812310303.mBV330B6012865@svn.freebsd.org> From: Kip Macy Date: Wed, 31 Dec 2008 03:03:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186624 - user/kmacy/HEAD_fast_net/sys/netinet X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Dec 2008 03:03:00 -0000 Author: kmacy Date: Wed Dec 31 03:02:59 2008 New Revision: 186624 URL: http://svn.freebsd.org/changeset/base/186624 Log: attempt to further streamline ip_output_fast checks_ Modified: user/kmacy/HEAD_fast_net/sys/netinet/ip_output.c Modified: user/kmacy/HEAD_fast_net/sys/netinet/ip_output.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/netinet/ip_output.c Wed Dec 31 02:27:31 2008 (r186623) +++ user/kmacy/HEAD_fast_net/sys/netinet/ip_output.c Wed Dec 31 03:02:59 2008 (r186624) @@ -117,10 +117,6 @@ ip_output_fast(struct mbuf *m, struct ro ifp = ro->ro_rt->rt_ifp; ro->ro_rt->rt_rmx.rmx_pksent++; - if (ro->ro_rt->rt_flags & RTF_GATEWAY) - bcopy(ro->ro_rt->rt_gateway, &ro->ro_dst, - sizeof(struct sockaddr)); - ip = mtod(m, struct ip *); /* * If the source address is not specified yet, use the address @@ -189,7 +185,9 @@ ip_output_fast(struct mbuf *m, struct ro return ((*ifp->if_output)(ifp, m, ro)); } - + +#define IP_RT_SET 0x1 +#define IP_LLE_SET 0x2 /* * IP output. The packet in mbuf chain m contains a skeletal IP * header (with len, off, ttl, proto, tos, src, dst). @@ -209,11 +207,12 @@ ip_output(struct mbuf *m, struct mbuf *o struct mbuf *m0; struct in_ifaddr *ia = NULL; int hlen = sizeof (struct ip); - int mtu; + int mtu, flerror = ENOENT; int len, error = 0; int neednewroute = 0, neednewlle = 0, nortfree = 0; struct sockaddr_in *dst = NULL; /* keep compiler happy */ int isbroadcast, sw_csum; + int stateflags = 0; struct route iproute; struct in_addr odst; #ifdef IPFIREWALL_FORWARD @@ -223,7 +222,8 @@ ip_output(struct mbuf *m, struct mbuf *o if (ro == NULL) { ro = &iproute; - bzero(ro, sizeof (*ro)); + ro->ro_rt = NULL; + ro->ro_lle = NULL; } if (inp != NULL) { @@ -261,24 +261,6 @@ ip_output(struct mbuf *m, struct mbuf *o dst = (struct sockaddr_in *)&ro->ro_dst; again: - /* - * If there is a cached route, - * check that it is to the same destination - * and is still up. If not, free it and try again. - * The address family should also be checked in case of sharing the - * cache with IPv6. - */ - if (ro->ro_rt != NULL && ((ro->ro_rt->rt_flags & RTF_UP) == 0 || - dst->sin_family != AF_INET || - dst->sin_addr.s_addr != ip->ip_dst.s_addr)) { - /* - * XXX need to check that ro->ro_rt isn't coming from a flow - * lookup in ip_forward ... perhaps pass in a new flag - * - */ - RTFREE(ro->ro_rt); - ro->ro_rt = NULL; - } #ifdef IPFIREWALL_FORWARD if (ro->ro_rt == NULL && fwd_tag == NULL) { #else @@ -289,8 +271,14 @@ again: dst->sin_len = sizeof(*dst); dst->sin_addr = ip->ip_dst; } - if (ro != &iproute) + if (ro != &iproute) { + if (ro->ro_rt != NULL && (ro->ro_rt->rt_flags & RTF_UP)) + stateflags |= IP_RT_SET; + if (ro->ro_lle != NULL && (ro->ro_lle->la_flags & LLE_VALID)) + stateflags |= IP_LLE_SET; goto skipcachecheck; + } + if (inp != NULL) { if (inp->inp_flags & (INP_HW_FLOWID|INP_SW_FLOWID)) { m->m_pkthdr.flowid = inp->inp_flowid; @@ -299,54 +287,79 @@ again: if (inp->inp_vflag & INP_RT_VALID) { if (inp->inp_rt->rt_flags & RTF_UP) { ro->ro_rt = inp->inp_rt; + stateflags |= IP_RT_SET; } else neednewroute = 1; } if (inp->inp_flags & INP_LLE_VALID) { if (inp->inp_lle->la_flags & LLE_VALID) { ro->ro_lle = inp->inp_lle; + stateflags |= IP_LLE_SET; } else neednewlle = 1; } } - if ((ro->ro_rt == NULL) && (ro->ro_lle == NULL)) { - if (flowtable_lookup(ipv4_ft, m, ro) == 0) + if ((stateflags & (IP_LLE_SET|IP_RT_SET)) != (IP_LLE_SET|IP_RT_SET)) { + if ((flerror = flowtable_lookup(ipv4_ft, m, ro)) == 0) { nortfree = 1; + stateflags |= IP_RT_SET; + if (ro->ro_lle != NULL) + stateflags |= IP_LLE_SET; + } } skipcachecheck: /* * Check if we can take a huge shortcut */ - if (ro->ro_rt != NULL && (ro->ro_rt->rt_flags & RTF_UP) && - ro->ro_lle != NULL && (ro->ro_lle->la_flags & LLE_VALID) && - (flags & (IP_SENDONES|IP_ROUTETOIF)) == 0 && - !PFIL_HOOKED(&inet_pfil_hook) && - !IN_MULTICAST(ntohl(ip->ip_dst.s_addr))) { + if ((stateflags & (IP_LLE_SET|IP_RT_SET)) == (IP_LLE_SET|IP_RT_SET) + && (flags & (IP_SENDONES|IP_ROUTETOIF)) == 0 + && !PFIL_HOOKED(&inet_pfil_hook) + && !IN_MULTICAST(ntohl(ip->ip_dst.s_addr))) { ifp = ro->ro_rt->rt_ifp; - if (ro->ro_rt->rt_flags & (RTF_UP|RTF_HOST)) { + dst = (struct sockaddr_in *)ro->ro_rt->rt_gateway; + if (ro->ro_rt->rt_flags & RTF_GATEWAY) + bcopy(ro->ro_rt->rt_gateway, &ro->ro_dst, + sizeof(struct sockaddr)); + + if (ro->ro_rt->rt_flags & RTF_HOST) { if (ro->ro_rt->rt_rmx.rmx_mtu > ifp->if_mtu) ro->ro_rt->rt_rmx.rmx_mtu = ifp->if_mtu; mtu = ro->ro_rt->rt_rmx.rmx_mtu; - } else - mtu = ifp->if_mtu; - - if (ro->ro_rt->rt_flags & RTF_GATEWAY) - dst = (struct sockaddr_in *)ro->ro_rt->rt_gateway; - else - dst = (struct sockaddr_in *)&ro->ro_dst; - if (ro->ro_rt->rt_flags & RTF_HOST) isbroadcast = (ro->ro_rt->rt_flags & RTF_BROADCAST); - else + } else { isbroadcast = in_broadcast(dst->sin_addr, ifp); - + mtu = ifp->if_mtu; + } + if (!isbroadcast && (ip->ip_len <= mtu || (m->m_pkthdr.csum_flags & ifp->if_hwassist & CSUM_TSO) != 0 || ((ip->ip_off & IP_DF) == 0 && (ifp->if_hwassist & CSUM_FRAGMENT)))) return (ip_output_fast(m, ro, flags, hlen, inp)); } + + /* + * If there is a cached route, + * check that it is to the same destination + * and is still up. If not, free it and try again. + * The address family should also be checked in case of sharing the + * cache with IPv6. + */ + if (ro->ro_rt != NULL && ((ro->ro_rt->rt_flags & RTF_UP) == 0 || + dst->sin_family != AF_INET || + dst->sin_addr.s_addr != ip->ip_dst.s_addr)) { + /* + * XXX need to check that ro->ro_rt isn't coming from a flow + * lookup in ip_forward ... perhaps pass in a new flag + * + */ + if (((inp->inp_vflag & INP_RT_VALID) == 0) && + flerror != 0) + RTFREE(ro->ro_rt); + ro->ro_rt = NULL; + } /* * If routing to interface only, short circuit routing lookup. From owner-svn-src-user@FreeBSD.ORG Wed Dec 31 03:13:06 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 30467106566C; Wed, 31 Dec 2008 03:13: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 1CEF38FC19; Wed, 31 Dec 2008 03:13: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 mBV3D6f5013241; Wed, 31 Dec 2008 03:13:06 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBV3D5ed013238; Wed, 31 Dec 2008 03:13:05 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200812310313.mBV3D5ed013238@svn.freebsd.org> From: Kip Macy Date: Wed, 31 Dec 2008 03:13:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186625 - user/kmacy/HEAD_fast_net/sys/net X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Dec 2008 03:13:06 -0000 Author: kmacy Date: Wed Dec 31 03:13:05 2008 New Revision: 186625 URL: http://svn.freebsd.org/changeset/base/186625 Log: import kernel support for route shutdown Modified: user/kmacy/HEAD_fast_net/sys/net/radix_mpath.c user/kmacy/HEAD_fast_net/sys/net/route.c user/kmacy/HEAD_fast_net/sys/net/route.h Modified: user/kmacy/HEAD_fast_net/sys/net/radix_mpath.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/radix_mpath.c Wed Dec 31 03:02:59 2008 (r186624) +++ user/kmacy/HEAD_fast_net/sys/net/radix_mpath.c Wed Dec 31 03:13:05 2008 (r186625) @@ -81,11 +81,15 @@ u_int32_t rn_mpath_count(struct radix_node *rn) { u_int32_t i; - + struct rtentry *rt; + i = 1; - while ((rn = rn_mpath_next(rn)) != NULL) - i++; - return i; + while ((rn = rn_mpath_next(rn)) != NULL) { + rt = (struct rtentry *)rn; + if ((rt->rt_flags & RTF_SHUTDOWN) == 0) + i++; + } + return (i); } struct rtentry * @@ -260,7 +264,8 @@ rtalloc_mpath_fib(struct route *ro, u_in { struct radix_node *rn0, *rn; u_int32_t n; - + struct rtentry *rt; + /* * XXX we don't attempt to lookup cached route again; what should * be done for sendto(3) case? @@ -285,6 +290,11 @@ rtalloc_mpath_fib(struct route *ro, u_in hash += hashjitter; hash %= n; while (hash-- > 0 && rn) { + rt = (struct rtentry *)rn; + if (rt->rt_flags & RTF_SHUTDOWN) { + hash++; + continue; + } /* stay within the multipath routes */ if (rn->rn_dupedkey && rn->rn_mask != rn->rn_dupedkey->rn_mask) break; Modified: user/kmacy/HEAD_fast_net/sys/net/route.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/route.c Wed Dec 31 03:02:59 2008 (r186624) +++ user/kmacy/HEAD_fast_net/sys/net/route.c Wed Dec 31 03:13:05 2008 (r186625) @@ -803,6 +803,98 @@ bad: return (error); } +#ifdef RADIX_MPATH +static int +rn_mpath_delete(int req, struct rt_addrinfo *info, + struct radix_node_head *rnh, struct rtentry **ret_nrt) +{ + /* + * if we got multipath routes, we require users to specify + * a matching RTAX_GATEWAY. + */ + struct rtentry *rto = NULL; + int error = 0; + + rn = rnh->rnh_matchaddr(dst, rnh); + if (rn == NULL) + return (ESRCH); + rto = rt = RNTORT(rn); + rt = rt_mpath_matchgate(rt, gateway); + if (!rt) + return (ESRCH); + /* + * this is the first entry in the chain + */ + if (rto == rt) { + rn = rn_mpath_next((struct radix_node *)rt); + /* + * there is another entry, now it's active + */ + if (rn) { + rto = RNTORT(rn); + RT_LOCK(rto); + rto->rt_flags |= RTF_UP; + RT_UNLOCK(rto); + } else if (rt->rt_flags & RTF_GATEWAY) { + /* + * For gateway routes, we need to + * make sure that we we are deleting + * the correct gateway. + * rt_mpath_matchgate() does not + * check the case when there is only + * one route in the chain. + */ + if (gateway && + (rt->rt_gateway->sa_len != gateway->sa_len || + memcmp(rt->rt_gateway, gateway, gateway->sa_len))) + error = ESRCH; + goto done; + } + /* + * use the normal delete code to remove + * the first entry + */ + error = ENOENT; + goto done; + } + + /* + * if the entry is 2nd and on up + */ + if ((req == RTM_DELETE) && !rt_mpath_deldup(rto, rt)) + panic ("rtrequest1: rt_mpath_deldup"); + RT_LOCK(rt); + RT_ADDREF(rt); + if (req == RTM_DELETE) { + rt->rt_flags &= ~RTF_UP; + /* + * One more rtentry floating around that is not + * linked to the routing table. rttrash will be decremented + * when RTFREE(rt) is eventually called. + */ + V_rttrash++; + + } else if (req == RTM_SHUTDOWN) + rt->rt_flags |= RTF_SHUTDOWN; + else + panic("unrecognized request %d", req); + + + /* + * If the caller wants it, then it can have it, + * but it's up to it to free the rtentry as we won't be + * doing it. + */ + if (ret_nrt) { + *ret_nrt = rt; + RT_UNLOCK(rt); + } else + RTFREE_LOCKED(rt); +done: + return (error); +} +#endif + int rtrequest1_fib(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt, u_int fibnum) @@ -841,65 +933,16 @@ rtrequest1_fib(int req, struct rt_addrin switch (req) { case RTM_DELETE: #ifdef RADIX_MPATH - /* - * if we got multipath routes, we require users to specify - * a matching RTAX_GATEWAY. - */ + case RTM_SHUTDOWN: if (rn_mpath_capable(rnh)) { - struct rtentry *rto = NULL; - - rn = rnh->rnh_matchaddr(dst, rnh); - if (rn == NULL) - senderr(ESRCH); - rto = rt = RNTORT(rn); - rt = rt_mpath_matchgate(rt, gateway); - if (!rt) - senderr(ESRCH); - /* - * this is the first entry in the chain - */ - if (rto == rt) { - rn = rn_mpath_next((struct radix_node *)rt); - /* - * there is another entry, now it's active - */ - if (rn) { - rto = RNTORT(rn); - RT_LOCK(rto); - rto->rt_flags |= RTF_UP; - RT_UNLOCK(rto); - } else if (rt->rt_flags & RTF_GATEWAY) { - /* - * For gateway routes, we need to - * make sure that we we are deleting - * the correct gateway. - * rt_mpath_matchgate() does not - * check the case when there is only - * one route in the chain. - */ - if (gateway && - (rt->rt_gateway->sa_len != gateway->sa_len || - memcmp(rt->rt_gateway, gateway, gateway->sa_len))) - senderr(ESRCH); - } - /* - * use the normal delete code to remove - * the first entry - */ - goto normal_rtdel; - } + error = rn_mpath_delete(req, info, rnh, ret_nrt); /* - * if the entry is 2nd and on up + * "bad" holds true for the success case + * as well */ - if (!rt_mpath_deldup(rto, rt)) - panic ("rtrequest1: rt_mpath_deldup"); - RT_LOCK(rt); - RT_ADDREF(rt); - rt->rt_flags &= ~RTF_UP; - goto deldone; /* done with the RTM_DELETE command */ + if (error != ENOENT) + goto bad; } - -normal_rtdel: #endif /* * Remove the item from the tree and return it. @@ -921,9 +964,6 @@ normal_rtdel: if ((ifa = rt->rt_ifa) && ifa->ifa_rtrequest) ifa->ifa_rtrequest(RTM_DELETE, rt, info); -#ifdef RADIX_MPATH -deldone: -#endif /* * One more rtentry floating around that is not * linked to the routing table. rttrash will be decremented Modified: user/kmacy/HEAD_fast_net/sys/net/route.h ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/route.h Wed Dec 31 03:02:59 2008 (r186624) +++ user/kmacy/HEAD_fast_net/sys/net/route.h Wed Dec 31 03:13:05 2008 (r186625) @@ -195,7 +195,8 @@ struct ortentry { #define RTF_BROADCAST 0x400000 /* route represents a bcast address */ #define RTF_MULTICAST 0x800000 /* route represents a mcast address */ /* 0x1000000 and up unassigned */ -#define RTF_RNH_LOCKED 0x40000000 /* radix node head locked by caller */ +#define RTF_SHUTDOWN 0x20000000 /* no new connections */ +#define RTF_RNH_LOCKED 0x40000000 /* Mask of RTF flags that are allowed to be modified by RTM_CHANGE. */ #define RTF_FMASK \ @@ -254,6 +255,7 @@ struct rt_msghdr { #define RTM_DELMADDR 0x10 /* mcast group membership being deleted */ #define RTM_IFANNOUNCE 0x11 /* iface arrival/departure */ #define RTM_IEEE80211 0x12 /* IEEE80211 wireless event */ +#define RTM_SHUTDOWN 0x13 /* don't use for new connections */ /* * Bitmask values for rtm_inits and rmx_locks. From owner-svn-src-user@FreeBSD.ORG Wed Dec 31 03:13:55 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0633C1065670; Wed, 31 Dec 2008 03:13:55 +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 E7FF88FC13; Wed, 31 Dec 2008 03:13:54 +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 mBV3Dspd013296; Wed, 31 Dec 2008 03:13:54 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBV3DsH6013294; Wed, 31 Dec 2008 03:13:54 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200812310313.mBV3DsH6013294@svn.freebsd.org> From: Kip Macy Date: Wed, 31 Dec 2008 03:13:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186626 - user/kmacy/HEAD_fast_net/sbin/route X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Dec 2008 03:13:55 -0000 Author: kmacy Date: Wed Dec 31 03:13:54 2008 New Revision: 186626 URL: http://svn.freebsd.org/changeset/base/186626 Log: import user support for route shutdown Modified: user/kmacy/HEAD_fast_net/sbin/route/keywords user/kmacy/HEAD_fast_net/sbin/route/route.c Modified: user/kmacy/HEAD_fast_net/sbin/route/keywords ============================================================================== --- user/kmacy/HEAD_fast_net/sbin/route/keywords Wed Dec 31 03:13:05 2008 (r186625) +++ user/kmacy/HEAD_fast_net/sbin/route/keywords Wed Dec 31 03:13:54 2008 (r186626) @@ -44,6 +44,7 @@ rtt rttvar sa sendpipe +shutdown ssthresh static x25 Modified: user/kmacy/HEAD_fast_net/sbin/route/route.c ============================================================================== --- user/kmacy/HEAD_fast_net/sbin/route/route.c Wed Dec 31 03:13:05 2008 (r186625) +++ user/kmacy/HEAD_fast_net/sbin/route/route.c Wed Dec 31 03:13:54 2008 (r186626) @@ -176,6 +176,7 @@ main(argc, argv) case K_ADD: case K_DEL: case K_DELETE: + case K_SHUTDOWN: newroute(argc, argv); /* NOTREACHED */ @@ -1197,7 +1198,9 @@ rtmsg(cmd, flags) so_ifp.sa.sa_len = sizeof(struct sockaddr_dl); rtm_addrs |= RTA_IFP; } - } else + } else if (cmd == 's') + cmd = RTM_SHUTDOWN; + else cmd = RTM_DELETE; #define rtm m_rtmsg.m_rtm rtm.rtm_type = cmd; From owner-svn-src-user@FreeBSD.ORG Wed Dec 31 03:15:19 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C038F1065672; Wed, 31 Dec 2008 03:15:19 +0000 (UTC) (envelope-from mat.macy@gmail.com) Received: from rv-out-0506.google.com (rv-out-0506.google.com [209.85.198.225]) by mx1.freebsd.org (Postfix) with ESMTP id 78AED8FC13; Wed, 31 Dec 2008 03:15:19 +0000 (UTC) (envelope-from mat.macy@gmail.com) Received: by rv-out-0506.google.com with SMTP id b25so6743179rvf.43 for ; Tue, 30 Dec 2008 19:15:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender :to:subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references :x-google-sender-auth; bh=BhI0Ae1CPN2N2xvSipTpaWvuf+o0ucwEk64jjXw4fRU=; b=NMRC6HVASHFEZeeD+GuS3NKg65wTaFfn8tXIw0iKuiB8p+Q6RdS3e2CGxEVqMOTEZW eNqrt/NS9/1Qq3iPnyCy7GNq9yISBHW4SASkoqTXFoLXvXCYlHgae6OqHRkNoNgKLj/e kByNZKeyEtxG2bNK1Ye175wYvQg+rV87I41ao= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references:x-google-sender-auth; b=cO3fDX2Cs7f89puICwSCN2YdF6rYp1CcFJQlmha0HWqd8BD1kTZxCYBj1T6kB0p3gj QFJy1HzKArp0th3mMUOaeD4nm5oJEXtIPb/dsZwkH+UKMEGu1yyxsSJGjck4T5wvNysO 4G/TZJoEaSgEqpuh2KtHuQLd/377jNrlhjJ5Q= Received: by 10.141.128.19 with SMTP id f19mr7597899rvn.9.1230693318963; Tue, 30 Dec 2008 19:15:18 -0800 (PST) Received: by 10.141.37.17 with HTTP; Tue, 30 Dec 2008 19:15:18 -0800 (PST) Message-ID: <3c1674c90812301915y5c42b01al445667b244cb0633@mail.gmail.com> Date: Tue, 30 Dec 2008 19:15:18 -0800 From: "Kip Macy" Sender: mat.macy@gmail.com To: "Bruce M. Simpson" In-Reply-To: <495A4F27.1050502@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <200812300438.mBU4ceDK076135@svn.freebsd.org> <495A4F27.1050502@FreeBSD.org> X-Google-Sender-Auth: bf88d08b1e34e7d3 Cc: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: Re: svn commit: r186585 - user/kmacy/HEAD_fast_net/sys/netinet X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Dec 2008 03:15:20 -0000 On Tue, Dec 30, 2008 at 8:41 AM, Bruce M. Simpson wrote: > Kip Macy wrote: >> >> Author: kmacy >> Date: Tue Dec 30 04:38:39 2008 >> New Revision: 186585 >> URL: http://svn.freebsd.org/changeset/base/186585 >> >> Log: >> make ipv4 forwarding flowtable aware >> > > This is so that we continue to use the same IPv4 next-hop consistently in an > ECMP enabled kernel for sockets, right? Caching the rtentry in the inpcb (an earlier commit) already does that for connected sockets. This allows ip_forward to consistently forward packets to the same host so that ECMP can be used for server load balancing. Cheers, Kip From owner-svn-src-user@FreeBSD.ORG Wed Dec 31 03:22:23 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 46779106566B; Wed, 31 Dec 2008 03:22:23 +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 33E0B8FC17; Wed, 31 Dec 2008 03:22:23 +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 mBV3MNap013485; Wed, 31 Dec 2008 03:22:23 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBV3MNiY013484; Wed, 31 Dec 2008 03:22:23 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200812310322.mBV3MNiY013484@svn.freebsd.org> From: Kip Macy Date: Wed, 31 Dec 2008 03:22:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186627 - user/kmacy/HEAD_fast_net/sys/dev/mxge X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Dec 2008 03:22:23 -0000 Author: kmacy Date: Wed Dec 31 03:22:22 2008 New Revision: 186627 URL: http://svn.freebsd.org/changeset/base/186627 Log: mark incoming packet's flowid as valid Modified: user/kmacy/HEAD_fast_net/sys/dev/mxge/if_mxge.c Modified: user/kmacy/HEAD_fast_net/sys/dev/mxge/if_mxge.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/dev/mxge/if_mxge.c Wed Dec 31 03:13:54 2008 (r186626) +++ user/kmacy/HEAD_fast_net/sys/dev/mxge/if_mxge.c Wed Dec 31 03:22:22 2008 (r186627) @@ -2482,6 +2482,7 @@ mxge_rx_done_big(struct mxge_slice_state m->m_pkthdr.rcvif = ifp; m->m_pkthdr.flowid = ss - sc->ss; + m->m_flags |= M_FLOWID; m->m_len = m->m_pkthdr.len = len; ss->ipackets++; eh = mtod(m, struct ether_header *); @@ -2543,6 +2544,7 @@ mxge_rx_done_small(struct mxge_slice_sta m->m_pkthdr.rcvif = ifp; m->m_pkthdr.flowid = ss - sc->ss; + m->m_flags |= M_FLOWID; m->m_len = m->m_pkthdr.len = len; ss->ipackets++; eh = mtod(m, struct ether_header *); From owner-svn-src-user@FreeBSD.ORG Wed Dec 31 03:38:17 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 17A1C1065670; Wed, 31 Dec 2008 03:38:17 +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 0552F8FC08; Wed, 31 Dec 2008 03:38:17 +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 mBV3cGb1013789; Wed, 31 Dec 2008 03:38:16 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBV3cGFQ013788; Wed, 31 Dec 2008 03:38:16 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200812310338.mBV3cGFQ013788@svn.freebsd.org> From: Kip Macy Date: Wed, 31 Dec 2008 03:38:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186628 - user/kmacy/HEAD_fast_net/sys/netinet X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Dec 2008 03:38:17 -0000 Author: kmacy Date: Wed Dec 31 03:38:16 2008 New Revision: 186628 URL: http://svn.freebsd.org/changeset/base/186628 Log: don't lookup laddr or lport if they're already set Modified: user/kmacy/HEAD_fast_net/sys/netinet/udp_usrreq.c Modified: user/kmacy/HEAD_fast_net/sys/netinet/udp_usrreq.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/netinet/udp_usrreq.c Wed Dec 31 03:22:22 2008 (r186627) +++ user/kmacy/HEAD_fast_net/sys/netinet/udp_usrreq.c Wed Dec 31 03:38:16 2008 (r186628) @@ -962,6 +962,10 @@ udp_output(struct inpcb *inp, struct mbu sin->sin_addr.s_addr == INADDR_ANY || sin->sin_addr.s_addr == INADDR_BROADCAST) { INP_INFO_LOCK_ASSERT(&V_udbinfo); + + if (inp->inp_laddr.s_addr != INADDR_ANY) + laddr.s_addr = inp->inp_laddr.s_addr; + lport = inp->inp_lport; error = in_pcbconnect_setup(inp, addr, &laddr.s_addr, &lport, &faddr.s_addr, &fport, NULL, td->td_ucred); From owner-svn-src-user@FreeBSD.ORG Wed Dec 31 04:56:18 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2B3F1106566C; Wed, 31 Dec 2008 04:56:18 +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 1A6268FC08; Wed, 31 Dec 2008 04:56:18 +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 mBV4uIEE015255; Wed, 31 Dec 2008 04:56:18 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBV4uHVu015254; Wed, 31 Dec 2008 04:56:17 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200812310456.mBV4uHVu015254@svn.freebsd.org> From: Kip Macy Date: Wed, 31 Dec 2008 04:56:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186629 - user/kmacy/HEAD_fast_net/sys/net X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Dec 2008 04:56:18 -0000 Author: kmacy Date: Wed Dec 31 04:56:17 2008 New Revision: 186629 URL: http://svn.freebsd.org/changeset/base/186629 Log: make flowtable_lookup handle case of NULL mbuf Modified: user/kmacy/HEAD_fast_net/sys/net/flowtable.c Modified: user/kmacy/HEAD_fast_net/sys/net/flowtable.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/flowtable.c Wed Dec 31 03:38:16 2008 (r186628) +++ user/kmacy/HEAD_fast_net/sys/net/flowtable.c Wed Dec 31 04:56:17 2008 (r186629) @@ -333,26 +333,32 @@ ipv4_flow_lookup_hash_internal(struct mb uint32_t *key, uint16_t *flags, uint8_t *protop) { uint16_t sport = 0, dport = 0; - struct ip *ip = mtod(m, struct ip *); - uint8_t proto = ip->ip_p; - int iphlen = ip->ip_hl << 2; + struct ip *ip; + uint8_t proto = 0; + int iphlen; uint32_t hash; struct sockaddr_in *sin; struct tcphdr *th; struct udphdr *uh; struct sctphdr *sh; - key[0] = 0; - key[1] = ip->ip_src.s_addr; - key[2] = ip->ip_dst.s_addr; + if (flowtable_enable == 0) + return (0); sin = (struct sockaddr_in *)&ro->ro_dst; - sin->sin_family = AF_INET; - sin->sin_len = sizeof(*sin); - sin->sin_addr = ip->ip_dst; + KASSERT(sin->sin_family == AF_INET, + ("bad address passed")); + key[0] = 0; + key[1] = 0; + key[2] = sin->sin_addr.s_addr; - if (flowtable_enable == 0) - return (0); + if (m == NULL || (*flags & FL_HASH_PORTS) == 0) + goto skipports; + + ip = mtod(m, struct ip *); + proto = ip->ip_p; + iphlen = ip->ip_hl << 2; /* XXX options? */ + key[1] = ip->ip_src.s_addr; switch (proto) { case IPPROTO_TCP: @@ -393,8 +399,9 @@ ipv4_flow_lookup_hash_internal(struct mb ((uint16_t *)key)[0] = sport; ((uint16_t *)key)[1] = dport; +skipports: hash = hashword(key, 3, hashjitter + proto); - if ((m->m_flags & M_FLOWID) == 0) + if (m != NULL && (m->m_flags & M_FLOWID) == 0) m->m_pkthdr.flowid = hash; CTR5(KTR_SPARE3, "proto=%d hash=%x key[0]=%x sport=%d dport=%d\n", proto, hash, key[0], sport, dport); @@ -563,7 +570,7 @@ flowtable_lookup(struct flowtable *ft, s struct flentry *fle; uint16_t flags; uint8_t proto = 0; - int cache = 1, error = 0; + int cache = 1, error = 0, fib = 0; struct rtentry *rt; struct llentry *lle; @@ -619,7 +626,10 @@ uncached: * of arpresolve with an rt_check variant that expected to * receive the route locked */ - ft->ft_rtalloc(ro, hash, M_GETFIB(m)); + if (m != NULL) + fib = M_GETFIB(m); + + ft->ft_rtalloc(ro, hash, fib); if (ro->ro_rt == NULL) error = ENETUNREACH; else { From owner-svn-src-user@FreeBSD.ORG Wed Dec 31 05:09:55 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1AA4C1065688; Wed, 31 Dec 2008 05:09:55 +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 09AB18FC1F; Wed, 31 Dec 2008 05:09:55 +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 mBV59rYJ015526; Wed, 31 Dec 2008 05:09:53 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBV59rDr015525; Wed, 31 Dec 2008 05:09:53 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200812310509.mBV59rDr015525@svn.freebsd.org> From: Kip Macy Date: Wed, 31 Dec 2008 05:09:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186630 - user/kmacy/HEAD_fast_net/sys/net X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Dec 2008 05:09:55 -0000 Author: kmacy Date: Wed Dec 31 05:09:53 2008 New Revision: 186630 URL: http://svn.freebsd.org/changeset/base/186630 Log: fix route shutdown merge Modified: user/kmacy/HEAD_fast_net/sys/net/route.c Modified: user/kmacy/HEAD_fast_net/sys/net/route.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/route.c Wed Dec 31 04:56:17 2008 (r186629) +++ user/kmacy/HEAD_fast_net/sys/net/route.c Wed Dec 31 05:09:53 2008 (r186630) @@ -812,7 +812,8 @@ rn_mpath_delete(int req, struct rt_addri * if we got multipath routes, we require users to specify * a matching RTAX_GATEWAY. */ - struct rtentry *rto = NULL; + struct rtentry *rt, *rto = NULL; + register struct radix_node *rn; int error = 0; rn = rnh->rnh_matchaddr(dst, rnh); @@ -820,7 +821,7 @@ rn_mpath_delete(int req, struct rt_addri return (ESRCH); rto = rt = RNTORT(rn); rt = rt_mpath_matchgate(rt, gateway); - if (!rt) + if (rt == NULL) return (ESRCH); /* * this is the first entry in the chain From owner-svn-src-user@FreeBSD.ORG Wed Dec 31 05:22:31 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EE8081065672; Wed, 31 Dec 2008 05:22:31 +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 DE4D48FC19; Wed, 31 Dec 2008 05:22:31 +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 mBV5MVkU015790; Wed, 31 Dec 2008 05:22:31 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBV5MVv3015789; Wed, 31 Dec 2008 05:22:31 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200812310522.mBV5MVv3015789@svn.freebsd.org> From: Kip Macy Date: Wed, 31 Dec 2008 05:22:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186631 - user/kmacy/HEAD_fast_net/sys/netinet X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Dec 2008 05:22:32 -0000 Author: kmacy Date: Wed Dec 31 05:22:31 2008 New Revision: 186631 URL: http://svn.freebsd.org/changeset/base/186631 Log: use flowtable_lookup in in_pcbladdr to avoid contending in calls to in_pcbconnect_setup when the laddr is not bound Modified: user/kmacy/HEAD_fast_net/sys/netinet/in_pcb.c Modified: user/kmacy/HEAD_fast_net/sys/netinet/in_pcb.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/netinet/in_pcb.c Wed Dec 31 05:09:53 2008 (r186630) +++ user/kmacy/HEAD_fast_net/sys/netinet/in_pcb.c Wed Dec 31 05:22:31 2008 (r186631) @@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$"); #include +#include #include #include #include @@ -87,6 +88,7 @@ __FBSDID("$FreeBSD$"); #include +extern struct flowtable *ipv4_ft; #ifdef VIMAGE_GLOBALS /* * These configure the range of local port addresses assigned to @@ -636,11 +638,14 @@ in_pcbladdr(struct inpcb *inp, struct in * If route is known our src addr is taken from the i/f, * else punt. * + * XXX need to account for fibnum * Find out route to destination. */ if ((inp->inp_socket->so_options & SO_DONTROUTE) == 0) + flowtable_lookup(ipv4_ft, NULL, &sro); +#if 0 in_rtalloc_ign(&sro, 0, inp->inp_inc.inc_fibnum); - +#endif /* * If we found a route, use the address corresponding to * the outgoing interface. @@ -806,8 +811,6 @@ in_pcbladdr(struct inpcb *inp, struct in } done: - if (sro.ro_rt != NULL) - RTFREE(sro.ro_rt); return (error); } From owner-svn-src-user@FreeBSD.ORG Wed Dec 31 05:44:00 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 86BB5106564A; Wed, 31 Dec 2008 05:44:00 +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 757A28FC14; Wed, 31 Dec 2008 05:44:00 +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 mBV5i0tu016185; Wed, 31 Dec 2008 05:44:00 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBV5i0rk016184; Wed, 31 Dec 2008 05:44:00 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200812310544.mBV5i0rk016184@svn.freebsd.org> From: Kip Macy Date: Wed, 31 Dec 2008 05:44:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186632 - user/kmacy/HEAD_fast_net/sys/amd64/conf X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Dec 2008 05:44:00 -0000 Author: kmacy Date: Wed Dec 31 05:44:00 2008 New Revision: 186632 URL: http://svn.freebsd.org/changeset/base/186632 Log: add PERFTEST config Added: user/kmacy/HEAD_fast_net/sys/amd64/conf/PERFTEST Added: user/kmacy/HEAD_fast_net/sys/amd64/conf/PERFTEST ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kmacy/HEAD_fast_net/sys/amd64/conf/PERFTEST Wed Dec 31 05:44:00 2008 (r186632) @@ -0,0 +1,319 @@ +# +# GENERIC -- Generic kernel configuration file for FreeBSD/amd64 +# +# For more information on this file, please read the handbook section on +# Kernel Configuration Files: +# +# http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# +# The handbook is also available locally in /usr/share/doc/handbook +# if you've installed the doc distribution, otherwise always see the +# FreeBSD World Wide Web server (http://www.FreeBSD.org/) for the +# latest information. +# +# An exhaustive list of options and more detailed explanations of the +# device lines is also present in the ../../conf/NOTES and NOTES files. +# If you are in doubt as to the purpose or necessity of a line, check first +# in NOTES. +# +# $FreeBSD: user/kmacy/HEAD_fast_net/sys/amd64/conf/GENERIC 185567 2008-12-02 19:09:08Z ed $ + +cpu HAMMER +ident GENERIC + +# To statically compile in device wiring instead of /boot/device.hints +#hints "GENERIC.hints" # Default places to look for devices. + +makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols + +options SCHED_ULE # ULE scheduler +options PREEMPTION # Enable kernel thread preemption +options INET # InterNETworking +options INET6 # IPv6 communications protocols +options SCTP # Stream Control Transmission Protocol +options FFS # Berkeley Fast Filesystem +options SOFTUPDATES # Enable FFS soft updates support +options UFS_ACL # Support for access control lists +options UFS_DIRHASH # Improve performance on big directories +options UFS_GJOURNAL # Enable gjournal-based UFS journaling +options MD_ROOT # MD is a potential root device +options NFSCLIENT # Network Filesystem Client +options NFSSERVER # Network Filesystem Server +options NFSLOCKD # Network Lock Manager +options NFS_ROOT # NFS usable as /, requires NFSCLIENT +options NTFS # NT File System +options MSDOSFS # MSDOS Filesystem +options CD9660 # ISO 9660 Filesystem +options PROCFS # Process filesystem (requires PSEUDOFS) +options PSEUDOFS # Pseudo-filesystem framework +options GEOM_PART_GPT # GUID Partition Tables. +options GEOM_LABEL # Provides labelization +options COMPAT_43TTY # BSD 4.3 TTY compat (sgtty) +options COMPAT_IA32 # Compatible with i386 binaries +options COMPAT_FREEBSD4 # Compatible with FreeBSD4 +options COMPAT_FREEBSD5 # Compatible with FreeBSD5 +options COMPAT_FREEBSD6 # Compatible with FreeBSD6 +options COMPAT_FREEBSD7 # Compatible with FreeBSD7 +options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI +options KTRACE # ktrace(1) support +options STACK # stack(9) support +options SYSVSHM # SYSV-style shared memory +options SYSVMSG # SYSV-style message queues +options SYSVSEM # SYSV-style semaphores +options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions +options KBD_INSTALL_CDEV # install a CDEV entry in /dev +options STOP_NMI # Stop CPUS using NMI instead of IPI +options AUDIT # Security event auditing +options HWPMC_HOOKS # Necessary kernel hooks for hwpmc(4) + +# Debugging for use in -current +options KDB # Enable kernel debugger support. +options DDB # Support DDB. +options GDB # Support remote GDB. +options ALT_BREAK_TO_DEBUGGER + +#options INVARIANTS # Enable calls of extra sanity checking +#options INVARIANT_SUPPORT # Extra sanity checks of internal structures, required by INVARIANTS +#options WITNESS # Enable checks to detect deadlocks and cycles +#options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed +options LOCK_PROFILING +options RADIX_MPATH + +# Make an SMP-capable kernel by default +options SMP # Symmetric MultiProcessor Kernel + +# CPU frequency control +device cpufreq + +# Bus support. +device acpi +device pci + +# Floppy drives +device fdc + +# ATA and ATAPI devices +device ata +device atadisk # ATA disk drives +device ataraid # ATA RAID drives +device atapicd # ATAPI CDROM drives +device atapifd # ATAPI floppy drives +device atapist # ATAPI tape drives +options ATA_STATIC_ID # Static device numbering + +# SCSI Controllers +device ahc # AHA2940 and onboard AIC7xxx devices +options AHC_REG_PRETTY_PRINT # Print register bitfields in debug + # output. Adds ~128k to driver. +device ahd # AHA39320/29320 and onboard AIC79xx devices +options AHD_REG_PRETTY_PRINT # Print register bitfields in debug + # output. Adds ~215k to driver. +device amd # AMD 53C974 (Tekram DC-390(T)) +device hptiop # Highpoint RocketRaid 3xxx series +device isp # Qlogic family +#device ispfw # Firmware for QLogic HBAs- normally a module +device mpt # LSI-Logic MPT-Fusion +#device ncr # NCR/Symbios Logic +device sym # NCR/Symbios Logic (newer chipsets + those of `ncr') +device trm # Tekram DC395U/UW/F DC315U adapters + +device adv # Advansys SCSI adapters +device adw # Advansys wide SCSI adapters +device aic # Adaptec 15[012]x SCSI adapters, AIC-6[23]60. +device bt # Buslogic/Mylex MultiMaster SCSI adapters + +# SCSI peripherals +device scbus # SCSI bus (required for SCSI) +device ch # SCSI media changers +device da # Direct Access (disks) +device sa # Sequential Access (tape etc) +device cd # CD +device pass # Passthrough device (direct SCSI access) +device ses # SCSI Environmental Services (and SAF-TE) + +# RAID controllers interfaced to the SCSI subsystem +device amr # AMI MegaRAID +device arcmsr # Areca SATA II RAID +device ciss # Compaq Smart RAID 5* +device dpt # DPT Smartcache III, IV - See NOTES for options +device hptmv # Highpoint RocketRAID 182x +device hptrr # Highpoint RocketRAID 17xx, 22xx, 23xx, 25xx +device iir # Intel Integrated RAID +device ips # IBM (Adaptec) ServeRAID +device mly # Mylex AcceleRAID/eXtremeRAID +device twa # 3ware 9000 series PATA/SATA RAID + +# RAID controllers +device aac # Adaptec FSA RAID +device aacp # SCSI passthrough for aac (requires CAM) +device ida # Compaq Smart RAID +device mfi # LSI MegaRAID SAS +device mlx # Mylex DAC960 family +#XXX pointer/int warnings +#device pst # Promise Supertrak SX6000 +device twe # 3ware ATA RAID + +# atkbdc0 controls both the keyboard and the PS/2 mouse +device atkbdc # AT keyboard controller +device atkbd # AT keyboard +device psm # PS/2 mouse + +device kbdmux # keyboard multiplexer + +device vga # VGA video card driver + +device splash # Splash screen and screen saver support + +# syscons is the default console driver, resembling an SCO console +device sc + +device agp # support several AGP chipsets + +# PCCARD (PCMCIA) support +# PCMCIA and cardbus bridge support +device cbb # cardbus (yenta) bridge +device pccard # PC Card (16-bit) bus +device cardbus # CardBus (32-bit) bus + +# Serial (COM) ports +device uart # Generic UART driver + +# Parallel port +device ppc +device ppbus # Parallel port bus (required) +device lpt # Printer +device plip # TCP/IP over parallel +device ppi # Parallel port interface device +#device vpo # Requires scbus and da + +# If you've got a "dumb" serial or parallel PCI card that is +# supported by the puc(4) glue driver, uncomment the following +# line to enable it (connects to sio, uart and/or ppc drivers): +#device puc + +# PCI Ethernet NICs. +device de # DEC/Intel DC21x4x (``Tulip'') +device em # Intel PRO/1000 Gigabit Ethernet Family +device igb # Intel PRO/1000 PCIE Server Gigabit Family +device ixgb # Intel PRO/10GbE Ethernet Card +device le # AMD Am7900 LANCE and Am79C9xx PCnet +device ti # Alteon Networks Tigon I/II gigabit Ethernet +device txp # 3Com 3cR990 (``Typhoon'') +device vx # 3Com 3c590, 3c595 (``Vortex'') + +# PCI Ethernet NICs that use the common MII bus controller code. +# NOTE: Be sure to keep the 'device miibus' line in order to use these NICs! +device miibus # MII bus support +device ae # Attansic/Atheros L2 FastEthernet +device age # Attansic/Atheros L1 Gigabit Ethernet +device ale # Atheros AR8121/AR8113/AR8114 Ethernet +device bce # Broadcom BCM5706/BCM5708 Gigabit Ethernet +device bfe # Broadcom BCM440x 10/100 Ethernet +device bge # Broadcom BCM570xx Gigabit Ethernet +device dc # DEC/Intel 21143 and various workalikes +device et # Agere ET1310 10/100/Gigabit Ethernet +device fxp # Intel EtherExpress PRO/100B (82557, 82558) +device jme # JMicron JMC250 Gigabit/JMC260 Fast Ethernet +device lge # Level 1 LXT1001 gigabit Ethernet +device msk # Marvell/SysKonnect Yukon II Gigabit Ethernet +device nfe # nVidia nForce MCP on-board Ethernet +device nge # NatSemi DP83820 gigabit Ethernet +#device nve # nVidia nForce MCP on-board Ethernet Networking +device pcn # AMD Am79C97x PCI 10/100 (precedence over 'le') +device re # RealTek 8139C+/8169/8169S/8110S +device rl # RealTek 8129/8139 +device sf # Adaptec AIC-6915 (``Starfire'') +device sis # Silicon Integrated Systems SiS 900/SiS 7016 +device sk # SysKonnect SK-984x & SK-982x gigabit Ethernet +device ste # Sundance ST201 (D-Link DFE-550TX) +device tl # Texas Instruments ThunderLAN +device tx # SMC EtherPower II (83c170 ``EPIC'') +device vge # VIA VT612x gigabit Ethernet +device vr # VIA Rhine, Rhine II +device wb # Winbond W89C840F +device xl # 3Com 3c90x (``Boomerang'', ``Cyclone'') + +# ISA Ethernet NICs. pccard NICs included. +device cs # Crystal Semiconductor CS89x0 NIC +# 'device ed' requires 'device miibus' +device ed # NE[12]000, SMC Ultra, 3c503, DS8390 cards +device ex # Intel EtherExpress Pro/10 and Pro/10+ +device ep # Etherlink III based cards +device fe # Fujitsu MB8696x based cards +device sn # SMC's 9000 series of Ethernet chips +device xe # Xircom pccard Ethernet + +# Wireless NIC cards +device wlan # 802.11 support +options IEEE80211_DEBUG # enable debug msgs +options IEEE80211_AMPDU_AGE # age frames in AMPDU reorder q's +device wlan_wep # 802.11 WEP support +device wlan_ccmp # 802.11 CCMP support +device wlan_tkip # 802.11 TKIP support +device wlan_amrr # AMRR transmit rate control algorithm +device an # Aironet 4500/4800 802.11 wireless NICs. +device ath # Atheros pci/cardbus NIC's +device ath_hal # pci/cardbus chip support +options AH_SUPPORT_AR5416 # enable AR5416 tx/rx descriptors +device ath_rate_sample # SampleRate tx rate control for ath +device ral # Ralink Technology RT2500 wireless NICs. +device wi # WaveLAN/Intersil/Symbol 802.11 wireless NICs. + +# Pseudo devices. +device loop # Network loopback +device random # Entropy device +device ether # Ethernet support +device tun # Packet tunnel. +device pty # BSD-style compatibility pseudo ttys +device md # Memory "disks" +device gif # IPv6 and IPv4 tunneling +device faith # IPv6-to-IPv4 relaying (translation) +device firmware # firmware assist module + +# The `bpf' device enables the Berkeley Packet Filter. +# Be aware of the administrative consequences of enabling this! +# Note that 'bpf' is required for DHCP. +device bpf # Berkeley packet filter + +# USB support +device uhci # UHCI PCI->USB interface +device ohci # OHCI PCI->USB interface +device ehci # EHCI PCI->USB interface (USB 2.0) +device usb # USB Bus (required) +#device udbp # USB Double Bulk Pipe devices +device ugen # Generic +device uhid # "Human Interface Devices" +device ukbd # Keyboard +device ulpt # Printer +device umass # Disks/Mass storage - Requires scbus and da +device ums # Mouse +device ural # Ralink Technology RT2500USB wireless NICs +device rum # Ralink Technology RT2501USB wireless NICs +device urio # Diamond Rio 500 MP3 player +device uscanner # Scanners +# USB Serial devices +device ucom # Generic com ttys +device uark # Technologies ARK3116 based serial adapters +device ubsa # Belkin F5U103 and compatible serial adapters +device uftdi # For FTDI usb serial adapters +device uipaq # Some WinCE based devices +device uplcom # Prolific PL-2303 serial adapters +device uslcom # SI Labs CP2101/CP2102 serial adapters +device uvisor # Visor and Palm devices +device uvscom # USB serial support for DDI pocket's PHS +# USB Ethernet, requires miibus +device aue # ADMtek USB Ethernet +device axe # ASIX Electronics USB Ethernet +device cdce # Generic USB over Ethernet +device cue # CATC USB Ethernet +device kue # Kawasaki LSI USB Ethernet +device rue # RealTek RTL8150 USB Ethernet +device udav # Davicom DM9601E USB + +# FireWire support +device firewire # FireWire bus code +device sbp # SCSI over FireWire (Requires scbus and da) +device fwe # Ethernet over FireWire (non-standard!) +device fwip # IP over FireWire (RFC 2734,3146) +device dcons # Dumb console driver +device dcons_crom # Configuration ROM for dcons From owner-svn-src-user@FreeBSD.ORG Wed Dec 31 08:57:55 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 21A82106564A; Wed, 31 Dec 2008 08:57:55 +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 0FFF08FC0C; Wed, 31 Dec 2008 08:57:55 +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 mBV8vsJE020189; Wed, 31 Dec 2008 08:57:54 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBV8vsi4020188; Wed, 31 Dec 2008 08:57:54 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200812310857.mBV8vsi4020188@svn.freebsd.org> From: Kip Macy Date: Wed, 31 Dec 2008 08:57:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186645 - user/kmacy/HEAD_fast_net/sys/net X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Dec 2008 08:57:55 -0000 Author: kmacy Date: Wed Dec 31 08:57:54 2008 New Revision: 186645 URL: http://svn.freebsd.org/changeset/base/186645 Log: fix loopback Modified: user/kmacy/HEAD_fast_net/sys/net/if_ethersubr.c Modified: user/kmacy/HEAD_fast_net/sys/net/if_ethersubr.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/net/if_ethersubr.c Wed Dec 31 08:56:49 2008 (r186644) +++ user/kmacy/HEAD_fast_net/sys/net/if_ethersubr.c Wed Dec 31 08:57:54 2008 (r186645) @@ -197,6 +197,7 @@ ether_output(struct ifnet *ifp, struct m * 5) is this not loopback? */ t = pf_find_mtag(m); +#if 0 if (lle != NULL && (lle->la_flags & LLE_VALID) && ifp->if_bridge == NULL && ifp->if_carp == NULL && IFP2AC(ifp)->ac_netgraph == NULL && @@ -226,7 +227,8 @@ ether_output(struct ifnet *ifp, struct m /* Continue with link-layer output */ return ether_output_frame(ifp, m); } - +#endif + /* * The shortcut failed, use default path * From owner-svn-src-user@FreeBSD.ORG Wed Dec 31 17:42:06 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A416F106568D; Wed, 31 Dec 2008 17:42:06 +0000 (UTC) (envelope-from sam@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7A5CC8FC19; Wed, 31 Dec 2008 17:42:06 +0000 (UTC) (envelope-from sam@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 mBVHg6n4031624; Wed, 31 Dec 2008 17:42:06 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBVHg6T5031623; Wed, 31 Dec 2008 17:42:06 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200812311742.mBVHg6T5031623@svn.freebsd.org> From: Sam Leffler Date: Wed, 31 Dec 2008 17:42:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186655 - user/sam X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Dec 2008 17:42:07 -0000 Author: sam Date: Wed Dec 31 17:42:05 2008 New Revision: 186655 URL: http://svn.freebsd.org/changeset/base/186655 Log: add a spot for odd bits Added: user/sam/ From owner-svn-src-user@FreeBSD.ORG Wed Dec 31 17:43:28 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B19481065670; Wed, 31 Dec 2008 17:43:28 +0000 (UTC) (envelope-from sam@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 87D0A8FC12; Wed, 31 Dec 2008 17:43:28 +0000 (UTC) (envelope-from sam@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 mBVHhSxl031684; Wed, 31 Dec 2008 17:43:28 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBVHhSKA031683; Wed, 31 Dec 2008 17:43:28 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200812311743.mBVHhSKA031683@svn.freebsd.org> From: Sam Leffler Date: Wed, 31 Dec 2008 17:43:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186656 - user/sam/wifi X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Dec 2008 17:43:29 -0000 Author: sam Date: Wed Dec 31 17:43:28 2008 New Revision: 186656 URL: http://svn.freebsd.org/changeset/base/186656 Log: branch from head for some wifi projects Added: user/sam/wifi/ (props changed) - copied from r186655, head/ From owner-svn-src-user@FreeBSD.ORG Wed Dec 31 23:21:08 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EC2B9106564A; Wed, 31 Dec 2008 23:21:07 +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 DA7F68FC14; Wed, 31 Dec 2008 23:21:07 +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 mBVNL7CZ037898; Wed, 31 Dec 2008 23:21:07 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBVNL75E037897; Wed, 31 Dec 2008 23:21:07 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200812312321.mBVNL75E037897@svn.freebsd.org> From: Kip Macy Date: Wed, 31 Dec 2008 23:21:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186661 - user/kmacy/HEAD_fast_net/sys/kern X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Dec 2008 23:21:08 -0000 Author: kmacy Date: Wed Dec 31 23:21:07 2008 New Revision: 186661 URL: http://svn.freebsd.org/changeset/base/186661 Log: make it possible to profile normal mutex acquisition by not calling knlist_mtx_lock Modified: user/kmacy/HEAD_fast_net/sys/kern/kern_event.c Modified: user/kmacy/HEAD_fast_net/sys/kern/kern_event.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/kern/kern_event.c Wed Dec 31 22:57:14 2008 (r186660) +++ user/kmacy/HEAD_fast_net/sys/kern/kern_event.c Wed Dec 31 23:21:07 2008 (r186661) @@ -86,6 +86,10 @@ MTX_SYSINIT(kq_global, &kq_global, "kque TASKQUEUE_DEFINE_THREAD(kqueue); +static void knlist_mtx_lock(void *arg); +static void knlist_mtx_unlock(void *arg); +static int knlist_mtx_locked(void *arg); + static int kevent_copyout(void *arg, struct kevent *kevp, int count); static int kevent_copyin(void *arg, struct kevent *kevp, int count); static int kqueue_register(struct kqueue *kq, struct kevent *kev, @@ -193,8 +197,14 @@ SYSCTL_INT(_kern, OID_AUTO, kq_calloutma mtx_assert(&(kq)->kq_lock, MA_NOTOWNED); \ } while (0) #define KN_LIST_LOCK(kn) do { \ - if (kn->kn_knlist != NULL) \ - kn->kn_knlist->kl_lock(kn->kn_knlist->kl_lockarg); \ + struct knlist *list = kn->kn_knlist; \ + \ + if (list != NULL){ \ + if (list->kl_lock != knlist_mtx_lock) \ + list->kl_lock(list->kl_lockarg); \ + else \ + mtx_lock((struct mtx *)list->kl_lockarg); \ + } \ } while (0) #define KN_LIST_UNLOCK(kn) do { \ if (kn->kn_knlist != NULL) \ @@ -424,8 +434,12 @@ knote_fork(struct knlist *list, int pid) if (list == NULL) return; - list->kl_lock(list->kl_lockarg); - + + if (list->kl_lock != knlist_mtx_lock) + list->kl_lock(list->kl_lockarg); + else + mtx_lock((struct mtx *)list->kl_lockarg); + SLIST_FOREACH(kn, &list->kl_list, kn_selnext) { if ((kn->kn_status & KN_INFLUX) == KN_INFLUX) continue; @@ -476,7 +490,10 @@ knote_fork(struct knlist *list, int pid) KQ_LOCK(kq); kn->kn_status &= ~KN_INFLUX; KQ_UNLOCK_FLUX(kq); - list->kl_lock(list->kl_lockarg); + if (list->kl_lock != knlist_mtx_lock) + list->kl_lock(list->kl_lockarg); + else + mtx_lock((struct mtx *)list->kl_lockarg); } list->kl_unlock(list->kl_lockarg); } @@ -1618,8 +1635,12 @@ knote(struct knlist *list, long hint, in KNL_ASSERT_LOCK(list, islocked); - if (!islocked) - list->kl_lock(list->kl_lockarg); + if (!islocked){ + if (list->kl_lock != knlist_mtx_lock) + list->kl_lock(list->kl_lockarg); + else + mtx_lock((struct mtx *)list->kl_lockarg); + } /* * If we unlock the list lock (and set KN_INFLUX), we can eliminate @@ -1657,8 +1678,14 @@ knlist_add(struct knlist *knl, struct kn KQ_NOTOWNED(kn->kn_kq); KASSERT((kn->kn_status & (KN_INFLUX|KN_DETACHED)) == (KN_INFLUX|KN_DETACHED), ("knote not KN_INFLUX and KN_DETACHED")); - if (!islocked) - knl->kl_lock(knl->kl_lockarg); + if (!islocked) { + struct knlist *list = kn->kn_knlist; + + if (list->kl_lock != knlist_mtx_lock) + list->kl_lock(list->kl_lockarg); + else + mtx_lock((struct mtx *)list->kl_lockarg); + } SLIST_INSERT_HEAD(&knl->kl_list, kn, kn_selnext); if (!islocked) knl->kl_unlock(knl->kl_lockarg); @@ -1677,8 +1704,15 @@ knlist_remove_kq(struct knlist *knl, str if (!kqislocked) KASSERT((kn->kn_status & (KN_INFLUX|KN_DETACHED)) == KN_INFLUX, ("knlist_remove called w/o knote being KN_INFLUX or already removed")); - if (!knlislocked) - knl->kl_lock(knl->kl_lockarg); + if (!knlislocked) { + struct knlist *list = kn->kn_knlist; + + if (list->kl_lock != knlist_mtx_lock) + list->kl_lock(list->kl_lockarg); + else + mtx_lock((struct mtx *)list->kl_lockarg); + } + SLIST_REMOVE(&knl->kl_list, kn, knote, kn_selnext); kn->kn_knlist = NULL; if (!knlislocked) @@ -1721,9 +1755,6 @@ knlist_empty(struct knlist *knl) static struct mtx knlist_lock; MTX_SYSINIT(knlist_lock, &knlist_lock, "knlist lock for lockless objects", MTX_DEF); -static void knlist_mtx_lock(void *arg); -static void knlist_mtx_unlock(void *arg); -static int knlist_mtx_locked(void *arg); static void knlist_mtx_lock(void *arg) @@ -1801,7 +1832,11 @@ knlist_cleardel(struct knlist *knl, stru else { KNL_ASSERT_UNLOCKED(knl); again: /* need to reacquire lock since we have dropped it */ - knl->kl_lock(knl->kl_lockarg); + + if (knl->kl_lock != knlist_mtx_lock) + knl->kl_lock(knl->kl_lockarg); + else + mtx_lock((struct mtx *)knl->kl_lockarg); } SLIST_FOREACH_SAFE(kn, &knl->kl_list, kn_selnext, kn2) { From owner-svn-src-user@FreeBSD.ORG Wed Dec 31 23:44:35 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 802BF106564A; Wed, 31 Dec 2008 23:44:35 +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 6DD498FC1A; Wed, 31 Dec 2008 23:44:35 +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 mBVNiZsE038364; Wed, 31 Dec 2008 23:44:35 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBVNiZGb038362; Wed, 31 Dec 2008 23:44:35 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200812312344.mBVNiZGb038362@svn.freebsd.org> From: Kip Macy Date: Wed, 31 Dec 2008 23:44:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186663 - in user/kmacy/HEAD_fast_net/sys: kern sys X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Dec 2008 23:44:36 -0000 Author: kmacy Date: Wed Dec 31 23:44:34 2008 New Revision: 186663 URL: http://svn.freebsd.org/changeset/base/186663 Log: avoid runtime switching of kqueue locking by adding knote_locked and KNOTE_ACTIVATE_LOCKED Modified: user/kmacy/HEAD_fast_net/sys/kern/kern_event.c user/kmacy/HEAD_fast_net/sys/sys/event.h Modified: user/kmacy/HEAD_fast_net/sys/kern/kern_event.c ============================================================================== --- user/kmacy/HEAD_fast_net/sys/kern/kern_event.c Wed Dec 31 23:22:45 2008 (r186662) +++ user/kmacy/HEAD_fast_net/sys/kern/kern_event.c Wed Dec 31 23:44:34 2008 (r186663) @@ -163,16 +163,16 @@ SYSCTL_INT(_kern, OID_AUTO, kq_calloutma &kq_calloutmax, 0, "Maximum number of callouts allocated for kqueue"); /* XXX - ensure not KN_INFLUX?? */ -#define KNOTE_ACTIVATE(kn, islock) do { \ - if ((islock)) \ - mtx_assert(&(kn)->kn_kq->kq_lock, MA_OWNED); \ - else \ - KQ_LOCK((kn)->kn_kq); \ +#define KNOTE_ACTIVATE_LOCKED(kn) do { \ + mtx_assert(&(kn)->kn_kq->kq_lock, MA_OWNED); \ (kn)->kn_status |= KN_ACTIVE; \ if (((kn)->kn_status & (KN_QUEUED | KN_DISABLED)) == 0) \ knote_enqueue((kn)); \ - if (!(islock)) \ - KQ_UNLOCK((kn)->kn_kq); \ +} while(0) +#define KNOTE_ACTIVATE(kn) do { \ + KQ_LOCK((kn)->kn_kq); \ + KNOTE_ACTIVATE_LOCKED(kn); \ + KQ_UNLOCK((kn)->kn_kq); \ } while(0) #define KQ_LOCK(kq) do { \ mtx_lock(&(kq)->kq_lock); \ @@ -357,7 +357,7 @@ filt_procattach(struct knote *kn) * process, e.g. a child, dies before the kevent is registered. */ if (immediate && filt_proc(kn, NOTE_EXIT)) - KNOTE_ACTIVATE(kn, 0); + KNOTE_ACTIVATE(kn); PROC_UNLOCK(p); @@ -456,7 +456,7 @@ knote_fork(struct knlist *list, int pid) if ((kn->kn_sfflags & NOTE_TRACK) == 0) { kn->kn_status |= KN_HASKQLOCK; if (kn->kn_fop->f_event(kn, NOTE_FORK | pid)) - KNOTE_ACTIVATE(kn, 1); + KNOTE_ACTIVATE_LOCKED(kn); kn->kn_status &= ~KN_HASKQLOCK; KQ_UNLOCK(kq); continue; @@ -484,7 +484,7 @@ knote_fork(struct knlist *list, int pid) kev.udata = kn->kn_kevent.udata;/* preserve udata */ error = kqueue_register(kq, &kev, NULL, 0); if (kn->kn_fop->f_event(kn, NOTE_FORK | pid)) - KNOTE_ACTIVATE(kn, 0); + KNOTE_ACTIVATE(kn); if (error) kn->kn_fflags |= NOTE_TRACKERR; KQ_LOCK(kq); @@ -519,7 +519,7 @@ filt_timerexpire(void *knx) struct callout *calloutp; kn->kn_data++; - KNOTE_ACTIVATE(kn, 0); /* XXX - handle locking */ + KNOTE_ACTIVATE(kn); /* XXX - handle locking */ if ((kn->kn_flags & EV_ONESHOT) != EV_ONESHOT) { calloutp = (struct callout *)kn->kn_hook; @@ -1011,7 +1011,7 @@ findkn: event = kn->kn_fop->f_event(kn, 0); KQ_LOCK(kq); if (event) - KNOTE_ACTIVATE(kn, 1); + KNOTE_ACTIVATE_LOCKED(kn); kn->kn_status &= ~KN_INFLUX; KN_LIST_UNLOCK(kn); } else if (kev->flags & EV_DELETE) { @@ -1625,23 +1625,15 @@ kqueue_wakeup(struct kqueue *kq) * first. */ void -knote(struct knlist *list, long hint, int islocked) +knote_locked(struct knlist *list, long hint) { + struct kqueue *kq; struct knote *kn; if (list == NULL) return; - - KNL_ASSERT_LOCK(list, islocked); - - if (!islocked){ - if (list->kl_lock != knlist_mtx_lock) - list->kl_lock(list->kl_lockarg); - else - mtx_lock((struct mtx *)list->kl_lockarg); - } - + /* * If we unlock the list lock (and set KN_INFLUX), we can eliminate * the kqueue scheduling, but this will introduce four @@ -1657,17 +1649,30 @@ knote(struct knlist *list, long hint, in if ((kn->kn_status & KN_INFLUX) != KN_INFLUX) { kn->kn_status |= KN_HASKQLOCK; if (kn->kn_fop->f_event(kn, hint)) - KNOTE_ACTIVATE(kn, 1); + KNOTE_ACTIVATE_LOCKED(kn); kn->kn_status &= ~KN_HASKQLOCK; } KQ_UNLOCK(kq); } kq = NULL; } - if (!islocked) - list->kl_unlock(list->kl_lockarg); } +void +knote(struct knlist *list, long hint) +{ + if (list == NULL) + return; + + if (list->kl_lock != knlist_mtx_lock) + list->kl_lock(list->kl_lockarg); + else + mtx_lock((struct mtx *)list->kl_lockarg); + knote_locked(list, hint); + list->kl_unlock(list->kl_lockarg); +} + + /* * add a knote to a knlist */ Modified: user/kmacy/HEAD_fast_net/sys/sys/event.h ============================================================================== --- user/kmacy/HEAD_fast_net/sys/sys/event.h Wed Dec 31 23:22:45 2008 (r186662) +++ user/kmacy/HEAD_fast_net/sys/sys/event.h Wed Dec 31 23:44:34 2008 (r186663) @@ -135,9 +135,15 @@ struct knlist { MALLOC_DECLARE(M_KQUEUE); #endif -#define KNOTE(list, hist, lock) knote(list, hist, lock) -#define KNOTE_LOCKED(list, hint) knote(list, hint, 1) -#define KNOTE_UNLOCKED(list, hint) knote(list, hint, 0) +#define KNOTE(list, hist, lock) do { \ + if (lock) \ + knote_locked(list, hist); \ + else \ + knote(list, hist); \ +} while (0) + +#define KNOTE_LOCKED(list, hint) knote_locked(list, hint) +#define KNOTE_UNLOCKED(list, hint) knote(list, hint) #define KNLIST_EMPTY(list) SLIST_EMPTY(&(list)->kl_list) @@ -204,7 +210,8 @@ struct thread; struct proc; struct knlist; -extern void knote(struct knlist *list, long hint, int islocked); +extern void knote(struct knlist *list, long hint); +extern void knote_locked(struct knlist *list, long hint); extern void knote_fork(struct knlist *list, int pid); extern void knlist_add(struct knlist *knl, struct knote *kn, int islocked); extern void knlist_remove(struct knlist *knl, struct knote *kn, int islocked);