From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 8 09:06:26 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 1B39F106564A; Sun, 8 Jul 2012 09:06:26 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E09D88FC14; Sun, 8 Jul 2012 09:06:25 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q6896PCW040451; Sun, 8 Jul 2012 09:06:25 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q6896PwF040448; Sun, 8 Jul 2012 09:06:25 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201207080906.q6896PwF040448@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Sun, 8 Jul 2012 09:06:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238223 - stable/9/sbin/ifconfig X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jul 2012 09:06:26 -0000 Author: bz Date: Sun Jul 8 09:06:25 2012 New Revision: 238223 URL: http://svn.freebsd.org/changeset/base/238223 Log: MFC r235671: Allow tso4 and tso6 be set individually given we have the bits. This will help with drivers not working as expected during the transition time and later. Approved by: re Modified: stable/9/sbin/ifconfig/ifconfig.8 stable/9/sbin/ifconfig/ifconfig.c Directory Properties: stable/9/sbin/ifconfig/ (props changed) Modified: stable/9/sbin/ifconfig/ifconfig.8 ============================================================================== --- stable/9/sbin/ifconfig/ifconfig.8 Sun Jul 8 08:49:37 2012 (r238222) +++ stable/9/sbin/ifconfig/ifconfig.8 Sun Jul 8 09:06:25 2012 (r238223) @@ -28,7 +28,7 @@ .\" From: @(#)ifconfig.8 8.3 (Berkeley) 1/5/94 .\" $FreeBSD$ .\" -.Dd March 7, 2012 +.Dd May 19, 2012 .Dt IFCONFIG 8 .Os .Sh NAME @@ -400,6 +400,22 @@ It will always disable TSO for .Xr ip 4 and .Xr ip6 4 . +.It Cm tso6 , tso4 +If the driver supports +.Xr tcp 4 +segmentation offloading for +.Xr ip6 4 +or +.Xr ip 4 +use one of these to selectively enabled it only for one protocol family. +.It Fl tso6 , tso4 +If the driver supports +.Xr tcp 4 +segmentation offloading for +.Xr ip6 4 +or +.Xr ip 4 +use one of these to selectively disable it only for one protocol family. .It Cm lro If the driver supports .Xr tcp 4 Modified: stable/9/sbin/ifconfig/ifconfig.c ============================================================================== --- stable/9/sbin/ifconfig/ifconfig.c Sun Jul 8 08:49:37 2012 (r238222) +++ stable/9/sbin/ifconfig/ifconfig.c Sun Jul 8 09:06:25 2012 (r238223) @@ -1178,6 +1178,10 @@ static struct cmd basic_cmds[] = { DEF_CMD("-netcons", -IFCAP_NETCONS, setifcap), DEF_CMD("polling", IFCAP_POLLING, setifcap), DEF_CMD("-polling", -IFCAP_POLLING, setifcap), + DEF_CMD("tso6", IFCAP_TSO6, setifcap), + DEF_CMD("-tso6", -IFCAP_TSO6, setifcap), + DEF_CMD("tso4", IFCAP_TSO4, setifcap), + DEF_CMD("-tso4", -IFCAP_TSO4, setifcap), DEF_CMD("tso", IFCAP_TSO, setifcap), DEF_CMD("-tso", -IFCAP_TSO, setifcap), DEF_CMD("lro", IFCAP_LRO, setifcap), From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 8 09:49:03 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 1EDBA1065694; Sun, 8 Jul 2012 09:49:02 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5F0618FC16; Sun, 8 Jul 2012 09:49:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q689n2Ys042219; Sun, 8 Jul 2012 09:49:02 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q689n2Zm042216; Sun, 8 Jul 2012 09:49:02 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201207080949.q689n2Zm042216@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Sun, 8 Jul 2012 09:49:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238224 - stable/9/sys/netinet6 X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jul 2012 09:49:03 -0000 Author: bz Date: Sun Jul 8 09:49:01 2012 New Revision: 238224 URL: http://svn.freebsd.org/changeset/base/238224 Log: MFC r235916: Introduce in6_getscope() to allow more effective checksum computations without the need to copy the address to clear the scope. Approved by: re Modified: stable/9/sys/netinet6/scope6.c stable/9/sys/netinet6/scope6_var.h Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet6/scope6.c ============================================================================== --- stable/9/sys/netinet6/scope6.c Sun Jul 8 09:06:25 2012 (r238223) +++ stable/9/sys/netinet6/scope6.c Sun Jul 8 09:49:01 2012 (r238224) @@ -494,3 +494,16 @@ in6_clearscope(struct in6_addr *in6) return (modified); } + +/* + * Return the scope identifier or zero. + */ +uint16_t +in6_getscope(struct in6_addr *in6) +{ + + if (IN6_IS_SCOPE_LINKLOCAL(in6) || IN6_IS_ADDR_MC_INTFACELOCAL(in6)) + return (in6->s6_addr16[1]); + + return (0); +} Modified: stable/9/sys/netinet6/scope6_var.h ============================================================================== --- stable/9/sys/netinet6/scope6_var.h Sun Jul 8 09:06:25 2012 (r238223) +++ stable/9/sys/netinet6/scope6_var.h Sun Jul 8 09:49:01 2012 (r238224) @@ -54,6 +54,7 @@ int sa6_embedscope __P((struct sockaddr_ int sa6_recoverscope __P((struct sockaddr_in6 *)); int in6_setscope __P((struct in6_addr *, struct ifnet *, u_int32_t *)); int in6_clearscope __P((struct in6_addr *)); +uint16_t in6_getscope(struct in6_addr *); #endif /* _KERNEL */ #endif /* _NETINET6_SCOPE6_VAR_H_ */ From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 8 10:04:30 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AEC4A106566B; Sun, 8 Jul 2012 10:04:30 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9956C8FC0C; Sun, 8 Jul 2012 10:04:30 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q68A4UEo042970; Sun, 8 Jul 2012 10:04:30 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q68A4Um1042968; Sun, 8 Jul 2012 10:04:30 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201207081004.q68A4Um1042968@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Sun, 8 Jul 2012 10:04:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238226 - stable/9/sys/netinet6 X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jul 2012 10:04:30 -0000 Author: bz Date: Sun Jul 8 10:04:30 2012 New Revision: 238226 URL: http://svn.freebsd.org/changeset/base/238226 Log: MFC r235921: Optimize in6_cksum(), re-ordering work and limiting variable initialization, removing a bzero() for mostly re-initialized struct values, making use of the newly introduced in6_getscope(), as well as converting an if/panic to a KASSERT(). Approved by: re Modified: stable/9/sys/netinet6/in6_cksum.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet6/in6_cksum.c ============================================================================== --- stable/9/sys/netinet6/in6_cksum.c Sun Jul 8 09:55:00 2012 (r238225) +++ stable/9/sys/netinet6/in6_cksum.c Sun Jul 8 10:04:30 2012 (r238226) @@ -89,12 +89,10 @@ __FBSDID("$FreeBSD$"); int in6_cksum(struct mbuf *m, u_int8_t nxt, u_int32_t off, u_int32_t len) { - u_int16_t *w; - int sum = 0; - int mlen = 0; - int byte_swapped = 0; struct ip6_hdr *ip6; - struct in6_addr in6; + u_int16_t *w, scope; + int byte_swapped, mlen; + int sum; union { u_int16_t phs[4]; struct { @@ -112,42 +110,38 @@ in6_cksum(struct mbuf *m, u_int8_t nxt, u_int32_t l; } l_util; - /* sanity check */ - if (m->m_pkthdr.len < off + len) { - panic("in6_cksum: mbuf len (%d) < off+len (%d+%d)", - m->m_pkthdr.len, off, len); - } - - bzero(&uph, sizeof(uph)); + /* Sanity check. */ + KASSERT(m->m_pkthdr.len >= off + len, ("%s: mbuf len (%d) < off(%d)+" + "len(%d)", __func__, m->m_pkthdr.len, off, len)); /* * First create IP6 pseudo header and calculate a summary. */ - ip6 = mtod(m, struct ip6_hdr *); uph.ph.ph_len = htonl(len); + uph.ph.ph_zero[0] = uph.ph.ph_zero[1] = uph.ph.ph_zero[2] = 0; uph.ph.ph_nxt = nxt; - /* - * IPv6 source address. - * XXX: we'd like to avoid copying the address, but we can't due to - * the possibly embedded scope zone ID. - */ - in6 = ip6->ip6_src; - in6_clearscope(&in6); - w = (u_int16_t *)&in6; + /* Payload length and upper layer identifier. */ + sum = uph.phs[0]; sum += uph.phs[1]; + sum += uph.phs[2]; sum += uph.phs[3]; + + ip6 = mtod(m, struct ip6_hdr *); + + /* IPv6 source address. */ + scope = in6_getscope(&ip6->ip6_src); + w = (u_int16_t *)&ip6->ip6_src; sum += w[0]; sum += w[1]; sum += w[2]; sum += w[3]; sum += w[4]; sum += w[5]; sum += w[6]; sum += w[7]; + if (scope != 0) + sum -= scope; - /* IPv6 destination address */ - in6 = ip6->ip6_dst; - in6_clearscope(&in6); - w = (u_int16_t *)&in6; + /* IPv6 destination address. */ + scope = in6_getscope(&ip6->ip6_dst); + w = (u_int16_t *)&ip6->ip6_dst; sum += w[0]; sum += w[1]; sum += w[2]; sum += w[3]; sum += w[4]; sum += w[5]; sum += w[6]; sum += w[7]; - - /* Payload length and upper layer identifier */ - sum += uph.phs[0]; sum += uph.phs[1]; - sum += uph.phs[2]; sum += uph.phs[3]; + if (scope != 0) + sum -= scope; /* * Secondly calculate a summary of the first mbuf excluding offset. @@ -167,14 +161,16 @@ in6_cksum(struct mbuf *m, u_int8_t nxt, /* * Force to even boundary. */ - if ((1 & (long) w) && (mlen > 0)) { + if ((1 & (long)w) && (mlen > 0)) { REDUCE; sum <<= 8; s_util.c[0] = *(u_char *)w; w = (u_int16_t *)((char *)w + 1); mlen--; byte_swapped = 1; - } + } else + byte_swapped = 0; + /* * Unroll the loop to make overhead from * branches &c small. From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 8 10:29:02 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5945D1065688; Sun, 8 Jul 2012 10:29:02 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3A2188FC12; Sun, 8 Jul 2012 10:29:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q68AT2dS043978; Sun, 8 Jul 2012 10:29:02 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q68AT24u043975; Sun, 8 Jul 2012 10:29:02 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201207081029.q68AT24u043975@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Sun, 8 Jul 2012 10:29:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238227 - stable/9/sys/netinet6 X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jul 2012 10:29:02 -0000 Author: bz Date: Sun Jul 8 10:29:01 2012 New Revision: 238227 URL: http://svn.freebsd.org/changeset/base/238227 Log: MFC r235924: Introduce a (for now copied stripped down) in6_cksum_pseudo() function. We should be able to use this from in6_cksum() but we should also ponder possible MD specific improvements. It takes an extra csum argument to allow for easy checks as will be done by the upper layer protocol input paths. Approved by: re Modified: stable/9/sys/netinet6/in6.h stable/9/sys/netinet6/in6_cksum.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet6/in6.h ============================================================================== --- stable/9/sys/netinet6/in6.h Sun Jul 8 10:04:30 2012 (r238226) +++ stable/9/sys/netinet6/in6.h Sun Jul 8 10:29:01 2012 (r238227) @@ -632,7 +632,9 @@ struct ip6_mtuinfo { #ifdef _KERNEL struct cmsghdr; +struct ip6_hdr; +int in6_cksum_pseudo(struct ip6_hdr *, uint32_t, uint8_t, uint16_t); int in6_cksum __P((struct mbuf *, u_int8_t, u_int32_t, u_int32_t)); int in6_localaddr __P((struct in6_addr *)); int in6_localip(struct in6_addr *); Modified: stable/9/sys/netinet6/in6_cksum.c ============================================================================== --- stable/9/sys/netinet6/in6_cksum.c Sun Jul 8 10:04:30 2012 (r238226) +++ stable/9/sys/netinet6/in6_cksum.c Sun Jul 8 10:29:01 2012 (r238227) @@ -80,6 +80,66 @@ __FBSDID("$FreeBSD$"); #define ADDCARRY(x) (x > 65535 ? x -= 65535 : x) #define REDUCE {l_util.l = sum; sum = l_util.s[0] + l_util.s[1]; (void)ADDCARRY(sum);} +static int +_in6_cksum_pseudo(struct ip6_hdr *ip6, uint32_t len, uint8_t nxt, uint16_t csum) +{ + int sum; + uint16_t scope, *w; + union { + u_int16_t phs[4]; + struct { + u_int32_t ph_len; + u_int8_t ph_zero[3]; + u_int8_t ph_nxt; + } __packed ph; + } uph; + + sum = csum; + + /* + * First create IP6 pseudo header and calculate a summary. + */ + uph.ph.ph_len = htonl(len); + uph.ph.ph_zero[0] = uph.ph.ph_zero[1] = uph.ph.ph_zero[2] = 0; + uph.ph.ph_nxt = nxt; + + /* Payload length and upper layer identifier. */ + sum += uph.phs[0]; sum += uph.phs[1]; + sum += uph.phs[2]; sum += uph.phs[3]; + + /* IPv6 source address. */ + scope = in6_getscope(&ip6->ip6_src); + w = (u_int16_t *)&ip6->ip6_src; + sum += w[0]; sum += w[1]; sum += w[2]; sum += w[3]; + sum += w[4]; sum += w[5]; sum += w[6]; sum += w[7]; + if (scope != 0) + sum -= scope; + + /* IPv6 destination address. */ + scope = in6_getscope(&ip6->ip6_dst); + w = (u_int16_t *)&ip6->ip6_dst; + sum += w[0]; sum += w[1]; sum += w[2]; sum += w[3]; + sum += w[4]; sum += w[5]; sum += w[6]; sum += w[7]; + if (scope != 0) + sum -= scope; + + return (sum); +} + +int +in6_cksum_pseudo(struct ip6_hdr *ip6, uint32_t len, uint8_t nxt, uint16_t csum) +{ + int sum; + union { + u_int16_t s[2]; + u_int32_t l; + } l_util; + + sum = _in6_cksum_pseudo(ip6, len, nxt, csum); + REDUCE; + return (sum); +} + /* * m MUST contain a contiguous IP6 header. * off is an offset where TCP/UDP/ICMP6 header starts. From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 8 10:46:55 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B4F6E106566C; Sun, 8 Jul 2012 10:46:55 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9CEB28FC0A; Sun, 8 Jul 2012 10:46:55 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q68AktK2044824; Sun, 8 Jul 2012 10:46:55 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q68AktaF044816; Sun, 8 Jul 2012 10:46:55 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201207081046.q68AktaF044816@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Sun, 8 Jul 2012 10:46:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238228 - in stable/9/sys: amd64/include arm/include i386/include ia64/include mips/include powerpc/include sparc64/include X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jul 2012 10:46:55 -0000 Author: bz Date: Sun Jul 8 10:46:55 2012 New Revision: 238228 URL: http://svn.freebsd.org/changeset/base/238228 Log: MFC r235941: in_cksum.h required ip.h to be included for struct ip. To be able to use some general checksum functions like in_addword() in a non-IPv4 context, limit the (also exported to user space) IPv4 specific functions to the times, when the ip.h header is present and IPVERSION is defined (to 4). Approved by: re Modified: stable/9/sys/amd64/include/in_cksum.h stable/9/sys/arm/include/in_cksum.h stable/9/sys/i386/include/in_cksum.h stable/9/sys/ia64/include/in_cksum.h stable/9/sys/mips/include/in_cksum.h stable/9/sys/powerpc/include/in_cksum.h stable/9/sys/sparc64/include/in_cksum.h Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/amd64/include/in_cksum.h ============================================================================== --- stable/9/sys/amd64/include/in_cksum.h Sun Jul 8 10:29:01 2012 (r238227) +++ stable/9/sys/amd64/include/in_cksum.h Sun Jul 8 10:46:55 2012 (r238228) @@ -43,6 +43,7 @@ #define in_cksum(m, len) in_cksum_skip(m, len, 0) +#if defined(IPVERSION) && (IPVERSION == 4) /* * It it useful to have an Internet checksum routine which is inlineable * and optimized specifically for the task of computing IP header checksums @@ -69,9 +70,12 @@ in_cksum_update(struct ip *ip) } while(0) #endif +#endif #ifdef _KERNEL +#if defined(IPVERSION) && (IPVERSION == 4) u_int in_cksum_hdr(const struct ip *ip); +#endif u_short in_addword(u_short sum, u_short b); u_short in_pseudo(u_int sum, u_int b, u_int c); u_short in_cksum_skip(struct mbuf *m, int len, int skip); Modified: stable/9/sys/arm/include/in_cksum.h ============================================================================== --- stable/9/sys/arm/include/in_cksum.h Sun Jul 8 10:29:01 2012 (r238227) +++ stable/9/sys/arm/include/in_cksum.h Sun Jul 8 10:46:55 2012 (r238228) @@ -46,7 +46,9 @@ u_short in_cksum(struct mbuf *m, int len u_short in_addword(u_short sum, u_short b); u_short in_cksum_skip(struct mbuf *m, int len, int skip); u_int do_cksum(const void *, int); +#if defined(IPVERSION) && (IPVERSION == 4) u_int in_cksum_hdr(const struct ip *); +#endif static __inline u_short in_pseudo(u_int sum, u_int b, u_int c) Modified: stable/9/sys/i386/include/in_cksum.h ============================================================================== --- stable/9/sys/i386/include/in_cksum.h Sun Jul 8 10:29:01 2012 (r238227) +++ stable/9/sys/i386/include/in_cksum.h Sun Jul 8 10:46:55 2012 (r238228) @@ -54,6 +54,7 @@ * therefore always exactly five 32-bit words. */ #if defined(__GNUCLIKE_ASM) && !defined(__INTEL_COMPILER) +#if defined(IPVERSION) && (IPVERSION == 4) static __inline u_int in_cksum_hdr(const struct ip *ip) { @@ -88,6 +89,7 @@ in_cksum_update(struct ip *ip) __tmpsum = (int)ntohs(ip->ip_sum) + 256; ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); } +#endif static __inline u_short in_addword(u_short sum, u_short b) @@ -121,6 +123,7 @@ in_pseudo(u_int sum, u_int b, u_int c) } #else +#if defined(IPVERSION) && (IPVERSION == 4) #define in_cksum_update(ip) \ do { \ int __tmpsum; \ @@ -129,10 +132,13 @@ in_pseudo(u_int sum, u_int b, u_int c) } while(0) #endif +#endif #ifdef _KERNEL #if !defined(__GNUCLIKE_ASM) || defined(__INTEL_COMPILER) +#if defined(IPVERSION) && (IPVERSION == 4) u_int in_cksum_hdr(const struct ip *ip); +#endif u_short in_addword(u_short sum, u_short b); u_short in_pseudo(u_int sum, u_int b, u_int c); #endif Modified: stable/9/sys/ia64/include/in_cksum.h ============================================================================== --- stable/9/sys/ia64/include/in_cksum.h Sun Jul 8 10:29:01 2012 (r238227) +++ stable/9/sys/ia64/include/in_cksum.h Sun Jul 8 10:46:55 2012 (r238228) @@ -39,6 +39,7 @@ #define in_cksum(m, len) in_cksum_skip(m, len, 0) +#if defined(IPVERSION) && (IPVERSION == 4) /* * It it useful to have an Internet checksum routine which is inlineable * and optimized specifically for the task of computing IP header checksums @@ -65,9 +66,12 @@ in_cksum_update(struct ip *ip) } while(0) #endif +#endif #ifdef _KERNEL +#if defined(IPVERSION) && (IPVERSION == 4) u_int in_cksum_hdr(const struct ip *ip); +#endif u_short in_addword(u_short sum, u_short b); u_short in_pseudo(u_int sum, u_int b, u_int c); u_short in_cksum_skip(struct mbuf *m, int len, int skip); Modified: stable/9/sys/mips/include/in_cksum.h ============================================================================== --- stable/9/sys/mips/include/in_cksum.h Sun Jul 8 10:29:01 2012 (r238227) +++ stable/9/sys/mips/include/in_cksum.h Sun Jul 8 10:46:55 2012 (r238228) @@ -40,6 +40,7 @@ #define in_cksum(m, len) in_cksum_skip(m, len, 0) +#if defined(IPVERSION) && (IPVERSION == 4) /* * It it useful to have an Internet checksum routine which is inlineable * and optimized specifically for the task of computing IP header checksums @@ -66,9 +67,12 @@ in_cksum_update(struct ip *ip) } while(0) #endif +#endif #ifdef _KERNEL +#if defined(IPVERSION) && (IPVERSION == 4) u_int in_cksum_hdr(const struct ip *ip); +#endif u_short in_addword(u_short sum, u_short b); u_short in_pseudo(u_int sum, u_int b, u_int c); u_short in_cksum_skip(struct mbuf *m, int len, int skip); Modified: stable/9/sys/powerpc/include/in_cksum.h ============================================================================== --- stable/9/sys/powerpc/include/in_cksum.h Sun Jul 8 10:29:01 2012 (r238227) +++ stable/9/sys/powerpc/include/in_cksum.h Sun Jul 8 10:46:55 2012 (r238228) @@ -39,6 +39,7 @@ #define in_cksum(m, len) in_cksum_skip(m, len, 0) +#if defined(IPVERSION) && (IPVERSION == 4) /* * It it useful to have an Internet checksum routine which is inlineable * and optimized specifically for the task of computing IP header checksums @@ -65,9 +66,12 @@ in_cksum_update(struct ip *ip) } while(0) #endif +#endif #ifdef _KERNEL +#if defined(IPVERSION) && (IPVERSION == 4) u_int in_cksum_hdr(const struct ip *ip); +#endif u_short in_addword(u_short sum, u_short b); u_short in_pseudo(u_int sum, u_int b, u_int c); u_short in_cksum_skip(struct mbuf *m, int len, int skip); Modified: stable/9/sys/sparc64/include/in_cksum.h ============================================================================== --- stable/9/sys/sparc64/include/in_cksum.h Sun Jul 8 10:29:01 2012 (r238227) +++ stable/9/sys/sparc64/include/in_cksum.h Sun Jul 8 10:46:55 2012 (r238228) @@ -65,6 +65,7 @@ #define in_cksum(m, len) in_cksum_skip(m, len, 0) +#if defined(IPVERSION) && (IPVERSION == 4) static __inline void in_cksum_update(struct ip *ip) { @@ -73,6 +74,7 @@ in_cksum_update(struct ip *ip) __tmp = (int)ip->ip_sum + 1; ip->ip_sum = __tmp + (__tmp >> 16); } +#endif static __inline u_short in_addword(u_short sum, u_short b) @@ -106,6 +108,7 @@ in_pseudo(u_int sum, u_int b, u_int c) return (sum); } +#if defined(IPVERSION) && (IPVERSION == 4) static __inline u_int in_cksum_hdr(struct ip *ip) { @@ -163,6 +166,7 @@ in_cksum_hdr(struct ip *ip) #undef __LD_ADD return (__ret); } +#endif #ifdef _KERNEL u_short in_cksum_skip(struct mbuf *m, int len, int skip); From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 8 10:59:21 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CE7C61065672; Sun, 8 Jul 2012 10:59:21 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from mx1.sbone.de (bird.sbone.de [46.4.1.90]) by mx1.freebsd.org (Postfix) with ESMTP id 870318FC12; Sun, 8 Jul 2012 10:59:21 +0000 (UTC) Received: from dhcp-128-232-132-170.eduroam.csx.cam.ac.uk (dhcp-128-232-132-170.eduroam.csx.cam.ac.uk [128.232.132.170]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mx1.sbone.de (Postfix) with ESMTPSA id 0D2E225D39FF; Sun, 8 Jul 2012 10:59:19 +0000 (UTC) Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: "Bjoern A. Zeeb" In-Reply-To: <201207081046.q68AktaF044816@svn.freebsd.org> Date: Sun, 8 Jul 2012 10:59:19 +0000 Content-Transfer-Encoding: 7bit Message-Id: <0F573FEB-F9CD-4AAD-B48A-CD16D3D75311@FreeBSD.org> References: <201207081046.q68AktaF044816@svn.freebsd.org> To: src-committers@freebsd.org X-Mailer: Apple Mail (2.1084) Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, svn-src-stable-9@freebsd.org Subject: Re: svn commit: r238228 - in stable/9/sys: amd64/include arm/include i386/include ia64/include mips/include powerpc/include sparc64/include X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jul 2012 10:59:21 -0000 On 8. Jul 2012, at 10:46 , Bjoern A. Zeeb wrote: > Author: bz > Date: Sun Jul 8 10:46:55 2012 > New Revision: 238228 > URL: http://svn.freebsd.org/changeset/base/238228 > > Log: > MFC r235941: > > in_cksum.h required ip.h to be included for struct ip. To be > able to use some general checksum functions like in_addword() > in a non-IPv4 context, limit the (also exported to user space) > IPv4 specific functions to the times, when the ip.h header is > present and IPVERSION is defined (to 4). > > Approved by: re > > Modified: > stable/9/sys/amd64/include/in_cksum.h > stable/9/sys/arm/include/in_cksum.h > stable/9/sys/i386/include/in_cksum.h > stable/9/sys/ia64/include/in_cksum.h > stable/9/sys/mips/include/in_cksum.h > stable/9/sys/powerpc/include/in_cksum.h > stable/9/sys/sparc64/include/in_cksum.h There still is cleanup to follow in HEAD as discussed with bde (general cleanup on these files) but for the time being it was not possible to address it anymore. /bz -- Bjoern A. Zeeb You have to have visions! It does not matter how good you are. It matters what good you do! From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 8 11:24:23 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 247D01065670; Sun, 8 Jul 2012 11:24:23 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0D8EB8FC14; Sun, 8 Jul 2012 11:24:23 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q68BOMKB047945; Sun, 8 Jul 2012 11:24:22 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q68BOMEZ047940; Sun, 8 Jul 2012 11:24:22 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201207081124.q68BOMEZ047940@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Sun, 8 Jul 2012 11:24:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238230 - in stable/9/sys: dev/cxgb dev/cxgbe netinet X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jul 2012 11:24:23 -0000 Author: bz Date: Sun Jul 8 11:24:22 2012 New Revision: 238230 URL: http://svn.freebsd.org/changeset/base/238230 Log: MFC r235944: Significantly update tcp_lro for mostly two things: 1) introduce basic support for IPv6 without extension headers. 2) try hard to also get the incremental checksum updates right, especially also in the IPv4 case for the IP and TCP header. Move variables around for better locality, factor things out into functions, allow checksum updates to be compiled out, ... Leave a few comments on further things to look at in the future, though that is not the full list. Update drivers with appropriate #includes as needed for IPv6 data type in LRO. Approved by: re Modified: stable/9/sys/dev/cxgb/cxgb_adapter.h stable/9/sys/dev/cxgbe/adapter.h stable/9/sys/netinet/tcp_lro.c stable/9/sys/netinet/tcp_lro.h Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/cxgb/cxgb_adapter.h ============================================================================== --- stable/9/sys/dev/cxgb/cxgb_adapter.h Sun Jul 8 10:57:49 2012 (r238229) +++ stable/9/sys/dev/cxgb/cxgb_adapter.h Sun Jul 8 11:24:22 2012 (r238230) @@ -46,6 +46,7 @@ $FreeBSD$ #include #include #include +#include #include #include Modified: stable/9/sys/dev/cxgbe/adapter.h ============================================================================== --- stable/9/sys/dev/cxgbe/adapter.h Sun Jul 8 10:57:49 2012 (r238229) +++ stable/9/sys/dev/cxgbe/adapter.h Sun Jul 8 11:24:22 2012 (r238230) @@ -44,6 +44,7 @@ #include #include #include +#include #include #include "offload.h" Modified: stable/9/sys/netinet/tcp_lro.c ============================================================================== --- stable/9/sys/netinet/tcp_lro.c Sun Jul 8 10:57:49 2012 (r238229) +++ stable/9/sys/netinet/tcp_lro.c Sun Jul 8 11:24:22 2012 (r238230) @@ -1,8 +1,12 @@ /*- * Copyright (c) 2007, Myricom Inc. * Copyright (c) 2008, Intel Corporation. + * Copyright (c) 2012 The FreeBSD Foundation * All rights reserved. * + * Portions of this software were developed by Bjoern Zeeb + * under sponsorship from the FreeBSD Foundation. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -27,365 +31,565 @@ * $FreeBSD$ */ +#include +__FBSDID("$FreeBSD$"); + +#include "opt_inet.h" +#include "opt_inet6.h" + #include #include -#include #include #include #include #include +#include #include -#include #include #include +#include #include #include #include -#include #include +#ifndef LRO_ENTRIES +#define LRO_ENTRIES 8 /* # of LRO entries per RX queue. */ +#endif + +#define TCP_LRO_UPDATE_CSUM 1 +#ifndef TCP_LRO_UPDATE_CSUM +#define TCP_LRO_INVALID_CSUM 0x0000 +#endif -static uint16_t do_csum_data(uint16_t *raw, int len) -{ - uint32_t csum; - csum = 0; - while (len > 0) { - csum += *raw; - raw++; - csum += *raw; - raw++; - len -= 4; - } - csum = (csum >> 16) + (csum & 0xffff); - csum = (csum >> 16) + (csum & 0xffff); - return (uint16_t)csum; -} - -/* - * Allocate and init the LRO data structures - */ int -tcp_lro_init(struct lro_ctrl *cntl) +tcp_lro_init(struct lro_ctrl *lc) { - struct lro_entry *lro; - int i, error = 0; - - SLIST_INIT(&cntl->lro_free); - SLIST_INIT(&cntl->lro_active); + struct lro_entry *le; + int error, i; - cntl->lro_bad_csum = 0; - cntl->lro_queued = 0; - cntl->lro_flushed = 0; + lc->lro_bad_csum = 0; + lc->lro_queued = 0; + lc->lro_flushed = 0; + lc->lro_cnt = 0; + SLIST_INIT(&lc->lro_free); + SLIST_INIT(&lc->lro_active); + error = 0; for (i = 0; i < LRO_ENTRIES; i++) { - lro = (struct lro_entry *) malloc(sizeof (struct lro_entry), - M_DEVBUF, M_NOWAIT | M_ZERO); - if (lro == NULL) { + le = (struct lro_entry *)malloc(sizeof(*le), M_DEVBUF, + M_NOWAIT | M_ZERO); + if (le == NULL) { if (i == 0) error = ENOMEM; break; } - cntl->lro_cnt = i; - SLIST_INSERT_HEAD(&cntl->lro_free, lro, next); + lc->lro_cnt = i + 1; + SLIST_INSERT_HEAD(&lc->lro_free, le, next); } return (error); } void -tcp_lro_free(struct lro_ctrl *cntl) +tcp_lro_free(struct lro_ctrl *lc) { - struct lro_entry *entry; + struct lro_entry *le; + + while (!SLIST_EMPTY(&lc->lro_free)) { + le = SLIST_FIRST(&lc->lro_free); + SLIST_REMOVE_HEAD(&lc->lro_free, next); + free(le, M_DEVBUF); + } +} - while (!SLIST_EMPTY(&cntl->lro_free)) { - entry = SLIST_FIRST(&cntl->lro_free); - SLIST_REMOVE_HEAD(&cntl->lro_free, next); - free(entry, M_DEVBUF); +#ifdef TCP_LRO_UPDATE_CSUM +static uint16_t +tcp_lro_csum_th(struct tcphdr *th) +{ + uint32_t ch; + uint16_t *p, l; + + ch = th->th_sum = 0x0000; + l = th->th_off; + p = (uint16_t *)th; + while (l > 0) { + ch += *p; + p++; + ch += *p; + p++; + l--; + } + while (ch > 0xffff) + ch = (ch >> 16) + (ch & 0xffff); + + return (ch & 0xffff); +} + +static uint16_t +tcp_lro_rx_csum_fixup(struct lro_entry *le, void *l3hdr, struct tcphdr *th, + uint16_t tcp_data_len, uint16_t csum) +{ + uint32_t c; + uint16_t cs; + + c = csum; + + /* Remove length from checksum. */ + switch (le->eh_type) { +#ifdef INET6 + case ETHERTYPE_IPV6: + { + struct ip6_hdr *ip6; + + ip6 = (struct ip6_hdr *)l3hdr; + if (le->append_cnt == 0) + cs = ip6->ip6_plen; + else { + uint32_t cx; + + cx = ntohs(ip6->ip6_plen); + cs = in6_cksum_pseudo(ip6, cx, ip6->ip6_nxt, 0); + } + break; + } +#endif +#ifdef INET + case ETHERTYPE_IP: + { + struct ip *ip4; + + ip4 = (struct ip *)l3hdr; + if (le->append_cnt == 0) + cs = ip4->ip_len; + else { + cs = in_addword(ntohs(ip4->ip_len) - sizeof(*ip4), + IPPROTO_TCP); + cs = in_pseudo(ip4->ip_src.s_addr, ip4->ip_dst.s_addr, + htons(cs)); + } + break; + } +#endif + default: + cs = 0; /* Keep compiler happy. */ } + + cs = ~cs; + c += cs; + + /* Remove TCP header csum. */ + cs = ~tcp_lro_csum_th(th); + c += cs; + while (c > 0xffff) + c = (c >> 16) + (c & 0xffff); + + return (c & 0xffff); } +#endif void -tcp_lro_flush(struct lro_ctrl *cntl, struct lro_entry *lro) +tcp_lro_flush(struct lro_ctrl *lc, struct lro_entry *le) { - struct ifnet *ifp; - struct ip *ip; - struct tcphdr *tcp; - uint32_t *ts_ptr; - uint32_t tcplen, tcp_csum; + if (le->append_cnt > 0) { + struct tcphdr *th; + uint16_t p_len; + + p_len = htons(le->p_len); + switch (le->eh_type) { +#ifdef INET6 + case ETHERTYPE_IPV6: + { + struct ip6_hdr *ip6; + + ip6 = le->le_ip6; + ip6->ip6_plen = p_len; + th = (struct tcphdr *)(ip6 + 1); + le->m_head->m_pkthdr.csum_flags = CSUM_DATA_VALID | + CSUM_PSEUDO_HDR; + le->p_len += ETHER_HDR_LEN + sizeof(*ip6); + break; + } +#endif +#ifdef INET + case ETHERTYPE_IP: + { + struct ip *ip4; +#ifdef TCP_LRO_UPDATE_CSUM + uint32_t cl; + uint16_t c; +#endif + + ip4 = le->le_ip4; +#ifdef TCP_LRO_UPDATE_CSUM + /* Fix IP header checksum for new length. */ + c = ~ip4->ip_sum; + cl = c; + c = ~ip4->ip_len; + cl += c + p_len; + while (cl > 0xffff) + cl = (cl >> 16) + (cl & 0xffff); + c = cl; + ip4->ip_sum = ~c; +#else + ip4->ip_sum = TCP_LRO_INVALID_CSUM; +#endif + ip4->ip_len = p_len; + th = (struct tcphdr *)(ip4 + 1); + le->m_head->m_pkthdr.csum_flags = CSUM_DATA_VALID | + CSUM_PSEUDO_HDR | CSUM_IP_CHECKED | CSUM_IP_VALID; + le->p_len += ETHER_HDR_LEN; + break; + } +#endif + default: + th = NULL; /* Keep compiler happy. */ + } + le->m_head->m_pkthdr.csum_data = 0xffff; + le->m_head->m_pkthdr.len = le->p_len; - if (lro->append_cnt) { - /* incorporate the new len into the ip header and - * re-calculate the checksum */ - ip = lro->ip; - ip->ip_len = htons(lro->len - ETHER_HDR_LEN); - ip->ip_sum = 0; - ip->ip_sum = 0xffff ^ - do_csum_data((uint16_t*)ip, - sizeof (*ip)); - - lro->m_head->m_pkthdr.csum_flags = CSUM_IP_CHECKED | - CSUM_IP_VALID | CSUM_DATA_VALID | CSUM_PSEUDO_HDR; - lro->m_head->m_pkthdr.csum_data = 0xffff; - lro->m_head->m_pkthdr.len = lro->len; - - /* incorporate the latest ack into the tcp header */ - tcp = (struct tcphdr *) (ip + 1); - tcp->th_ack = lro->ack_seq; - tcp->th_win = lro->window; - /* incorporate latest timestamp into the tcp header */ - if (lro->timestamp) { - ts_ptr = (uint32_t *)(tcp + 1); - ts_ptr[1] = htonl(lro->tsval); - ts_ptr[2] = lro->tsecr; - } - /* - * update checksum in tcp header by re-calculating the - * tcp pseudoheader checksum, and adding it to the checksum - * of the tcp payload data - */ - tcp->th_sum = 0; - tcplen = lro->len - sizeof(*ip) - ETHER_HDR_LEN; - tcp_csum = lro->data_csum; - tcp_csum += in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr, - htons(tcplen + IPPROTO_TCP)); - tcp_csum += do_csum_data((uint16_t*)tcp, - tcp->th_off << 2); - tcp_csum = (tcp_csum & 0xffff) + (tcp_csum >> 16); - tcp_csum = (tcp_csum & 0xffff) + (tcp_csum >> 16); - tcp->th_sum = 0xffff ^ tcp_csum; - } - ifp = cntl->ifp; - (*ifp->if_input)(cntl->ifp, lro->m_head); - cntl->lro_queued += lro->append_cnt + 1; - cntl->lro_flushed++; - lro->m_head = NULL; - lro->timestamp = 0; - lro->append_cnt = 0; - SLIST_INSERT_HEAD(&cntl->lro_free, lro, next); + /* Incorporate the latest ACK into the TCP header. */ + th->th_ack = le->ack_seq; + th->th_win = le->window; + /* Incorporate latest timestamp into the TCP header. */ + if (le->timestamp != 0) { + uint32_t *ts_ptr; + + ts_ptr = (uint32_t *)(th + 1); + ts_ptr[1] = htonl(le->tsval); + ts_ptr[2] = le->tsecr; + } +#ifdef TCP_LRO_UPDATE_CSUM + /* Update the TCP header checksum. */ + le->ulp_csum += p_len; + le->ulp_csum += tcp_lro_csum_th(th); + while (le->ulp_csum > 0xffff) + le->ulp_csum = (le->ulp_csum >> 16) + + (le->ulp_csum & 0xffff); + th->th_sum = (le->ulp_csum & 0xffff); + th->th_sum = ~th->th_sum; +#else + th->th_sum = TCP_LRO_INVALID_CSUM; +#endif + } + + (*lc->ifp->if_input)(lc->ifp, le->m_head); + lc->lro_queued += le->append_cnt + 1; + lc->lro_flushed++; + bzero(le, sizeof(*le)); + SLIST_INSERT_HEAD(&lc->lro_free, le, next); } -int -tcp_lro_rx(struct lro_ctrl *cntl, struct mbuf *m_head, uint32_t csum) +#ifdef INET6 +static int +tcp_lro_rx_ipv6(struct lro_ctrl *lc, struct mbuf *m, struct ip6_hdr *ip6, + struct tcphdr **th) { - struct ether_header *eh; - struct ip *ip; - struct tcphdr *tcp; - uint32_t *ts_ptr; - struct mbuf *m_nxt, *m_tail; - struct lro_entry *lro; - int hlen, ip_len, tcp_hdr_len, tcp_data_len, tot_len; - int opt_bytes, trim, csum_flags; - uint32_t seq, tmp_csum, device_mtu; - - - eh = mtod(m_head, struct ether_header *); - if (eh->ether_type != htons(ETHERTYPE_IP)) - return 1; - ip = (struct ip *) (eh + 1); - if (ip->ip_p != IPPROTO_TCP) - return 1; - - /* ensure there are no options */ - if ((ip->ip_hl << 2) != sizeof (*ip)) - return -1; - - /* .. and the packet is not fragmented */ - if (ip->ip_off & htons(IP_MF|IP_OFFMASK)) - return -1; - /* verify that the IP header checksum is correct */ - csum_flags = m_head->m_pkthdr.csum_flags; + /* XXX-BZ we should check the flow-label. */ + + /* XXX-BZ We do not yet support ext. hdrs. */ + if (ip6->ip6_nxt != IPPROTO_TCP) + return (TCP_LRO_NOT_SUPPORTED); + + /* Find the TCP header. */ + *th = (struct tcphdr *)(ip6 + 1); + + return (0); +} +#endif + +#ifdef INET +static int +tcp_lro_rx_ipv4(struct lro_ctrl *lc, struct mbuf *m, struct ip *ip4, + struct tcphdr **th) +{ + int csum_flags; + uint16_t csum; + + if (ip4->ip_p != IPPROTO_TCP) + return (TCP_LRO_NOT_SUPPORTED); + + /* Ensure there are no options. */ + if ((ip4->ip_hl << 2) != sizeof (*ip4)) + return (TCP_LRO_CANNOT); + + /* .. and the packet is not fragmented. */ + if (ip4->ip_off & htons(IP_MF|IP_OFFMASK)) + return (TCP_LRO_CANNOT); + + /* Legacy IP has a header checksum that needs to be correct. */ + csum_flags = m->m_pkthdr.csum_flags; if (csum_flags & CSUM_IP_CHECKED) { if (__predict_false((csum_flags & CSUM_IP_VALID) == 0)) { - cntl->lro_bad_csum++; - return -1; + lc->lro_bad_csum++; + return (TCP_LRO_CANNOT); } } else { - tmp_csum = do_csum_data((uint16_t *)ip, sizeof (*ip)); - if (__predict_false((tmp_csum ^ 0xffff) != 0)) { - cntl->lro_bad_csum++; - return -1; - } - } - - /* find the TCP header */ - tcp = (struct tcphdr *) (ip + 1); - - /* Get the TCP checksum if we dont have it */ - if (!csum) - csum = tcp->th_sum; - - /* ensure no bits set besides ack or psh */ - if ((tcp->th_flags & ~(TH_ACK | TH_PUSH)) != 0) - return -1; - - /* check for timestamps. Since the only option we handle are - timestamps, we only have to handle the simple case of - aligned timestamps */ - - opt_bytes = (tcp->th_off << 2) - sizeof (*tcp); - tcp_hdr_len = sizeof (*tcp) + opt_bytes; - ts_ptr = (uint32_t *)(tcp + 1); - if (opt_bytes != 0) { - if (__predict_false(opt_bytes != TCPOLEN_TSTAMP_APPA) || - (*ts_ptr != ntohl(TCPOPT_NOP<<24|TCPOPT_NOP<<16| - TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP))) - return -1; - } - - ip_len = ntohs(ip->ip_len); - tcp_data_len = ip_len - (tcp->th_off << 2) - sizeof (*ip); - - - /* - * If frame is padded beyond the end of the IP packet, - * then we must trim the extra bytes off the end. + csum = in_cksum_hdr(ip4); + if (__predict_false((csum ^ 0xffff) != 0)) { + lc->lro_bad_csum++; + return (TCP_LRO_CANNOT); + } + } + + /* Find the TCP header (we assured there are no IP options). */ + *th = (struct tcphdr *)(ip4 + 1); + + return (0); +} +#endif + +int +tcp_lro_rx(struct lro_ctrl *lc, struct mbuf *m, uint32_t csum) +{ + struct lro_entry *le; + struct ether_header *eh; +#ifdef INET6 + struct ip6_hdr *ip6 = NULL; /* Keep compiler happy. */ +#endif +#ifdef INET + struct ip *ip4 = NULL; /* Keep compiler happy. */ +#endif + struct tcphdr *th; + void *l3hdr = NULL; /* Keep compiler happy. */ + uint32_t *ts_ptr; + tcp_seq seq; + int error, ip_len, l; + uint16_t eh_type, tcp_data_len; + + /* We expect a contiguous header [eh, ip, tcp]. */ + + eh = mtod(m, struct ether_header *); + eh_type = ntohs(eh->ether_type); + switch (eh_type) { +#ifdef INET6 + case ETHERTYPE_IPV6: + l3hdr = ip6 = (struct ip6_hdr *)(eh + 1); + error = tcp_lro_rx_ipv6(lc, m, ip6, &th); + if (error != 0) + return (error); + tcp_data_len = ntohs(ip6->ip6_plen); + ip_len = sizeof(*ip6) + tcp_data_len; + break; +#endif +#ifdef INET + case ETHERTYPE_IP: + l3hdr = ip4 = (struct ip *)(eh + 1); + error = tcp_lro_rx_ipv4(lc, m, ip4, &th); + if (error != 0) + return (error); + ip_len = ntohs(ip4->ip_len); + tcp_data_len = ip_len - sizeof(*ip4); + break; +#endif + /* XXX-BZ what happens in case of VLAN(s)? */ + default: + return (TCP_LRO_NOT_SUPPORTED); + } + + /* + * If the frame is padded beyond the end of the IP packet, then we must + * trim the extra bytes off. + */ + l = m->m_pkthdr.len - (ETHER_HDR_LEN + ip_len); + if (l != 0) { + if (l < 0) + /* Truncated packet. */ + return (TCP_LRO_CANNOT); + + m_adj(m, -l); + } + + /* + * Check TCP header constraints. */ - tot_len = m_head->m_pkthdr.len; - trim = tot_len - (ip_len + ETHER_HDR_LEN); - if (trim != 0) { - if (trim < 0) { - /* truncated packet */ - return -1; - } - m_adj(m_head, -trim); - tot_len = m_head->m_pkthdr.len; - } - - m_nxt = m_head; - m_tail = NULL; /* -Wuninitialized */ - while (m_nxt != NULL) { - m_tail = m_nxt; - m_nxt = m_tail->m_next; - } - - hlen = ip_len + ETHER_HDR_LEN - tcp_data_len; - seq = ntohl(tcp->th_seq); - - SLIST_FOREACH(lro, &cntl->lro_active, next) { - if (lro->source_port == tcp->th_sport && - lro->dest_port == tcp->th_dport && - lro->source_ip == ip->ip_src.s_addr && - lro->dest_ip == ip->ip_dst.s_addr) { - /* Flush now if appending will result in overflow. */ - if (lro->len > (65535 - tcp_data_len)) { - SLIST_REMOVE(&cntl->lro_active, lro, - lro_entry, next); - tcp_lro_flush(cntl, lro); - break; - } - - /* Try to append it */ - - if (__predict_false(seq != lro->next_seq || - (tcp_data_len == 0 && - lro->ack_seq == tcp->th_ack))) { - /* out of order packet or dup ack */ - SLIST_REMOVE(&cntl->lro_active, lro, - lro_entry, next); - tcp_lro_flush(cntl, lro); - return -1; - } - - if (opt_bytes) { - uint32_t tsval = ntohl(*(ts_ptr + 1)); - /* make sure timestamp values are increasing */ - if (__predict_false(lro->tsval > tsval || - *(ts_ptr + 2) == 0)) { - return -1; - } - lro->tsval = tsval; - lro->tsecr = *(ts_ptr + 2); - } - - lro->next_seq += tcp_data_len; - lro->ack_seq = tcp->th_ack; - lro->window = tcp->th_win; - lro->append_cnt++; - if (tcp_data_len == 0) { - m_freem(m_head); - return 0; - } - /* subtract off the checksum of the tcp header - * from the hardware checksum, and add it to the - * stored tcp data checksum. Byteswap the checksum - * if the total length so far is odd - */ - tmp_csum = do_csum_data((uint16_t*)tcp, - tcp_hdr_len); - csum = csum + (tmp_csum ^ 0xffff); - csum = (csum & 0xffff) + (csum >> 16); - csum = (csum & 0xffff) + (csum >> 16); - if (lro->len & 0x1) { - /* Odd number of bytes so far, flip bytes */ - csum = ((csum << 8) | (csum >> 8)) & 0xffff; - } - csum = csum + lro->data_csum; - csum = (csum & 0xffff) + (csum >> 16); - csum = (csum & 0xffff) + (csum >> 16); - lro->data_csum = csum; - - lro->len += tcp_data_len; - - /* adjust mbuf so that m->m_data points to - the first byte of the payload */ - m_adj(m_head, hlen); - /* append mbuf chain */ - lro->m_tail->m_next = m_head; - /* advance the last pointer */ - lro->m_tail = m_tail; - /* flush packet if required */ - device_mtu = cntl->ifp->if_mtu; - if (lro->len > (65535 - device_mtu)) { - SLIST_REMOVE(&cntl->lro_active, lro, - lro_entry, next); - tcp_lro_flush(cntl, lro); - } - return 0; - } - } - - if (SLIST_EMPTY(&cntl->lro_free)) - return -1; - - /* start a new chain */ - lro = SLIST_FIRST(&cntl->lro_free); - SLIST_REMOVE_HEAD(&cntl->lro_free, next); - SLIST_INSERT_HEAD(&cntl->lro_active, lro, next); - lro->source_port = tcp->th_sport; - lro->dest_port = tcp->th_dport; - lro->source_ip = ip->ip_src.s_addr; - lro->dest_ip = ip->ip_dst.s_addr; - lro->next_seq = seq + tcp_data_len; - lro->mss = tcp_data_len; - lro->ack_seq = tcp->th_ack; - lro->window = tcp->th_win; - - /* save the checksum of just the TCP payload by - * subtracting off the checksum of the TCP header from - * the entire hardware checksum - * Since IP header checksum is correct, checksum over - * the IP header is -0. Substracting -0 is unnecessary. + /* Ensure no bits set besides ACK or PSH. */ + if ((th->th_flags & ~(TH_ACK | TH_PUSH)) != 0) + return (TCP_LRO_CANNOT); + + /* XXX-BZ We lose a AKC|PUSH flag concatinating multiple segments. */ + /* XXX-BZ Ideally we'd flush on PUSH? */ + + /* + * Check for timestamps. + * Since the only option we handle are timestamps, we only have to + * handle the simple case of aligned timestamps. + */ + l = (th->th_off << 2); + tcp_data_len -= l; + l -= sizeof(*th); + ts_ptr = (uint32_t *)(th + 1); + if (l != 0 && (__predict_false(l != TCPOLEN_TSTAMP_APPA) || + (*ts_ptr != ntohl(TCPOPT_NOP<<24|TCPOPT_NOP<<16| + TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP)))) + return (TCP_LRO_CANNOT); + + /* If the driver did not pass in the checksum, set it now. */ + if (csum == 0x0000) + csum = th->th_sum; + + seq = ntohl(th->th_seq); + + /* Try to find a matching previous segment. */ + SLIST_FOREACH(le, &lc->lro_active, next) { + if (le->eh_type != eh_type) + continue; + if (le->source_port != th->th_sport || + le->dest_port != th->th_dport) + continue; + switch (eh_type) { +#ifdef INET6 + case ETHERTYPE_IPV6: + if (bcmp(&le->source_ip6, &ip6->ip6_src, + sizeof(struct in6_addr)) != 0 || + bcmp(&le->dest_ip6, &ip6->ip6_dst, + sizeof(struct in6_addr)) != 0) + continue; + break; +#endif +#ifdef INET + case ETHERTYPE_IP: + if (le->source_ip4 != ip4->ip_src.s_addr || + le->dest_ip4 != ip4->ip_dst.s_addr) + continue; + break; +#endif + } + + /* Flush now if appending will result in overflow. */ + if (le->p_len > (65535 - tcp_data_len)) { + SLIST_REMOVE(&lc->lro_active, le, lro_entry, next); + tcp_lro_flush(lc, le); + break; + } + + /* Try to append the new segment. */ + if (__predict_false(seq != le->next_seq || + (tcp_data_len == 0 && le->ack_seq == th->th_ack))) { + /* Out of order packet or duplicate ACK. */ + SLIST_REMOVE(&lc->lro_active, le, lro_entry, next); + tcp_lro_flush(lc, le); + return (TCP_LRO_CANNOT); + } + + if (l != 0) { + uint32_t tsval = ntohl(*(ts_ptr + 1)); + /* Make sure timestamp values are increasing. */ + /* XXX-BZ flip and use TSTMP_GEQ macro for this? */ + if (__predict_false(le->tsval > tsval || + *(ts_ptr + 2) == 0)) + return (TCP_LRO_CANNOT); + le->tsval = tsval; + le->tsecr = *(ts_ptr + 2); + } + + le->next_seq += tcp_data_len; + le->ack_seq = th->th_ack; + le->window = th->th_win; + le->append_cnt++; + +#ifdef TCP_LRO_UPDATE_CSUM + le->ulp_csum += tcp_lro_rx_csum_fixup(le, l3hdr, th, + tcp_data_len, ~csum); +#endif + + if (tcp_data_len == 0) { + m_freem(m); + return (0); + } + + le->p_len += tcp_data_len; + + /* + * Adjust the mbuf so that m_data points to the first byte of + * the ULP payload. Adjust the mbuf to avoid complications and + * append new segment to existing mbuf chain. + */ + m_adj(m, m->m_pkthdr.len - tcp_data_len); + m->m_flags &= ~M_PKTHDR; + + le->m_tail->m_next = m; + le->m_tail = m_last(m); + + /* + * If a possible next full length packet would cause an + * overflow, pro-actively flush now. + */ + if (le->p_len > (65535 - lc->ifp->if_mtu)) { + SLIST_REMOVE(&lc->lro_active, le, lro_entry, next); + tcp_lro_flush(lc, le); + } + + return (0); + } + + /* Try to find an empty slot. */ + if (SLIST_EMPTY(&lc->lro_free)) + return (TCP_LRO_CANNOT); + + /* Start a new segment chain. */ + le = SLIST_FIRST(&lc->lro_free); + SLIST_REMOVE_HEAD(&lc->lro_free, next); + SLIST_INSERT_HEAD(&lc->lro_active, le, next); + + /* Start filling in details. */ + switch (eh_type) { +#ifdef INET6 + case ETHERTYPE_IPV6: + le->le_ip6 = ip6; + le->source_ip6 = ip6->ip6_src; + le->dest_ip6 = ip6->ip6_dst; + le->eh_type = eh_type; + le->p_len = m->m_pkthdr.len - ETHER_HDR_LEN - sizeof(*ip6); + break; +#endif +#ifdef INET + case ETHERTYPE_IP: + le->le_ip4 = ip4; + le->source_ip4 = ip4->ip_src.s_addr; + le->dest_ip4 = ip4->ip_dst.s_addr; + le->eh_type = eh_type; + le->p_len = m->m_pkthdr.len - ETHER_HDR_LEN; + break; +#endif + } + le->source_port = th->th_sport; + le->dest_port = th->th_dport; + + le->next_seq = seq + tcp_data_len; + le->ack_seq = th->th_ack; + le->window = th->th_win; + if (l != 0) { + le->timestamp = 1; + le->tsval = ntohl(*(ts_ptr + 1)); + le->tsecr = *(ts_ptr + 2); + } + +#ifdef TCP_LRO_UPDATE_CSUM + /* + * Do not touch the csum of the first packet. However save the + * "adjusted" checksum of just the source and destination addresses, + * the next header and the TCP payload. The length and TCP header + * parts may change, so we remove those from the saved checksum and + * re-add with final values on tcp_lro_flush() if needed. */ - tmp_csum = do_csum_data((uint16_t*)tcp, tcp_hdr_len); - csum = csum + (tmp_csum ^ 0xffff); - csum = (csum & 0xffff) + (csum >> 16); - csum = (csum & 0xffff) + (csum >> 16); - lro->data_csum = csum; - - lro->ip = ip; - /* record timestamp if it is present */ - if (opt_bytes) { - lro->timestamp = 1; - lro->tsval = ntohl(*(ts_ptr + 1)); - lro->tsecr = *(ts_ptr + 2); - } - lro->len = tot_len; - lro->m_head = m_head; - lro->m_tail = m_tail; - return 0; + KASSERT(le->ulp_csum == 0, ("%s: le=%p le->ulp_csum=0x%04x\n", + __func__, le, le->ulp_csum)); + + le->ulp_csum = tcp_lro_rx_csum_fixup(le, l3hdr, th, tcp_data_len, + ~csum); + th->th_sum = csum; /* Restore checksum on first packet. */ +#endif + + le->m_head = m; + le->m_tail = m_last(m); + + return (0); } + +/* end */ Modified: stable/9/sys/netinet/tcp_lro.h ============================================================================== --- stable/9/sys/netinet/tcp_lro.h Sun Jul 8 10:57:49 2012 (r238229) +++ stable/9/sys/netinet/tcp_lro.h Sun Jul 8 11:24:22 2012 (r238230) @@ -30,31 +30,46 @@ #ifndef _TCP_LRO_H_ #define _TCP_LRO_H_ -struct lro_entry; struct lro_entry { - SLIST_ENTRY(lro_entry) next; - struct mbuf *m_head; - struct mbuf *m_tail; - int timestamp; - struct ip *ip; - uint32_t tsval; - uint32_t tsecr; - uint32_t source_ip; - uint32_t dest_ip; - uint32_t next_seq; - uint32_t ack_seq; - uint32_t len; - uint32_t data_csum; - uint16_t window; - uint16_t source_port; - uint16_t dest_port; - uint16_t append_cnt; - uint16_t mss; - + SLIST_ENTRY(lro_entry) next; + struct mbuf *m_head; + struct mbuf *m_tail; + union { + struct ip *ip4; + struct ip6_hdr *ip6; + } leip; + union { + in_addr_t s_ip4; + struct in6_addr s_ip6; + } lesource; + union { + in_addr_t d_ip4; + struct in6_addr d_ip6; + } ledest; + uint16_t source_port; + uint16_t dest_port; + uint16_t eh_type; /* EthernetHeader type. */ + uint16_t append_cnt; + uint32_t p_len; /* IP header payload length. */ + uint32_t ulp_csum; /* TCP, etc. checksum. */ + uint32_t next_seq; /* tcp_seq */ + uint32_t ack_seq; /* tcp_seq */ + uint32_t tsval; + uint32_t tsecr; + uint16_t window; + uint16_t timestamp; /* flag, not a TCP hdr field. */ }; SLIST_HEAD(lro_head, lro_entry); +#define le_ip4 leip.ip4 +#define le_ip6 leip.ip6 +#define source_ip4 lesource.s_ip4 +#define dest_ip4 ledest.d_ip4 +#define source_ip6 lesource.s_ip6 +#define dest_ip6 ledest.d_ip6 + +/* NB: This is part of driver structs. */ struct lro_ctrl { struct ifnet *ifp; int lro_queued; @@ -66,13 +81,12 @@ struct lro_ctrl { struct lro_head lro_free; }; - int tcp_lro_init(struct lro_ctrl *); void tcp_lro_free(struct lro_ctrl *); void tcp_lro_flush(struct lro_ctrl *, struct lro_entry *); int tcp_lro_rx(struct lro_ctrl *, struct mbuf *, uint32_t); -/* Number of LRO entries - these are per rx queue */ -#define LRO_ENTRIES 8 +#define TCP_LRO_CANNOT -1 +#define TCP_LRO_NOT_SUPPORTED 1 #endif /* _TCP_LRO_H_ */ From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 8 11:28:34 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 65A45106564A; Sun, 8 Jul 2012 11:28:34 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 502918FC0C; Sun, 8 Jul 2012 11:28:34 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q68BSYO5048165; Sun, 8 Jul 2012 11:28:34 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q68BSYs9048163; Sun, 8 Jul 2012 11:28:34 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201207081128.q68BSYs9048163@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Sun, 8 Jul 2012 11:28:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238231 - stable/9/sys/netinet6 X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jul 2012 11:28:34 -0000 Author: bz Date: Sun Jul 8 11:28:33 2012 New Revision: 238231 URL: http://svn.freebsd.org/changeset/base/238231 Log: MFC r235954: We currently nowhere set IP6A_SWAP making the entire check useless with the current code. Keep around but do not compile in. Approved by: re Modified: stable/9/sys/netinet6/route6.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet6/route6.c ============================================================================== --- stable/9/sys/netinet6/route6.c Sun Jul 8 11:24:22 2012 (r238230) +++ stable/9/sys/netinet6/route6.c Sun Jul 8 11:28:33 2012 (r238231) @@ -62,6 +62,7 @@ route6_input(struct mbuf **mp, int *offp struct mbuf *m = *mp; struct ip6_rthdr *rh; int off = *offp, rhlen; +#ifdef __notyet__ struct ip6aux *ip6a; ip6a = ip6_findaux(m); @@ -73,6 +74,7 @@ route6_input(struct mbuf **mp, int *offp return IPPROTO_DONE; } } +#endif #ifndef PULLDOWN_TEST IP6_EXTHDR_CHECK(m, off, sizeof(*rh), IPPROTO_DONE); From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 8 11:33:49 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DBE46106566C; Sun, 8 Jul 2012 11:33:49 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C70838FC08; Sun, 8 Jul 2012 11:33:49 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q68BXnNO048440; Sun, 8 Jul 2012 11:33:49 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q68BXnNM048438; Sun, 8 Jul 2012 11:33:49 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201207081133.q68BXnNM048438@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Sun, 8 Jul 2012 11:33:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238232 - stable/9/sys/netinet6 X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jul 2012 11:33:50 -0000 Author: bz Date: Sun Jul 8 11:33:49 2012 New Revision: 238232 URL: http://svn.freebsd.org/changeset/base/238232 Log: MFC r235955: Simplify the code removing a return from an earlier else case, not differing from the default function return called now. Approved by: re Modified: stable/9/sys/netinet6/in6_src.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet6/in6_src.c ============================================================================== --- stable/9/sys/netinet6/in6_src.c Sun Jul 8 11:28:33 2012 (r238231) +++ stable/9/sys/netinet6/in6_src.c Sun Jul 8 11:33:49 2012 (r238232) @@ -873,8 +873,7 @@ in6_selecthlim(struct inpcb *in6p, struc RTFREE(ro6.ro_rt); if (lifp) return (ND_IFINFO(lifp)->chlim); - } else - return (V_ip6_defhlim); + } } return (V_ip6_defhlim); } From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 8 11:42:22 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 571DF1065713; Sun, 8 Jul 2012 11:42:22 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 27C4B8FC0C; Sun, 8 Jul 2012 11:42:22 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q68BgM4D048833; Sun, 8 Jul 2012 11:42:22 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q68BgLQf048830; Sun, 8 Jul 2012 11:42:21 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201207081142.q68BgLQf048830@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Sun, 8 Jul 2012 11:42:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238233 - stable/9/sys/netinet6 X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jul 2012 11:42:22 -0000 Author: bz Date: Sun Jul 8 11:42:21 2012 New Revision: 238233 URL: http://svn.freebsd.org/changeset/base/238233 Log: MFC r235956: Hide the ip6aux functions. The only one referenced outside ip6_input.c is not compiled in yet (__notyet__) in route6.c (r235954, r238231). We do have accessor functions that should be used. Approved by: re Modified: stable/9/sys/netinet6/ip6_input.c stable/9/sys/netinet6/ip6_var.h Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet6/ip6_input.c ============================================================================== --- stable/9/sys/netinet6/ip6_input.c Sun Jul 8 11:33:49 2012 (r238232) +++ stable/9/sys/netinet6/ip6_input.c Sun Jul 8 11:42:21 2012 (r238233) @@ -146,6 +146,9 @@ RW_SYSINIT(in6_ifaddr_lock, &in6_ifaddr_ static void ip6_init2(void *); static struct ip6aux *ip6_setdstifaddr(struct mbuf *, struct in6_ifaddr *); +static struct ip6aux *ip6_addaux(struct mbuf *); +static struct ip6aux *ip6_findaux(struct mbuf *m); +static void ip6_delaux (struct mbuf *); static int ip6_hopopts_input(u_int32_t *, u_int32_t *, struct mbuf **, int *); #ifdef PULLDOWN_TEST static struct mbuf *ip6_pullexthdr(struct mbuf *, size_t, int); @@ -1814,7 +1817,7 @@ ip6_lasthdr(struct mbuf *m, int off, int } } -struct ip6aux * +static struct ip6aux * ip6_addaux(struct mbuf *m) { struct m_tag *mtag; @@ -1831,7 +1834,7 @@ ip6_addaux(struct mbuf *m) return mtag ? (struct ip6aux *)(mtag + 1) : NULL; } -struct ip6aux * +static struct ip6aux * ip6_findaux(struct mbuf *m) { struct m_tag *mtag; @@ -1840,7 +1843,7 @@ ip6_findaux(struct mbuf *m) return mtag ? (struct ip6aux *)(mtag + 1) : NULL; } -void +static void ip6_delaux(struct mbuf *m) { struct m_tag *mtag; Modified: stable/9/sys/netinet6/ip6_var.h ============================================================================== --- stable/9/sys/netinet6/ip6_var.h Sun Jul 8 11:33:49 2012 (r238232) +++ stable/9/sys/netinet6/ip6_var.h Sun Jul 8 11:42:21 2012 (r238233) @@ -388,9 +388,9 @@ char * ip6_get_prevhdr __P((struct mbuf int ip6_nexthdr __P((struct mbuf *, int, int, int *)); int ip6_lasthdr __P((struct mbuf *, int, int, int *)); -struct ip6aux *ip6_addaux __P((struct mbuf *)); +#ifdef __notyet__ struct ip6aux *ip6_findaux __P((struct mbuf *)); -void ip6_delaux __P((struct mbuf *)); +#endif extern int (*ip6_mforward)(struct ip6_hdr *, struct ifnet *, struct mbuf *); From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 8 11:53:14 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5BCBD106564A; Sun, 8 Jul 2012 11:53:14 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3D01B8FC0A; Sun, 8 Jul 2012 11:53:14 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q68BrEhk049334; Sun, 8 Jul 2012 11:53:14 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q68BrEGj049331; Sun, 8 Jul 2012 11:53:14 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201207081153.q68BrEGj049331@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Sun, 8 Jul 2012 11:53:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238234 - stable/9/sys/netinet6 X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jul 2012 11:53:14 -0000 Author: bz Date: Sun Jul 8 11:53:13 2012 New Revision: 238234 URL: http://svn.freebsd.org/changeset/base/238234 Log: MFC r235958,236130: Add support for delayed checksum calculations in the IPv6 output path. We currently cannot offload to the card if we add extension headers (which incl. fragmentation). Fix two SCTP offload support copy&paste bugs: calculate checksums if fragmenting and no need to flag IPv4 header checksums in the IPv6 forwarding path. Correctly get the payload length in host byte order. While we already plan to support >64k payload here, the IPv6 header payload length obviously is only 16 bit and the calculations need to be right. Approved by: re Modified: stable/9/sys/netinet6/ip6_forward.c stable/9/sys/netinet6/ip6_output.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet6/ip6_forward.c ============================================================================== --- stable/9/sys/netinet6/ip6_forward.c Sun Jul 8 11:42:21 2012 (r238233) +++ stable/9/sys/netinet6/ip6_forward.c Sun Jul 8 11:53:13 2012 (r238234) @@ -586,8 +586,6 @@ skip_routing: CSUM_DATA_VALID | CSUM_PSEUDO_HDR; m->m_pkthdr.csum_data = 0xffff; } - m->m_pkthdr.csum_flags |= - CSUM_IP_CHECKED | CSUM_IP_VALID; #ifdef SCTP if (m->m_pkthdr.csum_flags & CSUM_SCTP) m->m_pkthdr.csum_flags |= CSUM_SCTP_VALID; Modified: stable/9/sys/netinet6/ip6_output.c ============================================================================== --- stable/9/sys/netinet6/ip6_output.c Sun Jul 8 11:42:21 2012 (r238233) +++ stable/9/sys/netinet6/ip6_output.c Sun Jul 8 11:53:13 2012 (r238234) @@ -83,6 +83,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include + #include #include #include @@ -182,6 +184,29 @@ static int copypktopts(struct ip6_pktopt }\ } while (/*CONSTCOND*/ 0) +static void +in6_delayed_cksum(struct mbuf *m, uint32_t plen, u_short offset) +{ + u_short csum; + + csum = in_cksum_skip(m, offset + plen, offset); + if (m->m_pkthdr.csum_flags & CSUM_UDP && csum == 0) + csum = 0xffff; + offset += m->m_pkthdr.csum_data; /* checksum offset */ + + if (offset + sizeof(u_short) > m->m_len) { + printf("%s: delayed m_pullup, m->len: %d off: %d\n", + __func__, m->m_len, offset); + /* + * XXX this should not happen, but if it does, the correct + * behavior may be to insert the checksum in the appropriate + * next mbuf in the chain. + */ + return; + } + *(u_short *)(m->m_data + offset) = csum; +} + /* * IP6 output. The packet in mbuf chain m contains a skeletal IP6 * header (with pri, len, nxt, hlim, src, dst). @@ -221,9 +246,7 @@ ip6_output(struct mbuf *m0, struct ip6_p int flevalid = 0; int hdrsplit = 0; int needipsec = 0; -#ifdef SCTP - int sw_csum; -#endif + int sw_csum, tso; #ifdef IPSEC struct ipsec_output_state state; struct ip6_rthdr *rh = NULL; @@ -867,8 +890,6 @@ again: CSUM_DATA_VALID | CSUM_PSEUDO_HDR; m->m_pkthdr.csum_data = 0xffff; } - m->m_pkthdr.csum_flags |= - CSUM_IP_CHECKED | CSUM_IP_VALID; #ifdef SCTP if (m->m_pkthdr.csum_flags & CSUM_SCTP) m->m_pkthdr.csum_flags |= CSUM_SCTP_VALID; @@ -891,7 +912,7 @@ again: } #ifdef SCTP if (m->m_pkthdr.csum_flags & CSUM_SCTP) - m->m_pkthdr.csum_flags |= CSUM_SCTP_VALID; + m->m_pkthdr.csum_flags |= CSUM_SCTP_VALID; #endif error = netisr_queue(NETISR_IPV6, m); goto done; @@ -927,16 +948,32 @@ passout: * 4: if dontfrag == 1 && alwaysfrag == 1 * error, as we cannot handle this conflicting request */ + sw_csum = m->m_pkthdr.csum_flags; + if (!hdrsplit) { + tso = ((sw_csum & ifp->if_hwassist & CSUM_TSO) != 0) ? 1 : 0; + sw_csum &= ~ifp->if_hwassist; + } else + tso = 0; + /* + * If we added extension headers, we will not do TSO and calculate the + * checksums ourselves for now. + * XXX-BZ Need a framework to know when the NIC can handle it, even + * with ext. hdrs. + */ + if (sw_csum & CSUM_DELAY_DATA) { + sw_csum &= ~CSUM_DELAY_DATA; + in6_delayed_cksum(m, plen, sizeof(struct ip6_hdr)); + } #ifdef SCTP - sw_csum = m->m_pkthdr.csum_flags & ~ifp->if_hwassist; if (sw_csum & CSUM_SCTP) { - sctp_delayed_cksum(m, sizeof(struct ip6_hdr)); sw_csum &= ~CSUM_SCTP; + sctp_delayed_cksum(m, sizeof(struct ip6_hdr)); } #endif + m->m_pkthdr.csum_flags &= ifp->if_hwassist; tlen = m->m_pkthdr.len; - if (opt && (opt->ip6po_flags & IP6PO_DONTFRAG)) + if ((opt && (opt->ip6po_flags & IP6PO_DONTFRAG)) || tso) dontfrag = 1; else dontfrag = 0; @@ -945,7 +982,7 @@ passout: error = EMSGSIZE; goto bad; } - if (dontfrag && tlen > IN6_LINKMTU(ifp)) { /* case 2-b */ + if (dontfrag && tlen > IN6_LINKMTU(ifp) && !tso) { /* case 2-b */ /* * Even if the DONTFRAG option is specified, we cannot send the * packet when the data length is larger than the MTU of the @@ -1033,6 +1070,22 @@ passout: goto bad; } + + /* + * If the interface will not calculate checksums on + * fragmented packets, then do it here. + * XXX-BZ handle the hw offloading case. Need flags. + */ + if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) { + in6_delayed_cksum(m, plen, hlen); + m->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA; + } +#ifdef SCTP + if (m->m_pkthdr.csum_flags & CSUM_SCTP) { + sctp_delayed_cksum(m, hlen); + m->m_pkthdr.csum_flags &= ~CSUM_SCTP; + } +#endif mnext = &m->m_nextpkt; /* From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 8 11:57:12 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5D5E8106568B; Sun, 8 Jul 2012 11:57:12 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 47EF28FC0C; Sun, 8 Jul 2012 11:57:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q68BvC1i049555; Sun, 8 Jul 2012 11:57:12 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q68BvCGX049553; Sun, 8 Jul 2012 11:57:12 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201207081157.q68BvCGX049553@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Sun, 8 Jul 2012 11:57:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238235 - stable/9/sys/netinet6 X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jul 2012 11:57:12 -0000 Author: bz Date: Sun Jul 8 11:57:11 2012 New Revision: 238235 URL: http://svn.freebsd.org/changeset/base/238235 Log: MFC r235959: Defer checksum calulations on UDP6 output and respect the mbuf flags set by NICs having done checksum validation for us already, thus saving the computing time in the input path as well. Approved by: re Modified: stable/9/sys/netinet6/udp6_usrreq.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet6/udp6_usrreq.c ============================================================================== --- stable/9/sys/netinet6/udp6_usrreq.c Sun Jul 8 11:53:13 2012 (r238234) +++ stable/9/sys/netinet6/udp6_usrreq.c Sun Jul 8 11:57:11 2012 (r238235) @@ -185,6 +185,7 @@ udp6_input(struct mbuf **mp, int *offp, #ifdef IPFIREWALL_FORWARD struct m_tag *fwd_tag; #endif + uint16_t uh_sum; ifp = m->m_pkthdr.rcvif; ip6 = mtod(m, struct ip6_hdr *); @@ -228,7 +229,18 @@ udp6_input(struct mbuf **mp, int *offp, UDPSTAT_INC(udps_nosum); goto badunlocked; } - if (in6_cksum(m, IPPROTO_UDP, off, ulen) != 0) { + + if (m->m_pkthdr.csum_flags & CSUM_DATA_VALID) { + if (m->m_pkthdr.csum_flags & CSUM_PSEUDO_HDR) + uh_sum = m->m_pkthdr.csum_data; + else + uh_sum = in6_cksum_pseudo(ip6, ulen, + IPPROTO_UDP, m->m_pkthdr.csum_data); + uh_sum ^= 0xffff; + } else + uh_sum = in6_cksum(m, IPPROTO_UDP, off, ulen); + + if (uh_sum != 0) { UDPSTAT_INC(udps_badsum); goto badunlocked; } @@ -771,10 +783,9 @@ udp6_output(struct inpcb *inp, struct mb ip6->ip6_src = *laddr; ip6->ip6_dst = *faddr; - if ((udp6->uh_sum = in6_cksum(m, IPPROTO_UDP, - sizeof(struct ip6_hdr), plen)) == 0) { - udp6->uh_sum = 0xffff; - } + udp6->uh_sum = in6_cksum_pseudo(ip6, plen, IPPROTO_UDP, 0); + m->m_pkthdr.csum_flags = CSUM_UDP; + m->m_pkthdr.csum_data = offsetof(struct udphdr, uh_sum); flags = 0; From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 8 12:01:12 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 2FE7A1065673; Sun, 8 Jul 2012 12:01:12 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 17D618FC1D; Sun, 8 Jul 2012 12:01:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q68C1BPK049787; Sun, 8 Jul 2012 12:01:11 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q68C1B5M049785; Sun, 8 Jul 2012 12:01:11 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201207081201.q68C1B5M049785@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Sun, 8 Jul 2012 12:01:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238236 - stable/9/sys/net X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jul 2012 12:01:12 -0000 Author: bz Date: Sun Jul 8 12:01:11 2012 New Revision: 238236 URL: http://svn.freebsd.org/changeset/base/238236 Log: MFC r235960: Simple yet effective change enabling checksum "offload" on loopback for IPv6 to avoid expensive computations. Approved by: re Modified: stable/9/sys/net/if_loop.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/net/if_loop.c ============================================================================== --- stable/9/sys/net/if_loop.c Sun Jul 8 11:57:11 2012 (r238235) +++ stable/9/sys/net/if_loop.c Sun Jul 8 12:01:11 2012 (r238236) @@ -247,12 +247,12 @@ looutput(struct ifnet *ifp, struct mbuf #if 1 /* XXX */ switch (dst->sa_family) { case AF_INET: + case AF_INET6: if (ifp->if_capenable & IFCAP_RXCSUM) { m->m_pkthdr.csum_data = 0xffff; m->m_pkthdr.csum_flags = LO_CSUM_SET; } m->m_pkthdr.csum_flags &= ~LO_CSUM_FEATURES; - case AF_INET6: case AF_IPX: case AF_APPLETALK: break; From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 8 12:12:34 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D385A106566C; Sun, 8 Jul 2012 12:12:34 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BDB3A8FC12; Sun, 8 Jul 2012 12:12:34 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q68CCYGu050288; Sun, 8 Jul 2012 12:12:34 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q68CCYMN050281; Sun, 8 Jul 2012 12:12:34 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201207081212.q68CCYMN050281@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Sun, 8 Jul 2012 12:12:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238237 - stable/9/sys/netinet X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jul 2012 12:12:35 -0000 Author: bz Date: Sun Jul 8 12:12:34 2012 New Revision: 238237 URL: http://svn.freebsd.org/changeset/base/238237 Log: MFC r235961: Add code to handle pre-checked TCP checksums as indicated by mbuf flags to save the entire computation for validation if not needed. In the IPv6 TCP output path only compute the pseudo-header checksum, set the checksum offset in the mbuf field along the appropriate flag as done in IPv4. In tcp_respond() just initialize the IPv6 payload length to 0 as ip6_output() will properly set it. Approved by: re Modified: stable/9/sys/netinet/tcp_input.c stable/9/sys/netinet/tcp_output.c stable/9/sys/netinet/tcp_subr.c stable/9/sys/netinet/tcp_syncache.c stable/9/sys/netinet/tcp_timewait.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/tcp_input.c ============================================================================== --- stable/9/sys/netinet/tcp_input.c Sun Jul 8 12:01:11 2012 (r238236) +++ stable/9/sys/netinet/tcp_input.c Sun Jul 8 12:12:34 2012 (r238237) @@ -610,13 +610,31 @@ tcp_input(struct mbuf *m, int off0) #ifdef INET6 if (isipv6) { /* IP6_EXTHDR_CHECK() is already done at tcp6_input(). */ + + if (m->m_len < (sizeof(*ip6) + sizeof(*th))) { + m = m_pullup(m, sizeof(*ip6) + sizeof(*th)); + if (m == NULL) { + TCPSTAT_INC(tcps_rcvshort); + return; + } + } + ip6 = mtod(m, struct ip6_hdr *); + th = (struct tcphdr *)((caddr_t)ip6 + off0); tlen = sizeof(*ip6) + ntohs(ip6->ip6_plen) - off0; - if (in6_cksum(m, IPPROTO_TCP, off0, tlen)) { + if (m->m_pkthdr.csum_flags & CSUM_DATA_VALID) { + if (m->m_pkthdr.csum_flags & CSUM_PSEUDO_HDR) + th->th_sum = m->m_pkthdr.csum_data; + else + th->th_sum = in6_cksum_pseudo(ip6, tlen, + IPPROTO_TCP, m->m_pkthdr.csum_data); + th->th_sum ^= 0xffff; + } else + th->th_sum = in6_cksum(m, IPPROTO_TCP, off0, tlen); + if (th->th_sum) { TCPSTAT_INC(tcps_rcvbadsum); goto drop; } - th = (struct tcphdr *)((caddr_t)ip6 + off0); /* * Be proactive about unspecified IPv6 address in source. Modified: stable/9/sys/netinet/tcp_output.c ============================================================================== --- stable/9/sys/netinet/tcp_output.c Sun Jul 8 12:01:11 2012 (r238236) +++ stable/9/sys/netinet/tcp_output.c Sun Jul 8 12:12:34 2012 (r238237) @@ -1052,19 +1052,23 @@ send: * checksum extended header and data. */ m->m_pkthdr.len = hdrlen + len; /* in6_cksum() need this */ + m->m_pkthdr.csum_flags = CSUM_TCP; + m->m_pkthdr.csum_data = offsetof(struct tcphdr, th_sum); #ifdef INET6 - if (isipv6) + if (isipv6) { /* * ip6_plen is not need to be filled now, and will be filled * in ip6_output. */ - th->th_sum = in6_cksum(m, IPPROTO_TCP, sizeof(struct ip6_hdr), - sizeof(struct tcphdr) + optlen + len); + th->th_sum = in6_cksum_pseudo(ip6, sizeof(struct tcphdr) + + optlen + len, IPPROTO_TCP, 0); + } +#endif +#if defined(INET6) && defined(INET) else -#endif /* INET6 */ +#endif +#ifdef INET { - m->m_pkthdr.csum_flags = CSUM_TCP; - m->m_pkthdr.csum_data = offsetof(struct tcphdr, th_sum); th->th_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr, htons(sizeof(struct tcphdr) + IPPROTO_TCP + len + optlen)); @@ -1072,6 +1076,7 @@ send: KASSERT(ip->ip_v == IPVERSION, ("%s: IP version incorrect: %d", __func__, ip->ip_v)); } +#endif /* * Enable TSO and specify the size of the segments. Modified: stable/9/sys/netinet/tcp_subr.c ============================================================================== --- stable/9/sys/netinet/tcp_subr.c Sun Jul 8 12:01:11 2012 (r238236) +++ stable/9/sys/netinet/tcp_subr.c Sun Jul 8 12:12:34 2012 (r238237) @@ -573,8 +573,7 @@ tcp_respond(struct tcpcb *tp, void *ipge ip6->ip6_flow = 0; ip6->ip6_vfc = IPV6_VERSION; ip6->ip6_nxt = IPPROTO_TCP; - ip6->ip6_plen = htons((u_short)(sizeof (struct tcphdr) + - tlen)); + ip6->ip6_plen = 0; /* Set in ip6_output(). */ tlen += sizeof (struct ip6_hdr) + sizeof (struct tcphdr); } #endif @@ -619,12 +618,13 @@ tcp_respond(struct tcpcb *tp, void *ipge else nth->th_win = htons((u_short)win); nth->th_urp = 0; + + m->m_pkthdr.csum_flags = CSUM_TCP; + m->m_pkthdr.csum_data = offsetof(struct tcphdr, th_sum); #ifdef INET6 if (isipv6) { - nth->th_sum = 0; - nth->th_sum = in6_cksum(m, IPPROTO_TCP, - sizeof(struct ip6_hdr), - tlen - sizeof(struct ip6_hdr)); + nth->th_sum = in6_cksum_pseudo(ip6, + tlen - sizeof(struct ip6_hdr), IPPROTO_TCP, 0); ip6->ip6_hlim = in6_selecthlim(tp != NULL ? tp->t_inpcb : NULL, NULL); } @@ -636,8 +636,6 @@ tcp_respond(struct tcpcb *tp, void *ipge { nth->th_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr, htons((u_short)(tlen - sizeof(struct ip) + ip->ip_p))); - m->m_pkthdr.csum_flags = CSUM_TCP; - m->m_pkthdr.csum_data = offsetof(struct tcphdr, th_sum); } #endif /* INET */ #ifdef TCPDEBUG Modified: stable/9/sys/netinet/tcp_syncache.c ============================================================================== --- stable/9/sys/netinet/tcp_syncache.c Sun Jul 8 12:01:11 2012 (r238236) +++ stable/9/sys/netinet/tcp_syncache.c Sun Jul 8 12:12:34 2012 (r238237) @@ -1472,11 +1472,12 @@ syncache_respond(struct syncache *sc) optlen = 0; M_SETFIB(m, sc->sc_inc.inc_fibnum); + m->m_pkthdr.csum_flags = CSUM_TCP; + m->m_pkthdr.csum_data = offsetof(struct tcphdr, th_sum); #ifdef INET6 if (sc->sc_inc.inc_flags & INC_ISIPV6) { - th->th_sum = 0; - th->th_sum = in6_cksum(m, IPPROTO_TCP, hlen, - tlen + optlen - hlen); + th->th_sum = in6_cksum_pseudo(ip6, tlen + optlen - hlen, + IPPROTO_TCP, 0); ip6->ip6_hlim = in6_selecthlim(NULL, NULL); error = ip6_output(m, NULL, NULL, 0, NULL, NULL, NULL); } @@ -1488,8 +1489,6 @@ syncache_respond(struct syncache *sc) { th->th_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr, htons(tlen + optlen - hlen + IPPROTO_TCP)); - m->m_pkthdr.csum_flags = CSUM_TCP; - m->m_pkthdr.csum_data = offsetof(struct tcphdr, th_sum); error = ip_output(m, sc->sc_ipopts, NULL, 0, NULL, NULL); } #endif Modified: stable/9/sys/netinet/tcp_timewait.c ============================================================================== --- stable/9/sys/netinet/tcp_timewait.c Sun Jul 8 12:01:11 2012 (r238236) +++ stable/9/sys/netinet/tcp_timewait.c Sun Jul 8 12:12:34 2012 (r238237) @@ -574,10 +574,12 @@ tcp_twrespond(struct tcptw *tw, int flag th->th_flags = flags; th->th_win = htons(tw->last_win); + m->m_pkthdr.csum_flags = CSUM_TCP; + m->m_pkthdr.csum_data = offsetof(struct tcphdr, th_sum); #ifdef INET6 if (isipv6) { - th->th_sum = in6_cksum(m, IPPROTO_TCP, sizeof(struct ip6_hdr), - sizeof(struct tcphdr) + optlen); + th->th_sum = in6_cksum_pseudo(ip6, + sizeof(struct tcphdr) + optlen, IPPROTO_TCP, 0); ip6->ip6_hlim = in6_selecthlim(inp, NULL); error = ip6_output(m, inp->in6p_outputopts, NULL, (tw->tw_so_options & SO_DONTROUTE), NULL, NULL, inp); @@ -590,8 +592,6 @@ tcp_twrespond(struct tcptw *tw, int flag { th->th_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr, htons(sizeof(struct tcphdr) + optlen + IPPROTO_TCP)); - m->m_pkthdr.csum_flags = CSUM_TCP; - m->m_pkthdr.csum_data = offsetof(struct tcphdr, th_sum); ip->ip_len = m->m_pkthdr.len; if (V_path_mtu_discovery) ip->ip_off |= IP_DF; From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 8 12:17:57 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 27EDA1065698; Sun, 8 Jul 2012 12:17:57 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 085338FC17; Sun, 8 Jul 2012 12:17:57 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q68CHu0M050553; Sun, 8 Jul 2012 12:17:56 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q68CHukI050551; Sun, 8 Jul 2012 12:17:56 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201207081217.q68CHukI050551@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Sun, 8 Jul 2012 12:17:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238238 - stable/9/sys/netinet6 X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jul 2012 12:17:57 -0000 Author: bz Date: Sun Jul 8 12:17:56 2012 New Revision: 238238 URL: http://svn.freebsd.org/changeset/base/238238 Log: MFC r235962: Factor out Hop-By-Hop option processing. It's still not heavily used, it reduces the footprint of ip6_input() and makes ip6_input() more readable. Approved by: re Modified: stable/9/sys/netinet6/ip6_input.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet6/ip6_input.c ============================================================================== --- stable/9/sys/netinet6/ip6_input.c Sun Jul 8 12:12:34 2012 (r238237) +++ stable/9/sys/netinet6/ip6_input.c Sun Jul 8 12:17:56 2012 (r238238) @@ -329,6 +329,83 @@ ip6_init2(void *dummy) /* This must be after route_init(), which is now SI_ORDER_THIRD */ SYSINIT(netinet6init2, SI_SUB_PROTO_DOMAIN, SI_ORDER_MIDDLE, ip6_init2, NULL); +static int +ip6_input_hbh(struct mbuf *m, uint32_t *plen, uint32_t *rtalert, int *off, + int *nxt, int *ours) +{ + struct ip6_hdr *ip6; + struct ip6_hbh *hbh; + + if (ip6_hopopts_input(plen, rtalert, &m, off)) { +#if 0 /*touches NULL pointer*/ + in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_discard); +#endif + goto out; /* m have already been freed */ + } + + /* adjust pointer */ + ip6 = mtod(m, struct ip6_hdr *); + + /* + * if the payload length field is 0 and the next header field + * indicates Hop-by-Hop Options header, then a Jumbo Payload + * option MUST be included. + */ + if (ip6->ip6_plen == 0 && *plen == 0) { + /* + * Note that if a valid jumbo payload option is + * contained, ip6_hopopts_input() must set a valid + * (non-zero) payload length to the variable plen. + */ + V_ip6stat.ip6s_badoptions++; + in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_discard); + in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_hdrerr); + icmp6_error(m, ICMP6_PARAM_PROB, + ICMP6_PARAMPROB_HEADER, + (caddr_t)&ip6->ip6_plen - (caddr_t)ip6); + goto out; + } +#ifndef PULLDOWN_TEST + /* ip6_hopopts_input() ensures that mbuf is contiguous */ + hbh = (struct ip6_hbh *)(ip6 + 1); +#else + IP6_EXTHDR_GET(hbh, struct ip6_hbh *, m, sizeof(struct ip6_hdr), + sizeof(struct ip6_hbh)); + if (hbh == NULL) { + V_ip6stat.ip6s_tooshort++; + goto out; + } +#endif + *nxt = hbh->ip6h_nxt; + + /* + * If we are acting as a router and the packet contains a + * router alert option, see if we know the option value. + * Currently, we only support the option value for MLD, in which + * case we should pass the packet to the multicast routing + * daemon. + */ + if (*rtalert != ~0) { + switch (*rtalert) { + case IP6OPT_RTALERT_MLD: + if (V_ip6_forwarding) + *ours = 1; + break; + default: + /* + * RFC2711 requires unrecognized values must be + * silently ignored. + */ + break; + } + } + + return (0); + +out: + return (1); +} + void ip6_input(struct mbuf *m) { @@ -827,71 +904,11 @@ passin: */ plen = (u_int32_t)ntohs(ip6->ip6_plen); if (ip6->ip6_nxt == IPPROTO_HOPOPTS) { - struct ip6_hbh *hbh; + int error; - if (ip6_hopopts_input(&plen, &rtalert, &m, &off)) { -#if 0 /*touches NULL pointer*/ - in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_discard); -#endif - goto out; /* m have already been freed */ - } - - /* adjust pointer */ - ip6 = mtod(m, struct ip6_hdr *); - - /* - * if the payload length field is 0 and the next header field - * indicates Hop-by-Hop Options header, then a Jumbo Payload - * option MUST be included. - */ - if (ip6->ip6_plen == 0 && plen == 0) { - /* - * Note that if a valid jumbo payload option is - * contained, ip6_hopopts_input() must set a valid - * (non-zero) payload length to the variable plen. - */ - V_ip6stat.ip6s_badoptions++; - in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_discard); - in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_hdrerr); - icmp6_error(m, ICMP6_PARAM_PROB, - ICMP6_PARAMPROB_HEADER, - (caddr_t)&ip6->ip6_plen - (caddr_t)ip6); + error = ip6_input_hbh(m, &plen, &rtalert, &off, &nxt, &ours); + if (error != 0) goto out; - } -#ifndef PULLDOWN_TEST - /* ip6_hopopts_input() ensures that mbuf is contiguous */ - hbh = (struct ip6_hbh *)(ip6 + 1); -#else - IP6_EXTHDR_GET(hbh, struct ip6_hbh *, m, sizeof(struct ip6_hdr), - sizeof(struct ip6_hbh)); - if (hbh == NULL) { - V_ip6stat.ip6s_tooshort++; - goto out; - } -#endif - nxt = hbh->ip6h_nxt; - - /* - * If we are acting as a router and the packet contains a - * router alert option, see if we know the option value. - * Currently, we only support the option value for MLD, in which - * case we should pass the packet to the multicast routing - * daemon. - */ - if (rtalert != ~0) { - switch (rtalert) { - case IP6OPT_RTALERT_MLD: - if (V_ip6_forwarding) - ours = 1; - break; - default: - /* - * RFC2711 requires unrecognized values must be - * silently ignored. - */ - break; - } - } } else nxt = ip6->ip6_nxt; From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 8 12:23:27 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D41621065673; Sun, 8 Jul 2012 12:23:27 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A2EE98FC08; Sun, 8 Jul 2012 12:23:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q68CNRVI050936; Sun, 8 Jul 2012 12:23:27 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q68CNROC050934; Sun, 8 Jul 2012 12:23:27 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201207081223.q68CNROC050934@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Sun, 8 Jul 2012 12:23:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238239 - stable/9/sys/netinet X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jul 2012 12:23:28 -0000 Author: bz Date: Sun Jul 8 12:23:27 2012 New Revision: 238239 URL: http://svn.freebsd.org/changeset/base/238239 Log: MFC r235981,236394 In case forwarding is turned on for a given address family, refuse to queue the packet for LRO and tell the driver to directly pass it on. This avoids re-assembly and later re-fragmentation problems when forwarding. It's not the best solution but the simplest and most effective for the moment. Make TCP LRO work properly with VIMAGE kernels rather than just panicing. There's no VIMAGE context set there yet as this is before if_ethersubr.c. Approved by: re Modified: stable/9/sys/netinet/tcp_lro.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/tcp_lro.c ============================================================================== --- stable/9/sys/netinet/tcp_lro.c Sun Jul 8 12:17:56 2012 (r238238) +++ stable/9/sys/netinet/tcp_lro.c Sun Jul 8 12:23:27 2012 (r238239) @@ -46,14 +46,18 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include #include +#include #include #include +#include + #include #ifndef LRO_ENTRIES @@ -369,6 +373,14 @@ tcp_lro_rx(struct lro_ctrl *lc, struct m switch (eh_type) { #ifdef INET6 case ETHERTYPE_IPV6: + { + CURVNET_SET(lc->ifp->if_vnet); + if (V_ip6_forwarding != 0) { + /* XXX-BZ stats but changing lro_ctrl is a problem. */ + CURVNET_RESTORE(); + return (TCP_LRO_CANNOT); + } + CURVNET_RESTORE(); l3hdr = ip6 = (struct ip6_hdr *)(eh + 1); error = tcp_lro_rx_ipv6(lc, m, ip6, &th); if (error != 0) @@ -376,9 +388,18 @@ tcp_lro_rx(struct lro_ctrl *lc, struct m tcp_data_len = ntohs(ip6->ip6_plen); ip_len = sizeof(*ip6) + tcp_data_len; break; + } #endif #ifdef INET case ETHERTYPE_IP: + { + CURVNET_SET(lc->ifp->if_vnet); + if (V_ipforwarding != 0) { + /* XXX-BZ stats but changing lro_ctrl is a problem. */ + CURVNET_RESTORE(); + return (TCP_LRO_CANNOT); + } + CURVNET_RESTORE(); l3hdr = ip4 = (struct ip *)(eh + 1); error = tcp_lro_rx_ipv4(lc, m, ip4, &th); if (error != 0) @@ -386,6 +407,7 @@ tcp_lro_rx(struct lro_ctrl *lc, struct m ip_len = ntohs(ip4->ip_len); tcp_data_len = ip_len - sizeof(*ip4); break; + } #endif /* XXX-BZ what happens in case of VLAN(s)? */ default: From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 8 12:26:33 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 817441065670; Sun, 8 Jul 2012 12:26:33 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6CAE78FC12; Sun, 8 Jul 2012 12:26:33 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q68CQXhJ051243; Sun, 8 Jul 2012 12:26:33 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q68CQXnY051241; Sun, 8 Jul 2012 12:26:33 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201207081226.q68CQXnY051241@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Sun, 8 Jul 2012 12:26:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238240 - stable/9/sys/netinet X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jul 2012 12:26:33 -0000 Author: bz Date: Sun Jul 8 12:26:32 2012 New Revision: 238240 URL: http://svn.freebsd.org/changeset/base/238240 Log: MFC r235985: Properly protect the inp read access when handling the control code. In the past this was expensive but given the rlock it's not so much anymore. Approved by: re Modified: stable/9/sys/netinet/udp_usrreq.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/udp_usrreq.c ============================================================================== --- stable/9/sys/netinet/udp_usrreq.c Sun Jul 8 12:23:27 2012 (r238239) +++ stable/9/sys/netinet/udp_usrreq.c Sun Jul 8 12:26:32 2012 (r238240) @@ -972,6 +972,7 @@ udp_output(struct inpcb *inp, struct mbu } src.sin_family = 0; + INP_RLOCK(inp); tos = inp->inp_ip_tos; if (control != NULL) { /* @@ -979,6 +980,7 @@ udp_output(struct inpcb *inp, struct mbu * stored in a single mbuf. */ if (control->m_next) { + INP_RUNLOCK(inp); m_freem(control); m_freem(m); return (EINVAL); @@ -1028,6 +1030,7 @@ udp_output(struct inpcb *inp, struct mbu m_freem(control); } if (error) { + INP_RUNLOCK(inp); m_freem(m); return (error); } @@ -1049,7 +1052,6 @@ udp_output(struct inpcb *inp, struct mbu * XXXRW: Check that hash locking update here is correct. */ sin = (struct sockaddr_in *)addr; - INP_RLOCK(inp); if (sin != NULL && (inp->inp_laddr.s_addr == INADDR_ANY && inp->inp_lport == 0)) { INP_RUNLOCK(inp); From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 8 12:30:25 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id BE75E106566C; Sun, 8 Jul 2012 12:30:25 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A92ED8FC20; Sun, 8 Jul 2012 12:30:25 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q68CUPAj051449; Sun, 8 Jul 2012 12:30:25 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q68CUP0v051447; Sun, 8 Jul 2012 12:30:25 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201207081230.q68CUP0v051447@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Sun, 8 Jul 2012 12:30:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238241 - stable/9/sys/netinet6 X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jul 2012 12:30:26 -0000 Author: bz Date: Sun Jul 8 12:30:25 2012 New Revision: 238241 URL: http://svn.freebsd.org/changeset/base/238241 Log: MFC r235986: Use M_ZERO with malloc rather than calling bzero() ourselves. Change if () panic() checks to KASSERT()s as they are only catching invariants in code flow but not dependent on network input/output. Move initial assigments indirecting pointers after the lock has been aquired. Passing layer boundries, reset M_PROTOFLAGS. Remove a NULL assignment before free. Approved by: re Modified: stable/9/sys/netinet6/nd6.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet6/nd6.c ============================================================================== --- stable/9/sys/netinet6/nd6.c Sun Jul 8 12:26:32 2012 (r238240) +++ stable/9/sys/netinet6/nd6.c Sun Jul 8 12:30:25 2012 (r238241) @@ -174,9 +174,7 @@ nd6_ifattach(struct ifnet *ifp) { struct nd_ifinfo *nd; - nd = (struct nd_ifinfo *)malloc(sizeof(*nd), M_IP6NDP, M_WAITOK); - bzero(nd, sizeof(*nd)); - + nd = (struct nd_ifinfo *)malloc(sizeof(*nd), M_IP6NDP, M_WAITOK|M_ZERO); nd->initialized = 1; nd->chlim = IPV6_DEFHLIM; @@ -284,10 +282,9 @@ nd6_option(union nd_opts *ndopts) struct nd_opt_hdr *nd_opt; int olen; - if (ndopts == NULL) - panic("ndopts == NULL in nd6_option"); - if (ndopts->nd_opts_last == NULL) - panic("uninitialized ndopts in nd6_option"); + KASSERT(ndopts != NULL, ("%s: ndopts == NULL", __func__)); + KASSERT(ndopts->nd_opts_last != NULL, ("%s: uninitialized ndopts", + __func__)); if (ndopts->nd_opts_search == NULL) return NULL; if (ndopts->nd_opts_done) @@ -335,10 +332,9 @@ nd6_options(union nd_opts *ndopts) struct nd_opt_hdr *nd_opt; int i = 0; - if (ndopts == NULL) - panic("ndopts == NULL in nd6_options"); - if (ndopts->nd_opts_last == NULL) - panic("uninitialized ndopts in nd6_options"); + KASSERT(ndopts != NULL, ("%s: ndopts == NULL", __func__)); + KASSERT(ndopts->nd_opts_last != NULL, ("%s: uninitialized ndopts", + __func__)); if (ndopts->nd_opts_search == NULL) return 0; @@ -1174,11 +1170,13 @@ done: void nd6_rtrequest(int req, struct rtentry *rt, struct rt_addrinfo *info) { - struct sockaddr_in6 *gateway = (struct sockaddr_in6 *)rt->rt_gateway; + struct sockaddr_in6 *gateway; struct nd_defrouter *dr; - struct ifnet *ifp = rt->rt_ifp; + struct ifnet *ifp; RT_LOCK_ASSERT(rt); + gateway = (struct sockaddr_in6 *)rt->rt_gateway; + ifp = rt->rt_ifp; switch (req) { case RTM_ADD: @@ -1557,10 +1555,8 @@ nd6_cache_lladdr(struct ifnet *ifp, stru IF_AFDATA_UNLOCK_ASSERT(ifp); - if (ifp == NULL) - panic("ifp == NULL in nd6_cache_lladdr"); - if (from == NULL) - panic("from == NULL in nd6_cache_lladdr"); + KASSERT(ifp != NULL, ("%s: ifp == NULL", __func__)); + KASSERT(from != NULL, ("%s: from == NULL", __func__)); /* nothing must be updated for unspecified address */ if (IN6_IS_ADDR_UNSPECIFIED(from)) @@ -2084,6 +2080,8 @@ nd6_output_lle(struct ifnet *ifp, struct } return (error); } + /* Reset layer specific mbuf flags to avoid confusing lower layers. */ + m->m_flags &= ~(M_PROTOFLAGS); if ((ifp->if_flags & IFF_LOOPBACK) != 0) { return ((*ifp->if_output)(origifp, m, (struct sockaddr *)dst, NULL)); @@ -2252,7 +2250,6 @@ clear_llinfo_pqueue(struct llentry *ln) for (m_hold = ln->la_hold; m_hold; m_hold = m_hold_next) { m_hold_next = m_hold->m_nextpkt; - m_hold->m_nextpkt = NULL; m_freem(m_hold); } From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 8 12:34:12 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id AE53E106566C; Sun, 8 Jul 2012 12:34:12 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 98EDD8FC08; Sun, 8 Jul 2012 12:34:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q68CYCxp051724; Sun, 8 Jul 2012 12:34:12 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q68CYC98051722; Sun, 8 Jul 2012 12:34:12 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201207081234.q68CYC98051722@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Sun, 8 Jul 2012 12:34:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238242 - stable/9/sys/netinet6 X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jul 2012 12:34:12 -0000 Author: bz Date: Sun Jul 8 12:34:12 2012 New Revision: 238242 URL: http://svn.freebsd.org/changeset/base/238242 Log: MFC r235953: No need to hold the (expensive) rt lock over (expensive) logging. Approved by: re Modified: stable/9/sys/netinet6/icmp6.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet6/icmp6.c ============================================================================== --- stable/9/sys/netinet6/icmp6.c Sun Jul 8 12:30:25 2012 (r238241) +++ stable/9/sys/netinet6/icmp6.c Sun Jul 8 12:34:12 2012 (r238242) @@ -2418,23 +2418,23 @@ icmp6_redirect_input(struct mbuf *m, int if (rt) { if (rt->rt_gateway == NULL || rt->rt_gateway->sa_family != AF_INET6) { + RTFREE_LOCKED(rt); nd6log((LOG_ERR, "ICMP6 redirect rejected; no route " "with inet6 gateway found for redirect dst: %s\n", icmp6_redirect_diag(&src6, &reddst6, &redtgt6))); - RTFREE_LOCKED(rt); goto bad; } gw6 = &(((struct sockaddr_in6 *)rt->rt_gateway)->sin6_addr); if (bcmp(&src6, gw6, sizeof(struct in6_addr)) != 0) { + RTFREE_LOCKED(rt); nd6log((LOG_ERR, "ICMP6 redirect rejected; " "not equal to gw-for-src=%s (must be same): " "%s\n", ip6_sprintf(ip6buf, gw6), icmp6_redirect_diag(&src6, &reddst6, &redtgt6))); - RTFREE_LOCKED(rt); goto bad; } } else { From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 8 12:36:45 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9D7E51065670; Sun, 8 Jul 2012 12:36:45 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 87F9B8FC0A; Sun, 8 Jul 2012 12:36:45 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q68CajrA051881; Sun, 8 Jul 2012 12:36:45 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q68Cajb7051879; Sun, 8 Jul 2012 12:36:45 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201207081236.q68Cajb7051879@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Sun, 8 Jul 2012 12:36:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238243 - stable/9/sys/netinet X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jul 2012 12:36:45 -0000 Author: bz Date: Sun Jul 8 12:36:44 2012 New Revision: 238243 URL: http://svn.freebsd.org/changeset/base/238243 Log: MFC r235950: Factor out the tcp_hc_getmtu() call. As the comments say it applies to both v4 and v6, so only write it once making it easier to read the protocol family specifc code. Approved by: re Modified: stable/9/sys/netinet/tcp_input.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/tcp_input.c ============================================================================== --- stable/9/sys/netinet/tcp_input.c Sun Jul 8 12:34:12 2012 (r238242) +++ stable/9/sys/netinet/tcp_input.c Sun Jul 8 12:36:44 2012 (r238243) @@ -3594,7 +3594,6 @@ tcp_mssopt(struct in_conninfo *inc) if (inc->inc_flags & INC_ISIPV6) { mss = V_tcp_v6mssdflt; maxmtu = tcp_maxmtu6(inc, NULL); - thcmtu = tcp_hc_getmtu(inc); /* IPv4 and IPv6 */ min_protoh = sizeof(struct ip6_hdr) + sizeof(struct tcphdr); } #endif @@ -3605,10 +3604,13 @@ tcp_mssopt(struct in_conninfo *inc) { mss = V_tcp_mssdflt; maxmtu = tcp_maxmtu(inc, NULL); - thcmtu = tcp_hc_getmtu(inc); /* IPv4 and IPv6 */ min_protoh = sizeof(struct tcpiphdr); } #endif +#if defined(INET6) || defined(INET) + thcmtu = tcp_hc_getmtu(inc); /* IPv4 and IPv6 */ +#endif + if (maxmtu && thcmtu) mss = min(maxmtu, thcmtu) - min_protoh; else if (maxmtu || thcmtu) From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 8 12:39:02 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 974D51065672; Sun, 8 Jul 2012 12:39:02 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 82A4B8FC0A; Sun, 8 Jul 2012 12:39:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q68Cd2RP052019; Sun, 8 Jul 2012 12:39:02 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q68Cd2UO052017; Sun, 8 Jul 2012 12:39:02 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201207081239.q68Cd2UO052017@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Sun, 8 Jul 2012 12:39:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238244 - stable/9/sys/netinet X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jul 2012 12:39:02 -0000 Author: bz Date: Sun Jul 8 12:39:02 2012 New Revision: 238244 URL: http://svn.freebsd.org/changeset/base/238244 Log: MFC r236093: Trim the extra $FreeBSD$ from the comment below the license. We use the __FBSDID() macro on the file now instead. Approved by: re Modified: stable/9/sys/netinet/tcp_lro.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/tcp_lro.c ============================================================================== --- stable/9/sys/netinet/tcp_lro.c Sun Jul 8 12:36:44 2012 (r238243) +++ stable/9/sys/netinet/tcp_lro.c Sun Jul 8 12:39:02 2012 (r238244) @@ -27,8 +27,6 @@ * 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. - * - * $FreeBSD$ */ #include From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 8 14:21:37 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id ACD3B106566B; Sun, 8 Jul 2012 14:21:37 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 950018FC1C; Sun, 8 Jul 2012 14:21:37 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q68ELbGM056546; Sun, 8 Jul 2012 14:21:37 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q68ELbB3056531; Sun, 8 Jul 2012 14:21:37 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201207081421.q68ELbB3056531@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Sun, 8 Jul 2012 14:21:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238247 - in stable/9: sbin/ifconfig sys/net sys/netinet sys/netinet6 sys/sys X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jul 2012 14:21:37 -0000 Author: bz Date: Sun Jul 8 14:21:36 2012 New Revision: 238247 URL: http://svn.freebsd.org/changeset/base/238247 Log: MFC r236170,236176: It turns out that too many drivers are not only parsing the L2/3/4 headers for TSO but also for generic checksum offloading. Ideally we would only have one common function shared amongst all drivers, and perhaps when updating them for IPv6 we should introduce that. Eventually we should provide the meta information along with mbufs to avoid (re-)parsing entirely. To not break IPv6 (checksums and offload) and to be able to MFC the changes without risking to hurt 3rd party drivers, duplicate the v4 framework, as other OSes have done as well. Introduce interface capability flags for TX/RX checksum offload with IPv6, to allow independent toggling (where possible). Add CSUM_*_IPV6 flags for UDP/TCP over IPv6, and reserve further for SCTP, and IPv6 fragmentation. Define CSUM_DELAY_DATA_IPV6 as we do for legacy IP and add an alias for CSUM_DATA_VALID_IPV6. This pretty much brings IPv6 handling in line with IPv4. TSO is still handled in a different way and not via if_hwassist. Update ifconfig to allow (un)setting of the new capability flags. Update loopback to announce the new capabilities and if_hwassist flags. Individual driver updates will have to follow, as will SCTP. Removed the IFCAP_ prefix when printing the IPv6 checksum capabilities. Approved by: re Modified: stable/9/sbin/ifconfig/ifconfig.8 stable/9/sbin/ifconfig/ifconfig.c stable/9/sys/net/if.h stable/9/sys/net/if_loop.c stable/9/sys/netinet/tcp_input.c stable/9/sys/netinet/tcp_output.c stable/9/sys/netinet/tcp_subr.c stable/9/sys/netinet/tcp_syncache.c stable/9/sys/netinet/tcp_timewait.c stable/9/sys/netinet6/ip6_forward.c stable/9/sys/netinet6/ip6_ipsec.c stable/9/sys/netinet6/ip6_output.c stable/9/sys/netinet6/udp6_usrreq.c stable/9/sys/sys/mbuf.h Directory Properties: stable/9/sbin/ifconfig/ (props changed) stable/9/sys/ (props changed) Modified: stable/9/sbin/ifconfig/ifconfig.8 ============================================================================== --- stable/9/sbin/ifconfig/ifconfig.8 Sun Jul 8 14:06:26 2012 (r238246) +++ stable/9/sbin/ifconfig/ifconfig.8 Sun Jul 8 14:21:36 2012 (r238247) @@ -28,7 +28,7 @@ .\" From: @(#)ifconfig.8 8.3 (Berkeley) 1/5/94 .\" $FreeBSD$ .\" -.Dd May 19, 2012 +.Dd May 27, 2012 .Dt IFCONFIG 8 .Os .Sh NAME @@ -372,16 +372,32 @@ This is useful for devices which have mu .It Cm name Ar name Set the interface name to .Ar name . -.It Cm rxcsum , txcsum +.It Cm rxcsum , txcsum , rxcsum6 , txcsum6 If the driver supports user-configurable checksum offloading, enable receive (or transmit) checksum offloading on the interface. +The feature can be turned on selectively per protocol family. +Use +.Cm rxcsum6 , txcsum6 +for +.Xr ip6 4 +or +.Cm rxcsum , txcsum +otherwise. Some drivers may not be able to enable these flags independently of each other, so setting one may also set the other. The driver will offload as much checksum work as it can reliably support, the exact level of offloading varies between drivers. -.It Fl rxcsum , txcsum +.It Fl rxcsum , txcsum , rxcsum6 , txcsum6 If the driver supports user-configurable checksum offloading, disable receive (or transmit) checksum offloading on the interface. +The feature can be turned off selectively per protocol family. +Use +.Fl rxcsum6 , txcsum6 +for +.Xr ip6 4 +or +.Fl rxcsum , txcsum +otherwise. These settings may not always be independent of each other. .It Cm tso If the driver supports Modified: stable/9/sbin/ifconfig/ifconfig.c ============================================================================== --- stable/9/sbin/ifconfig/ifconfig.c Sun Jul 8 14:06:26 2012 (r238246) +++ stable/9/sbin/ifconfig/ifconfig.c Sun Jul 8 14:21:36 2012 (r238247) @@ -910,7 +910,8 @@ unsetifdescr(const char *val, int value, #define IFCAPBITS \ "\020\1RXCSUM\2TXCSUM\3NETCONS\4VLAN_MTU\5VLAN_HWTAGGING\6JUMBO_MTU\7POLLING" \ "\10VLAN_HWCSUM\11TSO4\12TSO6\13LRO\14WOL_UCAST\15WOL_MCAST\16WOL_MAGIC" \ -"\21VLAN_HWFILTER\23VLAN_HWTSO\24LINKSTATE\25NETMAP" +"\21VLAN_HWFILTER\23VLAN_HWTSO\24LINKSTATE\25NETMAP" \ +"\26RXCSUM_IPV6\27TXCSUM_IPV6" /* * Print the status of the interface. If an address family was @@ -1170,6 +1171,10 @@ static struct cmd basic_cmds[] = { DEF_CMD("-monitor", -IFF_MONITOR, setifflags), DEF_CMD("staticarp", IFF_STATICARP, setifflags), DEF_CMD("-staticarp", -IFF_STATICARP, setifflags), + DEF_CMD("rxcsum6", IFCAP_RXCSUM_IPV6, setifcap), + DEF_CMD("-rxcsum6", -IFCAP_RXCSUM_IPV6, setifcap), + DEF_CMD("txcsum6", IFCAP_TXCSUM_IPV6, setifcap), + DEF_CMD("-txcsum6", -IFCAP_TXCSUM_IPV6, setifcap), DEF_CMD("rxcsum", IFCAP_RXCSUM, setifcap), DEF_CMD("-rxcsum", -IFCAP_RXCSUM, setifcap), DEF_CMD("txcsum", IFCAP_TXCSUM, setifcap), Modified: stable/9/sys/net/if.h ============================================================================== --- stable/9/sys/net/if.h Sun Jul 8 14:06:26 2012 (r238246) +++ stable/9/sys/net/if.h Sun Jul 8 14:21:36 2012 (r238247) @@ -230,6 +230,10 @@ struct if_data { #define IFCAP_VLAN_HWTSO 0x40000 /* can do IFCAP_TSO on VLANs */ #define IFCAP_LINKSTATE 0x80000 /* the runtime link state is dynamic */ #define IFCAP_NETMAP 0x100000 /* netmap mode supported/enabled */ +#define IFCAP_RXCSUM_IPV6 0x200000 /* can offload checksum on IPv6 RX */ +#define IFCAP_TXCSUM_IPV6 0x400000 /* can offload checksum on IPv6 TX */ + +#define IFCAP_HWCSUM_IPV6 (IFCAP_RXCSUM_IPV6 | IFCAP_TXCSUM_IPV6) #define IFCAP_HWCSUM (IFCAP_RXCSUM | IFCAP_TXCSUM) #define IFCAP_TSO (IFCAP_TSO4 | IFCAP_TSO6) Modified: stable/9/sys/net/if_loop.c ============================================================================== --- stable/9/sys/net/if_loop.c Sun Jul 8 14:06:26 2012 (r238246) +++ stable/9/sys/net/if_loop.c Sun Jul 8 14:21:36 2012 (r238247) @@ -92,7 +92,9 @@ #endif #define LO_CSUM_FEATURES (CSUM_IP | CSUM_TCP | CSUM_UDP | CSUM_SCTP) -#define LO_CSUM_SET (CSUM_DATA_VALID | CSUM_PSEUDO_HDR | \ +#define LO_CSUM_FEATURES6 (CSUM_TCP_IPV6 | CSUM_UDP_IPV6 | CSUM_SCTP) +#define LO_CSUM_SET (CSUM_DATA_VALID | CSUM_DATA_VALID_IPV6 | \ + CSUM_PSEUDO_HDR | \ CSUM_IP_CHECKED | CSUM_IP_VALID | \ CSUM_SCTP_VALID) @@ -143,8 +145,9 @@ lo_clone_create(struct if_clone *ifc, in ifp->if_ioctl = loioctl; ifp->if_output = looutput; ifp->if_snd.ifq_maxlen = ifqmaxlen; - ifp->if_capabilities = ifp->if_capenable = IFCAP_HWCSUM; - ifp->if_hwassist = LO_CSUM_FEATURES; + ifp->if_capabilities = ifp->if_capenable = + IFCAP_HWCSUM | IFCAP_HWCSUM_IPV6; + ifp->if_hwassist = LO_CSUM_FEATURES | LO_CSUM_FEATURES6; if_attach(ifp); bpfattach(ifp, DLT_NULL, sizeof(u_int32_t)); if (V_loif == NULL) @@ -247,12 +250,19 @@ looutput(struct ifnet *ifp, struct mbuf #if 1 /* XXX */ switch (dst->sa_family) { case AF_INET: - case AF_INET6: if (ifp->if_capenable & IFCAP_RXCSUM) { m->m_pkthdr.csum_data = 0xffff; m->m_pkthdr.csum_flags = LO_CSUM_SET; } m->m_pkthdr.csum_flags &= ~LO_CSUM_FEATURES; + break; + case AF_INET6: + if (ifp->if_capenable & IFCAP_RXCSUM_IPV6) { + m->m_pkthdr.csum_data = 0xffff; + m->m_pkthdr.csum_flags = LO_CSUM_SET; + } + m->m_pkthdr.csum_flags &= ~LO_CSUM_FEATURES6; + break; case AF_IPX: case AF_APPLETALK: break; @@ -436,10 +446,15 @@ loioctl(struct ifnet *ifp, u_long cmd, c ifp->if_capenable ^= IFCAP_RXCSUM; if ((mask & IFCAP_TXCSUM) != 0) ifp->if_capenable ^= IFCAP_TXCSUM; + if ((mask & IFCAP_RXCSUM_IPV6) != 0) + ifp->if_capenable ^= IFCAP_RXCSUM_IPV6; + if ((mask & IFCAP_TXCSUM_IPV6) != 0) + ifp->if_capenable ^= IFCAP_TXCSUM_IPV6; + ifp->if_hwassist = 0; if (ifp->if_capenable & IFCAP_TXCSUM) ifp->if_hwassist = LO_CSUM_FEATURES; - else - ifp->if_hwassist = 0; + if (ifp->if_capenable & IFCAP_TXCSUM_IPV6) + ifp->if_hwassist |= LO_CSUM_FEATURES6; break; default: Modified: stable/9/sys/netinet/tcp_input.c ============================================================================== --- stable/9/sys/netinet/tcp_input.c Sun Jul 8 14:06:26 2012 (r238246) +++ stable/9/sys/netinet/tcp_input.c Sun Jul 8 14:21:36 2012 (r238247) @@ -622,7 +622,7 @@ tcp_input(struct mbuf *m, int off0) ip6 = mtod(m, struct ip6_hdr *); th = (struct tcphdr *)((caddr_t)ip6 + off0); tlen = sizeof(*ip6) + ntohs(ip6->ip6_plen) - off0; - if (m->m_pkthdr.csum_flags & CSUM_DATA_VALID) { + if (m->m_pkthdr.csum_flags & CSUM_DATA_VALID_IPV6) { if (m->m_pkthdr.csum_flags & CSUM_PSEUDO_HDR) th->th_sum = m->m_pkthdr.csum_data; else Modified: stable/9/sys/netinet/tcp_output.c ============================================================================== --- stable/9/sys/netinet/tcp_output.c Sun Jul 8 14:06:26 2012 (r238246) +++ stable/9/sys/netinet/tcp_output.c Sun Jul 8 14:21:36 2012 (r238247) @@ -1052,7 +1052,6 @@ send: * checksum extended header and data. */ m->m_pkthdr.len = hdrlen + len; /* in6_cksum() need this */ - m->m_pkthdr.csum_flags = CSUM_TCP; m->m_pkthdr.csum_data = offsetof(struct tcphdr, th_sum); #ifdef INET6 if (isipv6) { @@ -1060,6 +1059,7 @@ send: * ip6_plen is not need to be filled now, and will be filled * in ip6_output. */ + m->m_pkthdr.csum_flags = CSUM_TCP_IPV6; th->th_sum = in6_cksum_pseudo(ip6, sizeof(struct tcphdr) + optlen + len, IPPROTO_TCP, 0); } @@ -1069,6 +1069,7 @@ send: #endif #ifdef INET { + m->m_pkthdr.csum_flags = CSUM_TCP; th->th_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr, htons(sizeof(struct tcphdr) + IPPROTO_TCP + len + optlen)); Modified: stable/9/sys/netinet/tcp_subr.c ============================================================================== --- stable/9/sys/netinet/tcp_subr.c Sun Jul 8 14:06:26 2012 (r238246) +++ stable/9/sys/netinet/tcp_subr.c Sun Jul 8 14:21:36 2012 (r238247) @@ -619,10 +619,10 @@ tcp_respond(struct tcpcb *tp, void *ipge nth->th_win = htons((u_short)win); nth->th_urp = 0; - m->m_pkthdr.csum_flags = CSUM_TCP; m->m_pkthdr.csum_data = offsetof(struct tcphdr, th_sum); #ifdef INET6 if (isipv6) { + m->m_pkthdr.csum_flags = CSUM_TCP_IPV6; nth->th_sum = in6_cksum_pseudo(ip6, tlen - sizeof(struct ip6_hdr), IPPROTO_TCP, 0); ip6->ip6_hlim = in6_selecthlim(tp != NULL ? tp->t_inpcb : @@ -634,6 +634,7 @@ tcp_respond(struct tcpcb *tp, void *ipge #endif #ifdef INET { + m->m_pkthdr.csum_flags = CSUM_TCP; nth->th_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr, htons((u_short)(tlen - sizeof(struct ip) + ip->ip_p))); } Modified: stable/9/sys/netinet/tcp_syncache.c ============================================================================== --- stable/9/sys/netinet/tcp_syncache.c Sun Jul 8 14:06:26 2012 (r238246) +++ stable/9/sys/netinet/tcp_syncache.c Sun Jul 8 14:21:36 2012 (r238247) @@ -1472,10 +1472,10 @@ syncache_respond(struct syncache *sc) optlen = 0; M_SETFIB(m, sc->sc_inc.inc_fibnum); - m->m_pkthdr.csum_flags = CSUM_TCP; m->m_pkthdr.csum_data = offsetof(struct tcphdr, th_sum); #ifdef INET6 if (sc->sc_inc.inc_flags & INC_ISIPV6) { + m->m_pkthdr.csum_flags = CSUM_TCP_IPV6; th->th_sum = in6_cksum_pseudo(ip6, tlen + optlen - hlen, IPPROTO_TCP, 0); ip6->ip6_hlim = in6_selecthlim(NULL, NULL); @@ -1487,6 +1487,7 @@ syncache_respond(struct syncache *sc) #endif #ifdef INET { + m->m_pkthdr.csum_flags = CSUM_TCP; th->th_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr, htons(tlen + optlen - hlen + IPPROTO_TCP)); error = ip_output(m, sc->sc_ipopts, NULL, 0, NULL, NULL); Modified: stable/9/sys/netinet/tcp_timewait.c ============================================================================== --- stable/9/sys/netinet/tcp_timewait.c Sun Jul 8 14:06:26 2012 (r238246) +++ stable/9/sys/netinet/tcp_timewait.c Sun Jul 8 14:21:36 2012 (r238247) @@ -574,10 +574,10 @@ tcp_twrespond(struct tcptw *tw, int flag th->th_flags = flags; th->th_win = htons(tw->last_win); - m->m_pkthdr.csum_flags = CSUM_TCP; m->m_pkthdr.csum_data = offsetof(struct tcphdr, th_sum); #ifdef INET6 if (isipv6) { + m->m_pkthdr.csum_flags = CSUM_TCP_IPV6; th->th_sum = in6_cksum_pseudo(ip6, sizeof(struct tcphdr) + optlen, IPPROTO_TCP, 0); ip6->ip6_hlim = in6_selecthlim(inp, NULL); @@ -590,6 +590,7 @@ tcp_twrespond(struct tcptw *tw, int flag #endif #ifdef INET { + m->m_pkthdr.csum_flags = CSUM_TCP; th->th_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr, htons(sizeof(struct tcphdr) + optlen + IPPROTO_TCP)); ip->ip_len = m->m_pkthdr.len; Modified: stable/9/sys/netinet6/ip6_forward.c ============================================================================== --- stable/9/sys/netinet6/ip6_forward.c Sun Jul 8 14:06:26 2012 (r238246) +++ stable/9/sys/netinet6/ip6_forward.c Sun Jul 8 14:21:36 2012 (r238247) @@ -581,9 +581,9 @@ skip_routing: m->m_flags |= M_FASTFWD_OURS; if (m->m_pkthdr.rcvif == NULL) m->m_pkthdr.rcvif = V_loif; - if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) { + if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA_IPV6) { m->m_pkthdr.csum_flags |= - CSUM_DATA_VALID | CSUM_PSEUDO_HDR; + CSUM_DATA_VALID_IPV6 | CSUM_PSEUDO_HDR; m->m_pkthdr.csum_data = 0xffff; } #ifdef SCTP @@ -601,9 +601,9 @@ skip_routing: if (m->m_flags & M_FASTFWD_OURS) { if (m->m_pkthdr.rcvif == NULL) m->m_pkthdr.rcvif = V_loif; - if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) { + if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA_IPV6) { m->m_pkthdr.csum_flags |= - CSUM_DATA_VALID | CSUM_PSEUDO_HDR; + CSUM_DATA_VALID_IPV6 | CSUM_PSEUDO_HDR; m->m_pkthdr.csum_data = 0xffff; } #ifdef SCTP Modified: stable/9/sys/netinet6/ip6_ipsec.c ============================================================================== --- stable/9/sys/netinet6/ip6_ipsec.c Sun Jul 8 14:06:26 2012 (r238246) +++ stable/9/sys/netinet6/ip6_ipsec.c Sun Jul 8 14:21:36 2012 (r238247) @@ -291,6 +291,7 @@ ip6_ipsec_output(struct mbuf **m, struct /* * Do delayed checksums now because we send before * this is done in the normal processing path. + * XXX-BZ CSUM_DELAY_DATA_IPV6? */ if ((*m)->m_pkthdr.csum_flags & CSUM_DELAY_DATA) { ipseclog((LOG_DEBUG, Modified: stable/9/sys/netinet6/ip6_output.c ============================================================================== --- stable/9/sys/netinet6/ip6_output.c Sun Jul 8 14:06:26 2012 (r238246) +++ stable/9/sys/netinet6/ip6_output.c Sun Jul 8 14:21:36 2012 (r238247) @@ -190,7 +190,7 @@ in6_delayed_cksum(struct mbuf *m, uint32 u_short csum; csum = in_cksum_skip(m, offset + plen, offset); - if (m->m_pkthdr.csum_flags & CSUM_UDP && csum == 0) + if (m->m_pkthdr.csum_flags & CSUM_UDP_IPV6 && csum == 0) csum = 0xffff; offset += m->m_pkthdr.csum_data; /* checksum offset */ @@ -885,9 +885,9 @@ again: m->m_flags |= M_FASTFWD_OURS; if (m->m_pkthdr.rcvif == NULL) m->m_pkthdr.rcvif = V_loif; - if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) { + if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA_IPV6) { m->m_pkthdr.csum_flags |= - CSUM_DATA_VALID | CSUM_PSEUDO_HDR; + CSUM_DATA_VALID_IPV6 | CSUM_PSEUDO_HDR; m->m_pkthdr.csum_data = 0xffff; } #ifdef SCTP @@ -905,9 +905,9 @@ again: if (m->m_flags & M_FASTFWD_OURS) { if (m->m_pkthdr.rcvif == NULL) m->m_pkthdr.rcvif = V_loif; - if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) { + if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA_IPV6) { m->m_pkthdr.csum_flags |= - CSUM_DATA_VALID | CSUM_PSEUDO_HDR; + CSUM_DATA_VALID_IPV6 | CSUM_PSEUDO_HDR; m->m_pkthdr.csum_data = 0xffff; } #ifdef SCTP @@ -960,8 +960,8 @@ passout: * XXX-BZ Need a framework to know when the NIC can handle it, even * with ext. hdrs. */ - if (sw_csum & CSUM_DELAY_DATA) { - sw_csum &= ~CSUM_DELAY_DATA; + if (sw_csum & CSUM_DELAY_DATA_IPV6) { + sw_csum &= ~CSUM_DELAY_DATA_IPV6; in6_delayed_cksum(m, plen, sizeof(struct ip6_hdr)); } #ifdef SCTP @@ -1076,9 +1076,9 @@ passout: * fragmented packets, then do it here. * XXX-BZ handle the hw offloading case. Need flags. */ - if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) { + if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA_IPV6) { in6_delayed_cksum(m, plen, hlen); - m->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA; + m->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA_IPV6; } #ifdef SCTP if (m->m_pkthdr.csum_flags & CSUM_SCTP) { Modified: stable/9/sys/netinet6/udp6_usrreq.c ============================================================================== --- stable/9/sys/netinet6/udp6_usrreq.c Sun Jul 8 14:06:26 2012 (r238246) +++ stable/9/sys/netinet6/udp6_usrreq.c Sun Jul 8 14:21:36 2012 (r238247) @@ -230,7 +230,7 @@ udp6_input(struct mbuf **mp, int *offp, goto badunlocked; } - if (m->m_pkthdr.csum_flags & CSUM_DATA_VALID) { + if (m->m_pkthdr.csum_flags & CSUM_DATA_VALID_IPV6) { if (m->m_pkthdr.csum_flags & CSUM_PSEUDO_HDR) uh_sum = m->m_pkthdr.csum_data; else @@ -784,7 +784,7 @@ udp6_output(struct inpcb *inp, struct mb ip6->ip6_dst = *faddr; udp6->uh_sum = in6_cksum_pseudo(ip6, plen, IPPROTO_UDP, 0); - m->m_pkthdr.csum_flags = CSUM_UDP; + m->m_pkthdr.csum_flags = CSUM_UDP_IPV6; m->m_pkthdr.csum_data = offsetof(struct udphdr, uh_sum); flags = 0; Modified: stable/9/sys/sys/mbuf.h ============================================================================== --- stable/9/sys/sys/mbuf.h Sun Jul 8 14:06:26 2012 (r238246) +++ stable/9/sys/sys/mbuf.h Sun Jul 8 14:21:36 2012 (r238247) @@ -283,15 +283,24 @@ struct mbuf { #define CSUM_FRAGMENT 0x0010 /* will do IP fragmentation */ #define CSUM_TSO 0x0020 /* will do TSO */ #define CSUM_SCTP 0x0040 /* will csum SCTP */ +/* CSUM_SCTP_IPV6 0x0080 will csum IPv6/SCTP */ #define CSUM_IP_CHECKED 0x0100 /* did csum IP */ #define CSUM_IP_VALID 0x0200 /* ... the csum is valid */ #define CSUM_DATA_VALID 0x0400 /* csum_data field is valid */ #define CSUM_PSEUDO_HDR 0x0800 /* csum_data has pseudo hdr */ #define CSUM_SCTP_VALID 0x1000 /* SCTP checksum is valid */ +#define CSUM_UDP_IPV6 0x2000 /* will csum IPv6/UDP */ +#define CSUM_TCP_IPV6 0x4000 /* will csum IPv6/TCP */ +/* CSUM_TSO_IPV6 0x8000 will do IPv6/TSO */ + +/* CSUM_FRAGMENT_IPV6 0x10000 will do IPv6 fragementation */ + +#define CSUM_DELAY_DATA_IPV6 (CSUM_TCP_IPV6 | CSUM_UDP_IPV6) +#define CSUM_DATA_VALID_IPV6 CSUM_DATA_VALID #define CSUM_DELAY_DATA (CSUM_TCP | CSUM_UDP) -#define CSUM_DELAY_IP (CSUM_IP) /* XXX add ipv6 here too? */ +#define CSUM_DELAY_IP (CSUM_IP) /* Only v4, no v6 IP hdr csum */ /* * mbuf types. From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 8 15:37:58 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D66C9106564A; Sun, 8 Jul 2012 15:37:58 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B69B18FC0A; Sun, 8 Jul 2012 15:37:58 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q68Fbweh059787; Sun, 8 Jul 2012 15:37:58 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q68FbwWQ059782; Sun, 8 Jul 2012 15:37:58 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201207081537.q68FbwWQ059782@svn.freebsd.org> From: Michael Tuexen Date: Sun, 8 Jul 2012 15:37:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238249 - in stable/9/sys: netinet netinet6 X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jul 2012 15:37:59 -0000 Author: tuexen Date: Sun Jul 8 15:37:58 2012 New Revision: 238249 URL: http://svn.freebsd.org/changeset/base/238249 Log: MFC r236087: Get rid of SCTP specific code to avoid CRC32C computations on loopback. Just use offloading. Approved by: re Modified: stable/9/sys/netinet/sctp_output.c stable/9/sys/netinet/sctp_sysctl.c stable/9/sys/netinet/sctp_sysctl.h stable/9/sys/netinet6/sctp6_usrreq.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp_output.c ============================================================================== --- stable/9/sys/netinet/sctp_output.c Sun Jul 8 15:30:24 2012 (r238248) +++ stable/9/sys/netinet/sctp_output.c Sun Jul 8 15:37:58 2012 (r238249) @@ -4116,14 +4116,8 @@ sctp_lowlevel_chunk_output(struct sctp_i #if defined(SCTP_WITH_NO_CSUM) SCTP_STAT_INCR(sctps_sendnocrc); #else - if (!(SCTP_BASE_SYSCTL(sctp_no_csum_on_loopback) && - (stcb) && - (stcb->asoc.loopback_scope))) { - sctphdr->checksum = sctp_calculate_cksum(m, sizeof(struct ip) + sizeof(struct udphdr)); - SCTP_STAT_INCR(sctps_sendswcrc); - } else { - SCTP_STAT_INCR(sctps_sendnocrc); - } + sctphdr->checksum = sctp_calculate_cksum(m, sizeof(struct ip) + sizeof(struct udphdr)); + SCTP_STAT_INCR(sctps_sendswcrc); #endif if (V_udp_cksum) { SCTP_ENABLE_UDP_CSUM(o_pak); @@ -4474,14 +4468,8 @@ sctp_lowlevel_chunk_output(struct sctp_i #if defined(SCTP_WITH_NO_CSUM) SCTP_STAT_INCR(sctps_sendnocrc); #else - if (!(SCTP_BASE_SYSCTL(sctp_no_csum_on_loopback) && - (stcb) && - (stcb->asoc.loopback_scope))) { - sctphdr->checksum = sctp_calculate_cksum(m, sizeof(struct ip6_hdr) + sizeof(struct udphdr)); - SCTP_STAT_INCR(sctps_sendswcrc); - } else { - SCTP_STAT_INCR(sctps_sendnocrc); - } + sctphdr->checksum = sctp_calculate_cksum(m, sizeof(struct ip6_hdr) + sizeof(struct udphdr)); + SCTP_STAT_INCR(sctps_sendswcrc); #endif if ((udp->uh_sum = in6_cksum(o_pak, IPPROTO_UDP, sizeof(struct ip6_hdr), packet_length - sizeof(struct ip6_hdr))) == 0) { udp->uh_sum = 0xffff; Modified: stable/9/sys/netinet/sctp_sysctl.c ============================================================================== --- stable/9/sys/netinet/sctp_sysctl.c Sun Jul 8 15:30:24 2012 (r238248) +++ stable/9/sys/netinet/sctp_sysctl.c Sun Jul 8 15:37:58 2012 (r238249) @@ -55,9 +55,6 @@ sctp_init_sysctls() SCTP_BASE_SYSCTL(sctp_multiple_asconfs) = SCTPCTL_MULTIPLEASCONFS_DEFAULT; SCTP_BASE_SYSCTL(sctp_ecn_enable) = SCTPCTL_ECN_ENABLE_DEFAULT; SCTP_BASE_SYSCTL(sctp_strict_sacks) = SCTPCTL_STRICT_SACKS_DEFAULT; -#if !defined(SCTP_WITH_NO_CSUM) - SCTP_BASE_SYSCTL(sctp_no_csum_on_loopback) = SCTPCTL_LOOPBACK_NOCSUM_DEFAULT; -#endif SCTP_BASE_SYSCTL(sctp_peer_chunk_oh) = SCTPCTL_PEER_CHKOH_DEFAULT; SCTP_BASE_SYSCTL(sctp_max_burst_default) = SCTPCTL_MAXBURST_DEFAULT; SCTP_BASE_SYSCTL(sctp_fr_max_burst_default) = SCTPCTL_FRMAXBURST_DEFAULT; @@ -604,9 +601,6 @@ sysctl_sctp_check(SYSCTL_HANDLER_ARGS) RANGECHK(SCTP_BASE_SYSCTL(sctp_auto_asconf), SCTPCTL_AUTOASCONF_MIN, SCTPCTL_AUTOASCONF_MAX); RANGECHK(SCTP_BASE_SYSCTL(sctp_ecn_enable), SCTPCTL_ECN_ENABLE_MIN, SCTPCTL_ECN_ENABLE_MAX); RANGECHK(SCTP_BASE_SYSCTL(sctp_strict_sacks), SCTPCTL_STRICT_SACKS_MIN, SCTPCTL_STRICT_SACKS_MAX); -#if !defined(SCTP_WITH_NO_CSUM) - RANGECHK(SCTP_BASE_SYSCTL(sctp_no_csum_on_loopback), SCTPCTL_LOOPBACK_NOCSUM_MIN, SCTPCTL_LOOPBACK_NOCSUM_MAX); -#endif RANGECHK(SCTP_BASE_SYSCTL(sctp_peer_chunk_oh), SCTPCTL_PEER_CHKOH_MIN, SCTPCTL_PEER_CHKOH_MAX); RANGECHK(SCTP_BASE_SYSCTL(sctp_max_burst_default), SCTPCTL_MAXBURST_MIN, SCTPCTL_MAXBURST_MAX); RANGECHK(SCTP_BASE_SYSCTL(sctp_fr_max_burst_default), SCTPCTL_FRMAXBURST_MIN, SCTPCTL_FRMAXBURST_MAX); @@ -870,11 +864,6 @@ SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUT &SCTP_BASE_SYSCTL(sctp_strict_sacks), 0, sysctl_sctp_check, "IU", SCTPCTL_STRICT_SACKS_DESC); -#if !defined(SCTP_WITH_NO_CSUM) -SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, loopback_nocsum, CTLTYPE_UINT | CTLFLAG_RW, - &SCTP_BASE_SYSCTL(sctp_no_csum_on_loopback), 0, sysctl_sctp_check, "IU", - SCTPCTL_LOOPBACK_NOCSUM_DESC); -#endif SYSCTL_VNET_PROC(_net_inet_sctp, OID_AUTO, peer_chkoh, CTLTYPE_UINT | CTLFLAG_RW, &SCTP_BASE_SYSCTL(sctp_peer_chunk_oh), 0, sysctl_sctp_check, "IU", Modified: stable/9/sys/netinet/sctp_sysctl.h ============================================================================== --- stable/9/sys/netinet/sctp_sysctl.h Sun Jul 8 15:30:24 2012 (r238248) +++ stable/9/sys/netinet/sctp_sysctl.h Sun Jul 8 15:37:58 2012 (r238249) @@ -47,9 +47,6 @@ struct sctp_sysctl { uint32_t sctp_ecn_enable; uint32_t sctp_fr_max_burst_default; uint32_t sctp_strict_sacks; -#if !defined(SCTP_WITH_NO_CSUM) - uint32_t sctp_no_csum_on_loopback; -#endif uint32_t sctp_peer_chunk_oh; uint32_t sctp_max_burst_default; uint32_t sctp_max_chunks_on_queue; Modified: stable/9/sys/netinet6/sctp6_usrreq.c ============================================================================== --- stable/9/sys/netinet6/sctp6_usrreq.c Sun Jul 8 15:30:24 2012 (r238248) +++ stable/9/sys/netinet6/sctp6_usrreq.c Sun Jul 8 15:37:58 2012 (r238249) @@ -150,11 +150,6 @@ sctp6_input(struct mbuf **i_pak, int *of goto sctp_skip_csum; } check = sh->checksum; /* save incoming checksum */ - if ((check == 0) && (SCTP_BASE_SYSCTL(sctp_no_csum_on_loopback)) && - (IN6_ARE_ADDR_EQUAL(&ip6->ip6_src, &ip6->ip6_dst))) { - SCTP_STAT_INCR(sctps_recvnocrc); - goto sctp_skip_csum; - } sh->checksum = 0; /* prepare for calc */ calc_check = sctp_calculate_cksum(m, iphlen); SCTP_STAT_INCR(sctps_recvswcrc); From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 8 16:00:46 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 89BA11065672; Sun, 8 Jul 2012 16:00:46 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 727E38FC08; Sun, 8 Jul 2012 16:00:46 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q68G0kmV060791; Sun, 8 Jul 2012 16:00:46 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q68G0kUl060785; Sun, 8 Jul 2012 16:00:46 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201207081600.q68G0kUl060785@svn.freebsd.org> From: Michael Tuexen Date: Sun, 8 Jul 2012 16:00:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238250 - in stable/9/sys: net netinet netinet6 sys X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jul 2012 16:00:46 -0000 Author: tuexen Date: Sun Jul 8 16:00:45 2012 New Revision: 238250 URL: http://svn.freebsd.org/changeset/base/238250 Log: MFC r236332: Seperate SCTP checksum offloading for IPv4 and IPv6. While there: remove some trainling whitespaces. Approved by: re@ Modified: stable/9/sys/net/if_loop.c stable/9/sys/netinet/sctp_output.c stable/9/sys/netinet6/ip6_forward.c stable/9/sys/netinet6/ip6_output.c stable/9/sys/sys/mbuf.h Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/net/if_loop.c ============================================================================== --- stable/9/sys/net/if_loop.c Sun Jul 8 15:37:58 2012 (r238249) +++ stable/9/sys/net/if_loop.c Sun Jul 8 16:00:45 2012 (r238250) @@ -92,7 +92,7 @@ #endif #define LO_CSUM_FEATURES (CSUM_IP | CSUM_TCP | CSUM_UDP | CSUM_SCTP) -#define LO_CSUM_FEATURES6 (CSUM_TCP_IPV6 | CSUM_UDP_IPV6 | CSUM_SCTP) +#define LO_CSUM_FEATURES6 (CSUM_TCP_IPV6 | CSUM_UDP_IPV6 | CSUM_SCTP_IPV6) #define LO_CSUM_SET (CSUM_DATA_VALID | CSUM_DATA_VALID_IPV6 | \ CSUM_PSEUDO_HDR | \ CSUM_IP_CHECKED | CSUM_IP_VALID | \ Modified: stable/9/sys/netinet/sctp_output.c ============================================================================== --- stable/9/sys/netinet/sctp_output.c Sun Jul 8 15:37:58 2012 (r238249) +++ stable/9/sys/netinet/sctp_output.c Sun Jul 8 16:00:45 2012 (r238250) @@ -4478,7 +4478,7 @@ sctp_lowlevel_chunk_output(struct sctp_i #if defined(SCTP_WITH_NO_CSUM) SCTP_STAT_INCR(sctps_sendnocrc); #else - m->m_pkthdr.csum_flags = CSUM_SCTP; + m->m_pkthdr.csum_flags = CSUM_SCTP_IPV6; m->m_pkthdr.csum_data = 0; SCTP_STAT_INCR(sctps_sendhwcrc); #endif @@ -11069,7 +11069,7 @@ sctp_send_shutdown_complete2(struct mbuf #if defined(SCTP_WITH_NO_CSUM) SCTP_STAT_INCR(sctps_sendnocrc); #else - mout->m_pkthdr.csum_flags = CSUM_SCTP; + mout->m_pkthdr.csum_flags = CSUM_SCTP_IPV6; mout->m_pkthdr.csum_data = 0; SCTP_STAT_INCR(sctps_sendhwcrc); #endif @@ -12168,7 +12168,7 @@ sctp_send_abort(struct mbuf *m, int iphl #if defined(SCTP_WITH_NO_CSUM) SCTP_STAT_INCR(sctps_sendnocrc); #else - mout->m_pkthdr.csum_flags = CSUM_SCTP; + mout->m_pkthdr.csum_flags = CSUM_SCTP_IPV6; mout->m_pkthdr.csum_data = 0; SCTP_STAT_INCR(sctps_sendhwcrc); #endif @@ -12424,7 +12424,7 @@ sctp_send_operr_to(struct mbuf *m, int i #if defined(SCTP_WITH_NO_CSUM) SCTP_STAT_INCR(sctps_sendnocrc); #else - mout->m_pkthdr.csum_flags = CSUM_SCTP; + mout->m_pkthdr.csum_flags = CSUM_SCTP_IPV6; mout->m_pkthdr.csum_data = 0; SCTP_STAT_INCR(sctps_sendhwcrc); #endif Modified: stable/9/sys/netinet6/ip6_forward.c ============================================================================== --- stable/9/sys/netinet6/ip6_forward.c Sun Jul 8 15:37:58 2012 (r238249) +++ stable/9/sys/netinet6/ip6_forward.c Sun Jul 8 16:00:45 2012 (r238250) @@ -587,7 +587,7 @@ skip_routing: m->m_pkthdr.csum_data = 0xffff; } #ifdef SCTP - if (m->m_pkthdr.csum_flags & CSUM_SCTP) + if (m->m_pkthdr.csum_flags & CSUM_SCTP_IPV6) m->m_pkthdr.csum_flags |= CSUM_SCTP_VALID; #endif error = netisr_queue(NETISR_IPV6, m); @@ -607,9 +607,9 @@ skip_routing: m->m_pkthdr.csum_data = 0xffff; } #ifdef SCTP - if (m->m_pkthdr.csum_flags & CSUM_SCTP) - m->m_pkthdr.csum_flags |= CSUM_SCTP_VALID; -#endif + if (m->m_pkthdr.csum_flags & CSUM_SCTP_IPV6) + m->m_pkthdr.csum_flags |= CSUM_SCTP_VALID; +#endif error = netisr_queue(NETISR_IPV6, m); goto out; } Modified: stable/9/sys/netinet6/ip6_output.c ============================================================================== --- stable/9/sys/netinet6/ip6_output.c Sun Jul 8 15:37:58 2012 (r238249) +++ stable/9/sys/netinet6/ip6_output.c Sun Jul 8 16:00:45 2012 (r238250) @@ -508,7 +508,7 @@ skip_ipsec2:; #ifdef FLOWTABLE if (ro == &ip6route) { struct flentry *fle; - + /* * The flow table returns route entries valid for up to 30 * seconds; we rely on the remainder of ip_output() taking no @@ -521,7 +521,7 @@ skip_ipsec2:; flevalid = 1; } } -#endif +#endif again: /* * if specified, try to fill in the traffic class field. @@ -667,7 +667,7 @@ again: /* * The outgoing interface must be in the zone of source and - * destination addresses. + * destination addresses. */ origifp = ifp; @@ -693,7 +693,7 @@ again: goto badscope; } - /* We should use ia_ifp to support the case of + /* We should use ia_ifp to support the case of * sending packets to an address of our own. */ if (ia != NULL && ia->ia_ifp) @@ -891,7 +891,7 @@ again: m->m_pkthdr.csum_data = 0xffff; } #ifdef SCTP - if (m->m_pkthdr.csum_flags & CSUM_SCTP) + if (m->m_pkthdr.csum_flags & CSUM_SCTP_IPV6) m->m_pkthdr.csum_flags |= CSUM_SCTP_VALID; #endif error = netisr_queue(NETISR_IPV6, m); @@ -911,9 +911,9 @@ again: m->m_pkthdr.csum_data = 0xffff; } #ifdef SCTP - if (m->m_pkthdr.csum_flags & CSUM_SCTP) + if (m->m_pkthdr.csum_flags & CSUM_SCTP_IPV6) m->m_pkthdr.csum_flags |= CSUM_SCTP_VALID; -#endif +#endif error = netisr_queue(NETISR_IPV6, m); goto done; } @@ -965,8 +965,8 @@ passout: in6_delayed_cksum(m, plen, sizeof(struct ip6_hdr)); } #ifdef SCTP - if (sw_csum & CSUM_SCTP) { - sw_csum &= ~CSUM_SCTP; + if (sw_csum & CSUM_SCTP_IPV6) { + sw_csum &= ~CSUM_SCTP_IPV6; sctp_delayed_cksum(m, sizeof(struct ip6_hdr)); } #endif @@ -1081,9 +1081,9 @@ passout: m->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA_IPV6; } #ifdef SCTP - if (m->m_pkthdr.csum_flags & CSUM_SCTP) { + if (m->m_pkthdr.csum_flags & CSUM_SCTP_IPV6) { sctp_delayed_cksum(m, hlen); - m->m_pkthdr.csum_flags &= ~CSUM_SCTP; + m->m_pkthdr.csum_flags &= ~CSUM_SCTP_IPV6; } #endif mnext = &m->m_nextpkt; Modified: stable/9/sys/sys/mbuf.h ============================================================================== --- stable/9/sys/sys/mbuf.h Sun Jul 8 15:37:58 2012 (r238249) +++ stable/9/sys/sys/mbuf.h Sun Jul 8 16:00:45 2012 (r238250) @@ -115,7 +115,7 @@ struct pkthdr { /* variables for ip and tcp reassembly */ void *header; /* pointer to packet header */ int len; /* total packet length */ - uint32_t flowid; /* packet's 4-tuple system + uint32_t flowid; /* packet's 4-tuple system * flow identifier */ /* variables for hardware checksum */ @@ -283,7 +283,7 @@ struct mbuf { #define CSUM_FRAGMENT 0x0010 /* will do IP fragmentation */ #define CSUM_TSO 0x0020 /* will do TSO */ #define CSUM_SCTP 0x0040 /* will csum SCTP */ -/* CSUM_SCTP_IPV6 0x0080 will csum IPv6/SCTP */ +#define CSUM_SCTP_IPV6 0x0080 /* will csum IPv6/SCTP */ #define CSUM_IP_CHECKED 0x0100 /* did csum IP */ #define CSUM_IP_VALID 0x0200 /* ... the csum is valid */ @@ -425,7 +425,7 @@ static __inline int m_gettype(int size) { int type; - + switch (size) { case MSIZE: type = EXT_MBUF; @@ -455,7 +455,7 @@ static __inline uma_zone_t m_getzone(int size) { uma_zone_t zone; - + switch (size) { case MSIZE: zone = zone_mbuf; @@ -594,7 +594,7 @@ m_free_fast(struct mbuf *m) if (m->m_flags & M_PKTHDR) KASSERT(SLIST_EMPTY(&m->m_pkthdr.tags), ("doing fast free of mbuf with tags")); #endif - + uma_zfree_arg(zone_mbuf, m, (void *)MB_NOTAGS); } @@ -654,7 +654,7 @@ m_cljset(struct mbuf *m, void *cl, int t { uma_zone_t zone; int size; - + switch (type) { case EXT_CLUSTER: size = MCLBYTES; @@ -706,7 +706,7 @@ m_last(struct mbuf *m) extern void (*m_addr_chg_pf_p)(struct mbuf *m); -static __inline void +static __inline void m_addr_changed(struct mbuf *m) { @@ -1074,7 +1074,7 @@ m_tag_find(struct mbuf *m, int type, str #define M_SETFIB(_m, _fib) do { \ _m->m_flags &= ~M_FIB; \ _m->m_flags |= (((_fib) << M_FIBSHIFT) & M_FIB); \ -} while (0) +} while (0) #endif /* _KERNEL */ From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 8 16:11:17 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 44D45106564A; Sun, 8 Jul 2012 16:11:17 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2D4FF8FC0C; Sun, 8 Jul 2012 16:11:17 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q68GBH57061265; Sun, 8 Jul 2012 16:11:17 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q68GBHq1061261; Sun, 8 Jul 2012 16:11:17 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201207081611.q68GBHq1061261@svn.freebsd.org> From: Michael Tuexen Date: Sun, 8 Jul 2012 16:11:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238251 - stable/9/sys/netinet X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jul 2012 16:11:17 -0000 Author: tuexen Date: Sun Jul 8 16:11:16 2012 New Revision: 238251 URL: http://svn.freebsd.org/changeset/base/238251 Log: MFC r236956: Unify the sending of ABORT, SHUTDOWN-COMPLETE and ERROR chunks. While there: Fix also some minor bugs and prepare for SCTP/DTLS. Approved by: re@ Modified: stable/9/sys/netinet/sctp_input.c stable/9/sys/netinet/sctp_output.c stable/9/sys/netinet/sctp_output.h Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp_input.c ============================================================================== --- stable/9/sys/netinet/sctp_input.c Sun Jul 8 16:00:45 2012 (r238250) +++ stable/9/sys/netinet/sctp_input.c Sun Jul 8 16:11:16 2012 (r238251) @@ -1442,7 +1442,7 @@ sctp_process_cookie_existing(struct mbuf ph = mtod(op_err, struct sctp_paramhdr *); ph->param_type = htons(SCTP_CAUSE_COOKIE_IN_SHUTDOWN); ph->param_length = htons(sizeof(struct sctp_paramhdr)); - sctp_send_operr_to(m, iphlen, op_err, cookie->peers_vtag, + sctp_send_operr_to(m, sh, cookie->peers_vtag, op_err, vrf_id, net->port); if (how_indx < sizeof(asoc->cookie_how)) asoc->cookie_how[how_indx] = 2; @@ -2570,7 +2570,7 @@ sctp_handle_cookie_echo(struct mbuf *m, if (tim == 0) tim = now.tv_usec - cookie->time_entered.tv_usec; scm->time_usec = htonl(tim); - sctp_send_operr_to(m, iphlen, op_err, cookie->peers_vtag, + sctp_send_operr_to(m, sh, cookie->peers_vtag, op_err, vrf_id, port); return (NULL); } Modified: stable/9/sys/netinet/sctp_output.c ============================================================================== --- stable/9/sys/netinet/sctp_output.c Sun Jul 8 16:00:45 2012 (r238250) +++ stable/9/sys/netinet/sctp_output.c Sun Jul 8 16:11:16 2012 (r238251) @@ -4478,7 +4478,7 @@ sctp_lowlevel_chunk_output(struct sctp_i #if defined(SCTP_WITH_NO_CSUM) SCTP_STAT_INCR(sctps_sendnocrc); #else - m->m_pkthdr.csum_flags = CSUM_SCTP_IPV6; + m->m_pkthdr.csum_flags = CSUM_SCTP; m->m_pkthdr.csum_data = 0; SCTP_STAT_INCR(sctps_sendhwcrc); #endif @@ -10854,19 +10854,20 @@ sctp_send_shutdown_complete(struct sctp_ return; } -void -sctp_send_shutdown_complete2(struct mbuf *m, struct sctphdr *sh, - uint32_t vrf_id, uint16_t port) +static void +sctp_send_resp_msg(struct mbuf *m, struct sctphdr *sh, uint32_t vtag, + uint8_t type, struct mbuf *cause, uint32_t vrf_id, uint16_t port) { - /* formulate and SEND a SHUTDOWN-COMPLETE */ struct mbuf *o_pak; struct mbuf *mout; + struct sctphdr *shout; + struct sctp_chunkhdr *ch; struct ip *iph; - struct udphdr *udp = NULL; - int offset_out, len, mlen; - struct sctp_shutdown_complete_msg *comp_cp; + struct udphdr *udp; + int len, cause_len, padding_len, ret; #ifdef INET + sctp_route_t ro; struct ip *iph_out; #endif @@ -10875,31 +10876,59 @@ sctp_send_shutdown_complete2(struct mbuf #endif + /* Compute the length of the cause and add final padding. */ + cause_len = 0; + if (cause != NULL) { + struct mbuf *m_at, *m_last = NULL; + + for (m_at = cause; m_at; m_at = SCTP_BUF_NEXT(m_at)) { + if (SCTP_BUF_NEXT(m_at) == NULL) + m_last = m_at; + cause_len += SCTP_BUF_LEN(m_at); + } + padding_len = cause_len % 4; + if (padding_len != 0) { + padding_len = 4 - padding_len; + } + if (padding_len != 0) { + if (sctp_add_pad_tombuf(m_last, padding_len)) { + sctp_m_freem(cause); + return; + } + } + } else { + padding_len = 0; + } + /* Get an mbuf for the header. */ + len = sizeof(struct sctphdr) + sizeof(struct sctp_chunkhdr); iph = mtod(m, struct ip *); switch (iph->ip_v) { #ifdef INET case IPVERSION: - len = (sizeof(struct ip) + sizeof(struct sctp_shutdown_complete_msg)); + len += sizeof(struct ip); break; #endif #ifdef INET6 case IPV6_VERSION >> 4: - len = (sizeof(struct ip6_hdr) + sizeof(struct sctp_shutdown_complete_msg)); + len += sizeof(struct ip6_hdr); break; #endif default: - return; + break; } if (port) { len += sizeof(struct udphdr); } mout = sctp_get_mbuf_for_msg(len + max_linkhdr, 1, M_DONTWAIT, 1, MT_DATA); if (mout == NULL) { + if (cause) { + sctp_m_freem(cause); + } return; } SCTP_BUF_RESV_UF(mout, max_linkhdr); SCTP_BUF_LEN(mout) = len; - SCTP_BUF_NEXT(mout) = NULL; + SCTP_BUF_NEXT(mout) = cause; if (m->m_flags & M_FLOWID) { mout->m_pkthdr.flowid = m->m_pkthdr.flowid; mout->m_flags |= M_FLOWID; @@ -10910,18 +10939,14 @@ sctp_send_shutdown_complete2(struct mbuf #ifdef INET6 ip6_out = NULL; #endif - offset_out = 0; - switch (iph->ip_v) { #ifdef INET case IPVERSION: iph_out = mtod(mout, struct ip *); - - /* Fill in the IP header for the ABORT */ iph_out->ip_v = IPVERSION; - iph_out->ip_hl = (sizeof(struct ip) / 4); - iph_out->ip_tos = (u_char)0; - iph_out->ip_id = 0; + iph_out->ip_hl = (sizeof(struct ip) >> 2); + iph_out->ip_tos = 0; + iph_out->ip_id = ip_newid(); iph_out->ip_off = 0; iph_out->ip_ttl = MODULE_GLOBAL(ip_defttl); if (port) { @@ -10931,21 +10956,19 @@ sctp_send_shutdown_complete2(struct mbuf } iph_out->ip_src.s_addr = iph->ip_dst.s_addr; iph_out->ip_dst.s_addr = iph->ip_src.s_addr; - - /* let IP layer calculate this */ iph_out->ip_sum = 0; - offset_out += sizeof(*iph_out); - comp_cp = (struct sctp_shutdown_complete_msg *)( - (caddr_t)iph_out + offset_out); + len = sizeof(struct ip); + shout = (struct sctphdr *)((caddr_t)iph_out + len); break; #endif #ifdef INET6 case IPV6_VERSION >> 4: ip6 = (struct ip6_hdr *)iph; ip6_out = mtod(mout, struct ip6_hdr *); - - /* Fill in the IPv6 header for the ABORT */ - ip6_out->ip6_flow = ip6->ip6_flow; + ip6_out->ip6_flow = htonl(0x60000000); + if (V_ip6_auto_flowlabel) { + ip6_out->ip6_flow |= (htonl(ip6_randomflowlabel()) & IPV6_FLOWLABEL_MASK); + } ip6_out->ip6_hlim = MODULE_GLOBAL(ip6_defhlim); if (port) { ip6_out->ip6_nxt = IPPROTO_UDP; @@ -10954,78 +10977,84 @@ sctp_send_shutdown_complete2(struct mbuf } ip6_out->ip6_src = ip6->ip6_dst; ip6_out->ip6_dst = ip6->ip6_src; - /* - * ?? The old code had both the iph len + payload, I think - * this is wrong and would never have worked - */ - ip6_out->ip6_plen = sizeof(struct sctp_shutdown_complete_msg); - offset_out += sizeof(*ip6_out); - comp_cp = (struct sctp_shutdown_complete_msg *)( - (caddr_t)ip6_out + offset_out); + len = sizeof(struct ip6_hdr); + shout = (struct sctphdr *)((caddr_t)ip6_out + len); break; -#endif /* INET6 */ +#endif default: - /* Currently not supported. */ - sctp_m_freem(mout); - return; + len = 0; + shout = mtod(mout, struct sctphdr *); + break; } if (port) { if (htons(SCTP_BASE_SYSCTL(sctp_udp_tunneling_port)) == 0) { sctp_m_freem(mout); return; } - udp = (struct udphdr *)comp_cp; + udp = (struct udphdr *)shout; udp->uh_sport = htons(SCTP_BASE_SYSCTL(sctp_udp_tunneling_port)); udp->uh_dport = port; - udp->uh_ulen = htons(sizeof(struct sctp_shutdown_complete_msg) + sizeof(struct udphdr)); -#ifdef INET - if (iph_out) { - if (V_udp_cksum) { - udp->uh_sum = in_pseudo(iph_out->ip_src.s_addr, iph_out->ip_dst.s_addr, udp->uh_ulen + htons(IPPROTO_UDP)); - } else { - udp->uh_sum = 0; - } - } -#endif - offset_out += sizeof(struct udphdr); - comp_cp = (struct sctp_shutdown_complete_msg *)((caddr_t)comp_cp + sizeof(struct udphdr)); + udp->uh_sum = 0; + udp->uh_ulen = htons(sizeof(struct udphdr) + + sizeof(struct sctphdr) + + sizeof(struct sctp_chunkhdr) + + cause_len + padding_len); + len += sizeof(struct udphdr); + shout = (struct sctphdr *)((caddr_t)shout + sizeof(struct udphdr)); + } else { + udp = NULL; + } + shout->src_port = sh->dest_port; + shout->dest_port = sh->src_port; + shout->checksum = 0; + if (vtag) { + shout->v_tag = htonl(vtag); + } else { + shout->v_tag = sh->v_tag; } + len += sizeof(struct sctphdr); + ch = (struct sctp_chunkhdr *)((caddr_t)shout + sizeof(struct sctphdr)); + ch->chunk_type = type; + if (vtag) { + ch->chunk_flags = 0; + } else { + ch->chunk_flags = SCTP_HAD_NO_TCB; + } + ch->chunk_length = htons(sizeof(struct sctp_chunkhdr) + cause_len); + len += sizeof(struct sctp_chunkhdr); + len += cause_len + padding_len; + if (SCTP_GET_HEADER_FOR_OUTPUT(o_pak)) { - /* no mbuf's */ sctp_m_freem(mout); return; } - /* Now copy in and fill in the ABORT tags etc. */ - comp_cp->sh.src_port = sh->dest_port; - comp_cp->sh.dest_port = sh->src_port; - comp_cp->sh.checksum = 0; - comp_cp->sh.v_tag = sh->v_tag; - comp_cp->shut_cmp.ch.chunk_flags = SCTP_HAD_NO_TCB; - comp_cp->shut_cmp.ch.chunk_type = SCTP_SHUTDOWN_COMPLETE; - comp_cp->shut_cmp.ch.chunk_length = htons(sizeof(struct sctp_shutdown_complete_chunk)); - + SCTP_ATTACH_CHAIN(o_pak, mout, len); #ifdef INET if (iph_out != NULL) { - sctp_route_t ro; - int ret; - - mlen = SCTP_BUF_LEN(mout); - bzero(&ro, sizeof ro); - /* set IPv4 length */ - iph_out->ip_len = mlen; -#ifdef SCTP_PACKET_LOGGING - if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LAST_PACKET_TRACING) - sctp_packet_log(mout, mlen); + /* zap the stack pointer to the route */ + bzero(&ro, sizeof(sctp_route_t)); + if (port) { + if (V_udp_cksum) { + udp->uh_sum = in_pseudo(iph_out->ip_src.s_addr, iph_out->ip_dst.s_addr, udp->uh_ulen + htons(IPPROTO_UDP)); + } else { + udp->uh_sum = 0; + } + } + iph_out->ip_len = len; +#ifdef SCTP_PACKET_LOGGING + if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LAST_PACKET_TRACING) { + sctp_packet_log(mout, len); + } #endif if (port) { #if defined(SCTP_WITH_NO_CSUM) SCTP_STAT_INCR(sctps_sendnocrc); #else - comp_cp->sh.checksum = sctp_calculate_cksum(mout, offset_out); + shout->checksum = sctp_calculate_cksum(mout, sizeof(struct ip) + sizeof(struct udphdr)); SCTP_STAT_INCR(sctps_sendswcrc); #endif if (V_udp_cksum) { - SCTP_ENABLE_UDP_CSUM(mout); + SCTP_ENABLE_UDP_CSUM(o_pak); } } else { #if defined(SCTP_WITH_NO_CSUM) @@ -11036,40 +11065,36 @@ sctp_send_shutdown_complete2(struct mbuf SCTP_STAT_INCR(sctps_sendhwcrc); #endif } - SCTP_ATTACH_CHAIN(o_pak, mout, mlen); - /* out it goes */ SCTP_IP_OUTPUT(ret, o_pak, &ro, NULL, vrf_id); - /* Free the route if we got one back */ - if (ro.ro_rt) + if (ro.ro_rt) { RTFREE(ro.ro_rt); + } } #endif #ifdef INET6 if (ip6_out != NULL) { - int ret; - - mlen = SCTP_BUF_LEN(mout); + ip6_out->ip6_plen = len - sizeof(struct ip6_hdr); #ifdef SCTP_PACKET_LOGGING - if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LAST_PACKET_TRACING) - sctp_packet_log(mout, mlen); + if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LAST_PACKET_TRACING) { + sctp_packet_log(mout, len); + } #endif - SCTP_ATTACH_CHAIN(o_pak, mout, mlen); if (port) { #if defined(SCTP_WITH_NO_CSUM) SCTP_STAT_INCR(sctps_sendnocrc); #else - comp_cp->sh.checksum = sctp_calculate_cksum(mout, sizeof(struct ip6_hdr) + sizeof(struct udphdr)); + shout->checksum = sctp_calculate_cksum(mout, sizeof(struct ip6_hdr) + sizeof(struct udphdr)); SCTP_STAT_INCR(sctps_sendswcrc); #endif - if ((udp->uh_sum = in6_cksum(o_pak, IPPROTO_UDP, sizeof(struct ip6_hdr), mlen - sizeof(struct ip6_hdr))) == 0) { + if ((udp->uh_sum = in6_cksum(o_pak, IPPROTO_UDP, sizeof(struct ip6_hdr), len - sizeof(struct ip6_hdr))) == 0) { udp->uh_sum = 0xffff; } } else { #if defined(SCTP_WITH_NO_CSUM) SCTP_STAT_INCR(sctps_sendnocrc); #else - mout->m_pkthdr.csum_flags = CSUM_SCTP_IPV6; + mout->m_pkthdr.csum_flags = CSUM_SCTP; mout->m_pkthdr.csum_data = 0; SCTP_STAT_INCR(sctps_sendhwcrc); #endif @@ -11081,7 +11106,13 @@ sctp_send_shutdown_complete2(struct mbuf SCTP_STAT_INCR_COUNTER64(sctps_outpackets); SCTP_STAT_INCR_COUNTER64(sctps_outcontrolchunks); return; +} +void +sctp_send_shutdown_complete2(struct mbuf *m, struct sctphdr *sh, + uint32_t vrf_id, uint16_t port) +{ + sctp_send_resp_msg(m, sh, 0, SCTP_SHUTDOWN_COMPLETE, NULL, vrf_id, port); } void @@ -11913,528 +11944,24 @@ skip_stuff: void sctp_send_abort(struct mbuf *m, int iphlen, struct sctphdr *sh, uint32_t vtag, - struct mbuf *err_cause, uint32_t vrf_id, uint16_t port) + struct mbuf *cause, uint32_t vrf_id, uint16_t port) { - /*- - * Formulate the abort message, and send it back down. - */ - struct mbuf *o_pak; - struct mbuf *mout; - struct sctp_abort_msg *abm; - struct ip *iph; - struct udphdr *udp; - int iphlen_out, len; - -#ifdef INET - struct ip *iph_out; - -#endif -#ifdef INET6 - struct ip6_hdr *ip6, *ip6_out; - -#endif - - /* don't respond to ABORT with ABORT */ + /* Don't respond to an ABORT with an ABORT. */ if (sctp_is_there_an_abort_here(m, iphlen, &vtag)) { - if (err_cause) - sctp_m_freem(err_cause); + if (cause) + sctp_m_freem(cause); return; } - iph = mtod(m, struct ip *); - switch (iph->ip_v) { -#ifdef INET - case IPVERSION: - len = (sizeof(struct ip) + sizeof(struct sctp_abort_msg)); - break; -#endif -#ifdef INET6 - case IPV6_VERSION >> 4: - len = (sizeof(struct ip6_hdr) + sizeof(struct sctp_abort_msg)); - break; -#endif - default: - if (err_cause) { - sctp_m_freem(err_cause); - } - return; - } - if (port) { - len += sizeof(struct udphdr); - } - mout = sctp_get_mbuf_for_msg(len + max_linkhdr, 1, M_DONTWAIT, 1, MT_DATA); - if (mout == NULL) { - if (err_cause) { - sctp_m_freem(err_cause); - } - return; - } - SCTP_BUF_RESV_UF(mout, max_linkhdr); - SCTP_BUF_LEN(mout) = len; - SCTP_BUF_NEXT(mout) = err_cause; - if (m->m_flags & M_FLOWID) { - mout->m_pkthdr.flowid = m->m_pkthdr.flowid; - mout->m_flags |= M_FLOWID; - } -#ifdef INET - iph_out = NULL; -#endif -#ifdef INET6 - ip6_out = NULL; -#endif - switch (iph->ip_v) { -#ifdef INET - case IPVERSION: - iph_out = mtod(mout, struct ip *); - - /* Fill in the IP header for the ABORT */ - iph_out->ip_v = IPVERSION; - iph_out->ip_hl = (sizeof(struct ip) / 4); - iph_out->ip_tos = (u_char)0; - iph_out->ip_id = 0; - iph_out->ip_off = 0; - iph_out->ip_ttl = MODULE_GLOBAL(ip_defttl); - if (port) { - iph_out->ip_p = IPPROTO_UDP; - } else { - iph_out->ip_p = IPPROTO_SCTP; - } - iph_out->ip_src.s_addr = iph->ip_dst.s_addr; - iph_out->ip_dst.s_addr = iph->ip_src.s_addr; - /* let IP layer calculate this */ - iph_out->ip_sum = 0; - - iphlen_out = sizeof(*iph_out); - abm = (struct sctp_abort_msg *)((caddr_t)iph_out + iphlen_out); - break; -#endif -#ifdef INET6 - case IPV6_VERSION >> 4: - ip6 = (struct ip6_hdr *)iph; - ip6_out = mtod(mout, struct ip6_hdr *); - - /* Fill in the IP6 header for the ABORT */ - ip6_out->ip6_flow = ip6->ip6_flow; - ip6_out->ip6_hlim = MODULE_GLOBAL(ip6_defhlim); - if (port) { - ip6_out->ip6_nxt = IPPROTO_UDP; - } else { - ip6_out->ip6_nxt = IPPROTO_SCTP; - } - ip6_out->ip6_src = ip6->ip6_dst; - ip6_out->ip6_dst = ip6->ip6_src; - - iphlen_out = sizeof(*ip6_out); - abm = (struct sctp_abort_msg *)((caddr_t)ip6_out + iphlen_out); - break; -#endif /* INET6 */ - default: - /* Currently not supported */ - sctp_m_freem(mout); - return; - } - - udp = (struct udphdr *)abm; - if (port) { - if (htons(SCTP_BASE_SYSCTL(sctp_udp_tunneling_port)) == 0) { - sctp_m_freem(mout); - return; - } - udp->uh_sport = htons(SCTP_BASE_SYSCTL(sctp_udp_tunneling_port)); - udp->uh_dport = port; - /* set udp->uh_ulen later */ - udp->uh_sum = 0; - iphlen_out += sizeof(struct udphdr); - abm = (struct sctp_abort_msg *)((caddr_t)abm + sizeof(struct udphdr)); - } - abm->sh.src_port = sh->dest_port; - abm->sh.dest_port = sh->src_port; - abm->sh.checksum = 0; - if (vtag == 0) { - abm->sh.v_tag = sh->v_tag; - abm->msg.ch.chunk_flags = SCTP_HAD_NO_TCB; - } else { - abm->sh.v_tag = htonl(vtag); - abm->msg.ch.chunk_flags = 0; - } - abm->msg.ch.chunk_type = SCTP_ABORT_ASSOCIATION; - - if (err_cause) { - struct mbuf *m_tmp = err_cause; - int err_len = 0; - - /* get length of the err_cause chain */ - while (m_tmp != NULL) { - err_len += SCTP_BUF_LEN(m_tmp); - m_tmp = SCTP_BUF_NEXT(m_tmp); - } - len = SCTP_BUF_LEN(mout) + err_len; - if (err_len % 4) { - /* need pad at end of chunk */ - uint32_t cpthis = 0; - int padlen; - - padlen = 4 - (len % 4); - m_copyback(mout, len, padlen, (caddr_t)&cpthis); - len += padlen; - } - abm->msg.ch.chunk_length = htons(sizeof(abm->msg.ch) + err_len); - } else { - len = SCTP_BUF_LEN(mout); - abm->msg.ch.chunk_length = htons(sizeof(abm->msg.ch)); - } - - if (SCTP_GET_HEADER_FOR_OUTPUT(o_pak)) { - /* no mbuf's */ - sctp_m_freem(mout); - return; - } -#ifdef INET - if (iph_out != NULL) { - sctp_route_t ro; - int ret; - - /* zap the stack pointer to the route */ - bzero(&ro, sizeof ro); - if (port) { - udp->uh_ulen = htons(len - sizeof(struct ip)); - if (V_udp_cksum) { - udp->uh_sum = in_pseudo(iph_out->ip_src.s_addr, iph_out->ip_dst.s_addr, udp->uh_ulen + htons(IPPROTO_UDP)); - } else { - udp->uh_sum = 0; - } - } - SCTPDBG(SCTP_DEBUG_OUTPUT2, "sctp_send_abort calling ip_output:\n"); - SCTPDBG_PKT(SCTP_DEBUG_OUTPUT2, iph_out, &abm->sh); - /* set IPv4 length */ - iph_out->ip_len = len; - /* out it goes */ -#ifdef SCTP_PACKET_LOGGING - if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LAST_PACKET_TRACING) - sctp_packet_log(mout, len); -#endif - SCTP_ATTACH_CHAIN(o_pak, mout, len); - if (port) { -#if defined(SCTP_WITH_NO_CSUM) - SCTP_STAT_INCR(sctps_sendnocrc); -#else - abm->sh.checksum = sctp_calculate_cksum(mout, iphlen_out); - SCTP_STAT_INCR(sctps_sendswcrc); -#endif - if (V_udp_cksum) { - SCTP_ENABLE_UDP_CSUM(o_pak); - } - } else { -#if defined(SCTP_WITH_NO_CSUM) - SCTP_STAT_INCR(sctps_sendnocrc); -#else - mout->m_pkthdr.csum_flags = CSUM_SCTP; - mout->m_pkthdr.csum_data = 0; - SCTP_STAT_INCR(sctps_sendhwcrc); -#endif - } - SCTP_IP_OUTPUT(ret, o_pak, &ro, NULL, vrf_id); - - /* Free the route if we got one back */ - if (ro.ro_rt) - RTFREE(ro.ro_rt); - } -#endif -#ifdef INET6 - if (ip6_out != NULL) { - int ret; - - if (port) { - udp->uh_ulen = htons(len - sizeof(struct ip6_hdr)); - } - SCTPDBG(SCTP_DEBUG_OUTPUT2, "sctp_send_abort calling ip6_output:\n"); - SCTPDBG_PKT(SCTP_DEBUG_OUTPUT2, (struct ip *)ip6_out, &abm->sh); - ip6_out->ip6_plen = len - sizeof(*ip6_out); -#ifdef SCTP_PACKET_LOGGING - if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LAST_PACKET_TRACING) - sctp_packet_log(mout, len); -#endif - SCTP_ATTACH_CHAIN(o_pak, mout, len); - if (port) { -#if defined(SCTP_WITH_NO_CSUM) - SCTP_STAT_INCR(sctps_sendnocrc); -#else - abm->sh.checksum = sctp_calculate_cksum(mout, sizeof(struct ip6_hdr) + sizeof(struct udphdr)); - SCTP_STAT_INCR(sctps_sendswcrc); -#endif - if ((udp->uh_sum = in6_cksum(o_pak, IPPROTO_UDP, sizeof(struct ip6_hdr), len - sizeof(struct ip6_hdr))) == 0) { - udp->uh_sum = 0xffff; - } - } else { -#if defined(SCTP_WITH_NO_CSUM) - SCTP_STAT_INCR(sctps_sendnocrc); -#else - mout->m_pkthdr.csum_flags = CSUM_SCTP_IPV6; - mout->m_pkthdr.csum_data = 0; - SCTP_STAT_INCR(sctps_sendhwcrc); -#endif - } - SCTP_IP6_OUTPUT(ret, o_pak, NULL, NULL, NULL, vrf_id); - } -#endif - SCTP_STAT_INCR(sctps_sendpackets); - SCTP_STAT_INCR_COUNTER64(sctps_outpackets); - SCTP_STAT_INCR_COUNTER64(sctps_outcontrolchunks); + sctp_send_resp_msg(m, sh, vtag, SCTP_ABORT_ASSOCIATION, cause, vrf_id, port); + return; } void -sctp_send_operr_to(struct mbuf *m, int iphlen, struct mbuf *scm, uint32_t vtag, - uint32_t vrf_id, uint16_t port) +sctp_send_operr_to(struct mbuf *m, struct sctphdr *sh, uint32_t vtag, + struct mbuf *cause, uint32_t vrf_id, uint16_t port) { - struct mbuf *o_pak; - struct sctphdr *sh, *sh_out; - struct sctp_chunkhdr *ch; - struct ip *iph; - struct udphdr *udp = NULL; - struct mbuf *mout; - int iphlen_out, len; - -#ifdef INET - struct ip *iph_out; - -#endif -#ifdef INET6 - struct ip6_hdr *ip6, *ip6_out; - -#endif - - iph = mtod(m, struct ip *); - sh = (struct sctphdr *)((caddr_t)iph + iphlen); - switch (iph->ip_v) { -#ifdef INET - case IPVERSION: - len = (sizeof(struct ip) + sizeof(struct sctphdr) + sizeof(struct sctp_chunkhdr)); - break; -#endif -#ifdef INET6 - case IPV6_VERSION >> 4: - len = (sizeof(struct ip6_hdr) + sizeof(struct sctphdr) + sizeof(struct sctp_chunkhdr)); - break; -#endif - default: - if (scm) { - sctp_m_freem(scm); - } - return; - } - if (port) { - len += sizeof(struct udphdr); - } - mout = sctp_get_mbuf_for_msg(len + max_linkhdr, 1, M_DONTWAIT, 1, MT_DATA); - if (mout == NULL) { - if (scm) { - sctp_m_freem(scm); - } - return; - } - SCTP_BUF_RESV_UF(mout, max_linkhdr); - SCTP_BUF_LEN(mout) = len; - SCTP_BUF_NEXT(mout) = scm; - if (m->m_flags & M_FLOWID) { - mout->m_pkthdr.flowid = m->m_pkthdr.flowid; - mout->m_flags |= M_FLOWID; - } -#ifdef INET - iph_out = NULL; -#endif -#ifdef INET6 - ip6_out = NULL; -#endif - switch (iph->ip_v) { -#ifdef INET - case IPVERSION: - iph_out = mtod(mout, struct ip *); - - /* Fill in the IP header for the ABORT */ - iph_out->ip_v = IPVERSION; - iph_out->ip_hl = (sizeof(struct ip) / 4); - iph_out->ip_tos = (u_char)0; - iph_out->ip_id = 0; - iph_out->ip_off = 0; - iph_out->ip_ttl = MODULE_GLOBAL(ip_defttl); - if (port) { - iph_out->ip_p = IPPROTO_UDP; - } else { - iph_out->ip_p = IPPROTO_SCTP; - } - iph_out->ip_src.s_addr = iph->ip_dst.s_addr; - iph_out->ip_dst.s_addr = iph->ip_src.s_addr; - /* let IP layer calculate this */ - iph_out->ip_sum = 0; - - iphlen_out = sizeof(struct ip); - sh_out = (struct sctphdr *)((caddr_t)iph_out + iphlen_out); - break; -#endif -#ifdef INET6 - case IPV6_VERSION >> 4: - ip6 = (struct ip6_hdr *)iph; - ip6_out = mtod(mout, struct ip6_hdr *); - - /* Fill in the IP6 header for the ABORT */ - ip6_out->ip6_flow = ip6->ip6_flow; - ip6_out->ip6_hlim = MODULE_GLOBAL(ip6_defhlim); - if (port) { - ip6_out->ip6_nxt = IPPROTO_UDP; - } else { - ip6_out->ip6_nxt = IPPROTO_SCTP; - } - ip6_out->ip6_src = ip6->ip6_dst; - ip6_out->ip6_dst = ip6->ip6_src; - - iphlen_out = sizeof(struct ip6_hdr); - sh_out = (struct sctphdr *)((caddr_t)ip6_out + iphlen_out); - break; -#endif /* INET6 */ - default: - /* Currently not supported */ - sctp_m_freem(mout); - return; - } - - udp = (struct udphdr *)sh_out; - if (port) { - if (htons(SCTP_BASE_SYSCTL(sctp_udp_tunneling_port)) == 0) { - sctp_m_freem(mout); - return; - } - udp->uh_sport = htons(SCTP_BASE_SYSCTL(sctp_udp_tunneling_port)); - udp->uh_dport = port; - /* set udp->uh_ulen later */ - udp->uh_sum = 0; - iphlen_out += sizeof(struct udphdr); - sh_out = (struct sctphdr *)((caddr_t)udp + sizeof(struct udphdr)); - } - sh_out->src_port = sh->dest_port; - sh_out->dest_port = sh->src_port; - sh_out->v_tag = vtag; - sh_out->checksum = 0; - - ch = (struct sctp_chunkhdr *)((caddr_t)sh_out + sizeof(struct sctphdr)); - ch->chunk_type = SCTP_OPERATION_ERROR; - ch->chunk_flags = 0; - - if (scm) { - struct mbuf *m_tmp = scm; - int cause_len = 0; - - /* get length of the err_cause chain */ - while (m_tmp != NULL) { - cause_len += SCTP_BUF_LEN(m_tmp); - m_tmp = SCTP_BUF_NEXT(m_tmp); - } - len = SCTP_BUF_LEN(mout) + cause_len; - if (cause_len % 4) { - /* need pad at end of chunk */ - uint32_t cpthis = 0; - int padlen; - - padlen = 4 - (len % 4); - m_copyback(mout, len, padlen, (caddr_t)&cpthis); - len += padlen; - } - ch->chunk_length = htons(sizeof(struct sctp_chunkhdr) + cause_len); - } else { - len = SCTP_BUF_LEN(mout); - ch->chunk_length = htons(sizeof(struct sctp_chunkhdr)); - } - - if (SCTP_GET_HEADER_FOR_OUTPUT(o_pak)) { - /* no mbuf's */ - sctp_m_freem(mout); - return; - } -#ifdef INET - if (iph_out != NULL) { - sctp_route_t ro; - int ret; - - /* zap the stack pointer to the route */ - bzero(&ro, sizeof ro); - if (port) { - udp->uh_ulen = htons(len - sizeof(struct ip)); - if (V_udp_cksum) { - udp->uh_sum = in_pseudo(iph_out->ip_src.s_addr, iph_out->ip_dst.s_addr, udp->uh_ulen + htons(IPPROTO_UDP)); - } else { - udp->uh_sum = 0; - } - } - /* set IPv4 length */ - iph_out->ip_len = len; - /* out it goes */ -#ifdef SCTP_PACKET_LOGGING - if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LAST_PACKET_TRACING) - sctp_packet_log(mout, len); -#endif - SCTP_ATTACH_CHAIN(o_pak, mout, len); - if (port) { -#if defined(SCTP_WITH_NO_CSUM) - SCTP_STAT_INCR(sctps_sendnocrc); -#else - sh_out->checksum = sctp_calculate_cksum(mout, iphlen_out); - SCTP_STAT_INCR(sctps_sendswcrc); -#endif - if (V_udp_cksum) { - SCTP_ENABLE_UDP_CSUM(o_pak); - } - } else { -#if defined(SCTP_WITH_NO_CSUM) - SCTP_STAT_INCR(sctps_sendnocrc); -#else - mout->m_pkthdr.csum_flags = CSUM_SCTP; - mout->m_pkthdr.csum_data = 0; - SCTP_STAT_INCR(sctps_sendhwcrc); -#endif - } - SCTP_IP_OUTPUT(ret, o_pak, &ro, NULL, vrf_id); - - /* Free the route if we got one back */ - if (ro.ro_rt) - RTFREE(ro.ro_rt); - } -#endif -#ifdef INET6 - if (ip6_out != NULL) { - int ret; - - if (port) { - udp->uh_ulen = htons(len - sizeof(struct ip6_hdr)); - } - ip6_out->ip6_plen = len - sizeof(*ip6_out); -#ifdef SCTP_PACKET_LOGGING - if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LAST_PACKET_TRACING) - sctp_packet_log(mout, len); -#endif - SCTP_ATTACH_CHAIN(o_pak, mout, len); - if (port) { -#if defined(SCTP_WITH_NO_CSUM) - SCTP_STAT_INCR(sctps_sendnocrc); -#else - sh_out->checksum = sctp_calculate_cksum(mout, sizeof(struct ip6_hdr) + sizeof(struct udphdr)); - SCTP_STAT_INCR(sctps_sendswcrc); -#endif - if ((udp->uh_sum = in6_cksum(o_pak, IPPROTO_UDP, sizeof(struct ip6_hdr), len - sizeof(struct ip6_hdr))) == 0) { - udp->uh_sum = 0xffff; - } - } else { -#if defined(SCTP_WITH_NO_CSUM) - SCTP_STAT_INCR(sctps_sendnocrc); -#else - mout->m_pkthdr.csum_flags = CSUM_SCTP_IPV6; - mout->m_pkthdr.csum_data = 0; - SCTP_STAT_INCR(sctps_sendhwcrc); -#endif - } - SCTP_IP6_OUTPUT(ret, o_pak, NULL, NULL, NULL, vrf_id); - } -#endif - SCTP_STAT_INCR(sctps_sendpackets); - SCTP_STAT_INCR_COUNTER64(sctps_outpackets); - SCTP_STAT_INCR_COUNTER64(sctps_outcontrolchunks); + sctp_send_resp_msg(m, sh, vtag, SCTP_OPERATION_ERROR, cause, vrf_id, port); + return; } static struct mbuf * Modified: stable/9/sys/netinet/sctp_output.h ============================================================================== --- stable/9/sys/netinet/sctp_output.h Sun Jul 8 16:00:45 2012 (r238250) +++ stable/9/sys/netinet/sctp_output.h Sun Jul 8 16:11:16 2012 (r238251) @@ -204,7 +204,9 @@ void sctp_send_abort(struct mbuf *, int, struct sctphdr *, uint32_t, struct mbuf *, uint32_t, uint16_t); -void sctp_send_operr_to(struct mbuf *, int, struct mbuf *, uint32_t, uint32_t, uint16_t); +void +sctp_send_operr_to(struct mbuf *, struct sctphdr *, uint32_t, + struct mbuf *, uint32_t, uint16_t); #endif /* _KERNEL || __Userspace__ */ From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 8 16:14:42 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D19E8106566C; Sun, 8 Jul 2012 16:14:42 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BA1738FC0C; Sun, 8 Jul 2012 16:14:42 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q68GEggK061484; Sun, 8 Jul 2012 16:14:42 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q68GEgST061474; Sun, 8 Jul 2012 16:14:42 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201207081614.q68GEgST061474@svn.freebsd.org> From: Michael Tuexen Date: Sun, 8 Jul 2012 16:14:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238253 - in stable/9/sys: netinet netinet6 X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jul 2012 16:14:43 -0000 Author: tuexen Date: Sun Jul 8 16:14:42 2012 New Revision: 238253 URL: http://svn.freebsd.org/changeset/base/238253 Log: MFC r237049: Pass flowid explicitly through the stack instead of taking it from the mbuf chain at different places. While there: Fix several bugs related to VRFs. Approved by: re@ Modified: stable/9/sys/netinet/sctp_indata.c stable/9/sys/netinet/sctp_indata.h stable/9/sys/netinet/sctp_input.c stable/9/sys/netinet/sctp_input.h stable/9/sys/netinet/sctp_output.c stable/9/sys/netinet/sctp_output.h stable/9/sys/netinet/sctputil.c stable/9/sys/netinet/sctputil.h stable/9/sys/netinet6/sctp6_usrreq.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp_indata.c ============================================================================== --- stable/9/sys/netinet/sctp_indata.c Sun Jul 8 16:12:59 2012 (r238252) +++ stable/9/sys/netinet/sctp_indata.c Sun Jul 8 16:14:42 2012 (r238253) @@ -2516,8 +2516,10 @@ doit_again: int sctp_process_data(struct mbuf **mm, int iphlen, int *offset, int length, - struct sctphdr *sh, struct sctp_inpcb *inp, struct sctp_tcb *stcb, - struct sctp_nets *net, uint32_t * high_tsn) + struct sctphdr *sh, struct sctp_inpcb *inp, + struct sctp_tcb *stcb, struct sctp_nets *net, uint32_t * high_tsn, + uint8_t use_mflowid, uint32_t mflowid, + uint32_t vrf_id, uint16_t port) { struct sctp_data_chunk *ch, chunk_buf; struct sctp_association *asoc; @@ -2625,7 +2627,9 @@ sctp_process_data(struct mbuf **mm, int } stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_19; sctp_abort_association(inp, stcb, m, iphlen, sh, - op_err, 0, net->port); + op_err, + use_mflowid, mflowid, + vrf_id, port); return (2); } #ifdef SCTP_AUDITING_ENABLED @@ -2689,7 +2693,11 @@ sctp_process_data(struct mbuf **mm, int struct mbuf *op_err; op_err = sctp_generate_invmanparam(SCTP_CAUSE_PROTOCOL_VIOLATION); - sctp_abort_association(inp, stcb, m, iphlen, sh, op_err, 0, net->port); + sctp_abort_association(inp, stcb, + m, iphlen, + sh, op_err, + use_mflowid, mflowid, + vrf_id, port); return (2); } break; Modified: stable/9/sys/netinet/sctp_indata.h ============================================================================== --- stable/9/sys/netinet/sctp_indata.h Sun Jul 8 16:12:59 2012 (r238252) +++ stable/9/sys/netinet/sctp_indata.h Sun Jul 8 16:14:42 2012 (r238253) @@ -113,7 +113,9 @@ void int sctp_process_data(struct mbuf **, int, int *, int, struct sctphdr *, struct sctp_inpcb *, struct sctp_tcb *, - struct sctp_nets *, uint32_t *); + struct sctp_nets *, uint32_t *, + uint8_t, uint32_t, + uint32_t, uint16_t); void sctp_slide_mapping_arrays(struct sctp_tcb *stcb); Modified: stable/9/sys/netinet/sctp_input.c ============================================================================== --- stable/9/sys/netinet/sctp_input.c Sun Jul 8 16:12:59 2012 (r238252) +++ stable/9/sys/netinet/sctp_input.c Sun Jul 8 16:14:42 2012 (r238253) @@ -81,8 +81,10 @@ sctp_stop_all_cookie_timers(struct sctp_ /* INIT handler */ static void sctp_handle_init(struct mbuf *m, int iphlen, int offset, struct sctphdr *sh, - struct sctp_init_chunk *cp, struct sctp_inpcb *inp, struct sctp_tcb *stcb, - int *abort_no_unlock, uint32_t vrf_id, uint16_t port) + struct sctp_init_chunk *cp, struct sctp_inpcb *inp, + struct sctp_tcb *stcb, int *abort_no_unlock, + uint8_t use_mflowid, uint32_t mflowid, + uint32_t vrf_id, uint16_t port) { struct sctp_init *init; struct mbuf *op_err; @@ -96,6 +98,7 @@ sctp_handle_init(struct mbuf *m, int iph if (ntohs(cp->ch.chunk_length) < sizeof(struct sctp_init_chunk)) { op_err = sctp_generate_invmanparam(SCTP_CAUSE_INVALID_PARAM); sctp_abort_association(inp, stcb, m, iphlen, sh, op_err, + use_mflowid, mflowid, vrf_id, port); if (stcb) *abort_no_unlock = 1; @@ -107,6 +110,7 @@ sctp_handle_init(struct mbuf *m, int iph /* protocol error... send abort */ op_err = sctp_generate_invmanparam(SCTP_CAUSE_INVALID_PARAM); sctp_abort_association(inp, stcb, m, iphlen, sh, op_err, + use_mflowid, mflowid, vrf_id, port); if (stcb) *abort_no_unlock = 1; @@ -116,6 +120,7 @@ sctp_handle_init(struct mbuf *m, int iph /* invalid parameter... send abort */ op_err = sctp_generate_invmanparam(SCTP_CAUSE_INVALID_PARAM); sctp_abort_association(inp, stcb, m, iphlen, sh, op_err, + use_mflowid, mflowid, vrf_id, port); if (stcb) *abort_no_unlock = 1; @@ -125,6 +130,7 @@ sctp_handle_init(struct mbuf *m, int iph /* protocol error... send abort */ op_err = sctp_generate_invmanparam(SCTP_CAUSE_INVALID_PARAM); sctp_abort_association(inp, stcb, m, iphlen, sh, op_err, + use_mflowid, mflowid, vrf_id, port); if (stcb) *abort_no_unlock = 1; @@ -134,6 +140,7 @@ sctp_handle_init(struct mbuf *m, int iph /* protocol error... send abort */ op_err = sctp_generate_invmanparam(SCTP_CAUSE_INVALID_PARAM); sctp_abort_association(inp, stcb, m, iphlen, sh, op_err, + use_mflowid, mflowid, vrf_id, port); if (stcb) *abort_no_unlock = 1; @@ -142,7 +149,9 @@ sctp_handle_init(struct mbuf *m, int iph if (sctp_validate_init_auth_params(m, offset + sizeof(*cp), offset + ntohs(cp->ch.chunk_length))) { /* auth parameter(s) error... send abort */ - sctp_abort_association(inp, stcb, m, iphlen, sh, NULL, vrf_id, port); + sctp_abort_association(inp, stcb, m, iphlen, sh, NULL, + use_mflowid, mflowid, + vrf_id, port); if (stcb) *abort_no_unlock = 1; goto outnow; @@ -169,7 +178,9 @@ sctp_handle_init(struct mbuf *m, int iph * state :-) */ if (SCTP_BASE_SYSCTL(sctp_blackhole) == 0) { - sctp_send_abort(m, iphlen, sh, 0, NULL, vrf_id, port); + sctp_send_abort(m, iphlen, sh, 0, NULL, + use_mflowid, mflowid, + vrf_id, port); } goto outnow; } @@ -180,7 +191,9 @@ sctp_handle_init(struct mbuf *m, int iph sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_CONTROL_PROC, SCTP_SO_NOT_LOCKED); } else { SCTPDBG(SCTP_DEBUG_INPUT3, "sctp_handle_init: sending INIT-ACK\n"); - sctp_send_initiate_ack(inp, stcb, m, iphlen, offset, sh, cp, vrf_id, port, + sctp_send_initiate_ack(inp, stcb, m, iphlen, offset, sh, cp, + use_mflowid, mflowid, + vrf_id, port, ((stcb == NULL) ? SCTP_HOLDS_LOCK : SCTP_NOT_LOCKED)); } outnow: @@ -406,9 +419,11 @@ sctp_process_init(struct sctp_init_chunk * INIT-ACK message processing/consumption returns value < 0 on error */ static int -sctp_process_init_ack(struct mbuf *m, int iphlen, int offset, - struct sctphdr *sh, struct sctp_init_ack_chunk *cp, struct sctp_tcb *stcb, - struct sctp_nets *net, int *abort_no_unlock, uint32_t vrf_id) +sctp_process_init_ack(struct mbuf *m, int iphlen, int offset, struct sctphdr *sh, + struct sctp_init_ack_chunk *cp, struct sctp_tcb *stcb, + struct sctp_nets *net, int *abort_no_unlock, + uint8_t use_mflowid, uint32_t mflowid, + uint32_t vrf_id) { struct sctp_association *asoc; struct mbuf *op_err; @@ -445,8 +460,9 @@ sctp_process_init_ack(struct mbuf *m, in SCTPDBG(SCTP_DEBUG_INPUT1, "Load addresses from INIT causes an abort %d\n", retval); - sctp_abort_association(stcb->sctp_ep, stcb, m, iphlen, sh, - NULL, 0, net->port); + sctp_abort_association(stcb->sctp_ep, stcb, m, iphlen, sh, NULL, + use_mflowid, mflowid, + vrf_id, net->port); *abort_no_unlock = 1; return (-1); } @@ -520,7 +536,9 @@ sctp_process_init_ack(struct mbuf *m, in mp->resv = 0; } sctp_abort_association(stcb->sctp_ep, stcb, m, iphlen, - sh, op_err, vrf_id, net->port); + sh, op_err, + use_mflowid, mflowid, + vrf_id, net->port); *abort_no_unlock = 1; } return (retval); @@ -1260,9 +1278,11 @@ sctp_handle_error(struct sctp_chunkhdr * } static int -sctp_handle_init_ack(struct mbuf *m, int iphlen, int offset, - struct sctphdr *sh, struct sctp_init_ack_chunk *cp, struct sctp_tcb *stcb, - struct sctp_nets *net, int *abort_no_unlock, uint32_t vrf_id) +sctp_handle_init_ack(struct mbuf *m, int iphlen, int offset, struct sctphdr *sh, + struct sctp_init_ack_chunk *cp, struct sctp_tcb *stcb, + struct sctp_nets *net, int *abort_no_unlock, + uint8_t use_mflowid, uint32_t mflowid, + uint32_t vrf_id) { struct sctp_init_ack *init_ack; struct mbuf *op_err; @@ -1279,7 +1299,9 @@ sctp_handle_init_ack(struct mbuf *m, int /* Invalid length */ op_err = sctp_generate_invmanparam(SCTP_CAUSE_INVALID_PARAM); sctp_abort_association(stcb->sctp_ep, stcb, m, iphlen, sh, - op_err, 0, net->port); + op_err, + use_mflowid, mflowid, + vrf_id, net->port); *abort_no_unlock = 1; return (-1); } @@ -1289,7 +1311,9 @@ sctp_handle_init_ack(struct mbuf *m, int /* protocol error... send an abort */ op_err = sctp_generate_invmanparam(SCTP_CAUSE_INVALID_PARAM); sctp_abort_association(stcb->sctp_ep, stcb, m, iphlen, sh, - op_err, 0, net->port); + op_err, + use_mflowid, mflowid, + vrf_id, net->port); *abort_no_unlock = 1; return (-1); } @@ -1297,7 +1321,9 @@ sctp_handle_init_ack(struct mbuf *m, int /* protocol error... send an abort */ op_err = sctp_generate_invmanparam(SCTP_CAUSE_INVALID_PARAM); sctp_abort_association(stcb->sctp_ep, stcb, m, iphlen, sh, - op_err, 0, net->port); + op_err, + use_mflowid, mflowid, + vrf_id, net->port); *abort_no_unlock = 1; return (-1); } @@ -1305,7 +1331,9 @@ sctp_handle_init_ack(struct mbuf *m, int /* protocol error... send an abort */ op_err = sctp_generate_invmanparam(SCTP_CAUSE_INVALID_PARAM); sctp_abort_association(stcb->sctp_ep, stcb, m, iphlen, sh, - op_err, 0, net->port); + op_err, + use_mflowid, mflowid, + vrf_id, net->port); *abort_no_unlock = 1; return (-1); } @@ -1313,7 +1341,9 @@ sctp_handle_init_ack(struct mbuf *m, int /* protocol error... send an abort */ op_err = sctp_generate_invmanparam(SCTP_CAUSE_INVALID_PARAM); sctp_abort_association(stcb->sctp_ep, stcb, m, iphlen, sh, - op_err, 0, net->port); + op_err, + use_mflowid, mflowid, + vrf_id, net->port); *abort_no_unlock = 1; return (-1); } @@ -1336,7 +1366,9 @@ sctp_handle_init_ack(struct mbuf *m, int stcb, 0, (void *)stcb->asoc.primary_destination, SCTP_SO_NOT_LOCKED); } if (sctp_process_init_ack(m, iphlen, offset, sh, cp, stcb, - net, abort_no_unlock, vrf_id) < 0) { + net, abort_no_unlock, + use_mflowid, mflowid, + vrf_id) < 0) { /* error in parsing parameters */ return (-1); } @@ -1391,6 +1423,7 @@ sctp_process_cookie_new(struct mbuf *m, struct sctp_inpcb *inp, struct sctp_nets **netp, struct sockaddr *init_src, int *notification, int auth_skipped, uint32_t auth_offset, uint32_t auth_len, + uint8_t use_mflowid, uint32_t mflowid, uint32_t vrf_id, uint16_t port); @@ -1405,7 +1438,9 @@ sctp_process_cookie_existing(struct mbuf struct sctphdr *sh, struct sctp_state_cookie *cookie, int cookie_len, struct sctp_inpcb *inp, struct sctp_tcb *stcb, struct sctp_nets **netp, struct sockaddr *init_src, int *notification, - uint32_t vrf_id, int auth_skipped, uint32_t auth_offset, uint32_t auth_len, uint16_t port) + int auth_skipped, uint32_t auth_offset, uint32_t auth_len, + uint8_t use_mflowid, uint32_t mflowid, + uint32_t vrf_id, uint16_t port) { struct sctp_association *asoc; struct sctp_init_chunk *init_cp, init_buf; @@ -1443,6 +1478,7 @@ sctp_process_cookie_existing(struct mbuf ph->param_type = htons(SCTP_CAUSE_COOKIE_IN_SHUTDOWN); ph->param_length = htons(sizeof(struct sctp_paramhdr)); sctp_send_operr_to(m, sh, cookie->peers_vtag, op_err, + use_mflowid, mflowid, vrf_id, net->port); if (how_indx < sizeof(asoc->cookie_how)) asoc->cookie_how[how_indx] = 2; @@ -1667,7 +1703,9 @@ sctp_process_cookie_existing(struct mbuf ph = mtod(op_err, struct sctp_paramhdr *); ph->param_type = htons(SCTP_CAUSE_NAT_COLLIDING_STATE); ph->param_length = htons(sizeof(struct sctp_paramhdr)); - sctp_send_abort(m, iphlen, sh, 0, op_err, vrf_id, port); + sctp_send_abort(m, iphlen, sh, 0, op_err, + use_mflowid, mflowid, + vrf_id, port); return (NULL); } if ((ntohl(initack_cp->init.initiate_tag) == asoc->my_vtag) && @@ -1832,6 +1870,7 @@ sctp_process_cookie_existing(struct mbuf return (sctp_process_cookie_new(m, iphlen, offset, sh, cookie, cookie_len, inp, netp, init_src, notification, auth_skipped, auth_offset, auth_len, + use_mflowid, mflowid, vrf_id, port)); } /* @@ -1962,12 +2001,13 @@ sctp_process_cookie_existing(struct mbuf * cookie-echo chunk length: length of the cookie chunk to: where the init * was from returns a new TCB */ -struct sctp_tcb * +static struct sctp_tcb * sctp_process_cookie_new(struct mbuf *m, int iphlen, int offset, struct sctphdr *sh, struct sctp_state_cookie *cookie, int cookie_len, struct sctp_inpcb *inp, struct sctp_nets **netp, struct sockaddr *init_src, int *notification, int auth_skipped, uint32_t auth_offset, uint32_t auth_len, + uint8_t use_mflowid, uint32_t mflowid, uint32_t vrf_id, uint16_t port) { struct sctp_tcb *stcb; @@ -2062,7 +2102,9 @@ sctp_process_cookie_new(struct mbuf *m, op_err = sctp_generate_invmanparam(SCTP_CAUSE_OUT_OF_RESC); sctp_abort_association(inp, (struct sctp_tcb *)NULL, m, iphlen, - sh, op_err, vrf_id, port); + sh, op_err, + use_mflowid, mflowid, + vrf_id, port); return (NULL); } /* get the correct sctp_nets */ @@ -2088,7 +2130,9 @@ sctp_process_cookie_new(struct mbuf *m, atomic_add_int(&stcb->asoc.refcnt, 1); op_err = sctp_generate_invmanparam(SCTP_CAUSE_OUT_OF_RESC); sctp_abort_association(inp, (struct sctp_tcb *)NULL, m, iphlen, - sh, op_err, vrf_id, port); + sh, op_err, + use_mflowid, mflowid, + vrf_id, port); #if defined (__APPLE__) || defined(SCTP_SO_LOCK_TESTING) SCTP_TCB_UNLOCK(stcb); SCTP_SOCKET_LOCK(so, 1); @@ -2335,7 +2379,9 @@ sctp_handle_cookie_echo(struct mbuf *m, struct sctphdr *sh, struct sctp_cookie_echo_chunk *cp, struct sctp_inpcb **inp_p, struct sctp_tcb **stcb, struct sctp_nets **netp, int auth_skipped, uint32_t auth_offset, uint32_t auth_len, - struct sctp_tcb **locked_tcb, uint32_t vrf_id, uint16_t port) + struct sctp_tcb **locked_tcb, + uint8_t use_mflowid, uint32_t mflowid, + uint32_t vrf_id, uint16_t port) { struct sctp_state_cookie *cookie; struct sctp_tcb *l_stcb = *stcb; @@ -2571,6 +2617,7 @@ sctp_handle_cookie_echo(struct mbuf *m, tim = now.tv_usec - cookie->time_entered.tv_usec; scm->time_usec = htonl(tim); sctp_send_operr_to(m, sh, cookie->peers_vtag, op_err, + use_mflowid, mflowid, vrf_id, port); return (NULL); } @@ -2658,21 +2705,25 @@ sctp_handle_cookie_echo(struct mbuf *m, /* this is the "normal" case... get a new TCB */ *stcb = sctp_process_cookie_new(m, iphlen, offset, sh, cookie, cookie_len, *inp_p, netp, to, ¬ification, - auth_skipped, auth_offset, auth_len, vrf_id, port); + auth_skipped, auth_offset, auth_len, + use_mflowid, mflowid, + vrf_id, port); } else { /* this is abnormal... cookie-echo on existing TCB */ had_a_existing_tcb = 1; *stcb = sctp_process_cookie_existing(m, iphlen, offset, sh, cookie, cookie_len, *inp_p, *stcb, netp, to, - ¬ification, vrf_id, auth_skipped, auth_offset, auth_len, port); + ¬ification, auth_skipped, auth_offset, auth_len, + use_mflowid, mflowid, + vrf_id, port); } if (*stcb == NULL) { /* still no TCB... must be bad cookie-echo */ return (NULL); } - if ((*netp != NULL) && (m->m_flags & M_FLOWID)) { - (*netp)->flowid = m->m_pkthdr.flowid; + if ((*netp != NULL) && (use_mflowid != 0)) { + (*netp)->flowid = mflowid; #ifdef INVARIANTS (*netp)->flowidset = 1; #endif @@ -2745,7 +2796,9 @@ sctp_handle_cookie_echo(struct mbuf *m, SCTPDBG(SCTP_DEBUG_INPUT1, "process_cookie_new: no room for another socket!\n"); op_err = sctp_generate_invmanparam(SCTP_CAUSE_OUT_OF_RESC); sctp_abort_association(*inp_p, NULL, m, iphlen, - sh, op_err, vrf_id, port); + sh, op_err, + use_mflowid, mflowid, + vrf_id, port); #if defined (__APPLE__) || defined(SCTP_SO_LOCK_TESTING) pcb_so = SCTP_INP_SO(*inp_p); atomic_add_int(&(*stcb)->asoc.refcnt, 1); @@ -4361,6 +4414,7 @@ __attribute__((noinline)) sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length, struct sctphdr *sh, struct sctp_chunkhdr *ch, struct sctp_inpcb *inp, struct sctp_tcb *stcb, struct sctp_nets **netp, int *fwd_tsn_seen, + uint8_t use_mflowid, uint32_t mflowid, uint32_t vrf_id, uint16_t port) { struct sctp_association *asoc; @@ -4517,6 +4571,7 @@ __attribute__((noinline)) if (stcb == NULL) { /* no association, so it's out of the blue... */ sctp_handle_ootb(m, iphlen, *offset, sh, inp, + use_mflowid, mflowid, vrf_id, port); *offset = length; if (locked_tcb) { @@ -4554,6 +4609,7 @@ __attribute__((noinline)) SCTP_TCB_UNLOCK(locked_tcb); } sctp_handle_ootb(m, iphlen, *offset, sh, inp, + use_mflowid, mflowid, vrf_id, port); return (NULL); } @@ -4695,7 +4751,9 @@ process_control_chunks: if ((num_chunks > 1) || (length - *offset > (int)SCTP_SIZE32(chk_length))) { sctp_abort_association(inp, stcb, m, - iphlen, sh, NULL, vrf_id, port); + iphlen, sh, NULL, + use_mflowid, mflowid, + vrf_id, port); *offset = length; return (NULL); } @@ -4705,13 +4763,17 @@ process_control_chunks: op_err = sctp_generate_invmanparam(SCTP_CAUSE_OUT_OF_RESC); sctp_abort_association(inp, stcb, m, - iphlen, sh, op_err, vrf_id, port); + iphlen, sh, op_err, + use_mflowid, mflowid, + vrf_id, port); *offset = length; return (NULL); } sctp_handle_init(m, iphlen, *offset, sh, (struct sctp_init_chunk *)ch, inp, - stcb, &abort_no_unlock, vrf_id, port); + stcb, &abort_no_unlock, + use_mflowid, mflowid, + vrf_id, port); *offset = length; if ((!abort_no_unlock) && (locked_tcb)) { SCTP_TCB_UNLOCK(locked_tcb); @@ -4760,7 +4822,11 @@ process_control_chunks: } if ((netp) && (*netp)) { ret = sctp_handle_init_ack(m, iphlen, *offset, sh, - (struct sctp_init_ack_chunk *)ch, stcb, *netp, &abort_no_unlock, vrf_id); + (struct sctp_init_ack_chunk *)ch, + stcb, *netp, + &abort_no_unlock, + use_mflowid, mflowid, + vrf_id); } else { ret = -1; } @@ -5066,7 +5132,9 @@ process_control_chunks: op_err = sctp_generate_invmanparam(SCTP_CAUSE_OUT_OF_RESC); sctp_abort_association(inp, stcb, m, - iphlen, sh, op_err, vrf_id, port); + iphlen, sh, op_err, + use_mflowid, mflowid, + vrf_id, port); } *offset = length; return (NULL); @@ -5098,6 +5166,8 @@ process_control_chunks: auth_offset, auth_len, &locked_tcb, + use_mflowid, + mflowid, vrf_id, port); } else { @@ -5550,8 +5620,10 @@ __attribute__((noinline)) void sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int length, struct sctphdr *sh, struct sctp_chunkhdr *ch, - struct sctp_inpcb *inp, struct sctp_tcb *stcb, struct sctp_nets *net, - uint8_t ecn_bits, uint32_t vrf_id, uint16_t port) + struct sctp_inpcb *inp, struct sctp_tcb *stcb, + struct sctp_nets *net, uint8_t ecn_bits, + uint8_t use_mflowid, uint32_t mflowid, + uint32_t vrf_id, uint16_t port) { /* * Control chunk processing @@ -5587,6 +5659,7 @@ sctp_common_input_processing(struct mbuf */ SCTP_TCB_UNLOCK(stcb); sctp_handle_ootb(m, iphlen, offset, sh, inp, + use_mflowid, mflowid, vrf_id, port); goto out_now; } @@ -5595,7 +5668,9 @@ sctp_common_input_processing(struct mbuf /* process the control portion of the SCTP packet */ /* sa_ignore NO_NULL_CHK */ stcb = sctp_process_control(m, iphlen, &offset, length, sh, ch, - inp, stcb, &net, &fwd_tsn_seen, vrf_id, port); + inp, stcb, &net, &fwd_tsn_seen, + use_mflowid, mflowid, + vrf_id, port); if (stcb) { /* * This covers us if the cookie-echo was there and @@ -5631,6 +5706,7 @@ sctp_common_input_processing(struct mbuf if (stcb == NULL) { /* out of the blue DATA chunk */ sctp_handle_ootb(m, iphlen, offset, sh, inp, + use_mflowid, mflowid, vrf_id, port); goto out_now; } @@ -5700,6 +5776,7 @@ sctp_common_input_processing(struct mbuf * We consider OOTB any data sent during asoc setup. */ sctp_handle_ootb(m, iphlen, offset, sh, inp, + use_mflowid, mflowid, vrf_id, port); SCTP_TCB_UNLOCK(stcb); goto out_now; @@ -5720,7 +5797,9 @@ sctp_common_input_processing(struct mbuf } /* plow through the data chunks while length > offset */ retval = sctp_process_data(mm, iphlen, &offset, length, sh, - inp, stcb, net, &high_tsn); + inp, stcb, net, &high_tsn, + use_mflowid, mflowid, + vrf_id, port); if (retval == 2) { /* * The association aborted, NO UNLOCK needed since @@ -5820,6 +5899,8 @@ sctp_input_with_port(struct mbuf *i_pak, struct sctp_chunkhdr *ch; int refcount_up = 0; int length, mlen, offset; + uint32_t mflowid; + uint8_t use_mflowid; #if !defined(SCTP_WITH_NO_CSUM) uint32_t check, calc_check; @@ -5855,6 +5936,13 @@ sctp_input_with_port(struct mbuf *i_pak, if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LAST_PACKET_TRACING) sctp_packet_log(m, mlen); #endif + if (m->m_flags & M_FLOWID) { + mflowid = m->m_pkthdr.flowid; + use_mflowid = 1; + } else { + mflowid = 0; + use_mflowid = 0; + } /* * Must take out the iphlen, since mlen expects this (only effect lb * case) @@ -5926,8 +6014,8 @@ sctp_input_with_port(struct mbuf *i_pak, } net->port = port; } - if ((net != NULL) && (m->m_flags & M_FLOWID)) { - net->flowid = m->m_pkthdr.flowid; + if ((net != NULL) && (use_mflowid != 0)) { + net->flowid = mflowid; #ifdef INVARIANTS net->flowidset = 1; #endif @@ -5961,8 +6049,8 @@ sctp_skip_csum_4: } net->port = port; } - if ((net != NULL) && (m->m_flags & M_FLOWID)) { - net->flowid = m->m_pkthdr.flowid; + if ((net != NULL) && (use_mflowid != 0)) { + net->flowid = mflowid; #ifdef INVARIANTS net->flowidset = 1; #endif @@ -5989,7 +6077,9 @@ sctp_skip_csum_4: sh->v_tag = init_chk->init.initiate_tag; } if (ch->chunk_type == SCTP_SHUTDOWN_ACK) { - sctp_send_shutdown_complete2(m, sh, vrf_id, port); + sctp_send_shutdown_complete2(m, sh, + use_mflowid, mflowid, + vrf_id, port); goto bad; } if (ch->chunk_type == SCTP_SHUTDOWN_COMPLETE) { @@ -5999,7 +6089,9 @@ sctp_skip_csum_4: if ((SCTP_BASE_SYSCTL(sctp_blackhole) == 0) || ((SCTP_BASE_SYSCTL(sctp_blackhole) == 1) && (ch->chunk_type != SCTP_INIT))) { - sctp_send_abort(m, iphlen, sh, 0, NULL, vrf_id, port); + sctp_send_abort(m, iphlen, sh, 0, NULL, + use_mflowid, mflowid, + vrf_id, port); } } goto bad; @@ -6028,7 +6120,9 @@ sctp_skip_csum_4: /* sa_ignore NO_NULL_CHK */ sctp_common_input_processing(&m, iphlen, offset, length, sh, ch, - inp, stcb, net, ecn_bits, vrf_id, port); + inp, stcb, net, ecn_bits, + use_mflowid, mflowid, + vrf_id, port); /* inp's ref-count reduced && stcb unlocked */ if (m) { sctp_m_freem(m); Modified: stable/9/sys/netinet/sctp_input.h ============================================================================== --- stable/9/sys/netinet/sctp_input.h Sun Jul 8 16:12:59 2012 (r238252) +++ stable/9/sys/netinet/sctp_input.h Sun Jul 8 16:14:42 2012 (r238253) @@ -39,8 +39,11 @@ __FBSDID("$FreeBSD$"); #if defined(_KERNEL) || defined(__Userspace__) void sctp_common_input_processing(struct mbuf **, int, int, int, - struct sctphdr *, struct sctp_chunkhdr *, struct sctp_inpcb *, - struct sctp_tcb *, struct sctp_nets *, uint8_t, uint32_t, uint16_t); + struct sctphdr *, struct sctp_chunkhdr *, + struct sctp_inpcb *, struct sctp_tcb *, + struct sctp_nets *, uint8_t, + uint8_t, uint32_t, + uint32_t, uint16_t); struct sctp_stream_reset_out_request * sctp_find_stream_reset(struct sctp_tcb *stcb, uint32_t seq, Modified: stable/9/sys/netinet/sctp_output.c ============================================================================== --- stable/9/sys/netinet/sctp_output.c Sun Jul 8 16:12:59 2012 (r238252) +++ stable/9/sys/netinet/sctp_output.c Sun Jul 8 16:14:42 2012 (r238253) @@ -3859,13 +3859,13 @@ sctp_lowlevel_chunk_output(struct sctp_i uint16_t dest_port, uint32_t v_tag, uint16_t port, + union sctp_sockstore *over_addr, + uint8_t use_mflowid, uint32_t mflowid, #if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING) - int so_locked SCTP_UNUSED, + int so_locked SCTP_UNUSED #else - int so_locked, + int so_locked #endif - union sctp_sockstore *over_addr, - struct mbuf *init ) /* nofragment_flag to tell if IP_DF should be set (IPv4 only) */ { @@ -3951,8 +3951,8 @@ sctp_lowlevel_chunk_output(struct sctp_i m->m_pkthdr.flowid = net->flowid; m->m_flags |= M_FLOWID; } else { - if ((init != NULL) && (init->m_flags & M_FLOWID)) { - m->m_pkthdr.flowid = init->m_pkthdr.flowid; + if (use_mflowid != 0) { + m->m_pkthdr.flowid = mflowid; m->m_flags |= M_FLOWID; } } @@ -4243,8 +4243,8 @@ sctp_lowlevel_chunk_output(struct sctp_i m->m_pkthdr.flowid = net->flowid; m->m_flags |= M_FLOWID; } else { - if ((init != NULL) && (init->m_flags & M_FLOWID)) { - m->m_pkthdr.flowid = init->m_pkthdr.flowid; + if (use_mflowid != 0) { + m->m_pkthdr.flowid = mflowid; m->m_flags |= M_FLOWID; } } @@ -4841,7 +4841,9 @@ sctp_send_initiate(struct sctp_inpcb *in (struct sockaddr *)&net->ro._l_addr, m, 0, NULL, 0, 0, 0, 0, inp->sctp_lport, stcb->rport, htonl(0), - net->port, so_locked, NULL, NULL); + net->port, NULL, + 0, 0, + so_locked); SCTPDBG(SCTP_DEBUG_OUTPUT4, "lowlevel_output - %d\n", ret); SCTP_STAT_INCR_COUNTER64(sctps_outcontrolchunks); (void)SCTP_GETTIME_TIMEVAL(&net->last_sent_time); @@ -5370,8 +5372,10 @@ sctp_are_there_new_addresses(struct sctp */ void sctp_send_initiate_ack(struct sctp_inpcb *inp, struct sctp_tcb *stcb, - struct mbuf *init_pkt, int iphlen, int offset, struct sctphdr *sh, - struct sctp_init_chunk *init_chk, uint32_t vrf_id, uint16_t port, int hold_inp_lock) + struct mbuf *init_pkt, int iphlen, int offset, + struct sctphdr *sh, struct sctp_init_chunk *init_chk, + uint8_t use_mflowid, uint32_t mflowid, + uint32_t vrf_id, uint16_t port, int hold_inp_lock) { struct sctp_association *asoc; struct mbuf *m, *m_at, *m_tmp, *m_cookie, *op_err, *mp_last; @@ -5422,7 +5426,9 @@ sctp_send_initiate_ack(struct sctp_inpcb * though we even set the T bit and copy in the 0 tag.. this * looks no different than if no listener was present. */ - sctp_send_abort(init_pkt, iphlen, sh, 0, NULL, vrf_id, port); + sctp_send_abort(init_pkt, iphlen, sh, 0, NULL, + use_mflowid, mflowid, + vrf_id, port); return; } abort_flag = 0; @@ -5432,7 +5438,9 @@ sctp_send_initiate_ack(struct sctp_inpcb if (abort_flag) { do_a_abort: sctp_send_abort(init_pkt, iphlen, sh, - init_chk->init.initiate_tag, op_err, vrf_id, port); + init_chk->init.initiate_tag, op_err, + use_mflowid, mflowid, + vrf_id, port); return; } m = sctp_get_mbuf_for_msg(MCLBYTES, 0, M_DONTWAIT, 1, MT_DATA); @@ -6034,7 +6042,9 @@ do_a_abort: (void)sctp_lowlevel_chunk_output(inp, NULL, NULL, to, m, 0, NULL, 0, 0, 0, 0, inp->sctp_lport, sh->src_port, init_chk->init.initiate_tag, - port, SCTP_SO_NOT_LOCKED, over_addr, init_pkt); + port, over_addr, + use_mflowid, mflowid, + SCTP_SO_NOT_LOCKED); SCTP_STAT_INCR_COUNTER64(sctps_outcontrolchunks); } @@ -8116,7 +8126,9 @@ again_one_more_time: no_fragmentflg, 0, asconf, inp->sctp_lport, stcb->rport, htonl(stcb->asoc.peer_vtag), - net->port, so_locked, NULL, NULL))) { + net->port, NULL, + 0, 0, + so_locked))) { if (error == ENOBUFS) { asoc->ifp_had_enobuf = 1; SCTP_STAT_INCR(sctps_lowlevelerr); @@ -8388,7 +8400,9 @@ again_one_more_time: no_fragmentflg, 0, asconf, inp->sctp_lport, stcb->rport, htonl(stcb->asoc.peer_vtag), - net->port, so_locked, NULL, NULL))) { + net->port, NULL, + 0, 0, + so_locked))) { if (error == ENOBUFS) { asoc->ifp_had_enobuf = 1; SCTP_STAT_INCR(sctps_lowlevelerr); @@ -8727,7 +8741,9 @@ no_data_fill: asconf, inp->sctp_lport, stcb->rport, htonl(stcb->asoc.peer_vtag), - net->port, so_locked, NULL, NULL))) { + net->port, NULL, + 0, 0, + so_locked))) { /* error, we could not output */ if (error == ENOBUFS) { SCTP_STAT_INCR(sctps_lowlevelerr); @@ -9429,7 +9445,9 @@ sctp_chunk_retransmission(struct sctp_in auth_offset, auth, stcb->asoc.authinfo.active_keyid, no_fragmentflg, 0, 0, inp->sctp_lport, stcb->rport, htonl(stcb->asoc.peer_vtag), - chk->whoTo->port, so_locked, NULL, NULL))) { + chk->whoTo->port, NULL, + 0, 0, + so_locked))) { SCTP_STAT_INCR(sctps_lowlevelerr); return (error); } @@ -9694,7 +9712,9 @@ one_chunk_around: auth_offset, auth, auth_keyid, no_fragmentflg, 0, 0, inp->sctp_lport, stcb->rport, htonl(stcb->asoc.peer_vtag), - net->port, so_locked, NULL, NULL))) { + net->port, NULL, + 0, 0, + so_locked))) { /* error, we could not output */ SCTP_STAT_INCR(sctps_lowlevelerr); return (error); @@ -10812,7 +10832,9 @@ sctp_send_abort_tcb(struct sctp_tcb *stc (struct sockaddr *)&net->ro._l_addr, m_out, auth_offset, auth, stcb->asoc.authinfo.active_keyid, 1, 0, 0, stcb->sctp_ep->sctp_lport, stcb->rport, htonl(stcb->asoc.peer_vtag), - stcb->asoc.primary_destination->port, so_locked, NULL, NULL); + stcb->asoc.primary_destination->port, NULL, + 0, 0, + so_locked); SCTP_STAT_INCR_COUNTER64(sctps_outcontrolchunks); } @@ -10849,14 +10871,18 @@ sctp_send_shutdown_complete(struct sctp_ m_shutdown_comp, 0, NULL, 0, 1, 0, 0, stcb->sctp_ep->sctp_lport, stcb->rport, htonl(vtag), - net->port, SCTP_SO_NOT_LOCKED, NULL, NULL); + net->port, NULL, + 0, 0, + SCTP_SO_NOT_LOCKED); SCTP_STAT_INCR_COUNTER64(sctps_outcontrolchunks); return; } static void sctp_send_resp_msg(struct mbuf *m, struct sctphdr *sh, uint32_t vtag, - uint8_t type, struct mbuf *cause, uint32_t vrf_id, uint16_t port) + uint8_t type, struct mbuf *cause, + uint8_t use_mflowid, uint32_t mflowid, + uint32_t vrf_id, uint16_t port) { struct mbuf *o_pak; struct mbuf *mout; @@ -10929,8 +10955,8 @@ sctp_send_resp_msg(struct mbuf *m, struc SCTP_BUF_RESV_UF(mout, max_linkhdr); SCTP_BUF_LEN(mout) = len; SCTP_BUF_NEXT(mout) = cause; - if (m->m_flags & M_FLOWID) { - mout->m_pkthdr.flowid = m->m_pkthdr.flowid; + if (use_mflowid != 0) { + mout->m_pkthdr.flowid = mflowid; mout->m_flags |= M_FLOWID; } #ifdef INET @@ -11110,9 +11136,12 @@ sctp_send_resp_msg(struct mbuf *m, struc void sctp_send_shutdown_complete2(struct mbuf *m, struct sctphdr *sh, + uint8_t use_mflowid, uint32_t mflowid, uint32_t vrf_id, uint16_t port) { - sctp_send_resp_msg(m, sh, 0, SCTP_SHUTDOWN_COMPLETE, NULL, vrf_id, port); + sctp_send_resp_msg(m, sh, 0, SCTP_SHUTDOWN_COMPLETE, NULL, + use_mflowid, mflowid, + vrf_id, port); } void @@ -11944,7 +11973,9 @@ skip_stuff: void sctp_send_abort(struct mbuf *m, int iphlen, struct sctphdr *sh, uint32_t vtag, - struct mbuf *cause, uint32_t vrf_id, uint16_t port) + struct mbuf *cause, + uint8_t use_mflowid, uint32_t mflowid, + uint32_t vrf_id, uint16_t port) { /* Don't respond to an ABORT with an ABORT. */ if (sctp_is_there_an_abort_here(m, iphlen, &vtag)) { @@ -11952,15 +11983,21 @@ sctp_send_abort(struct mbuf *m, int iphl sctp_m_freem(cause); return; } - sctp_send_resp_msg(m, sh, vtag, SCTP_ABORT_ASSOCIATION, cause, vrf_id, port); + sctp_send_resp_msg(m, sh, vtag, SCTP_ABORT_ASSOCIATION, cause, + use_mflowid, mflowid, + vrf_id, port); return; } void sctp_send_operr_to(struct mbuf *m, struct sctphdr *sh, uint32_t vtag, - struct mbuf *cause, uint32_t vrf_id, uint16_t port) + struct mbuf *cause, + uint8_t use_mflowid, uint32_t mflowid, + uint32_t vrf_id, uint16_t port) { - sctp_send_resp_msg(m, sh, vtag, SCTP_OPERATION_ERROR, cause, vrf_id, port); + sctp_send_resp_msg(m, sh, vtag, SCTP_OPERATION_ERROR, cause, + use_mflowid, mflowid, + vrf_id, port); return; } Modified: stable/9/sys/netinet/sctp_output.h ============================================================================== --- stable/9/sys/netinet/sctp_output.h Sun Jul 8 16:12:59 2012 (r238252) +++ stable/9/sys/netinet/sctp_output.h Sun Jul 8 16:14:42 2012 (r238253) @@ -83,8 +83,9 @@ sctp_send_initiate(struct sctp_inpcb *, ); void -sctp_send_initiate_ack(struct sctp_inpcb *, struct sctp_tcb *, - struct mbuf *, int, int, struct sctphdr *, struct sctp_init_chunk *, +sctp_send_initiate_ack(struct sctp_inpcb *, struct sctp_tcb *, struct mbuf *, + int, int, struct sctphdr *, struct sctp_init_chunk *, + uint8_t, uint32_t, uint32_t, uint16_t, int); struct mbuf * @@ -116,6 +117,7 @@ void sctp_send_shutdown_complete(struct void sctp_send_shutdown_complete2(struct mbuf *, struct sctphdr *, + uint8_t, uint32_t, uint32_t, uint16_t); void sctp_send_asconf(struct sctp_tcb *, struct sctp_nets *, int addr_locked); @@ -202,15 +204,19 @@ sctp_send_str_reset_req(struct sctp_tcb void sctp_send_abort(struct mbuf *, int, struct sctphdr *, uint32_t, - struct mbuf *, uint32_t, uint16_t); + struct mbuf *, + uint8_t, uint32_t, + uint32_t, uint16_t); void sctp_send_operr_to(struct mbuf *, struct sctphdr *, uint32_t, - struct mbuf *, uint32_t, uint16_t); + struct mbuf *, + uint8_t, uint32_t, + uint32_t, uint16_t); #endif /* _KERNEL || __Userspace__ */ -#if defined(_KERNEL) || defined (__Userspace__) +#if defined(_KERNEL) || defined(__Userspace__) int sctp_sosend(struct socket *so, struct sockaddr *addr, Modified: stable/9/sys/netinet/sctputil.c ============================================================================== --- stable/9/sys/netinet/sctputil.c Sun Jul 8 16:12:59 2012 (r238252) +++ stable/9/sys/netinet/sctputil.c Sun Jul 8 16:14:42 2012 (r238253) @@ -3823,7 +3823,9 @@ sctp_abort_notification(struct sctp_tcb void sctp_abort_association(struct sctp_inpcb *inp, struct sctp_tcb *stcb, - struct mbuf *m, int iphlen, struct sctphdr *sh, struct mbuf *op_err, + struct mbuf *m, int iphlen, struct sctphdr *sh, + struct mbuf *op_err, + uint8_t use_mflowid, uint32_t mflowid, uint32_t vrf_id, uint16_t port) { uint32_t vtag; @@ -3842,7 +3844,9 @@ sctp_abort_association(struct sctp_inpcb vrf_id = stcb->asoc.vrf_id; stcb->asoc.state |= SCTP_STATE_WAS_ABORTED; } - sctp_send_abort(m, iphlen, sh, vtag, op_err, vrf_id, port); + sctp_send_abort(m, iphlen, sh, vtag, op_err, + use_mflowid, mflowid, + vrf_id, port); if (stcb != NULL) { /* Ok, now lets free it */ #if defined (__APPLE__) || defined(SCTP_SO_LOCK_TESTING) @@ -3992,7 +3996,9 @@ sctp_abort_an_association(struct sctp_in void sctp_handle_ootb(struct mbuf *m, int iphlen, int offset, struct sctphdr *sh, - struct sctp_inpcb *inp, uint32_t vrf_id, uint16_t port) + struct sctp_inpcb *inp, + uint8_t use_mflowid, uint32_t mflowid, + uint32_t vrf_id, uint16_t port) { struct sctp_chunkhdr *ch, chunk_buf; unsigned int chk_length; @@ -4035,7 +4041,9 @@ sctp_handle_ootb(struct mbuf *m, int iph */ return; case SCTP_SHUTDOWN_ACK: - sctp_send_shutdown_complete2(m, sh, vrf_id, port); + sctp_send_shutdown_complete2(m, sh, + use_mflowid, mflowid, + vrf_id, port); return; default: break; @@ -4047,7 +4055,9 @@ sctp_handle_ootb(struct mbuf *m, int iph if ((SCTP_BASE_SYSCTL(sctp_blackhole) == 0) || ((SCTP_BASE_SYSCTL(sctp_blackhole) == 1) && (contains_init_chunk == 0))) { - sctp_send_abort(m, iphlen, sh, 0, NULL, vrf_id, port); + sctp_send_abort(m, iphlen, sh, 0, NULL, + use_mflowid, mflowid, + vrf_id, port); } } Modified: stable/9/sys/netinet/sctputil.h ============================================================================== --- stable/9/sys/netinet/sctputil.h Sun Jul 8 16:12:59 2012 (r238252) +++ stable/9/sys/netinet/sctputil.h Sun Jul 8 16:14:42 2012 (r238253) @@ -185,8 +185,10 @@ sctp_abort_notification(struct sctp_tcb /* We abort responding to an IP packet for some reason */ void -sctp_abort_association(struct sctp_inpcb *, struct sctp_tcb *, - struct mbuf *, int, struct sctphdr *, struct mbuf *, uint32_t, uint16_t); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 8 19:29:09 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 492291065670; Sun, 8 Jul 2012 19:29:09 +0000 (UTC) (envelope-from trociny@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 333258FC12; Sun, 8 Jul 2012 19:29:09 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q68JT98P070212; Sun, 8 Jul 2012 19:29:09 GMT (envelope-from trociny@svn.freebsd.org) Received: (from trociny@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q68JT8It070210; Sun, 8 Jul 2012 19:29:09 GMT (envelope-from trociny@svn.freebsd.org) Message-Id: <201207081929.q68JT8It070210@svn.freebsd.org> From: Mikolaj Golub Date: Sun, 8 Jul 2012 19:29:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238259 - stable/9/sys/netinet X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jul 2012 19:29:09 -0000 Author: trociny Date: Sun Jul 8 19:29:08 2012 New Revision: 238259 URL: http://svn.freebsd.org/changeset/base/238259 Log: Fix RTTVAR scale in net.inet.tcp.hostcache.list sysctl. Reviewed by: andre Approved by: re (kib) Modified: stable/9/sys/netinet/tcp_hostcache.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/tcp_hostcache.c ============================================================================== --- stable/9/sys/netinet/tcp_hostcache.c Sun Jul 8 18:04:26 2012 (r238258) +++ stable/9/sys/netinet/tcp_hostcache.c Sun Jul 8 19:29:08 2012 (r238259) @@ -624,7 +624,7 @@ sysctl_tcp_hc_list(SYSCTL_HANDLER_ARGS) msec(hc_entry->rmx_rtt * (RTM_RTTUNIT / (hz * TCP_RTT_SCALE))), msec(hc_entry->rmx_rttvar * - (RTM_RTTUNIT / (hz * TCP_RTT_SCALE))), + (RTM_RTTUNIT / (hz * TCP_RTTVAR_SCALE))), hc_entry->rmx_bandwidth * 8, hc_entry->rmx_cwnd, hc_entry->rmx_sendpipe, From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 8 19:36:47 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BCBAE1065670; Sun, 8 Jul 2012 19:36:47 +0000 (UTC) (envelope-from to.my.trociny@gmail.com) Received: from mail-we0-f182.google.com (mail-we0-f182.google.com [74.125.82.182]) by mx1.freebsd.org (Postfix) with ESMTP id C52348FC14; Sun, 8 Jul 2012 19:36:46 +0000 (UTC) Received: by werp13 with SMTP id p13so7279158wer.13 for ; Sun, 08 Jul 2012 12:36:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:references:x-comment-to:sender:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=s8CWv8V2oGvpVzZUcS19WF2O1SwlAjkLEwxMs1fx/Ig=; b=anpcQ0WJsjqRvJqCBPKusJ6qKJLcmGfYjdWMwCQixoNpRmt0MkcoxCVFqSoH4VAe0D VkdAZEYvwzoa0KJ9HvtitVuCavgi96AaQSYQ0V9TmBupbYyLTp3DRzbuWNXIN5dHhRpT GFPkAg12SazelQYYg3UMz7ybnyEP0MWmA/qx+9P1e968u7YuObjWY8O5J/Zsx22j3y1z JkVVLiLf7ipJLbBB8/txEFoXl1ybMbJV1fQtiGvM986uBuOaiIRA7M9g7fpcHMNTYmqL t+KB0+c0seSNVGwbjdapf97qAiN2yXDzcTTi1Bbr4XiEcjg6tJsV1Rmmx4QC21PmgPdU A+Pg== Received: by 10.180.98.200 with SMTP id ek8mr23854864wib.0.1341776205744; Sun, 08 Jul 2012 12:36:45 -0700 (PDT) Received: from localhost ([95.69.175.25]) by mx.google.com with ESMTPS id l5sm28843403wix.5.2012.07.08.12.36.43 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 08 Jul 2012 12:36:44 -0700 (PDT) From: Mikolaj Golub To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org References: <201207081929.q68JT8It070210@svn.freebsd.org> X-Comment-To: Mikolaj Golub Sender: Mikolaj Golub Date: Sun, 08 Jul 2012 22:36:41 +0300 In-Reply-To: <201207081929.q68JT8It070210@svn.freebsd.org> (Mikolaj Golub's message of "Sun, 8 Jul 2012 19:29:08 +0000 (UTC)") Message-ID: <86sjd2qc3a.fsf@kopusha.home.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Subject: Re: svn commit: r238259 - stable/9/sys/netinet X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jul 2012 19:36:47 -0000 On Sun, 8 Jul 2012 19:29:08 +0000 (UTC) Mikolaj Golub wrote: MG> Author: trociny MG> Date: Sun Jul 8 19:29:08 2012 MG> New Revision: 238259 MG> URL: http://svn.freebsd.org/changeset/base/238259 MG> Log: MG> Fix RTTVAR scale in net.inet.tcp.hostcache.list sysctl. MG> MG> Reviewed by: andre MG> Approved by: re (kib) Forgot to add to the log message that it was MFC r238083. Sorry. -- Mikolaj Golub From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 8 20:35:57 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7604E106566B; Sun, 8 Jul 2012 20:35:57 +0000 (UTC) (envelope-from jfv@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5F0568FC1D; Sun, 8 Jul 2012 20:35:57 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q68KZvCc073216; Sun, 8 Jul 2012 20:35:57 GMT (envelope-from jfv@svn.freebsd.org) Received: (from jfv@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q68KZvZu073204; Sun, 8 Jul 2012 20:35:57 GMT (envelope-from jfv@svn.freebsd.org) Message-Id: <201207082035.q68KZvZu073204@svn.freebsd.org> From: Jack F Vogel Date: Sun, 8 Jul 2012 20:35:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238262 - in stable/9/sys: conf dev/e1000 modules/em modules/igb X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jul 2012 20:35:57 -0000 Author: jfv Date: Sun Jul 8 20:35:56 2012 New Revision: 238262 URL: http://svn.freebsd.org/changeset/base/238262 Log: MFC of the e1000 drivers: 236406,238148,238151,238181, and 238214 Approved by:re Added: stable/9/sys/dev/e1000/e1000_i210.c - copied unchanged from r238148, head/sys/dev/e1000/e1000_i210.c stable/9/sys/dev/e1000/e1000_i210.h - copied unchanged from r238148, head/sys/dev/e1000/e1000_i210.h Modified: stable/9/sys/conf/files stable/9/sys/dev/e1000/e1000_82541.c stable/9/sys/dev/e1000/e1000_82543.c stable/9/sys/dev/e1000/e1000_82571.c stable/9/sys/dev/e1000/e1000_82575.c stable/9/sys/dev/e1000/e1000_api.c stable/9/sys/dev/e1000/e1000_api.h stable/9/sys/dev/e1000/e1000_defines.h stable/9/sys/dev/e1000/e1000_hw.h stable/9/sys/dev/e1000/e1000_ich8lan.c stable/9/sys/dev/e1000/e1000_mac.c stable/9/sys/dev/e1000/e1000_mac.h stable/9/sys/dev/e1000/e1000_manage.c stable/9/sys/dev/e1000/e1000_manage.h stable/9/sys/dev/e1000/e1000_phy.c stable/9/sys/dev/e1000/e1000_phy.h stable/9/sys/dev/e1000/e1000_regs.h stable/9/sys/dev/e1000/if_em.c stable/9/sys/dev/e1000/if_igb.c stable/9/sys/modules/em/Makefile stable/9/sys/modules/igb/Makefile Directory Properties: stable/9/sys/ (props changed) stable/9/sys/conf/ (props changed) stable/9/sys/dev/ (props changed) stable/9/sys/dev/e1000/ (props changed) stable/9/sys/modules/ (props changed) Modified: stable/9/sys/conf/files ============================================================================== --- stable/9/sys/conf/files Sun Jul 8 19:33:20 2012 (r238261) +++ stable/9/sys/conf/files Sun Jul 8 20:35:56 2012 (r238262) @@ -1042,6 +1042,8 @@ dev/e1000/e1000_82575.c optional em | i compile-with "${NORMAL_C} -I$S/dev/e1000" dev/e1000/e1000_ich8lan.c optional em | igb \ compile-with "${NORMAL_C} -I$S/dev/e1000" +dev/e1000/e1000_i210.c optional em | igb \ + compile-with "${NORMAL_C} -I$S/dev/e1000" dev/e1000/e1000_api.c optional em | igb \ compile-with "${NORMAL_C} -I$S/dev/e1000" dev/e1000/e1000_mac.c optional em | igb \ Modified: stable/9/sys/dev/e1000/e1000_82541.c ============================================================================== --- stable/9/sys/dev/e1000/e1000_82541.c Sun Jul 8 19:33:20 2012 (r238261) +++ stable/9/sys/dev/e1000/e1000_82541.c Sun Jul 8 20:35:56 2012 (r238262) @@ -642,7 +642,7 @@ static s32 e1000_check_for_link_82541(st * of MAC speed/duplex configuration. So we only need to * configure Collision Distance in the MAC. */ - e1000_config_collision_dist_generic(hw); + mac->ops.config_collision_dist(hw); /* * Configure Flow Control now that Auto-Neg has completed. Modified: stable/9/sys/dev/e1000/e1000_82543.c ============================================================================== --- stable/9/sys/dev/e1000/e1000_82543.c Sun Jul 8 19:33:20 2012 (r238261) +++ stable/9/sys/dev/e1000/e1000_82543.c Sun Jul 8 20:35:56 2012 (r238262) @@ -1126,7 +1126,7 @@ static s32 e1000_setup_copper_link_82543 DEBUGOUT("Valid link established!!!\n"); /* Config the MAC and PHY after link is up */ if (hw->mac.type == e1000_82544) { - e1000_config_collision_dist_generic(hw); + hw->mac.ops.config_collision_dist(hw); } else { ret_val = e1000_config_mac_to_phy_82543(hw); if (ret_val) @@ -1160,7 +1160,7 @@ static s32 e1000_setup_fiber_link_82543( /* Take the link out of reset */ ctrl &= ~E1000_CTRL_LRST; - e1000_config_collision_dist_generic(hw); + hw->mac.ops.config_collision_dist(hw); ret_val = e1000_commit_fc_settings_generic(hw); if (ret_val) @@ -1259,7 +1259,7 @@ static s32 e1000_check_for_copper_link_8 * settings. */ if (mac->type == e1000_82544) - e1000_config_collision_dist_generic(hw); + hw->mac.ops.config_collision_dist(hw); else { ret_val = e1000_config_mac_to_phy_82543(hw); if (ret_val) { @@ -1433,7 +1433,7 @@ static s32 e1000_config_mac_to_phy_82543 if (phy_data & M88E1000_PSSR_DPLX) ctrl |= E1000_CTRL_FD; - e1000_config_collision_dist_generic(hw); + hw->mac.ops.config_collision_dist(hw); /* * Set up speed in the Device Control register depending on Modified: stable/9/sys/dev/e1000/e1000_82571.c ============================================================================== --- stable/9/sys/dev/e1000/e1000_82571.c Sun Jul 8 19:33:20 2012 (r238261) +++ stable/9/sys/dev/e1000/e1000_82571.c Sun Jul 8 20:35:56 2012 (r238262) @@ -1907,7 +1907,7 @@ void e1000_set_laa_state_82571(struct e1 * incoming packets directed to this port are dropped. * Eventually the LAA will be in RAR[0] and RAR[14]. */ - e1000_rar_set_generic(hw, hw->mac.addr, + hw->mac.ops.rar_set(hw, hw->mac.addr, hw->mac.rar_entry_count - 1); return; } Modified: stable/9/sys/dev/e1000/e1000_82575.c ============================================================================== --- stable/9/sys/dev/e1000/e1000_82575.c Sun Jul 8 19:33:20 2012 (r238261) +++ stable/9/sys/dev/e1000/e1000_82575.c Sun Jul 8 20:35:56 2012 (r238262) @@ -1,6 +1,6 @@ /****************************************************************************** - Copyright (c) 2001-2011, Intel Corporation + Copyright (c) 2001-2012, Intel Corporation All rights reserved. Redistribution and use in source and binary forms, with or without @@ -38,9 +38,12 @@ * 82575GB Gigabit Network Connection * 82576 Gigabit Network Connection * 82576 Quad Port Gigabit Mezzanine Adapter + * 82580 Gigabit Network Connection + * I350 Gigabit Network Connection */ #include "e1000_api.h" +#include "e1000_i210.h" static s32 e1000_init_phy_params_82575(struct e1000_hw *hw); static s32 e1000_init_mac_params_82575(struct e1000_hw *hw); @@ -162,6 +165,9 @@ static s32 e1000_init_phy_params_82575(s DEBUGFUNC("e1000_init_phy_params_82575"); + phy->ops.read_i2c_byte = e1000_read_i2c_byte_generic; + phy->ops.write_i2c_byte = e1000_write_i2c_byte_generic; + if (hw->phy.media_type != e1000_media_type_copper) { phy->type = e1000_phy_none; goto out; @@ -195,12 +201,22 @@ static s32 e1000_init_phy_params_82575(s if (e1000_sgmii_active_82575(hw) && !e1000_sgmii_uses_mdio_82575(hw)) { phy->ops.read_reg = e1000_read_phy_reg_sgmii_82575; phy->ops.write_reg = e1000_write_phy_reg_sgmii_82575; - } else if (hw->mac.type >= e1000_82580) { - phy->ops.read_reg = e1000_read_phy_reg_82580; - phy->ops.write_reg = e1000_write_phy_reg_82580; } else { - phy->ops.read_reg = e1000_read_phy_reg_igp; - phy->ops.write_reg = e1000_write_phy_reg_igp; + switch (hw->mac.type) { + case e1000_82580: + case e1000_i350: + phy->ops.read_reg = e1000_read_phy_reg_82580; + phy->ops.write_reg = e1000_write_phy_reg_82580; + break; + case e1000_i210: + case e1000_i211: + phy->ops.read_reg = e1000_read_phy_reg_gs40g; + phy->ops.write_reg = e1000_write_phy_reg_gs40g; + break; + default: + phy->ops.read_reg = e1000_read_phy_reg_igp; + phy->ops.write_reg = e1000_write_phy_reg_igp; + } } /* Set phy->phy_addr and phy->id. */ @@ -245,6 +261,15 @@ static s32 e1000_init_phy_params_82575(s phy->ops.set_d0_lplu_state = e1000_set_d0_lplu_state_82580; phy->ops.set_d3_lplu_state = e1000_set_d3_lplu_state_82580; break; + case I210_I_PHY_ID: + phy->type = e1000_phy_i210; + phy->ops.check_polarity = e1000_check_polarity_m88; + phy->ops.get_info = e1000_get_phy_info_m88; + phy->ops.get_cable_length = e1000_get_cable_length_m88_gen2; + phy->ops.set_d0_lplu_state = e1000_set_d0_lplu_state_82580; + phy->ops.set_d3_lplu_state = e1000_set_d3_lplu_state_82580; + phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_m88; + break; default: ret_val = -E1000_ERR_PHY; goto out; @@ -281,28 +306,32 @@ s32 e1000_init_nvm_params_82575(struct e size = 15; nvm->word_size = 1 << size; - nvm->opcode_bits = 8; - nvm->delay_usec = 1; - switch (nvm->override) { - case e1000_nvm_override_spi_large: - nvm->page_size = 32; - nvm->address_bits = 16; - break; - case e1000_nvm_override_spi_small: - nvm->page_size = 8; - nvm->address_bits = 8; - break; - default: - nvm->page_size = eecd & E1000_EECD_ADDR_BITS ? 32 : 8; - nvm->address_bits = eecd & E1000_EECD_ADDR_BITS ? 16 : 8; - break; - } - - nvm->type = e1000_nvm_eeprom_spi; - - if (nvm->word_size == (1 << 15)) - nvm->page_size = 128; + if (hw->mac.type < e1000_i210) { + nvm->opcode_bits = 8; + nvm->delay_usec = 1; + + switch (nvm->override) { + case e1000_nvm_override_spi_large: + nvm->page_size = 32; + nvm->address_bits = 16; + break; + case e1000_nvm_override_spi_small: + nvm->page_size = 8; + nvm->address_bits = 8; + break; + default: + nvm->page_size = eecd & E1000_EECD_ADDR_BITS ? 32 : 8; + nvm->address_bits = eecd & E1000_EECD_ADDR_BITS ? + 16 : 8; + break; + } + if (nvm->word_size == (1 << 15)) + nvm->page_size = 128; + nvm->type = e1000_nvm_eeprom_spi; + } else { + nvm->type = e1000_nvm_flash_hw; + } /* Function Pointers */ nvm->ops.acquire = e1000_acquire_nvm_82575; nvm->ops.release = e1000_release_nvm_82575; @@ -316,7 +345,7 @@ s32 e1000_init_nvm_params_82575(struct e nvm->ops.update = e1000_update_nvm_checksum_generic; nvm->ops.valid_led_default = e1000_valid_led_default_82575; - /* override genric family function pointers for specific descendants */ + /* override generic family function pointers for specific descendants */ switch (hw->mac.type) { case e1000_82580: nvm->ops.validate = e1000_validate_nvm_checksum_82580; @@ -368,8 +397,7 @@ static s32 e1000_init_mac_params_82575(s mac->has_fwsm = TRUE; /* ARC supported; valid only if manageability features are enabled. */ mac->arc_subsystem_valid = - (E1000_READ_REG(hw, E1000_FWSM) & E1000_FWSM_MODE_MASK) - ? TRUE : FALSE; + !!(E1000_READ_REG(hw, E1000_FWSM) & E1000_FWSM_MODE_MASK); /* Function pointers */ @@ -394,8 +422,6 @@ static s32 e1000_init_mac_params_82575(s mac->ops.power_up_serdes = e1000_power_up_serdes_link_82575; /* check for link */ mac->ops.check_for_link = e1000_check_for_link_82575; - /* receive address register setting */ - mac->ops.rar_set = e1000_rar_set_generic; /* read mac address */ mac->ops.read_mac_addr = e1000_read_mac_addr_82575; /* configure collision distance */ @@ -428,6 +454,13 @@ static s32 e1000_init_mac_params_82575(s mac->ops.clear_hw_cntrs = e1000_clear_hw_cntrs_82575; /* link info */ mac->ops.get_link_up_info = e1000_get_link_up_info_82575; + /* acquire SW_FW sync */ + mac->ops.acquire_swfw_sync = e1000_acquire_swfw_sync_82575; + mac->ops.release_swfw_sync = e1000_release_swfw_sync_82575; + if (mac->type >= e1000_i210) { + mac->ops.acquire_swfw_sync = e1000_acquire_swfw_sync_i210; + mac->ops.release_swfw_sync = e1000_release_swfw_sync_i210; + } /* set lan id for port to determine which phy lock to use */ hw->mac.ops.set_lan_id(hw); @@ -470,7 +503,7 @@ static s32 e1000_acquire_phy_82575(struc else if (hw->bus.func == E1000_FUNC_3) mask = E1000_SWFW_PHY3_SM; - return e1000_acquire_swfw_sync_82575(hw, mask); + return hw->mac.ops.acquire_swfw_sync(hw, mask); } /** @@ -492,7 +525,7 @@ static void e1000_release_phy_82575(stru else if (hw->bus.func == E1000_FUNC_3) mask = E1000_SWFW_PHY3_SM; - e1000_release_swfw_sync_82575(hw, mask); + hw->mac.ops.release_swfw_sync(hw, mask); } /** @@ -796,7 +829,7 @@ static s32 e1000_set_d0_lplu_state_82580 { struct e1000_phy_info *phy = &hw->phy; s32 ret_val = E1000_SUCCESS; - u16 data; + u32 data; DEBUGFUNC("e1000_set_d0_lplu_state_82580"); @@ -844,7 +877,7 @@ s32 e1000_set_d3_lplu_state_82580(struct { struct e1000_phy_info *phy = &hw->phy; s32 ret_val = E1000_SUCCESS; - u16 data; + u32 data; DEBUGFUNC("e1000_set_d3_lplu_state_82580"); @@ -918,11 +951,7 @@ static s32 e1000_acquire_nvm_82575(struc } - switch (hw->mac.type) { - default: - ret_val = e1000_acquire_nvm_generic(hw); - } - + ret_val = e1000_acquire_nvm_generic(hw); if (ret_val) e1000_release_swfw_sync_82575(hw, E1000_SWFW_EEP_SM); @@ -941,10 +970,8 @@ static void e1000_release_nvm_82575(stru { DEBUGFUNC("e1000_release_nvm_82575"); - switch (hw->mac.type) { - default: - e1000_release_nvm_generic(hw); - } + e1000_release_nvm_generic(hw); + e1000_release_swfw_sync_82575(hw, E1000_SWFW_EEP_SM); } @@ -1058,7 +1085,7 @@ static s32 e1000_get_cfg_done_82575(stru DEBUGOUT("MNG configuration cycle has not completed.\n"); /* If EEPROM is not marked present, init the PHY manually */ - if (((E1000_READ_REG(hw, E1000_EECD) & E1000_EECD_PRES) == 0) && + if (!(E1000_READ_REG(hw, E1000_EECD) & E1000_EECD_PRES) && (hw->phy.type == e1000_phy_igp_3)) e1000_phy_init_script_igp3(hw); @@ -1115,6 +1142,7 @@ static s32 e1000_check_for_link_82575(st * continue to check for link. */ hw->mac.get_link_status = !hw->mac.serdes_has_link; + } else { ret_val = e1000_check_for_copper_link_generic(hw); } @@ -1168,11 +1196,6 @@ static s32 e1000_get_pcs_speed_and_duple DEBUGFUNC("e1000_get_pcs_speed_and_duplex_82575"); - /* Set up defaults for the return values of this function */ - mac->serdes_has_link = FALSE; - *speed = 0; - *duplex = 0; - /* * Read the PCS Status register for link state. For non-copper mode, * the status register is not accurate. The PCS status register is @@ -1181,11 +1204,9 @@ static s32 e1000_get_pcs_speed_and_duple pcs = E1000_READ_REG(hw, E1000_PCS_LSTAT); /* - * The link up bit determines when link is up on autoneg. The sync ok - * gets set once both sides sync up and agree upon link. Stable link - * can be determined by checking for both link up and link sync ok + * The link up bit determines when link is up on autoneg. */ - if ((pcs & E1000_PCS_LSTS_LINK_OK) && (pcs & E1000_PCS_LSTS_SYNK_OK)) { + if (pcs & E1000_PCS_LSTS_LINK_OK) { mac->serdes_has_link = TRUE; /* Detect and store PCS speed */ @@ -1201,6 +1222,10 @@ static s32 e1000_get_pcs_speed_and_duple *duplex = FULL_DUPLEX; else *duplex = HALF_DUPLEX; + } else { + mac->serdes_has_link = FALSE; + *speed = 0; + *duplex = 0; } return E1000_SUCCESS; @@ -1293,7 +1318,7 @@ static s32 e1000_reset_hw_82575(struct e } /* If EEPROM is not present, run manual init scripts */ - if ((E1000_READ_REG(hw, E1000_EECD) & E1000_EECD_PRES) == 0) + if (!(E1000_READ_REG(hw, E1000_EECD) & E1000_EECD_PRES)) e1000_reset_init_script_82575(hw); /* Clear any pending interrupt events. */ @@ -1396,6 +1421,7 @@ static s32 e1000_setup_copper_link_82575 } } switch (hw->phy.type) { + case e1000_phy_i210: case e1000_phy_m88: if (hw->phy.id == I347AT4_E_PHY_ID || hw->phy.id == M88E1112_E_PHY_ID || @@ -1605,31 +1631,28 @@ static s32 e1000_get_media_type_82575(st } /* Read Init Control Word #3*/ hw->nvm.ops.read(hw, init_ctrl_wd_3_offset, 1, &init_ctrl_wd_3); + + /* + * Align link mode bits to + * their CTRL_EXT location. + */ current_link_mode = init_ctrl_wd_3; + current_link_mode <<= (E1000_CTRL_EXT_LINK_MODE_OFFSET - + init_ctrl_wd_3_bit_offset); + current_link_mode &= E1000_CTRL_EXT_LINK_MODE_MASK; + /* * Switch to CSR for all but internal PHY. */ - if ((init_ctrl_wd_3 << (E1000_CTRL_EXT_LINK_MODE_OFFSET - - init_ctrl_wd_3_bit_offset)) != - E1000_CTRL_EXT_LINK_MODE_GMII) { - current_link_mode = ctrl_ext; - init_ctrl_wd_3_bit_offset = - E1000_CTRL_EXT_LINK_MODE_OFFSET; - } + if (current_link_mode != E1000_CTRL_EXT_LINK_MODE_GMII) + /* Take link mode from CSR */ + current_link_mode = ctrl_ext & + E1000_CTRL_EXT_LINK_MODE_MASK; } else { /* Take link mode from CSR */ - current_link_mode = ctrl_ext; - init_ctrl_wd_3_bit_offset = E1000_CTRL_EXT_LINK_MODE_OFFSET; + current_link_mode = ctrl_ext & E1000_CTRL_EXT_LINK_MODE_MASK; } - /* - * Align link mode bits to - * their CTRL_EXT location. - */ - current_link_mode <<= (E1000_CTRL_EXT_LINK_MODE_OFFSET - - init_ctrl_wd_3_bit_offset); - current_link_mode &= E1000_CTRL_EXT_LINK_MODE_MASK; - switch (current_link_mode) { case E1000_CTRL_EXT_LINK_MODE_1000BASE_KX: @@ -2331,7 +2354,7 @@ static s32 e1000_reset_hw_82580(struct e msec_delay(10); /* Determine whether or not a global dev reset is requested */ - if (global_device_reset && e1000_acquire_swfw_sync_82575(hw, + if (global_device_reset && hw->mac.ops.acquire_swfw_sync(hw, swmbsw_mask)) global_device_reset = FALSE; @@ -2359,7 +2382,7 @@ static s32 e1000_reset_hw_82580(struct e } /* If EEPROM is not present, run manual init scripts */ - if ((E1000_READ_REG(hw, E1000_EECD) & E1000_EECD_PRES) == 0) + if (!(E1000_READ_REG(hw, E1000_EECD) & E1000_EECD_PRES)) e1000_reset_init_script_82575(hw); /* clear global device reset status bit */ @@ -2378,7 +2401,7 @@ static s32 e1000_reset_hw_82580(struct e /* Release semaphore */ if (global_device_reset) - e1000_release_swfw_sync_82575(hw, swmbsw_mask); + hw->mac.ops.release_swfw_sync(hw, swmbsw_mask); return ret_val; } @@ -2538,7 +2561,7 @@ static s32 e1000_update_nvm_checksum_825 goto out; } - if ((nvm_data & NVM_COMPATIBILITY_BIT_MASK) == 0) { + if (!(nvm_data & NVM_COMPATIBILITY_BIT_MASK)) { /* set compatibility bit to validate checksums appropriately */ nvm_data = nvm_data | NVM_COMPATIBILITY_BIT_MASK; ret_val = hw->nvm.ops.write(hw, NVM_COMPATIBILITY_REG_3, 1, @@ -2737,6 +2760,7 @@ s32 e1000_set_i2c_bb(struct e1000_hw *hw * e1000_read_i2c_byte_generic - Reads 8 bit word over I2C * @hw: pointer to hardware structure * @byte_offset: byte offset to read + * @dev_addr: device address * @data: value read * * Performs byte read operation over I2C interface at @@ -2750,14 +2774,14 @@ s32 e1000_read_i2c_byte_generic(struct e u32 retry = 1; u16 swfw_mask = 0; - bool nack = 1; + bool nack = TRUE; DEBUGFUNC("e1000_read_i2c_byte_generic"); swfw_mask = E1000_SWFW_PHY0_SM; do { - if (e1000_acquire_swfw_sync_82575(hw, swfw_mask) + if (hw->mac.ops.acquire_swfw_sync(hw, swfw_mask) != E1000_SUCCESS) { status = E1000_ERR_SWFW_SYNC; goto read_byte_out; @@ -2805,7 +2829,7 @@ s32 e1000_read_i2c_byte_generic(struct e break; fail: - e1000_release_swfw_sync_82575(hw, swfw_mask); + hw->mac.ops.release_swfw_sync(hw, swfw_mask); msec_delay(100); e1000_i2c_bus_clear(hw); retry++; @@ -2816,7 +2840,7 @@ fail: } while (retry < max_retry); - e1000_release_swfw_sync_82575(hw, swfw_mask); + hw->mac.ops.release_swfw_sync(hw, swfw_mask); read_byte_out: @@ -2827,6 +2851,7 @@ read_byte_out: * e1000_write_i2c_byte_generic - Writes 8 bit word over I2C * @hw: pointer to hardware structure * @byte_offset: byte offset to write + * @dev_addr: device address * @data: value to write * * Performs byte write operation over I2C interface at @@ -2844,7 +2869,7 @@ s32 e1000_write_i2c_byte_generic(struct swfw_mask = E1000_SWFW_PHY0_SM; - if (e1000_acquire_swfw_sync_82575(hw, swfw_mask) != E1000_SUCCESS) { + if (hw->mac.ops.acquire_swfw_sync(hw, swfw_mask) != E1000_SUCCESS) { status = E1000_ERR_SWFW_SYNC; goto write_byte_out; } @@ -2888,7 +2913,7 @@ fail: DEBUGOUT("I2C byte write error.\n"); } while (retry < max_retry); - e1000_release_swfw_sync_82575(hw, swfw_mask); + hw->mac.ops.release_swfw_sync(hw, swfw_mask); write_byte_out: @@ -3020,7 +3045,7 @@ static s32 e1000_get_i2c_ack(struct e100 u32 i = 0; u32 i2cctl = E1000_READ_REG(hw, E1000_I2CPARAMS); u32 timeout = 10; - bool ack = 1; + bool ack = TRUE; DEBUGFUNC("e1000_get_i2c_ack"); @@ -3040,7 +3065,7 @@ static s32 e1000_get_i2c_ack(struct e100 return E1000_ERR_I2C; ack = e1000_get_i2c_data(&i2cctl); - if (ack == 1) { + if (ack) { DEBUGOUT("I2C ack was not received.\n"); status = E1000_ERR_I2C; } Modified: stable/9/sys/dev/e1000/e1000_api.c ============================================================================== --- stable/9/sys/dev/e1000/e1000_api.c Sun Jul 8 19:33:20 2012 (r238261) +++ stable/9/sys/dev/e1000/e1000_api.c Sun Jul 8 20:35:56 2012 (r238262) @@ -1,6 +1,6 @@ /****************************************************************************** - Copyright (c) 2001-2011, Intel Corporation + Copyright (c) 2001-2012, Intel Corporation All rights reserved. Redistribution and use in source and binary forms, with or without @@ -323,6 +323,17 @@ s32 e1000_set_mac_type(struct e1000_hw * case E1000_DEV_ID_I350_DA4: mac->type = e1000_i350; break; + case E1000_DEV_ID_I210_COPPER: + case E1000_DEV_ID_I210_COPPER_OEM1: + case E1000_DEV_ID_I210_COPPER_IT: + case E1000_DEV_ID_I210_FIBER: + case E1000_DEV_ID_I210_SERDES: + case E1000_DEV_ID_I210_SGMII: + mac->type = e1000_i210; + break; + case E1000_DEV_ID_I211_COPPER: + mac->type = e1000_i211; + break; case E1000_DEV_ID_82576_VF: mac->type = e1000_vfadapt; break; @@ -425,6 +436,10 @@ s32 e1000_setup_init_funcs(struct e1000_ case e1000_i350: e1000_init_function_pointers_82575(hw); break; + case e1000_i210: + case e1000_i211: + e1000_init_function_pointers_i210(hw); + break; case e1000_vfadapt: e1000_init_function_pointers_vf(hw); break; Modified: stable/9/sys/dev/e1000/e1000_api.h ============================================================================== --- stable/9/sys/dev/e1000/e1000_api.h Sun Jul 8 19:33:20 2012 (r238261) +++ stable/9/sys/dev/e1000/e1000_api.h Sun Jul 8 20:35:56 2012 (r238262) @@ -1,6 +1,6 @@ /****************************************************************************** - Copyright (c) 2001-2011, Intel Corporation + Copyright (c) 2001-2012, Intel Corporation All rights reserved. Redistribution and use in source and binary forms, with or without @@ -49,6 +49,7 @@ extern void e1000_rx_fifo_flush_82575(st extern void e1000_init_function_pointers_vf(struct e1000_hw *hw); extern void e1000_power_up_fiber_serdes_link(struct e1000_hw *hw); extern void e1000_shutdown_fiber_serdes_link(struct e1000_hw *hw); +extern void e1000_init_function_pointers_i210(struct e1000_hw *hw); s32 e1000_set_mac_type(struct e1000_hw *hw); s32 e1000_setup_init_funcs(struct e1000_hw *hw, bool init_device); @@ -118,6 +119,7 @@ s32 e1000_mng_write_dhcp_info(struct e10 u32 e1000_translate_register_82542(u32 reg); + /* * TBI_ACCEPT macro definition: * Modified: stable/9/sys/dev/e1000/e1000_defines.h ============================================================================== --- stable/9/sys/dev/e1000/e1000_defines.h Sun Jul 8 19:33:20 2012 (r238261) +++ stable/9/sys/dev/e1000/e1000_defines.h Sun Jul 8 20:35:56 2012 (r238262) @@ -1,6 +1,6 @@ /****************************************************************************** - Copyright (c) 2001-2011, Intel Corporation + Copyright (c) 2001-2012, Intel Corporation All rights reserved. Redistribution and use in source and binary forms, with or without @@ -1344,6 +1344,16 @@ #define E1000_EECD_SEC1VAL 0x00400000 /* Sector One Valid */ #define E1000_EECD_SECVAL_SHIFT 22 #define E1000_EECD_SEC1VAL_VALID_MASK (E1000_EECD_AUTO_RD | E1000_EECD_PRES) +#define E1000_EECD_FLUPD_I210 0x00800000 /* Update FLASH */ +#define E1000_EECD_FLUDONE_I210 0x04000000 /* Update FLASH done */ +#define E1000_EECD_FLASH_DETECTED_I210 0x00080000 /* FLASH detected */ +#define E1000_FLUDONE_ATTEMPTS 20000 +#define E1000_EERD_EEWR_MAX_COUNT 512 /* buffered EEPROM words rw */ +#define E1000_I210_FIFO_SEL_RX 0x00 +#define E1000_I210_FIFO_SEL_TX_QAV(_i) (0x02 + (_i)) +#define E1000_I210_FIFO_SEL_TX_LEGACY E1000_I210_FIFO_SEL_TX_QAV(0) +#define E1000_I210_FIFO_SEL_BMC2OS_TX 0x06 +#define E1000_I210_FIFO_SEL_BMC2OS_RX 0x01 #define E1000_NVM_SWDPIN0 0x0001 /* SWDPIN 0 NVM Value */ #define E1000_NVM_LED_LOGIC 0x0020 /* Led Logic Word */ @@ -1361,6 +1371,20 @@ #define NVM_VERSION 0x0005 #define NVM_SERDES_AMPLITUDE 0x0006 /* SERDES output amplitude */ #define NVM_PHY_CLASS_WORD 0x0007 +#define NVM_ETRACK_WORD 0x0042 +#define NVM_COMB_VER_OFF 0x0083 +#define NVM_COMB_VER_PTR 0x003d + +#define NVM_MAC_ADDR 0x0000 +#define NVM_SUB_DEV_ID 0x000B +#define NVM_SUB_VEN_ID 0x000C +#define NVM_DEV_ID 0x000D +#define NVM_VEN_ID 0x000E +#define NVM_INIT_CTRL_2 0x000F +#define NVM_INIT_CTRL_4 0x0013 +#define NVM_LED_1_CFG 0x001C +#define NVM_LED_0_2_CFG 0x001F + #define NVM_INIT_CONTROL1_REG 0x000A #define NVM_INIT_CONTROL2_REG 0x000F #define NVM_SWDEF_PINS_CTRL_PORT_1 0x0010 @@ -1380,12 +1404,12 @@ #define E1000_NVM_CFG_DONE_PORT_2 0x100000 /* ...for third port */ #define E1000_NVM_CFG_DONE_PORT_3 0x200000 /* ...for fourth port */ -#define NVM_82580_LAN_FUNC_OFFSET(a) (a ? (0x40 + (0x40 * a)) : 0) +#define NVM_82580_LAN_FUNC_OFFSET(a) ((a) ? (0x40 + (0x40 * (a))) : 0) /* Mask bits for fields in Word 0x24 of the NVM */ #define NVM_WORD24_COM_MDIO 0x0008 /* MDIO interface shared */ #define NVM_WORD24_EXT_MDIO 0x0004 /* MDIO accesses routed extrnl */ -/* Offset of Link Mode bits for 82575 up to Kawela */ +/* Offset of Link Mode bits for 82575/82576 */ #define NVM_WORD24_LNK_MODE_OFFSET 8 /* Offset of Link Mode bits for 82580 up */ #define NVM_WORD24_82580_LNK_MODE_OFFSET 4 @@ -1525,6 +1549,7 @@ #define I82579_E_PHY_ID 0x01540090 #define I82580_I_PHY_ID 0x015403A0 #define I350_I_PHY_ID 0x015403B0 +#define I210_I_PHY_ID 0x01410C00 #define IGP04E1000_E_PHY_ID 0x02A80391 #define M88_VENDOR 0x0141 @@ -1787,6 +1812,8 @@ #define E1000_DMACR_DMAC_LX_MASK 0x30000000 #define E1000_DMACR_DMAC_LX_SHIFT 28 #define E1000_DMACR_DMAC_EN 0x80000000 /* Enable DMA Coalescing */ +/* DMA Coalescing BMC-to-OS Watchdog Enable */ +#define E1000_DMACR_DC_BMC2OSW_EN 0x00008000 /* DMA Coalescing Transmit Threshold */ #define E1000_DMCTXTH_DMCTTHR_MASK 0x00000FFF @@ -1807,8 +1834,9 @@ /* Lx power decision based on DMA coal */ #define E1000_PCIEMISC_LX_DECISION 0x00000080 -#define E1000_LTRC_EEEMS_EN 0x00000005 /* Enable EEE LTR max send */ #define E1000_RXPBS_SIZE_I210_MASK 0x0000003F /* Rx packet buffer size */ +#define E1000_TXPB0S_SIZE_I210_MASK 0x0000003F /* Tx packet buffer 0 size */ +#define E1000_LTRC_EEEMS_EN 0x00000020 /* Enable EEE LTR max send */ /* Minimum time for 1000BASE-T where no data will be transmit following move out * of EEE LPI Tx state */ @@ -1826,12 +1854,14 @@ #define E1000_LTRMINV_SCALE_1024 2 /* Reg val to set scale to 32768 nsec */ #define E1000_LTRMINV_SCALE_32768 3 +#define E1000_LTRMINV_LSNP_REQ 0x00008000 /* LTR Snoop Requirement */ #define E1000_LTRMAXV_SCALE_MASK 0x00001C00 /* LTR maximum scale */ #define E1000_LTRMAXV_SCALE_SHIFT 10 /* Reg val to set scale to 1024 nsec */ #define E1000_LTRMAXV_SCALE_1024 2 /* Reg val to set scale to 32768 nsec */ #define E1000_LTRMAXV_SCALE_32768 3 +#define E1000_LTRMAXV_LSNP_REQ 0x00008000 /* LTR Snoop Requirement */ #define E1000_DOBFFCTL_OBFFTHR_MASK 0x000000FF /* OBFF threshold */ #define E1000_DOBFFCTL_EXIT_ACT_MASK 0x01000000 /* Exit active CB */ Modified: stable/9/sys/dev/e1000/e1000_hw.h ============================================================================== --- stable/9/sys/dev/e1000/e1000_hw.h Sun Jul 8 19:33:20 2012 (r238261) +++ stable/9/sys/dev/e1000/e1000_hw.h Sun Jul 8 20:35:56 2012 (r238262) @@ -1,6 +1,6 @@ /****************************************************************************** - Copyright (c) 2001-2011, Intel Corporation + Copyright (c) 2001-2012, Intel Corporation All rights reserved. Redistribution and use in source and binary forms, with or without @@ -154,6 +154,13 @@ struct e1000_hw; #define E1000_DEV_ID_I350_SERDES 0x1523 #define E1000_DEV_ID_I350_SGMII 0x1524 #define E1000_DEV_ID_I350_DA4 0x1546 +#define E1000_DEV_ID_I210_COPPER 0x1533 +#define E1000_DEV_ID_I210_COPPER_OEM1 0x1534 +#define E1000_DEV_ID_I210_COPPER_IT 0x1535 +#define E1000_DEV_ID_I210_FIBER 0x1536 +#define E1000_DEV_ID_I210_SERDES 0x1537 +#define E1000_DEV_ID_I210_SGMII 0x1538 +#define E1000_DEV_ID_I211_COPPER 0x1539 #define E1000_DEV_ID_DH89XXCC_SGMII 0x0438 #define E1000_DEV_ID_DH89XXCC_SERDES 0x043A #define E1000_DEV_ID_DH89XXCC_BACKPLANE 0x043C @@ -203,6 +210,8 @@ enum e1000_mac_type { e1000_82576, e1000_82580, e1000_i350, + e1000_i210, + e1000_i211, e1000_vfadapt, e1000_vfadapt_i350, e1000_num_macs /* List is 1-based, so subtract 1 for TRUE count. */ @@ -248,6 +257,7 @@ enum e1000_phy_type { e1000_phy_82579, e1000_phy_82580, e1000_phy_vf, + e1000_phy_i210, }; enum e1000_bus_type { @@ -674,6 +684,8 @@ struct e1000_mac_operations { struct e1000_host_mng_command_header*); s32 (*mng_enable_host_if)(struct e1000_hw *); s32 (*wait_autoneg)(struct e1000_hw *); + s32 (*acquire_swfw_sync)(struct e1000_hw *, u16); + void (*release_swfw_sync)(struct e1000_hw *, u16); }; /* @@ -911,13 +923,13 @@ struct e1000_dev_spec_ich8lan { E1000_MUTEX nvm_mutex; E1000_MUTEX swflag_mutex; bool nvm_k1_enabled; - int eee_disable; + bool eee_disable; }; struct e1000_dev_spec_82575 { bool sgmii_active; bool global_device_reset; - int eee_disable; + bool eee_disable; bool module_plugged; u32 mtu; }; @@ -967,6 +979,7 @@ struct e1000_hw { #include "e1000_80003es2lan.h" #include "e1000_ich8lan.h" #include "e1000_82575.h" +#include "e1000_i210.h" /* These functions must be implemented by drivers */ void e1000_pci_clear_mwi(struct e1000_hw *hw); Copied: stable/9/sys/dev/e1000/e1000_i210.c (from r238148, head/sys/dev/e1000/e1000_i210.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/9/sys/dev/e1000/e1000_i210.c Sun Jul 8 20:35:56 2012 (r238262, copy of r238148, head/sys/dev/e1000/e1000_i210.c) @@ -0,0 +1,740 @@ +/****************************************************************************** + + Copyright (c) 2001-2012, Intel Corporation + 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. Neither the name of the Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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. + +******************************************************************************/ +/*$FreeBSD$*/ + +#include "e1000_api.h" + + +static s32 e1000_acquire_nvm_i210(struct e1000_hw *hw); +static void e1000_release_nvm_i210(struct e1000_hw *hw); +static s32 e1000_get_hw_semaphore_i210(struct e1000_hw *hw); +static void e1000_put_hw_semaphore_i210(struct e1000_hw *hw); +static s32 e1000_write_nvm_srwr(struct e1000_hw *hw, u16 offset, u16 words, + u16 *data); +static s32 e1000_pool_flash_update_done_i210(struct e1000_hw *hw); +static s32 e1000_valid_led_default_i210(struct e1000_hw *hw, u16 *data); +static s32 e1000_read_nvm_i211(struct e1000_hw *hw, u16 offset, u16 words, + u16 *data); + +/** + * e1000_acquire_nvm_i210 - Request for access to EEPROM + * @hw: pointer to the HW structure + * + * Acquire the necessary semaphores for exclusive access to the EEPROM. + * Set the EEPROM access request bit and wait for EEPROM access grant bit. + * Return successful if access grant bit set, else clear the request for + * EEPROM access and return -E1000_ERR_NVM (-1). + **/ +static s32 e1000_acquire_nvm_i210(struct e1000_hw *hw) +{ + s32 ret_val; + + DEBUGFUNC("e1000_acquire_nvm_i210"); + + ret_val = e1000_acquire_swfw_sync_i210(hw, E1000_SWFW_EEP_SM); + + return ret_val; +} + +/** + * e1000_release_nvm_i210 - Release exclusive access to EEPROM + * @hw: pointer to the HW structure + * + * Stop any current commands to the EEPROM and clear the EEPROM request bit, + * then release the semaphores acquired. + **/ +static void e1000_release_nvm_i210(struct e1000_hw *hw) +{ + DEBUGFUNC("e1000_release_nvm_i210"); + + e1000_release_swfw_sync_i210(hw, E1000_SWFW_EEP_SM); +} + +/** + * e1000_acquire_swfw_sync_i210 - Acquire SW/FW semaphore + * @hw: pointer to the HW structure + * @mask: specifies which semaphore to acquire + * + * Acquire the SW/FW semaphore to access the PHY or NVM. The mask + * will also specify which port we're acquiring the lock for. + **/ +s32 e1000_acquire_swfw_sync_i210(struct e1000_hw *hw, u16 mask) +{ + u32 swfw_sync; + u32 swmask = mask; + u32 fwmask = mask << 16; + s32 ret_val = E1000_SUCCESS; + s32 i = 0, timeout = 200; /* FIXME: find real value to use here */ + + DEBUGFUNC("e1000_acquire_swfw_sync_i210"); + + while (i < timeout) { + if (e1000_get_hw_semaphore_i210(hw)) { + ret_val = -E1000_ERR_SWFW_SYNC; + goto out; + } + + swfw_sync = E1000_READ_REG(hw, E1000_SW_FW_SYNC); + if (!(swfw_sync & fwmask)) + break; + + /* + * Firmware currently using resource (fwmask) + */ + e1000_put_hw_semaphore_i210(hw); + msec_delay_irq(5); + i++; + } + + if (i == timeout) { + DEBUGOUT("Driver can't access resource, SW_FW_SYNC timeout.\n"); + ret_val = -E1000_ERR_SWFW_SYNC; + goto out; + } + + swfw_sync |= swmask; + E1000_WRITE_REG(hw, E1000_SW_FW_SYNC, swfw_sync); + + e1000_put_hw_semaphore_i210(hw); + +out: + return ret_val; +} + +/** + * e1000_release_swfw_sync_i210 - Release SW/FW semaphore + * @hw: pointer to the HW structure + * @mask: specifies which semaphore to acquire + * + * Release the SW/FW semaphore used to access the PHY or NVM. The mask + * will also specify which port we're releasing the lock for. + **/ +void e1000_release_swfw_sync_i210(struct e1000_hw *hw, u16 mask) +{ + u32 swfw_sync; + + DEBUGFUNC("e1000_release_swfw_sync_i210"); + + while (e1000_get_hw_semaphore_i210(hw) != E1000_SUCCESS) + ; /* Empty */ + + swfw_sync = E1000_READ_REG(hw, E1000_SW_FW_SYNC); + swfw_sync &= ~mask; + E1000_WRITE_REG(hw, E1000_SW_FW_SYNC, swfw_sync); + + e1000_put_hw_semaphore_i210(hw); +} + +/** + * e1000_get_hw_semaphore_i210 - Acquire hardware semaphore + * @hw: pointer to the HW structure + * + * Acquire the HW semaphore to access the PHY or NVM + **/ +static s32 e1000_get_hw_semaphore_i210(struct e1000_hw *hw) +{ + u32 swsm; + s32 ret_val = E1000_SUCCESS; + s32 timeout = hw->nvm.word_size + 1; + s32 i = 0; + + DEBUGFUNC("e1000_get_hw_semaphore_i210"); + + /* Get the FW semaphore. */ + for (i = 0; i < timeout; i++) { + swsm = E1000_READ_REG(hw, E1000_SWSM); + E1000_WRITE_REG(hw, E1000_SWSM, swsm | E1000_SWSM_SWESMBI); + + /* Semaphore acquired if bit latched */ + if (E1000_READ_REG(hw, E1000_SWSM) & E1000_SWSM_SWESMBI) + break; + + usec_delay(50); + } + + if (i == timeout) { + /* Release semaphores */ + e1000_put_hw_semaphore_generic(hw); + DEBUGOUT("Driver can't access the NVM\n"); + ret_val = -E1000_ERR_NVM; + goto out; + } + +out: + return ret_val; +} + +/** + * e1000_put_hw_semaphore_i210 - Release hardware semaphore + * @hw: pointer to the HW structure + * + * Release hardware semaphore used to access the PHY or NVM + **/ +static void e1000_put_hw_semaphore_i210(struct e1000_hw *hw) +{ + u32 swsm; + *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 8 20:39:01 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 46401106566B; Sun, 8 Jul 2012 20:39:01 +0000 (UTC) (envelope-from jfv@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2F02B8FC0A; Sun, 8 Jul 2012 20:39:01 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q68Kd1Kb073380; Sun, 8 Jul 2012 20:39:01 GMT (envelope-from jfv@svn.freebsd.org) Received: (from jfv@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q68Kd07A073371; Sun, 8 Jul 2012 20:39:00 GMT (envelope-from jfv@svn.freebsd.org) Message-Id: <201207082039.q68Kd07A073371@svn.freebsd.org> From: Jack F Vogel Date: Sun, 8 Jul 2012 20:39:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238263 - stable/9/sys/dev/ixgbe X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jul 2012 20:39:01 -0000 Author: jfv Date: Sun Jul 8 20:39:00 2012 New Revision: 238263 URL: http://svn.freebsd.org/changeset/base/238263 Log: MFC of 238149 Approved by:re Modified: stable/9/sys/dev/ixgbe/ixgbe.c stable/9/sys/dev/ixgbe/ixgbe_82598.c stable/9/sys/dev/ixgbe/ixgbe_82598.h stable/9/sys/dev/ixgbe/ixgbe_82599.c stable/9/sys/dev/ixgbe/ixgbe_api.c stable/9/sys/dev/ixgbe/ixgbe_api.h stable/9/sys/dev/ixgbe/ixgbe_common.c stable/9/sys/dev/ixgbe/ixgbe_common.h stable/9/sys/dev/ixgbe/ixgbe_osdep.h stable/9/sys/dev/ixgbe/ixgbe_phy.c stable/9/sys/dev/ixgbe/ixgbe_type.h stable/9/sys/dev/ixgbe/ixgbe_vf.c stable/9/sys/dev/ixgbe/ixgbe_x540.c stable/9/sys/dev/ixgbe/ixv.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) stable/9/sys/dev/ixgbe/ (props changed) Modified: stable/9/sys/dev/ixgbe/ixgbe.c ============================================================================== --- stable/9/sys/dev/ixgbe/ixgbe.c Sun Jul 8 20:35:56 2012 (r238262) +++ stable/9/sys/dev/ixgbe/ixgbe.c Sun Jul 8 20:39:00 2012 (r238263) @@ -47,7 +47,7 @@ int ixgbe_display_debug_stat /********************************************************************* * Driver version *********************************************************************/ -char ixgbe_driver_version[] = "2.4.5"; +char ixgbe_driver_version[] = "2.4.8"; /********************************************************************* * PCI Device ID Table @@ -80,8 +80,10 @@ static ixgbe_vendor_info_t ixgbe_vendor_ {IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_T3_LOM, 0, 0, 0}, {IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_COMBO_BACKPLANE, 0, 0, 0}, {IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_BACKPLANE_FCOE, 0, 0, 0}, + {IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP_SF2, 0, 0, 0}, {IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP_FCOE, 0, 0, 0}, {IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599EN_SFP, 0, 0, 0}, + {IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X540T1, 0, 0, 0}, {IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X540T, 0, 0, 0}, /* required last entry */ {0, 0, 0, 0, 0} @@ -242,10 +244,6 @@ TUNABLE_INT("hw.ixgbe.max_interrupt_rate static int ixgbe_rx_process_limit = 128; TUNABLE_INT("hw.ixgbe.rx_process_limit", &ixgbe_rx_process_limit); -/* Flow control setting, default to full */ -static int ixgbe_flow_control = ixgbe_fc_full; -TUNABLE_INT("hw.ixgbe.flow_control", &ixgbe_flow_control); - /* ** Smart speed setting, default to on ** this only works as a compile option @@ -526,28 +524,25 @@ ixgbe_attach(device_t dev) goto err_late; } - /* Get Hardware Flow Control setting */ - hw->fc.requested_mode = ixgbe_fc_full; - adapter->fc = hw->fc.requested_mode; - hw->fc.pause_time = IXGBE_FC_PAUSE; - hw->fc.low_water = IXGBE_FC_LO; - hw->fc.high_water[0] = IXGBE_FC_HI; - hw->fc.send_xon = TRUE; - error = ixgbe_init_hw(hw); - if (error == IXGBE_ERR_EEPROM_VERSION) { + switch (error) { + case IXGBE_ERR_EEPROM_VERSION: device_printf(dev, "This device is a pre-production adapter/" "LOM. Please be aware there may be issues associated " "with your hardware.\n If you are experiencing problems " "please contact your Intel or hardware representative " "who provided you with this hardware.\n"); - } else if (error == IXGBE_ERR_SFP_NOT_SUPPORTED) + break; + case IXGBE_ERR_SFP_NOT_SUPPORTED: device_printf(dev,"Unsupported SFP+ Module\n"); - - if (error) { error = EIO; device_printf(dev,"Hardware Initialization Failure\n"); goto err_late; + case IXGBE_ERR_SFP_NOT_PRESENT: + device_printf(dev,"No SFP+ Module found\n"); + /* falls thru */ + default: + break; } /* Detect and set physical type */ @@ -1234,7 +1229,7 @@ ixgbe_init_locked(struct adapter *adapte #ifdef IXGBE_FDIR /* Init Flow director */ if (hw->mac.type != ixgbe_mac_82598EB) { - u32 hdrm = 64 << fdir_pballoc; + u32 hdrm = 32 << fdir_pballoc; hw->mac.ops.setup_rxpba(hw, 0, hdrm, PBA_STRATEGY_EQUAL); ixgbe_init_fdir_signature_82599(&adapter->hw, fdir_pballoc); @@ -1260,6 +1255,35 @@ ixgbe_init_locked(struct adapter *adapte /* Config/Enable Link */ ixgbe_config_link(adapter); + /* Hardware Packet Buffer & Flow Control setup */ + { + u32 rxpb, frame, size, tmp; + + frame = adapter->max_frame_size; + + /* Calculate High Water */ + if (hw->mac.type == ixgbe_mac_X540) + tmp = IXGBE_DV_X540(frame, frame); + else + tmp = IXGBE_DV(frame, frame); + size = IXGBE_BT2KB(tmp); + rxpb = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(0)) >> 10; + hw->fc.high_water[0] = rxpb - size; + + /* Now calculate Low Water */ + if (hw->mac.type == ixgbe_mac_X540) + tmp = IXGBE_LOW_DV_X540(frame); + else + tmp = IXGBE_LOW_DV(frame); + hw->fc.low_water[0] = IXGBE_BT2KB(tmp); + + adapter->fc = hw->fc.requested_mode = ixgbe_fc_full; + hw->fc.pause_time = IXGBE_FC_PAUSE; + hw->fc.send_xon = TRUE; + } + /* Initialize the FC settings */ + ixgbe_start_hw(hw); + /* And now turn on interrupts */ ixgbe_enable_intr(adapter); @@ -1549,10 +1573,8 @@ ixgbe_msix_link(void *arg) /* This is probably overkill :) */ if (!atomic_cmpset_int(&adapter->fdir_reinit, 0, 1)) return; - /* Clear the interrupt */ - IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_FLOW_DIR); - /* Turn off the interface */ - adapter->ifp->if_drv_flags &= ~IFF_DRV_RUNNING; + /* Disable the interrupt */ + IXGBE_WRITE_REG(hw, IXGBE_EIMC, IXGBE_EICR_FLOW_DIR); taskqueue_enqueue(adapter->tq, &adapter->fdir_task); } else #endif @@ -2055,6 +2077,8 @@ ixgbe_update_link_status(struct adapter ((adapter->link_speed == 128)? 10:1), "Full Duplex"); adapter->link_active = TRUE; + /* Update any Flow Control changes */ + ixgbe_fc_enable(&adapter->hw); if_link_state_change(ifp, LINK_STATE_UP); } } else { /* Link down */ @@ -3062,7 +3086,7 @@ ixgbe_initialize_transmit_units(struct a txctrl = IXGBE_READ_REG(hw, IXGBE_DCA_TXCTRL_82599(i)); break; } - txctrl &= ~IXGBE_DCA_TXCTRL_TX_WB_RO_EN; + txctrl &= ~IXGBE_DCA_TXCTRL_DESC_WRO_EN; switch (hw->mac.type) { case ixgbe_mac_82598EB: IXGBE_WRITE_REG(hw, IXGBE_DCA_TXCTRL(i), txctrl); @@ -5057,6 +5081,8 @@ ixgbe_reinit_fdir(void *context, int pen return; ixgbe_reinit_fdir_tables_82599(&adapter->hw); adapter->fdir_reinit = 0; + /* re-enable flow director interrupts */ + IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMS, IXGBE_EIMS_FLOW_DIR); /* Restart the interface */ ifp->if_drv_flags |= IFF_DRV_RUNNING; return; @@ -5614,8 +5640,9 @@ ixgbe_set_flowcntl(SYSCTL_HANDLER_ARGS) default: adapter->hw.fc.requested_mode = ixgbe_fc_none; } - - ixgbe_fc_enable(&adapter->hw, 0); + /* Don't autoneg if forcing a value */ + adapter->hw.fc.disable_fc_autoneg = TRUE; + ixgbe_fc_enable(&adapter->hw); return error; } @@ -5631,9 +5658,9 @@ ixgbe_add_rx_process_limit(struct adapte /* ** Control link advertise speed: -** 0 - normal ** 1 - advertise only 1G ** 2 - advertise 100Mb +** 3 - advertise normal */ static int ixgbe_set_advertise(SYSCTL_HANDLER_ARGS) @@ -5647,13 +5674,15 @@ ixgbe_set_advertise(SYSCTL_HANDLER_ARGS) adapter = (struct adapter *) arg1; dev = adapter->dev; hw = &adapter->hw; - last = hw->phy.autoneg_advertised; + last = adapter->advertise; error = sysctl_handle_int(oidp, &adapter->advertise, 0, req); - if ((error) || (adapter->advertise == -1)) return (error); + if (adapter->advertise == last) /* no change */ + return (0); + if (!((hw->phy.media_type == ixgbe_media_type_copper) || (hw->phy.multispeed_fiber))) return (error); @@ -5667,11 +5696,10 @@ ixgbe_set_advertise(SYSCTL_HANDLER_ARGS) speed = IXGBE_LINK_SPEED_1GB_FULL; else if (adapter->advertise == 2) speed = IXGBE_LINK_SPEED_100_FULL; - else + else if (adapter->advertise == 3) speed = IXGBE_LINK_SPEED_1GB_FULL | IXGBE_LINK_SPEED_10GB_FULL; - - if (speed == last) /* no change */ + else /* bogus value */ return (error); hw->mac.autotry_restart = TRUE; Modified: stable/9/sys/dev/ixgbe/ixgbe_82598.c ============================================================================== --- stable/9/sys/dev/ixgbe/ixgbe_82598.c Sun Jul 8 20:35:56 2012 (r238262) +++ stable/9/sys/dev/ixgbe/ixgbe_82598.c Sun Jul 8 20:39:00 2012 (r238263) @@ -104,31 +104,6 @@ out: } /** - * ixgbe_get_pcie_msix_count_82598 - Gets MSI-X vector count - * @hw: pointer to hardware structure - * - * Read PCIe configuration space, and get the MSI-X vector count from - * the capabilities table. - **/ -u32 ixgbe_get_pcie_msix_count_82598(struct ixgbe_hw *hw) -{ - u32 msix_count = 18; - - DEBUGFUNC("ixgbe_get_pcie_msix_count_82598"); - - if (hw->mac.msix_vectors_from_pcie) { - msix_count = IXGBE_READ_PCIE_WORD(hw, - IXGBE_PCIE_MSIX_82598_CAPS); - msix_count &= IXGBE_PCIE_MSIX_TBL_SZ_MASK; - - /* MSI-X count is zero-based in HW, so increment to give - * proper value */ - msix_count++; - } - return msix_count; -} - -/** * ixgbe_init_ops_82598 - Inits func ptrs and MAC type * @hw: pointer to hardware structure * @@ -176,7 +151,7 @@ s32 ixgbe_init_ops_82598(struct ixgbe_hw mac->rx_pb_size = 512; mac->max_tx_queues = 32; mac->max_rx_queues = 64; - mac->max_msix_vectors = ixgbe_get_pcie_msix_count_82598(hw); + mac->max_msix_vectors = ixgbe_get_pcie_msix_count_generic(hw); /* SFP+ Module */ phy->ops.read_i2c_eeprom = &ixgbe_read_i2c_eeprom_82598; @@ -280,15 +255,15 @@ s32 ixgbe_start_hw_82598(struct ixgbe_hw for (i = 0; ((i < hw->mac.max_tx_queues) && (i < IXGBE_DCA_MAX_QUEUES_82598)); i++) { regval = IXGBE_READ_REG(hw, IXGBE_DCA_TXCTRL(i)); - regval &= ~IXGBE_DCA_TXCTRL_TX_WB_RO_EN; + regval &= ~IXGBE_DCA_TXCTRL_DESC_WRO_EN; IXGBE_WRITE_REG(hw, IXGBE_DCA_TXCTRL(i), regval); } for (i = 0; ((i < hw->mac.max_rx_queues) && (i < IXGBE_DCA_MAX_QUEUES_82598)); i++) { regval = IXGBE_READ_REG(hw, IXGBE_DCA_RXCTRL(i)); - regval &= ~(IXGBE_DCA_RXCTRL_DESC_WRO_EN | - IXGBE_DCA_RXCTRL_DESC_HSRO_EN); + regval &= ~(IXGBE_DCA_RXCTRL_DATA_WRO_EN | + IXGBE_DCA_RXCTRL_HEAD_WRO_EN); IXGBE_WRITE_REG(hw, IXGBE_DCA_RXCTRL(i), regval); } @@ -416,21 +391,41 @@ out: /** * ixgbe_fc_enable_82598 - Enable flow control * @hw: pointer to hardware structure - * @packetbuf_num: packet buffer number (0-7) * * Enable flow control according to the current settings. **/ -s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw, s32 packetbuf_num) +s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw) { s32 ret_val = IXGBE_SUCCESS; u32 fctrl_reg; u32 rmcs_reg; u32 reg; + u32 fcrtl, fcrth; u32 link_speed = 0; + int i; bool link_up; DEBUGFUNC("ixgbe_fc_enable_82598"); + /* Validate the water mark configuration */ + if (!hw->fc.pause_time) { + ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS; + goto out; + } + + /* Low water mark of zero causes XOFF floods */ + for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) { + if ((hw->fc.current_mode & ixgbe_fc_tx_pause) && + hw->fc.high_water[i]) { + if (!hw->fc.low_water[i] || + hw->fc.low_water[i] >= hw->fc.high_water[i]) { + DEBUGOUT("Invalid water mark configuration\n"); + ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS; + goto out; + } + } + } + /* * On 82598 having Rx FC on causes resets while doing 1G * so if it's on turn it off once we know link_speed. For @@ -452,9 +447,7 @@ s32 ixgbe_fc_enable_82598(struct ixgbe_h } /* Negotiate the fc mode to use */ - ret_val = ixgbe_fc_autoneg(hw); - if (ret_val == IXGBE_ERR_FLOW_CONTROL) - goto out; + ixgbe_fc_autoneg(hw); /* Disable any previous flow control settings */ fctrl_reg = IXGBE_READ_REG(hw, IXGBE_FCTRL); @@ -516,28 +509,27 @@ s32 ixgbe_fc_enable_82598(struct ixgbe_h IXGBE_WRITE_REG(hw, IXGBE_RMCS, rmcs_reg); /* Set up and enable Rx high/low water mark thresholds, enable XON. */ - if (hw->fc.current_mode & ixgbe_fc_tx_pause) { - reg = hw->fc.low_water << 6; - if (hw->fc.send_xon) - reg |= IXGBE_FCRTL_XONE; - - IXGBE_WRITE_REG(hw, IXGBE_FCRTL(packetbuf_num), reg); - - reg = hw->fc.high_water[packetbuf_num] << 6; - reg |= IXGBE_FCRTH_FCEN; + for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) { + if ((hw->fc.current_mode & ixgbe_fc_tx_pause) && + hw->fc.high_water[i]) { + fcrtl = (hw->fc.low_water[i] << 10) | IXGBE_FCRTL_XONE; + fcrth = (hw->fc.high_water[i] << 10) | IXGBE_FCRTH_FCEN; + IXGBE_WRITE_REG(hw, IXGBE_FCRTL(i), fcrtl); + IXGBE_WRITE_REG(hw, IXGBE_FCRTH(i), fcrth); + } else { + IXGBE_WRITE_REG(hw, IXGBE_FCRTL(i), 0); + IXGBE_WRITE_REG(hw, IXGBE_FCRTH(i), 0); + } - IXGBE_WRITE_REG(hw, IXGBE_FCRTH(packetbuf_num), reg); } /* Configure pause time (2 TCs per register) */ - reg = IXGBE_READ_REG(hw, IXGBE_FCTTV(packetbuf_num / 2)); - if ((packetbuf_num & 1) == 0) - reg = (reg & 0xFFFF0000) | hw->fc.pause_time; - else - reg = (reg & 0x0000FFFF) | (hw->fc.pause_time << 16); - IXGBE_WRITE_REG(hw, IXGBE_FCTTV(packetbuf_num / 2), reg); + reg = hw->fc.pause_time * 0x00010001; + for (i = 0; i < (IXGBE_DCB_MAX_TRAFFIC_CLASS / 2); i++) + IXGBE_WRITE_REG(hw, IXGBE_FCTTV(i), reg); - IXGBE_WRITE_REG(hw, IXGBE_FCRTV, (hw->fc.pause_time >> 1)); + /* Configure flow control refresh threshold value */ + IXGBE_WRITE_REG(hw, IXGBE_FCRTV, hw->fc.pause_time / 2); out: return ret_val; @@ -1325,15 +1317,15 @@ void ixgbe_enable_relaxed_ordering_82598 for (i = 0; ((i < hw->mac.max_tx_queues) && (i < IXGBE_DCA_MAX_QUEUES_82598)); i++) { regval = IXGBE_READ_REG(hw, IXGBE_DCA_TXCTRL(i)); - regval |= IXGBE_DCA_TXCTRL_TX_WB_RO_EN; + regval |= IXGBE_DCA_TXCTRL_DESC_WRO_EN; IXGBE_WRITE_REG(hw, IXGBE_DCA_TXCTRL(i), regval); } for (i = 0; ((i < hw->mac.max_rx_queues) && (i < IXGBE_DCA_MAX_QUEUES_82598)); i++) { regval = IXGBE_READ_REG(hw, IXGBE_DCA_RXCTRL(i)); - regval |= (IXGBE_DCA_RXCTRL_DESC_WRO_EN | - IXGBE_DCA_RXCTRL_DESC_HSRO_EN); + regval |= IXGBE_DCA_RXCTRL_DATA_WRO_EN | + IXGBE_DCA_RXCTRL_HEAD_WRO_EN; IXGBE_WRITE_REG(hw, IXGBE_DCA_RXCTRL(i), regval); } Modified: stable/9/sys/dev/ixgbe/ixgbe_82598.h ============================================================================== --- stable/9/sys/dev/ixgbe/ixgbe_82598.h Sun Jul 8 20:35:56 2012 (r238262) +++ stable/9/sys/dev/ixgbe/ixgbe_82598.h Sun Jul 8 20:39:00 2012 (r238263) @@ -36,7 +36,7 @@ #define _IXGBE_82598_H_ u32 ixgbe_get_pcie_msix_count_82598(struct ixgbe_hw *hw); -s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw, s32 packetbuf_num); +s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw); s32 ixgbe_start_hw_82598(struct ixgbe_hw *hw); void ixgbe_enable_relaxed_ordering_82598(struct ixgbe_hw *hw); s32 ixgbe_set_vmdq_82598(struct ixgbe_hw *hw, u32 rar, u32 vmdq); Modified: stable/9/sys/dev/ixgbe/ixgbe_82599.c ============================================================================== --- stable/9/sys/dev/ixgbe/ixgbe_82599.c Sun Jul 8 20:35:56 2012 (r238262) +++ stable/9/sys/dev/ixgbe/ixgbe_82599.c Sun Jul 8 20:39:00 2012 (r238263) @@ -243,6 +243,7 @@ s32 ixgbe_init_ops_82599(struct ixgbe_hw /* RAR, Multicast, VLAN */ mac->ops.set_vmdq = &ixgbe_set_vmdq_generic; + mac->ops.set_vmdq_san_mac = &ixgbe_set_vmdq_san_mac_generic; mac->ops.clear_vmdq = &ixgbe_clear_vmdq_generic; mac->ops.insert_mac_addr = &ixgbe_insert_mac_addr_generic; mac->rar_highwater = 1; @@ -304,7 +305,9 @@ s32 ixgbe_get_link_capabilities_82599(st /* Check if 1G SFP module. */ if (hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core0 || - hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core1) { + hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core1 || + hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 || + hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1) { *speed = IXGBE_LINK_SPEED_1GB_FULL; *negotiation = TRUE; goto out; @@ -420,6 +423,7 @@ enum ixgbe_media_type ixgbe_get_media_ty case IXGBE_DEV_ID_82599_SFP: case IXGBE_DEV_ID_82599_SFP_FCOE: case IXGBE_DEV_ID_82599_SFP_EM: + case IXGBE_DEV_ID_82599_SFP_SF2: case IXGBE_DEV_ID_82599EN_SFP: media_type = ixgbe_media_type_fiber; break; @@ -1088,6 +1092,9 @@ mac_reset_top: hw->mac.ops.set_rar(hw, hw->mac.num_rar_entries - 1, hw->mac.san_addr, 0, IXGBE_RAH_AV); + /* Save the SAN MAC RAR index */ + hw->mac.san_mac_rar_index = hw->mac.num_rar_entries - 1; + /* Reserve the last RAR for the SAN MAC address */ hw->mac.num_rar_entries--; } @@ -2037,6 +2044,8 @@ sfp_check: physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_LR; else if (comp_codes_1g & IXGBE_SFF_1GBASET_CAPABLE) physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_T; + else if (comp_codes_1g & IXGBE_SFF_1GBASESX_CAPABLE) + physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_SX; break; default: break; @@ -2233,3 +2242,4 @@ static s32 ixgbe_read_eeprom_82599(struc return ret_val; } + Modified: stable/9/sys/dev/ixgbe/ixgbe_api.c ============================================================================== --- stable/9/sys/dev/ixgbe/ixgbe_api.c Sun Jul 8 20:35:56 2012 (r238262) +++ stable/9/sys/dev/ixgbe/ixgbe_api.c Sun Jul 8 20:39:00 2012 (r238263) @@ -118,6 +118,7 @@ s32 ixgbe_set_mac_type(struct ixgbe_hw * case IXGBE_DEV_ID_82599_BACKPLANE_FCOE: case IXGBE_DEV_ID_82599_SFP_FCOE: case IXGBE_DEV_ID_82599_SFP_EM: + case IXGBE_DEV_ID_82599_SFP_SF2: case IXGBE_DEV_ID_82599EN_SFP: case IXGBE_DEV_ID_82599_CX4: case IXGBE_DEV_ID_82599_T3_LOM: @@ -130,6 +131,7 @@ s32 ixgbe_set_mac_type(struct ixgbe_hw * hw->mac.type = ixgbe_mac_X540_vf; break; case IXGBE_DEV_ID_X540T: + case IXGBE_DEV_ID_X540T1: hw->mac.type = ixgbe_mac_X540; break; default: @@ -811,6 +813,18 @@ s32 ixgbe_set_vmdq(struct ixgbe_hw *hw, { return ixgbe_call_func(hw, hw->mac.ops.set_vmdq, (hw, rar, vmdq), IXGBE_NOT_IMPLEMENTED); + +} + +/** + * ixgbe_set_vmdq_san_mac - Associate VMDq index 127 with a receive address + * @hw: pointer to hardware structure + * @vmdq: VMDq default pool index + **/ +s32 ixgbe_set_vmdq_san_mac(struct ixgbe_hw *hw, u32 vmdq) +{ + return ixgbe_call_func(hw, hw->mac.ops.set_vmdq_san_mac, + (hw, vmdq), IXGBE_NOT_IMPLEMENTED); } /** @@ -960,13 +974,12 @@ s32 ixgbe_set_vlvf(struct ixgbe_hw *hw, /** * ixgbe_fc_enable - Enable flow control * @hw: pointer to hardware structure - * @packetbuf_num: packet buffer number (0-7) * * Configures the flow control settings based on SW configuration. **/ -s32 ixgbe_fc_enable(struct ixgbe_hw *hw, s32 packetbuf_num) +s32 ixgbe_fc_enable(struct ixgbe_hw *hw) { - return ixgbe_call_func(hw, hw->mac.ops.fc_enable, (hw, packetbuf_num), + return ixgbe_call_func(hw, hw->mac.ops.fc_enable, (hw), IXGBE_NOT_IMPLEMENTED); } @@ -1102,7 +1115,7 @@ u32 ixgbe_get_supported_physical_layer(s } /** - * ixgbe_enable_rx_dma - Enables Rx DMA unit, dependant on device specifics + * ixgbe_enable_rx_dma - Enables Rx DMA unit, dependent on device specifics * @hw: pointer to hardware structure * @regval: bitfield to write to the Rx DMA register * Modified: stable/9/sys/dev/ixgbe/ixgbe_api.h ============================================================================== --- stable/9/sys/dev/ixgbe/ixgbe_api.h Sun Jul 8 20:35:56 2012 (r238262) +++ stable/9/sys/dev/ixgbe/ixgbe_api.h Sun Jul 8 20:39:00 2012 (r238263) @@ -104,6 +104,7 @@ s32 ixgbe_set_rar(struct ixgbe_hw *hw, u u32 enable_addr); s32 ixgbe_clear_rar(struct ixgbe_hw *hw, u32 index); s32 ixgbe_set_vmdq(struct ixgbe_hw *hw, u32 rar, u32 vmdq); +s32 ixgbe_set_vmdq_san_mac(struct ixgbe_hw *hw, u32 vmdq); s32 ixgbe_clear_vmdq(struct ixgbe_hw *hw, u32 rar, u32 vmdq); s32 ixgbe_init_rx_addrs(struct ixgbe_hw *hw); u32 ixgbe_get_num_rx_addrs(struct ixgbe_hw *hw); @@ -120,7 +121,7 @@ s32 ixgbe_set_vfta(struct ixgbe_hw *hw, u32 vind, bool vlan_on); s32 ixgbe_set_vlvf(struct ixgbe_hw *hw, u32 vlan, u32 vind, bool vlan_on, bool *vfta_changed); -s32 ixgbe_fc_enable(struct ixgbe_hw *hw, s32 packetbuf_num); +s32 ixgbe_fc_enable(struct ixgbe_hw *hw); s32 ixgbe_set_fw_drv_ver(struct ixgbe_hw *hw, u8 maj, u8 min, u8 build, u8 ver); void ixgbe_set_mta(struct ixgbe_hw *hw, u8 *mc_addr); Modified: stable/9/sys/dev/ixgbe/ixgbe_common.c ============================================================================== --- stable/9/sys/dev/ixgbe/ixgbe_common.c Sun Jul 8 20:35:56 2012 (r238262) +++ stable/9/sys/dev/ixgbe/ixgbe_common.c Sun Jul 8 20:39:00 2012 (r238263) @@ -51,13 +51,6 @@ static void ixgbe_release_eeprom(struct static s32 ixgbe_mta_vector(struct ixgbe_hw *hw, u8 *mc_addr); static s32 ixgbe_get_san_mac_addr_offset(struct ixgbe_hw *hw, u16 *san_mac_offset); -static s32 ixgbe_fc_autoneg_fiber(struct ixgbe_hw *hw); -static s32 ixgbe_fc_autoneg_backplane(struct ixgbe_hw *hw); -static s32 ixgbe_fc_autoneg_copper(struct ixgbe_hw *hw); -static s32 ixgbe_device_supports_autoneg_fc(struct ixgbe_hw *hw); -static s32 ixgbe_negotiate_fc(struct ixgbe_hw *hw, u32 adv_reg, u32 lp_reg, - u32 adv_sym, u32 adv_asm, u32 lp_sym, u32 lp_asm); -static s32 ixgbe_setup_fc(struct ixgbe_hw *hw, s32 packetbuf_num); static s32 ixgbe_read_eeprom_buffer_bit_bang(struct ixgbe_hw *hw, u16 offset, u16 words, u16 *data); static s32 ixgbe_write_eeprom_buffer_bit_bang(struct ixgbe_hw *hw, u16 offset, @@ -146,6 +139,177 @@ s32 ixgbe_init_ops_generic(struct ixgbe_ } /** + * ixgbe_device_supports_autoneg_fc - Check if phy supports autoneg flow + * control + * @hw: pointer to hardware structure + * + * There are several phys that do not support autoneg flow control. This + * function check the device id to see if the associated phy supports + * autoneg flow control. + **/ +static s32 ixgbe_device_supports_autoneg_fc(struct ixgbe_hw *hw) +{ + + DEBUGFUNC("ixgbe_device_supports_autoneg_fc"); + + switch (hw->device_id) { + case IXGBE_DEV_ID_X540T: + case IXGBE_DEV_ID_X540T1: + return IXGBE_SUCCESS; + case IXGBE_DEV_ID_82599_T3_LOM: + return IXGBE_SUCCESS; + default: + return IXGBE_ERR_FC_NOT_SUPPORTED; + } +} + +/** + * ixgbe_setup_fc - Set up flow control + * @hw: pointer to hardware structure + * + * Called at init time to set up flow control. + **/ +static s32 ixgbe_setup_fc(struct ixgbe_hw *hw) +{ + s32 ret_val = IXGBE_SUCCESS; + u32 reg = 0, reg_bp = 0; + u16 reg_cu = 0; + + DEBUGFUNC("ixgbe_setup_fc"); + + /* + * Validate the requested mode. Strict IEEE mode does not allow + * ixgbe_fc_rx_pause because it will cause us to fail at UNH. + */ + if (hw->fc.strict_ieee && hw->fc.requested_mode == ixgbe_fc_rx_pause) { + DEBUGOUT("ixgbe_fc_rx_pause not valid in strict IEEE mode\n"); + ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS; + goto out; + } + + /* + * 10gig parts do not have a word in the EEPROM to determine the + * default flow control setting, so we explicitly set it to full. + */ + if (hw->fc.requested_mode == ixgbe_fc_default) + hw->fc.requested_mode = ixgbe_fc_full; + + /* + * Set up the 1G and 10G flow control advertisement registers so the + * HW will be able to do fc autoneg once the cable is plugged in. If + * we link at 10G, the 1G advertisement is harmless and vice versa. + */ + switch (hw->phy.media_type) { + case ixgbe_media_type_fiber: + case ixgbe_media_type_backplane: + reg = IXGBE_READ_REG(hw, IXGBE_PCS1GANA); + reg_bp = IXGBE_READ_REG(hw, IXGBE_AUTOC); + break; + case ixgbe_media_type_copper: + hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_ADVT, + IXGBE_MDIO_AUTO_NEG_DEV_TYPE, ®_cu); + break; + default: + break; + } + + /* + * The possible values of fc.requested_mode are: + * 0: Flow control is completely disabled + * 1: Rx flow control is enabled (we can receive pause frames, + * but not send pause frames). + * 2: Tx flow control is enabled (we can send pause frames but + * we do not support receiving pause frames). + * 3: Both Rx and Tx flow control (symmetric) are enabled. + * other: Invalid. + */ + switch (hw->fc.requested_mode) { + case ixgbe_fc_none: + /* Flow control completely disabled by software override. */ + reg &= ~(IXGBE_PCS1GANA_SYM_PAUSE | IXGBE_PCS1GANA_ASM_PAUSE); + if (hw->phy.media_type == ixgbe_media_type_backplane) + reg_bp &= ~(IXGBE_AUTOC_SYM_PAUSE | + IXGBE_AUTOC_ASM_PAUSE); + else if (hw->phy.media_type == ixgbe_media_type_copper) + reg_cu &= ~(IXGBE_TAF_SYM_PAUSE | IXGBE_TAF_ASM_PAUSE); + break; + case ixgbe_fc_tx_pause: + /* + * Tx Flow control is enabled, and Rx Flow control is + * disabled by software override. + */ + reg |= IXGBE_PCS1GANA_ASM_PAUSE; + reg &= ~IXGBE_PCS1GANA_SYM_PAUSE; + if (hw->phy.media_type == ixgbe_media_type_backplane) { + reg_bp |= IXGBE_AUTOC_ASM_PAUSE; + reg_bp &= ~IXGBE_AUTOC_SYM_PAUSE; + } else if (hw->phy.media_type == ixgbe_media_type_copper) { + reg_cu |= IXGBE_TAF_ASM_PAUSE; + reg_cu &= ~IXGBE_TAF_SYM_PAUSE; + } + break; + case ixgbe_fc_rx_pause: + /* + * Rx Flow control is enabled and Tx Flow control is + * disabled by software override. Since there really + * isn't a way to advertise that we are capable of RX + * Pause ONLY, we will advertise that we support both + * symmetric and asymmetric Rx PAUSE, as such we fall + * through to the fc_full statement. Later, we will + * disable the adapter's ability to send PAUSE frames. + */ + case ixgbe_fc_full: + /* Flow control (both Rx and Tx) is enabled by SW override. */ + reg |= IXGBE_PCS1GANA_SYM_PAUSE | IXGBE_PCS1GANA_ASM_PAUSE; + if (hw->phy.media_type == ixgbe_media_type_backplane) + reg_bp |= IXGBE_AUTOC_SYM_PAUSE | + IXGBE_AUTOC_ASM_PAUSE; + else if (hw->phy.media_type == ixgbe_media_type_copper) + reg_cu |= IXGBE_TAF_SYM_PAUSE | IXGBE_TAF_ASM_PAUSE; + break; + default: + DEBUGOUT("Flow control param set incorrectly\n"); + ret_val = IXGBE_ERR_CONFIG; + goto out; + break; + } + + if (hw->mac.type != ixgbe_mac_X540) { + /* + * Enable auto-negotiation between the MAC & PHY; + * the MAC will advertise clause 37 flow control. + */ + IXGBE_WRITE_REG(hw, IXGBE_PCS1GANA, reg); + reg = IXGBE_READ_REG(hw, IXGBE_PCS1GLCTL); + + /* Disable AN timeout */ + if (hw->fc.strict_ieee) + reg &= ~IXGBE_PCS1GLCTL_AN_1G_TIMEOUT_EN; + + IXGBE_WRITE_REG(hw, IXGBE_PCS1GLCTL, reg); + DEBUGOUT1("Set up FC; PCS1GLCTL = 0x%08X\n", reg); + } + + /* + * AUTOC restart handles negotiation of 1G and 10G on backplane + * and copper. There is no need to set the PCS1GCTL register. + * + */ + if (hw->phy.media_type == ixgbe_media_type_backplane) { + reg_bp |= IXGBE_AUTOC_AN_RESTART; + IXGBE_WRITE_REG(hw, IXGBE_AUTOC, reg_bp); + } else if ((hw->phy.media_type == ixgbe_media_type_copper) && + (ixgbe_device_supports_autoneg_fc(hw) == IXGBE_SUCCESS)) { + hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_ADVT, + IXGBE_MDIO_AUTO_NEG_DEV_TYPE, reg_cu); + } + + DEBUGOUT1("Set up FC; IXGBE_AUTOC = 0x%08X\n", reg); +out: + return ret_val; +} + +/** * ixgbe_start_hw_generic - Prepare hardware for Tx/Rx * @hw: pointer to hardware structure * @@ -156,6 +320,7 @@ s32 ixgbe_init_ops_generic(struct ixgbe_ **/ s32 ixgbe_start_hw_generic(struct ixgbe_hw *hw) { + s32 ret_val; u32 ctrl_ext; DEBUGFUNC("ixgbe_start_hw_generic"); @@ -178,12 +343,15 @@ s32 ixgbe_start_hw_generic(struct ixgbe_ IXGBE_WRITE_FLUSH(hw); /* Setup flow control */ - ixgbe_setup_fc(hw, 0); + ret_val = ixgbe_setup_fc(hw); + if (ret_val != IXGBE_SUCCESS) + goto out; /* Clear adapter stopped flag */ hw->adapter_stopped = FALSE; - return IXGBE_SUCCESS; +out: + return ret_val; } /** @@ -211,14 +379,14 @@ s32 ixgbe_start_hw_gen2(struct ixgbe_hw /* Disable relaxed ordering */ for (i = 0; i < hw->mac.max_tx_queues; i++) { regval = IXGBE_READ_REG(hw, IXGBE_DCA_TXCTRL_82599(i)); - regval &= ~IXGBE_DCA_TXCTRL_TX_WB_RO_EN; + regval &= ~IXGBE_DCA_TXCTRL_DESC_WRO_EN; IXGBE_WRITE_REG(hw, IXGBE_DCA_TXCTRL_82599(i), regval); } for (i = 0; i < hw->mac.max_rx_queues; i++) { regval = IXGBE_READ_REG(hw, IXGBE_DCA_RXCTRL(i)); - regval &= ~(IXGBE_DCA_RXCTRL_DESC_WRO_EN | - IXGBE_DCA_RXCTRL_DESC_HSRO_EN); + regval &= ~(IXGBE_DCA_RXCTRL_DATA_WRO_EN | + IXGBE_DCA_RXCTRL_HEAD_WRO_EN); IXGBE_WRITE_REG(hw, IXGBE_DCA_RXCTRL(i), regval); } @@ -583,6 +751,9 @@ s32 ixgbe_get_bus_info_generic(struct ix case IXGBE_PCI_LINK_SPEED_5000: hw->bus.speed = ixgbe_bus_speed_5000; break; + case IXGBE_PCI_LINK_SPEED_8000: + hw->bus.speed = ixgbe_bus_speed_8000; + break; default: hw->bus.speed = ixgbe_bus_speed_unknown; break; @@ -2242,27 +2413,44 @@ s32 ixgbe_disable_mc_generic(struct ixgb /** * ixgbe_fc_enable_generic - Enable flow control * @hw: pointer to hardware structure - * @packetbuf_num: packet buffer number (0-7) * * Enable flow control according to the current settings. **/ -s32 ixgbe_fc_enable_generic(struct ixgbe_hw *hw, s32 packetbuf_num) +s32 ixgbe_fc_enable_generic(struct ixgbe_hw *hw) { s32 ret_val = IXGBE_SUCCESS; u32 mflcn_reg, fccfg_reg; u32 reg; u32 fcrtl, fcrth; + int i; DEBUGFUNC("ixgbe_fc_enable_generic"); - /* Negotiate the fc mode to use */ - ret_val = ixgbe_fc_autoneg(hw); - if (ret_val == IXGBE_ERR_FLOW_CONTROL) + /* Validate the water mark configuration */ + if (!hw->fc.pause_time) { + ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS; goto out; + } + + /* Low water mark of zero causes XOFF floods */ + for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) { + if ((hw->fc.current_mode & ixgbe_fc_tx_pause) && + hw->fc.high_water[i]) { + if (!hw->fc.low_water[i] || + hw->fc.low_water[i] >= hw->fc.high_water[i]) { + DEBUGOUT("Invalid water mark configuration\n"); + ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS; + goto out; + } + } + } + + /* Negotiate the fc mode to use */ + ixgbe_fc_autoneg(hw); /* Disable any previous flow control settings */ mflcn_reg = IXGBE_READ_REG(hw, IXGBE_MFLCN); - mflcn_reg &= ~(IXGBE_MFLCN_RFCE | IXGBE_MFLCN_RPFCE); + mflcn_reg &= ~(IXGBE_MFLCN_RPFCE_MASK | IXGBE_MFLCN_RFCE); fccfg_reg = IXGBE_READ_REG(hw, IXGBE_FCCFG); fccfg_reg &= ~(IXGBE_FCCFG_TFCE_802_3X | IXGBE_FCCFG_TFCE_PRIORITY); @@ -2319,120 +2507,110 @@ s32 ixgbe_fc_enable_generic(struct ixgbe IXGBE_WRITE_REG(hw, IXGBE_MFLCN, mflcn_reg); IXGBE_WRITE_REG(hw, IXGBE_FCCFG, fccfg_reg); - fcrth = hw->fc.high_water[packetbuf_num] << 10; - fcrtl = hw->fc.low_water << 10; - if (hw->fc.current_mode & ixgbe_fc_tx_pause) { - fcrth |= IXGBE_FCRTH_FCEN; - if (hw->fc.send_xon) - fcrtl |= IXGBE_FCRTL_XONE; - } + /* Set up and enable Rx high/low water mark thresholds, enable XON. */ + for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) { + if ((hw->fc.current_mode & ixgbe_fc_tx_pause) && + hw->fc.high_water[i]) { + fcrtl = (hw->fc.low_water[i] << 10) | IXGBE_FCRTL_XONE; + IXGBE_WRITE_REG(hw, IXGBE_FCRTL_82599(i), fcrtl); + fcrth = (hw->fc.high_water[i] << 10) | IXGBE_FCRTH_FCEN; + } else { + IXGBE_WRITE_REG(hw, IXGBE_FCRTL_82599(i), 0); + /* + * In order to prevent Tx hangs when the internal Tx + * switch is enabled we must set the high water mark + * to the maximum FCRTH value. This allows the Tx + * switch to function even under heavy Rx workloads. + */ + fcrth = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(i)) - 32; + } - IXGBE_WRITE_REG(hw, IXGBE_FCRTH_82599(packetbuf_num), fcrth); - IXGBE_WRITE_REG(hw, IXGBE_FCRTL_82599(packetbuf_num), fcrtl); + IXGBE_WRITE_REG(hw, IXGBE_FCRTH_82599(i), fcrth); + } /* Configure pause time (2 TCs per register) */ - reg = IXGBE_READ_REG(hw, IXGBE_FCTTV(packetbuf_num / 2)); - if ((packetbuf_num & 1) == 0) - reg = (reg & 0xFFFF0000) | hw->fc.pause_time; - else - reg = (reg & 0x0000FFFF) | (hw->fc.pause_time << 16); - IXGBE_WRITE_REG(hw, IXGBE_FCTTV(packetbuf_num / 2), reg); + reg = hw->fc.pause_time * 0x00010001; + for (i = 0; i < (IXGBE_DCB_MAX_TRAFFIC_CLASS / 2); i++) + IXGBE_WRITE_REG(hw, IXGBE_FCTTV(i), reg); - IXGBE_WRITE_REG(hw, IXGBE_FCRTV, (hw->fc.pause_time >> 1)); + /* Configure flow control refresh threshold value */ + IXGBE_WRITE_REG(hw, IXGBE_FCRTV, hw->fc.pause_time / 2); out: return ret_val; } /** - * ixgbe_fc_autoneg - Configure flow control + * ixgbe_negotiate_fc - Negotiate flow control * @hw: pointer to hardware structure + * @adv_reg: flow control advertised settings + * @lp_reg: link partner's flow control settings + * @adv_sym: symmetric pause bit in advertisement + * @adv_asm: asymmetric pause bit in advertisement + * @lp_sym: symmetric pause bit in link partner advertisement + * @lp_asm: asymmetric pause bit in link partner advertisement * - * Compares our advertised flow control capabilities to those advertised by - * our link partner, and determines the proper flow control mode to use. + * Find the intersection between advertised settings and link partner's + * advertised settings **/ -s32 ixgbe_fc_autoneg(struct ixgbe_hw *hw) +static s32 ixgbe_negotiate_fc(struct ixgbe_hw *hw, u32 adv_reg, u32 lp_reg, + u32 adv_sym, u32 adv_asm, u32 lp_sym, u32 lp_asm) { - s32 ret_val = IXGBE_ERR_FC_NOT_NEGOTIATED; - ixgbe_link_speed speed; - bool link_up; + if ((!(adv_reg)) || (!(lp_reg))) + return IXGBE_ERR_FC_NOT_NEGOTIATED; - DEBUGFUNC("ixgbe_fc_autoneg"); + if ((adv_reg & adv_sym) && (lp_reg & lp_sym)) { + /* + * Now we need to check if the user selected Rx ONLY + * of pause frames. In this case, we had to advertise + * FULL flow control because we could not advertise RX + * ONLY. Hence, we must now check to see if we need to + * turn OFF the TRANSMISSION of PAUSE frames. + */ + if (hw->fc.requested_mode == ixgbe_fc_full) { + hw->fc.current_mode = ixgbe_fc_full; + DEBUGOUT("Flow Control = FULL.\n"); + } else { + hw->fc.current_mode = ixgbe_fc_rx_pause; + DEBUGOUT("Flow Control=RX PAUSE frames only\n"); + } + } else if (!(adv_reg & adv_sym) && (adv_reg & adv_asm) && + (lp_reg & lp_sym) && (lp_reg & lp_asm)) { + hw->fc.current_mode = ixgbe_fc_tx_pause; + DEBUGOUT("Flow Control = TX PAUSE frames only.\n"); + } else if ((adv_reg & adv_sym) && (adv_reg & adv_asm) && + !(lp_reg & lp_sym) && (lp_reg & lp_asm)) { + hw->fc.current_mode = ixgbe_fc_rx_pause; + DEBUGOUT("Flow Control = RX PAUSE frames only.\n"); + } else { + hw->fc.current_mode = ixgbe_fc_none; + DEBUGOUT("Flow Control = NONE.\n"); + } + return IXGBE_SUCCESS; +} - if (hw->fc.disable_fc_autoneg) - goto out; +/** + * ixgbe_fc_autoneg_fiber - Enable flow control on 1 gig fiber + * @hw: pointer to hardware structure + * + * Enable flow control according on 1 gig fiber. + **/ +static s32 ixgbe_fc_autoneg_fiber(struct ixgbe_hw *hw) +{ + u32 pcs_anadv_reg, pcs_lpab_reg, linkstat; + s32 ret_val = IXGBE_ERR_FC_NOT_NEGOTIATED; /* - * AN should have completed when the cable was plugged in. - * Look for reasons to bail out. Bail out if: - * - FC autoneg is disabled, or if - * - link is not up. - * - * Since we're being called from an LSC, link is already known to be up. - * So use link_up_wait_to_complete=FALSE. - */ - hw->mac.ops.check_link(hw, &speed, &link_up, FALSE); - if (!link_up) { - ret_val = IXGBE_ERR_FLOW_CONTROL; - goto out; - } - - switch (hw->phy.media_type) { - /* Autoneg flow control on fiber adapters */ - case ixgbe_media_type_fiber: - if (speed == IXGBE_LINK_SPEED_1GB_FULL) - ret_val = ixgbe_fc_autoneg_fiber(hw); - break; - - /* Autoneg flow control on backplane adapters */ - case ixgbe_media_type_backplane: - ret_val = ixgbe_fc_autoneg_backplane(hw); - break; - - /* Autoneg flow control on copper adapters */ - case ixgbe_media_type_copper: - if (ixgbe_device_supports_autoneg_fc(hw) == IXGBE_SUCCESS) - ret_val = ixgbe_fc_autoneg_copper(hw); - break; - - default: - break; - } - -out: - if (ret_val == IXGBE_SUCCESS) { - hw->fc.fc_was_autonegged = TRUE; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 8 20:41:55 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7E3D5106566B; Sun, 8 Jul 2012 20:41:55 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 685BD8FC12; Sun, 8 Jul 2012 20:41:55 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q68KftrW073533; Sun, 8 Jul 2012 20:41:55 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q68Kftoa073531; Sun, 8 Jul 2012 20:41:55 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <201207082041.q68Kftoa073531@svn.freebsd.org> From: Robert Watson Date: Sun, 8 Jul 2012 20:41:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238264 - stable/9/contrib/openbsm/libauditd X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jul 2012 20:41:55 -0000 Author: rwatson Date: Sun Jul 8 20:41:54 2012 New Revision: 238264 URL: http://svn.freebsd.org/changeset/base/238264 Log: Merge r234034 from head to stable/9: Merge a local fix to OpenBSM's libauditd to avoid a directory descriptor leak when iterating over possible audit trail directories. This fix will be merged upstream in an identical form, but hasn't yet appeared in an OpenBSM release. Submitted by: guido Obtained from: TrustedBSD Project Approved by: re (kib) Modified: stable/9/contrib/openbsm/libauditd/auditd_lib.c Directory Properties: stable/9/contrib/openbsm/ (props changed) Modified: stable/9/contrib/openbsm/libauditd/auditd_lib.c ============================================================================== --- stable/9/contrib/openbsm/libauditd/auditd_lib.c Sun Jul 8 20:39:00 2012 (r238263) +++ stable/9/contrib/openbsm/libauditd/auditd_lib.c Sun Jul 8 20:41:54 2012 (r238264) @@ -520,6 +520,7 @@ auditd_expire_trails(int (*warn_expired) } } + closedir(dirp); } oldest_time = current_time - expire_age; From owner-svn-src-stable-9@FreeBSD.ORG Sun Jul 8 21:21:45 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D619F1065674; Sun, 8 Jul 2012 21:21:45 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C04948FC0A; Sun, 8 Jul 2012 21:21:45 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q68LLjbX075271; Sun, 8 Jul 2012 21:21:45 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q68LLjZq075268; Sun, 8 Jul 2012 21:21:45 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <201207082121.q68LLjZq075268@svn.freebsd.org> From: Robert Watson Date: Sun, 8 Jul 2012 21:21:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238266 - stable/9/sys/mips/mips X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jul 2012 21:21:46 -0000 Author: rwatson Date: Sun Jul 8 21:21:45 2012 New Revision: 238266 URL: http://svn.freebsd.org/changeset/base/238266 Log: Merge r231712 from head to stable/9: When initialising the CP0 status register during boot on 64-bit MIPS, set all three of the kernel, supervisor, and user-mode 64-bit mode flags. While FreeBSD does not currently use the supervisor ring (and hence this is effectively a NOP on most systems), doing this avoids triggering an exception on 64-bit MIPS CPUs that don't support 32-bit compatibility mode, and therefore don't allow clearing the SX bit. Reviewed by: gonzo Sponsored by: DARPA, SRI International Approved by: re (kib) Modified: stable/9/sys/mips/mips/locore.S Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/mips/mips/locore.S ============================================================================== --- stable/9/sys/mips/mips/locore.S Sun Jul 8 21:13:04 2012 (r238265) +++ stable/9/sys/mips/mips/locore.S Sun Jul 8 21:21:45 2012 (r238266) @@ -118,7 +118,7 @@ VECTOR(_locore, unknown) */ li t1, MIPS_SR_COP_1_BIT #ifdef __mips_n64 - or t1, MIPS_SR_KX | MIPS_SR_UX + or t1, MIPS_SR_KX | MIPS_SR_SX | MIPS_SR_UX #endif #endif /* From owner-svn-src-stable-9@FreeBSD.ORG Mon Jul 9 08:27:05 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BFADE106564A; Mon, 9 Jul 2012 08:27:05 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6AD378FC12; Mon, 9 Jul 2012 08:27:05 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q698R5TP005283; Mon, 9 Jul 2012 08:27:05 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q698R5Yt005281; Mon, 9 Jul 2012 08:27:05 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <201207090827.q698R5Yt005281@svn.freebsd.org> From: Robert Watson Date: Mon, 9 Jul 2012 08:27:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238283 - stable/9/gnu/usr.bin/gdb/kgdb X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Jul 2012 08:27:05 -0000 Author: rwatson Date: Mon Jul 9 08:27:04 2012 New Revision: 238283 URL: http://svn.freebsd.org/changeset/base/238283 Log: Merge r229521 from head to stable/9: Add missing -w to kgdb(1)'s usage(). Sponsored by: Adara Networks, Inc. Approved by: re (kib) Modified: stable/9/gnu/usr.bin/gdb/kgdb/main.c Directory Properties: stable/9/gnu/usr.bin/gdb/kgdb/ (props changed) Modified: stable/9/gnu/usr.bin/gdb/kgdb/main.c ============================================================================== --- stable/9/gnu/usr.bin/gdb/kgdb/main.c Mon Jul 9 08:11:16 2012 (r238282) +++ stable/9/gnu/usr.bin/gdb/kgdb/main.c Mon Jul 9 08:27:04 2012 (r238283) @@ -83,7 +83,7 @@ usage(void) { fprintf(stderr, - "usage: %s [-afqv] [-d crashdir] [-c core | -n dumpnr | -r device]\n" + "usage: %s [-afqvw] [-d crashdir] [-c core | -n dumpnr | -r device]\n" "\t[kernel [core]]\n", getprogname()); exit(1); } From owner-svn-src-stable-9@FreeBSD.ORG Mon Jul 9 08:42:54 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C8606106566B; Mon, 9 Jul 2012 08:42:54 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B1F838FC0C; Mon, 9 Jul 2012 08:42:54 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q698gs3d005999; Mon, 9 Jul 2012 08:42:54 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q698gs4g005997; Mon, 9 Jul 2012 08:42:54 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <201207090842.q698gs4g005997@svn.freebsd.org> From: Robert Watson Date: Mon, 9 Jul 2012 08:42:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238285 - stable/9/sys/security/mac X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Jul 2012 08:42:54 -0000 Author: rwatson Date: Mon Jul 9 08:42:54 2012 New Revision: 238285 URL: http://svn.freebsd.org/changeset/base/238285 Log: Merge r234032 from head to stable/9: When allocation of labels on files is implicitly disabled due to MAC policy configuration, avoid leaking resources following failed calls to get and set MAC labels by file descriptor. Reported by: Mateusz Guzik + clang scan-build Approved by: re (kib) Modified: stable/9/sys/security/mac/mac_syscalls.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/security/mac/mac_syscalls.c ============================================================================== --- stable/9/sys/security/mac/mac_syscalls.c Mon Jul 9 08:37:59 2012 (r238284) +++ stable/9/sys/security/mac/mac_syscalls.c Mon Jul 9 08:42:54 2012 (r238285) @@ -256,8 +256,10 @@ sys___mac_get_fd(struct thread *td, stru switch (fp->f_type) { case DTYPE_FIFO: case DTYPE_VNODE: - if (!(mac_labeled & MPC_OBJECT_VNODE)) - return (EINVAL); + if (!(mac_labeled & MPC_OBJECT_VNODE)) { + error = EINVAL; + goto out_fdrop; + } vp = fp->f_vnode; intlabel = mac_vnode_label_alloc(); vfslocked = VFS_LOCK_GIANT(vp->v_mount); @@ -271,8 +273,10 @@ sys___mac_get_fd(struct thread *td, stru break; case DTYPE_PIPE: - if (!(mac_labeled & MPC_OBJECT_PIPE)) - return (EINVAL); + if (!(mac_labeled & MPC_OBJECT_PIPE)) { + error = EINVAL; + goto out_fdrop; + } pipe = fp->f_data; intlabel = mac_pipe_label_alloc(); PIPE_LOCK(pipe); @@ -284,8 +288,10 @@ sys___mac_get_fd(struct thread *td, stru break; case DTYPE_SOCKET: - if (!(mac_labeled & MPC_OBJECT_SOCKET)) - return (EINVAL); + if (!(mac_labeled & MPC_OBJECT_SOCKET)) { + error = EINVAL; + goto out_fdrop; + } so = fp->f_data; intlabel = mac_socket_label_alloc(M_WAITOK); SOCK_LOCK(so); @@ -299,10 +305,10 @@ sys___mac_get_fd(struct thread *td, stru default: error = EINVAL; } - fdrop(fp, td); if (error == 0) error = copyout(buffer, mac.m_string, strlen(buffer)+1); - +out_fdrop: + fdrop(fp, td); out: free(buffer, M_MACTEMP); free(elements, M_MACTEMP); @@ -450,8 +456,10 @@ sys___mac_set_fd(struct thread *td, stru switch (fp->f_type) { case DTYPE_FIFO: case DTYPE_VNODE: - if (!(mac_labeled & MPC_OBJECT_VNODE)) - return (EINVAL); + if (!(mac_labeled & MPC_OBJECT_VNODE)) { + error = EINVAL; + goto out_fdrop; + } intlabel = mac_vnode_label_alloc(); error = mac_vnode_internalize_label(intlabel, buffer); if (error) { @@ -475,8 +483,10 @@ sys___mac_set_fd(struct thread *td, stru break; case DTYPE_PIPE: - if (!(mac_labeled & MPC_OBJECT_PIPE)) - return (EINVAL); + if (!(mac_labeled & MPC_OBJECT_PIPE)) { + error = EINVAL; + goto out_fdrop; + } intlabel = mac_pipe_label_alloc(); error = mac_pipe_internalize_label(intlabel, buffer); if (error == 0) { @@ -490,8 +500,10 @@ sys___mac_set_fd(struct thread *td, stru break; case DTYPE_SOCKET: - if (!(mac_labeled & MPC_OBJECT_SOCKET)) - return (EINVAL); + if (!(mac_labeled & MPC_OBJECT_SOCKET)) { + error = EINVAL; + goto out_fdrop; + } intlabel = mac_socket_label_alloc(M_WAITOK); error = mac_socket_internalize_label(intlabel, buffer); if (error == 0) { @@ -505,6 +517,7 @@ sys___mac_set_fd(struct thread *td, stru default: error = EINVAL; } +out_fdrop: fdrop(fp, td); out: free(buffer, M_MACTEMP); From owner-svn-src-stable-9@FreeBSD.ORG Mon Jul 9 09:11:07 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 976471065670; Mon, 9 Jul 2012 09:11:07 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8073A8FC16; Mon, 9 Jul 2012 09:11:07 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q699B7uJ007206; Mon, 9 Jul 2012 09:11:07 GMT (envelope-from pfg@svn.freebsd.org) Received: (from pfg@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q699B7aN007200; Mon, 9 Jul 2012 09:11:07 GMT (envelope-from pfg@svn.freebsd.org) Message-Id: <201207090911.q699B7aN007200@svn.freebsd.org> From: "Pedro F. Giffuni" Date: Mon, 9 Jul 2012 09:11:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238286 - stable/9/lib/libedit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Jul 2012 09:11:07 -0000 Author: pfg Date: Mon Jul 9 09:11:07 2012 New Revision: 238286 URL: http://svn.freebsd.org/changeset/base/238286 Log: MFC r238173: Fix issue resizing bin/sh This partially reverts some changes from r237448 that are causing breakage when resizing under bin/sh . Reverted changes from NetBSD are: Mar 10 20:46:15 2009 - editline.3 read.c make el_gets set the count to -1 on error to distinguish between EOF and error. Feb 19 15:20:22 2009 - read.c sig.c sig.h reset and redraw on sigcont. From Anon Ymous. Feb 15 21:24:13 2009 don't restart on EINTR, instead return NULL immediately. From Anon Ymous PR: 169603 Reported by: Peter Jeremy, David Shao MFC after: 3 days Approved by: re Modified: stable/9/lib/libedit/editline.3 stable/9/lib/libedit/el.h stable/9/lib/libedit/read.c stable/9/lib/libedit/sig.c stable/9/lib/libedit/sig.h Directory Properties: stable/9/lib/libedit/ (props changed) Modified: stable/9/lib/libedit/editline.3 ============================================================================== --- stable/9/lib/libedit/editline.3 Mon Jul 9 08:42:54 2012 (r238285) +++ stable/9/lib/libedit/editline.3 Mon Jul 9 09:11:07 2012 (r238286) @@ -162,11 +162,6 @@ is modified to contain the number of cha Returns the line read if successful, or .Dv NULL if no characters were read or if an error occurred. -If an error occurred, -.Fa count -is set to \-1 and -.Dv errno -contains the error code that caused it. The return value may not remain valid across calls to .Fn el_gets and must be copied if the data is to be retained. Modified: stable/9/lib/libedit/el.h ============================================================================== --- stable/9/lib/libedit/el.h Mon Jul 9 08:42:54 2012 (r238285) +++ stable/9/lib/libedit/el.h Mon Jul 9 09:11:07 2012 (r238286) @@ -115,7 +115,6 @@ struct editline { FILE *el_errfile; /* Stdio stuff */ int el_infd; /* Input file descriptor */ int el_flags; /* Various flags. */ - int el_errno; /* Local copy of errno */ coord_t el_cursor; /* Cursor location */ char **el_display; /* Real screen image = what is there */ char **el_vdisplay; /* Virtual screen image = what we see */ Modified: stable/9/lib/libedit/read.c ============================================================================== --- stable/9/lib/libedit/read.c Mon Jul 9 08:42:54 2012 (r238285) +++ stable/9/lib/libedit/read.c Mon Jul 9 09:11:07 2012 (r238286) @@ -49,7 +49,7 @@ __FBSDID("$FreeBSD$"); #include #include "el.h" -#define OKCMD -1 /* must be -1! */ +#define OKCMD -1 private int read__fixio(int, int); private int read_preread(EditLine *); @@ -170,7 +170,7 @@ read__fixio(int fd __unused, int e) return (e ? 0 : -1); case EINTR: - return (-1); + return (0); default: return (-1); @@ -235,12 +235,9 @@ read_getcmd(EditLine *el, el_action_t *c el_action_t cmd; int num; - el->el_errno = 0; do { - if ((num = el_getc(el, ch)) != 1) { /* if EOF or error */ - el->el_errno = num == 0 ? 0 : errno; + if ((num = el_getc(el, ch)) != 1) /* if EOF or error */ return (num); - } #ifdef KANJI if ((*ch & 0200)) { @@ -292,21 +289,14 @@ read_char(EditLine *el, char *cp) ssize_t num_read; int tried = 0; - again: - el->el_signal->sig_no = 0; - while ((num_read = read(el->el_infd, cp, 1)) == -1) { - if (el->el_signal->sig_no == SIGCONT) { - sig_set(el); - el_set(el, EL_REFRESH); - goto again; - } + while ((num_read = read(el->el_infd, cp, 1)) == -1) if (!tried && read__fixio(el->el_infd, errno) == 0) tried = 1; else { *cp = '\0'; return (-1); } - } + return (int)num_read; } @@ -413,20 +403,17 @@ el_gets(EditLine *el, int *nread) int num; /* how many chars we have read at NL */ char ch; int crlf = 0; - int nrb; #ifdef FIONREAD c_macro_t *ma = &el->el_chared.c_macro; #endif /* FIONREAD */ - if (nread == NULL) - nread = &nrb; *nread = 0; if (el->el_flags & NO_TTY) { char *cp = el->el_line.buffer; size_t idx; - while ((num = (*el->el_read.read_char)(el, cp)) == 1) { + while ((*el->el_read.read_char)(el, cp) == 1) { /* make sure there is space for next character */ if (cp + 1 >= el->el_line.limit) { idx = (cp - el->el_line.buffer); @@ -440,16 +427,12 @@ el_gets(EditLine *el, int *nread) if (cp[-1] == '\r' || cp[-1] == '\n') break; } - if (num == -1) { - if (errno == EINTR) - cp = el->el_line.buffer; - el->el_errno = errno; - } el->el_line.cursor = el->el_line.lastchar = cp; *cp = '\0'; - *nread = (int)(el->el_line.cursor - el->el_line.buffer); - goto done; + if (nread) + *nread = (int)(el->el_line.cursor - el->el_line.buffer); + return (*nread ? el->el_line.buffer : NULL); } @@ -460,8 +443,8 @@ el_gets(EditLine *el, int *nread) (void) ioctl(el->el_infd, FIONREAD, (ioctl_t) & chrs); if (chrs == 0) { if (tty_rawmode(el) < 0) { - errno = 0; - *nread = 0; + if (nread) + *nread = 0; return (NULL); } } @@ -474,7 +457,6 @@ el_gets(EditLine *el, int *nread) if (el->el_flags & EDIT_DISABLED) { char *cp; size_t idx; - if ((el->el_flags & UNBUFFERED) == 0) cp = el->el_line.buffer; else @@ -482,7 +464,7 @@ el_gets(EditLine *el, int *nread) term__flush(el); - while ((num = (*el->el_read.read_char)(el, cp)) == 1) { + while ((*el->el_read.read_char)(el, cp) == 1) { /* make sure there is space next character */ if (cp + 1 >= el->el_line.limit) { idx = (cp - el->el_line.buffer); @@ -498,15 +480,11 @@ el_gets(EditLine *el, int *nread) break; } - if (num == -1) { - if (errno == EINTR) - cp = el->el_line.buffer; - el->el_errno = errno; - } - el->el_line.cursor = el->el_line.lastchar = cp; *cp = '\0'; - goto done; + if (nread) + *nread = (int)(el->el_line.cursor - el->el_line.buffer); + return (*nread ? el->el_line.buffer : NULL); } for (num = OKCMD; num == OKCMD;) { /* while still editing this @@ -522,12 +500,6 @@ el_gets(EditLine *el, int *nread) #endif /* DEBUG_READ */ break; } - if (el->el_errno == EINTR) { - el->el_line.buffer[0] = '\0'; - el->el_line.lastchar = - el->el_line.cursor = el->el_line.buffer; - break; - } if ((unsigned int)cmdnum >= (unsigned int)el->el_map.nfunc) { /* BUG CHECK command */ #ifdef DEBUG_EDIT (void) fprintf(el->el_errfile, @@ -645,17 +617,12 @@ el_gets(EditLine *el, int *nread) /* make sure the tty is set up correctly */ if ((el->el_flags & UNBUFFERED) == 0) { read_finish(el); - *nread = num != -1 ? num : 0; + if (nread) + *nread = num; } else { - *nread = (int)(el->el_line.lastchar - el->el_line.buffer); + if (nread) + *nread = + (int)(el->el_line.lastchar - el->el_line.buffer); } -done: - if (*nread == 0) { - if (num == -1) { - *nread = -1; - errno = el->el_errno; - } - return NULL; - } else - return el->el_line.buffer; + return (num ? el->el_line.buffer : NULL); } Modified: stable/9/lib/libedit/sig.c ============================================================================== --- stable/9/lib/libedit/sig.c Mon Jul 9 08:42:54 2012 (r238285) +++ stable/9/lib/libedit/sig.c Mon Jul 9 09:11:07 2012 (r238286) @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $NetBSD: sig.c,v 1.15 2009/02/19 15:20:22 christos Exp $ + * $NetBSD: sig.c,v 1.14 2009/02/18 15:04:40 christos Exp $ */ #if !defined(lint) && !defined(SCCSID) @@ -73,8 +73,6 @@ sig_handler(int signo) (void) sigaddset(&nset, signo); (void) sigprocmask(SIG_BLOCK, &nset, &oset); - sel->el_signal->sig_no = signo; - switch (signo) { case SIGCONT: tty_rawmode(sel); @@ -160,12 +158,12 @@ sig_set(EditLine *el) struct sigaction osa, nsa; nsa.sa_handler = sig_handler; - nsa.sa_flags = 0; sigemptyset(&nsa.sa_mask); (void) sigprocmask(SIG_BLOCK, &el->el_signal->sig_set, &oset); for (i = 0; sighdl[i] != -1; i++) { + nsa.sa_flags = SIGINT ? 0 : SA_RESTART; /* This could happen if we get interrupted */ if (sigaction(sighdl[i], &nsa, &osa) != -1 && osa.sa_handler != sig_handler) Modified: stable/9/lib/libedit/sig.h ============================================================================== --- stable/9/lib/libedit/sig.h Mon Jul 9 08:42:54 2012 (r238285) +++ stable/9/lib/libedit/sig.h Mon Jul 9 09:11:07 2012 (r238286) @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * @(#)sig.h 8.1 (Berkeley) 6/4/93 - * $NetBSD: sig.h,v 1.5 2003/08/07 16:44:33 agc Exp $ + * $NetBSD: sig.h,v 1.7 2009/02/15 21:25:01 christos Exp $ * $FreeBSD$ */ @@ -61,7 +61,6 @@ typedef struct { struct sigaction sig_action[ALLSIGSNO]; sigset_t sig_set; - volatile sig_atomic_t sig_no; } *el_signal_t; protected void sig_end(EditLine*); From owner-svn-src-stable-9@FreeBSD.ORG Mon Jul 9 10:33:54 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 56A5C106566C; Mon, 9 Jul 2012 10:33:54 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 279B48FC12; Mon, 9 Jul 2012 10:33:54 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q69AXsAZ010892; Mon, 9 Jul 2012 10:33:54 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q69AXrii010888; Mon, 9 Jul 2012 10:33:53 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201207091033.q69AXrii010888@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 9 Jul 2012 10:33:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238291 - stable/9/usr.bin/xinstall X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Jul 2012 10:33:54 -0000 Author: kib Date: Mon Jul 9 10:33:53 2012 New Revision: 238291 URL: http://svn.freebsd.org/changeset/base/238291 Log: MFC r237988: Issue proper diagnostic on the short writes, also consider the case of write reporting 0 bytes as short write. Approved by: re (hrs) Modified: stable/9/usr.bin/xinstall/xinstall.c Directory Properties: stable/9/usr.bin/xinstall/ (props changed) Modified: stable/9/usr.bin/xinstall/xinstall.c ============================================================================== --- stable/9/usr.bin/xinstall/xinstall.c Mon Jul 9 10:24:45 2012 (r238290) +++ stable/9/usr.bin/xinstall/xinstall.c Mon Jul 9 10:33:53 2012 (r238291) @@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -670,11 +671,18 @@ copy(int from_fd, const char *from_name, if (size <= 8 * 1048576 && trymmap(from_fd) && (p = mmap(NULL, (size_t)size, PROT_READ, MAP_SHARED, from_fd, (off_t)0)) != (char *)MAP_FAILED) { - if ((nw = write(to_fd, p, size)) != size) { + nw = write(to_fd, p, size); + if (nw != size) { serrno = errno; (void)unlink(to_name); - errno = nw > 0 ? EIO : serrno; - err(EX_OSERR, "%s", to_name); + if (nw >= 0) { + errx(EX_OSERR, + "short write to %s: %jd bytes written, %jd bytes asked to write", + to_name, (uintmax_t)nw, (uintmax_t)size); + } else { + errno = serrno; + err(EX_OSERR, "%s", to_name); + } } done_copy = 1; } @@ -683,8 +691,15 @@ copy(int from_fd, const char *from_name, if ((nw = write(to_fd, buf, nr)) != nr) { serrno = errno; (void)unlink(to_name); - errno = nw > 0 ? EIO : serrno; - err(EX_OSERR, "%s", to_name); + if (nw >= 0) { + errx(EX_OSERR, + "short write to %s: %jd bytes written, %jd bytes asked to write", + to_name, (uintmax_t)nw, + (uintmax_t)size); + } else { + errno = serrno; + err(EX_OSERR, "%s", to_name); + } } if (nr != 0) { serrno = errno; From owner-svn-src-stable-9@FreeBSD.ORG Mon Jul 9 11:53:07 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 2E689106566B; Mon, 9 Jul 2012 11:53:07 +0000 (UTC) (envelope-from melifaro@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0F55C8FC14; Mon, 9 Jul 2012 11:53:07 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q69Br6KR016437; Mon, 9 Jul 2012 11:53:06 GMT (envelope-from melifaro@svn.freebsd.org) Received: (from melifaro@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q69Br6hJ016434; Mon, 9 Jul 2012 11:53:06 GMT (envelope-from melifaro@svn.freebsd.org) Message-Id: <201207091153.q69Br6hJ016434@svn.freebsd.org> From: "Alexander V. Chernikov" Date: Mon, 9 Jul 2012 11:53:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238295 - stable/9/sys/netgraph/netflow X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Jul 2012 11:53:07 -0000 Author: melifaro Date: Mon Jul 9 11:53:06 2012 New Revision: 238295 URL: http://svn.freebsd.org/changeset/base/238295 Log: Merge r237162, r237163, r237164, r237226. Fix improper L4 header handling for IPv6 packets passed via DLT_RAW. Set netflow v9 observation domain value to fib number instead of node id. This fixes multi-fib netflow v9 export. Use time_uptime instead of getnanotime for accouting integer number of seconds. Simplify IP pointer recovery in case of mbuf reallocation. Approved by: ae(mentor) Approved by: re Modified: stable/9/sys/netgraph/netflow/netflow_v9.c stable/9/sys/netgraph/netflow/ng_netflow.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netgraph/netflow/netflow_v9.c ============================================================================== --- stable/9/sys/netgraph/netflow/netflow_v9.c Mon Jul 9 10:59:39 2012 (r238294) +++ stable/9/sys/netgraph/netflow/netflow_v9.c Mon Jul 9 11:53:06 2012 (r238295) @@ -222,7 +222,7 @@ export9_send(priv_p priv, fib_export_p f header->unix_secs = htonl(ts.tv_sec); header->seq_num = htonl(atomic_fetchadd_32(&fe->flow9_seq, 1)); header->count = htons(t->count); - header->source_id = htonl(NG_NODE_ID(priv->node)); + header->source_id = htonl(fe->domain_id); if (priv->export9 != NULL) NG_FWD_ITEM_HOOK_FLAGS(error, item, priv->export9, flags); @@ -416,16 +416,14 @@ get_export9_dgram(priv_p priv, fib_expor * Check if we need to insert templates into packet */ - struct timespec ts; struct netflow_v9_flowset_header *fl; - getnanotime(&ts); - if ((ts.tv_sec >= priv->templ_time + fe->templ_last_ts) || + if ((time_uptime >= priv->templ_time + fe->templ_last_ts) || (fe->sent_packets >= priv->templ_packets + fe->templ_last_pkt)) { - atomic_store_rel_32(&fe->templ_last_ts, ts.tv_sec); - atomic_store_rel_32(&fe->templ_last_pkt, fe->sent_packets); - + fe->templ_last_ts = time_uptime; + fe->templ_last_pkt = fe->sent_packets; + fl = priv->v9_flowsets[0]; m_append(m, ntohs(fl->length), (void *)fl); t->flow_header = m->m_len; Modified: stable/9/sys/netgraph/netflow/ng_netflow.c ============================================================================== --- stable/9/sys/netgraph/netflow/ng_netflow.c Mon Jul 9 10:59:39 2012 (r238294) +++ stable/9/sys/netgraph/netflow/ng_netflow.c Mon Jul 9 11:53:06 2012 (r238295) @@ -560,8 +560,8 @@ ng_netflow_rcvdata (hook_p hook, item_p struct ip6_hdr *ip6 = NULL; struct m_tag *mtag; int pullup_len = 0, off; - uint8_t upper_proto = 0, is_frag = 0; - int error = 0, bypass = 0, acct = 0; + uint8_t acct = 0, bypass = 0, is_frag = 0, upper_proto = 0; + int error = 0, l3_off = 0; unsigned int src_if_index; caddr_t upper_ptr = NULL; fib_export_p fe; @@ -666,6 +666,7 @@ ng_netflow_rcvdata (hook_p hook, item_p M_CHECK(sizeof(struct ip)); eh = mtod(m, struct ether_header *); ip = (struct ip *)(eh + 1); + l3_off = sizeof(struct ether_header); break; #ifdef INET6 case ETHERTYPE_IPV6: @@ -676,6 +677,7 @@ ng_netflow_rcvdata (hook_p hook, item_p M_CHECK(sizeof(struct ip6_hdr)); eh = mtod(m, struct ether_header *); ip6 = (struct ip6_hdr *)(eh + 1); + l3_off = sizeof(struct ether_header); break; #endif case ETHERTYPE_VLAN: @@ -686,6 +688,7 @@ ng_netflow_rcvdata (hook_p hook, item_p sizeof(struct ether_header)); evh = mtod(m, struct ether_vlan_header *); etype = ntohs(evh->evl_proto); + l3_off = sizeof(struct ether_vlan_header); if (etype == ETHERTYPE_IP) { M_CHECK(sizeof(struct ip)); @@ -707,12 +710,13 @@ ng_netflow_rcvdata (hook_p hook, item_p case DLT_RAW: /* IP packets */ M_CHECK(sizeof(struct ip)); ip = mtod(m, struct ip *); + /* l3_off is already zero */ #ifdef INET6 /* If INET6 is not defined IPv6 packets will be discarded in ng_netflow_flow_add() */ if (ip->ip_v == IP6VERSION) { /* IPv6 packet */ ip = NULL; - M_CHECK(sizeof(struct ip6_hdr)); + M_CHECK(sizeof(struct ip6_hdr) - sizeof(struct ip)); ip6 = mtod(m, struct ip6_hdr *); } #endif @@ -824,7 +828,10 @@ ng_netflow_rcvdata (hook_p hook, item_p case IPPROTO_NONE: goto loopend; #endif - /* Any unknow header (new extension or IPv6/IPv4 header for tunnels) */ + /* + * Any unknow header (new extension or IPv6/IPv4 + * header for tunnels) ends loop. + */ default: goto loopend; } @@ -842,56 +849,11 @@ loopend: /* Just in case of real reallocation in M_CHECK() / m_pullup() */ if (m != m_old) { atomic_fetchadd_32(&priv->info.nfinfo_realloc_mbuf, 1); - ip = NULL; - ip6 = NULL; - switch (iface->info.ifinfo_dlt) { - case DLT_EN10MB: /* Ethernet */ - { - struct ether_header *eh; - - eh = mtod(m, struct ether_header *); - switch (ntohs(eh->ether_type)) { - case ETHERTYPE_IP: - ip = (struct ip *)(eh + 1); - break; -#ifdef INET6 - case ETHERTYPE_IPV6: - ip6 = (struct ip6_hdr *)(eh + 1); - break; -#endif - case ETHERTYPE_VLAN: - { - struct ether_vlan_header *evh; - - evh = mtod(m, struct ether_vlan_header *); - if (ntohs(evh->evl_proto) == ETHERTYPE_IP) { - ip = (struct ip *)(evh + 1); - break; -#ifdef INET6 - } else if (ntohs(evh->evl_proto) == ETHERTYPE_IPV6) { - ip6 = (struct ip6_hdr *)(evh + 1); - break; -#endif - } - } - default: - panic("ng_netflow entered deadcode"); - } - break; - } - case DLT_RAW: /* IP packets */ - ip = mtod(m, struct ip *); -#ifdef INET6 - if (ip->ip_v == IP6VERSION) { - /* IPv6 packet */ - ip = NULL; - ip6 = mtod(m, struct ip6_hdr *); - } -#endif - break; - default: - panic("ng_netflow entered deadcode"); - } + /* Restore ip/ipv6 pointer */ + if (ip != NULL) + ip = (struct ip *)(mtod(m, caddr_t) + l3_off); + else if (ip6 != NULL) + ip6 = (struct ip6_hdr *)(mtod(m, caddr_t) + l3_off); } upper_ptr = (caddr_t)(mtod(m, caddr_t) + off); From owner-svn-src-stable-9@FreeBSD.ORG Mon Jul 9 13:21:50 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3A503106566C; Mon, 9 Jul 2012 13:21:50 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 258118FC19; Mon, 9 Jul 2012 13:21:50 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q69DLoFQ020295; Mon, 9 Jul 2012 13:21:50 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q69DLnPY020293; Mon, 9 Jul 2012 13:21:49 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201207091321.q69DLnPY020293@svn.freebsd.org> From: Michael Tuexen Date: Mon, 9 Jul 2012 13:21:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238296 - stable/9/sys/netinet X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Jul 2012 13:21:50 -0000 Author: tuexen Date: Mon Jul 9 13:21:49 2012 New Revision: 238296 URL: http://svn.freebsd.org/changeset/base/238296 Log: MFC r238121: Use CSUM_SCTP_IPV6 for IPv6. Approved by: re@ Modified: stable/9/sys/netinet/sctp_output.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet/sctp_output.c ============================================================================== --- stable/9/sys/netinet/sctp_output.c Mon Jul 9 11:53:06 2012 (r238295) +++ stable/9/sys/netinet/sctp_output.c Mon Jul 9 13:21:49 2012 (r238296) @@ -4478,7 +4478,7 @@ sctp_lowlevel_chunk_output(struct sctp_i #if defined(SCTP_WITH_NO_CSUM) SCTP_STAT_INCR(sctps_sendnocrc); #else - m->m_pkthdr.csum_flags = CSUM_SCTP; + m->m_pkthdr.csum_flags = CSUM_SCTP_IPV6; m->m_pkthdr.csum_data = 0; SCTP_STAT_INCR(sctps_sendhwcrc); #endif @@ -11120,7 +11120,7 @@ sctp_send_resp_msg(struct mbuf *m, struc #if defined(SCTP_WITH_NO_CSUM) SCTP_STAT_INCR(sctps_sendnocrc); #else - mout->m_pkthdr.csum_flags = CSUM_SCTP; + mout->m_pkthdr.csum_flags = CSUM_SCTP_IPV6; mout->m_pkthdr.csum_data = 0; SCTP_STAT_INCR(sctps_sendhwcrc); #endif From owner-svn-src-stable-9@FreeBSD.ORG Mon Jul 9 17:25:57 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8C1E7106564A; Mon, 9 Jul 2012 17:25:57 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6CB708FC08; Mon, 9 Jul 2012 17:25:57 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q69HPvB5030676; Mon, 9 Jul 2012 17:25:57 GMT (envelope-from np@svn.freebsd.org) Received: (from np@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q69HPvO0030671; Mon, 9 Jul 2012 17:25:57 GMT (envelope-from np@svn.freebsd.org) Message-Id: <201207091725.q69HPvO0030671@svn.freebsd.org> From: Navdeep Parhar Date: Mon, 9 Jul 2012 17:25:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238302 - in stable/9/sys/dev: cxgb cxgbe X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Jul 2012 17:25:57 -0000 Author: np Date: Mon Jul 9 17:25:56 2012 New Revision: 238302 URL: http://svn.freebsd.org/changeset/base/238302 Log: Re-enable IFCAP_TSO6 in cxgb(4) and cxgbe(4) in stable/9. The kernel changes needed for all this to work have now been MFC'd to 9 by bz@. This is a direct commit to stable/9 that removes earlier changes made to drivers in this branch only. Approved by: re (kib) Modified: stable/9/sys/dev/cxgb/cxgb_adapter.h stable/9/sys/dev/cxgb/cxgb_main.c stable/9/sys/dev/cxgbe/adapter.h stable/9/sys/dev/cxgbe/t4_main.c Modified: stable/9/sys/dev/cxgb/cxgb_adapter.h ============================================================================== --- stable/9/sys/dev/cxgb/cxgb_adapter.h Mon Jul 9 16:23:59 2012 (r238301) +++ stable/9/sys/dev/cxgb/cxgb_adapter.h Mon Jul 9 17:25:56 2012 (r238302) @@ -81,15 +81,6 @@ extern int cxgb_debug; #define MTX_DESTROY mtx_destroy #endif -#ifndef IFCAP_HWCSUM_IPV6 -#define IFCAP_HWCSUM_IPV6 0 -#define CSUM_TCP_IPV6 0 -#define CSUM_UDP_IPV6 0 -#define IFCAP_TXCSUM_IPV6 0 -#define IFCAP_RXCSUM_IPV6 0 -#define CSUM_DATA_VALID_IPV6 0 -#endif - enum { LF_NO = 0, LF_MAYBE, Modified: stable/9/sys/dev/cxgb/cxgb_main.c ============================================================================== --- stable/9/sys/dev/cxgb/cxgb_main.c Mon Jul 9 16:23:59 2012 (r238301) +++ stable/9/sys/dev/cxgb/cxgb_main.c Mon Jul 9 17:25:56 2012 (r238302) @@ -987,7 +987,7 @@ cxgb_makedev(struct port_info *pi) #define CXGB_CAP (IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU | IFCAP_HWCSUM | \ IFCAP_VLAN_HWCSUM | IFCAP_TSO | IFCAP_JUMBO_MTU | IFCAP_LRO | \ IFCAP_VLAN_HWTSO | IFCAP_LINKSTATE | IFCAP_HWCSUM_IPV6) -#define CXGB_CAP_ENABLE (CXGB_CAP & ~IFCAP_TSO6) +#define CXGB_CAP_ENABLE (CXGB_CAP) static int cxgb_port_attach(device_t dev) Modified: stable/9/sys/dev/cxgbe/adapter.h ============================================================================== --- stable/9/sys/dev/cxgbe/adapter.h Mon Jul 9 16:23:59 2012 (r238301) +++ stable/9/sys/dev/cxgbe/adapter.h Mon Jul 9 17:25:56 2012 (r238302) @@ -57,15 +57,6 @@ MALLOC_DECLARE(M_CXGBE); #define CXGBE_UNIMPLEMENTED(s) \ panic("%s (%s, line %d) not implemented yet.", s, __FILE__, __LINE__) -#ifndef IFCAP_HWCSUM_IPV6 -#define IFCAP_HWCSUM_IPV6 0 -#define CSUM_TCP_IPV6 0 -#define CSUM_UDP_IPV6 0 -#define IFCAP_TXCSUM_IPV6 0 -#define IFCAP_RXCSUM_IPV6 0 -#define CSUM_DATA_VALID_IPV6 0 -#endif - #if defined(__i386__) || defined(__amd64__) static __inline void prefetch(void *x) Modified: stable/9/sys/dev/cxgbe/t4_main.c ============================================================================== --- stable/9/sys/dev/cxgbe/t4_main.c Mon Jul 9 16:23:59 2012 (r238301) +++ stable/9/sys/dev/cxgbe/t4_main.c Mon Jul 9 17:25:56 2012 (r238302) @@ -824,7 +824,7 @@ cxgbe_probe(device_t dev) #define T4_CAP (IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU | IFCAP_HWCSUM | \ IFCAP_VLAN_HWCSUM | IFCAP_TSO | IFCAP_JUMBO_MTU | IFCAP_LRO | \ IFCAP_VLAN_HWTSO | IFCAP_LINKSTATE | IFCAP_HWCSUM_IPV6) -#define T4_CAP_ENABLE (T4_CAP & ~IFCAP_TSO6) +#define T4_CAP_ENABLE (T4_CAP) static int cxgbe_attach(device_t dev) From owner-svn-src-stable-9@FreeBSD.ORG Tue Jul 10 19:05:28 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0025D106566C; Tue, 10 Jul 2012 19:05:27 +0000 (UTC) (envelope-from kensmith@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DECF08FC16; Tue, 10 Jul 2012 19:05:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q6AJ5RR3098210; Tue, 10 Jul 2012 19:05:27 GMT (envelope-from kensmith@svn.freebsd.org) Received: (from kensmith@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q6AJ5Rp6098208; Tue, 10 Jul 2012 19:05:27 GMT (envelope-from kensmith@svn.freebsd.org) Message-Id: <201207101905.q6AJ5Rp6098208@svn.freebsd.org> From: Ken Smith Date: Tue, 10 Jul 2012 19:05:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238351 - stable/9/gnu/usr.bin/groff/tmac X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Jul 2012 19:05:28 -0000 Author: kensmith Date: Tue Jul 10 19:05:27 2012 New Revision: 238351 URL: http://svn.freebsd.org/changeset/base/238351 Log: Shift to "FreeBSD 9.1" for what gets printed in manual pages. Approved by: re (implicit) Modified: stable/9/gnu/usr.bin/groff/tmac/mdoc.local Modified: stable/9/gnu/usr.bin/groff/tmac/mdoc.local ============================================================================== --- stable/9/gnu/usr.bin/groff/tmac/mdoc.local Tue Jul 10 18:57:05 2012 (r238350) +++ stable/9/gnu/usr.bin/groff/tmac/mdoc.local Tue Jul 10 19:05:27 2012 (r238351) @@ -71,12 +71,13 @@ .ds doc-volume-as-arm arm . .\" Default .Os value -.ds doc-default-operating-system FreeBSD\~9.0 +.ds doc-default-operating-system FreeBSD\~9.1 . .\" FreeBSD releases not found in doc-common .ds doc-operating-system-FreeBSD-7.4 7.4 .ds doc-operating-system-FreeBSD-8.3 8.3 .ds doc-operating-system-FreeBSD-9.0 9.0 +.ds doc-operating-system-FreeBSD-9.1 9.1 . .\" Definitions not (yet) in doc-syms . From owner-svn-src-stable-9@FreeBSD.ORG Tue Jul 10 19:08:56 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EAF55106564A; Tue, 10 Jul 2012 19:08:56 +0000 (UTC) (envelope-from kensmith@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D64088FC0A; Tue, 10 Jul 2012 19:08:56 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q6AJ8ub1098381; Tue, 10 Jul 2012 19:08:56 GMT (envelope-from kensmith@svn.freebsd.org) Received: (from kensmith@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q6AJ8uhJ098379; Tue, 10 Jul 2012 19:08:56 GMT (envelope-from kensmith@svn.freebsd.org) Message-Id: <201207101908.q6AJ8uhJ098379@svn.freebsd.org> From: Ken Smith Date: Tue, 10 Jul 2012 19:08:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238352 - stable/9/release X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Jul 2012 19:08:57 -0000 Author: kensmith Date: Tue Jul 10 19:08:56 2012 New Revision: 238352 URL: http://svn.freebsd.org/changeset/base/238352 Log: Adjustments for 9.0 -> 9.1. Approved by: re (implicit) Modified: stable/9/release/Makefile.sysinstall Modified: stable/9/release/Makefile.sysinstall ============================================================================== --- stable/9/release/Makefile.sysinstall Tue Jul 10 19:05:27 2012 (r238351) +++ stable/9/release/Makefile.sysinstall Tue Jul 10 19:08:56 2012 (r238352) @@ -24,11 +24,11 @@ # Set these, release builder! # # Fixed version: -#BUILDNAME=9.0-CURRENT +#BUILDNAME=9.1-STABLE # # Automatic SNAP versioning: DATE != date +%Y%m%d -BASE = 9.0 +BASE = 9.1 BUILDNAME?=${BASE}-${DATE}-SNAP # #CHROOTDIR=/junk/release @@ -72,7 +72,7 @@ BUILDNAME?=${BASE}-${DATE}-SNAP # # Subversion branch to build for src. If this is not set then it is # automatically computed from RELEASETAG. -#SVNBRANCH=stable/8 +#SVNBRANCH=stable/9 # # Non-zero if ${RELEASETAG} is in the form "RELENG_ver_RELEASE"; we # are building an official release. Otherwise, we are building for From owner-svn-src-stable-9@FreeBSD.ORG Tue Jul 10 19:10:39 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id CC0FF106564A; Tue, 10 Jul 2012 19:10:39 +0000 (UTC) (envelope-from kensmith@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B600E8FC0C; Tue, 10 Jul 2012 19:10:39 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q6AJAdvq098488; Tue, 10 Jul 2012 19:10:39 GMT (envelope-from kensmith@svn.freebsd.org) Received: (from kensmith@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q6AJAduP098485; Tue, 10 Jul 2012 19:10:39 GMT (envelope-from kensmith@svn.freebsd.org) Message-Id: <201207101910.q6AJAduP098485@svn.freebsd.org> From: Ken Smith Date: Tue, 10 Jul 2012 19:10:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238353 - stable/9/sys/conf X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Jul 2012 19:10:39 -0000 Author: kensmith Date: Tue Jul 10 19:10:39 2012 New Revision: 238353 URL: http://svn.freebsd.org/changeset/base/238353 Log: Ready for 9.1-BETA1 builds. Approved by: re (implicit) Modified: stable/9/sys/conf/newvers.sh Modified: stable/9/sys/conf/newvers.sh ============================================================================== --- stable/9/sys/conf/newvers.sh Tue Jul 10 19:08:56 2012 (r238352) +++ stable/9/sys/conf/newvers.sh Tue Jul 10 19:10:39 2012 (r238353) @@ -31,8 +31,8 @@ # $FreeBSD$ TYPE="FreeBSD" -REVISION="9.0" -BRANCH="STABLE" +REVISION="9.1" +BRANCH="BETA1" if [ "X${BRANCH_OVERRIDE}" != "X" ]; then BRANCH=${BRANCH_OVERRIDE} fi