From owner-svn-src-all@freebsd.org Sun Sep 6 20:57:59 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 71AEC9CB448; Sun, 6 Sep 2015 20:57:59 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 61FDBAFA; Sun, 6 Sep 2015 20:57:59 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t86KvxJ3042748; Sun, 6 Sep 2015 20:57:59 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t86KvwYT042745; Sun, 6 Sep 2015 20:57:58 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <201509062057.t86KvwYT042745@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Sun, 6 Sep 2015 20:57:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r287525 - head/sys/netinet6 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Sep 2015 20:57:59 -0000 Author: adrian Date: Sun Sep 6 20:57:57 2015 New Revision: 287525 URL: https://svnweb.freebsd.org/changeset/base/287525 Log: Add support for receiving flowtype, flowid and RSS bucket information as part of recvmsg(). Submitted by: Tiwei Bie Differential Revision: https://reviews.freebsd.org/D3562 Modified: head/sys/netinet6/in6.h head/sys/netinet6/ip6_input.c head/sys/netinet6/ip6_output.c Modified: head/sys/netinet6/in6.h ============================================================================== --- head/sys/netinet6/in6.h Sun Sep 6 20:20:48 2015 (r287524) +++ head/sys/netinet6/in6.h Sun Sep 6 20:57:57 2015 (r287525) @@ -485,6 +485,8 @@ struct route_in6 { #define IPV6_FLOWID 67 /* int; flowid of given socket */ #define IPV6_FLOWTYPE 68 /* int; flowtype of given socket */ #define IPV6_RSSBUCKETID 69 /* int; RSS bucket ID of given socket */ +#define IPV6_RECVFLOWID 70 /* bool; receive IP6 flowid/flowtype w/ datagram */ +#define IPV6_RECVRSSBUCKETID 71 /* bool; receive IP6 RSS bucket id w/ datagram */ /* * The following option is private; do not use it from user applications. Modified: head/sys/netinet6/ip6_input.c ============================================================================== --- head/sys/netinet6/ip6_input.c Sun Sep 6 20:20:48 2015 (r287524) +++ head/sys/netinet6/ip6_input.c Sun Sep 6 20:57:57 2015 (r287525) @@ -93,6 +93,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -1349,6 +1350,44 @@ ip6_savecontrol(struct inpcb *in6p, stru loopend: ; } + + if (in6p->inp_flags2 & INP_RECVFLOWID) { + uint32_t flowid, flow_type; + + flowid = m->m_pkthdr.flowid; + flow_type = M_HASHTYPE_GET(m); + + /* + * XXX should handle the failure of one or the + * other - don't populate both? + */ + *mp = sbcreatecontrol((caddr_t) &flowid, + sizeof(uint32_t), IPV6_FLOWID, IPPROTO_IPV6); + if (*mp) + mp = &(*mp)->m_next; + *mp = sbcreatecontrol((caddr_t) &flow_type, + sizeof(uint32_t), IPV6_FLOWTYPE, IPPROTO_IPV6); + if (*mp) + mp = &(*mp)->m_next; + } + +#ifdef RSS + if (in6p->inp_flags2 & INP_RECVRSSBUCKETID) { + uint32_t flowid, flow_type; + uint32_t rss_bucketid; + + flowid = m->m_pkthdr.flowid; + flow_type = M_HASHTYPE_GET(m); + + if (rss_hash2bucket(flowid, flow_type, &rss_bucketid) == 0) { + *mp = sbcreatecontrol((caddr_t) &rss_bucketid, + sizeof(uint32_t), IPV6_RSSBUCKETID, IPPROTO_IPV6); + if (*mp) + mp = &(*mp)->m_next; + } + } +#endif + } #undef IS2292 Modified: head/sys/netinet6/ip6_output.c ============================================================================== --- head/sys/netinet6/ip6_output.c Sun Sep 6 20:20:48 2015 (r287524) +++ head/sys/netinet6/ip6_output.c Sun Sep 6 20:57:57 2015 (r287525) @@ -1400,6 +1400,10 @@ ip6_ctloutput(struct socket *so, struct case IPV6_RECVRTHDR: case IPV6_RECVPATHMTU: case IPV6_RECVTCLASS: + case IPV6_RECVFLOWID: +#ifdef RSS + case IPV6_RECVRSSBUCKETID: +#endif case IPV6_V6ONLY: case IPV6_AUTOFLOWLABEL: case IPV6_BINDANY: @@ -1548,6 +1552,16 @@ do { \ OPTSET(IN6P_MTU); break; + case IPV6_RECVFLOWID: + OPTSET2(INP_RECVFLOWID, optval); + break; + +#ifdef RSS + case IPV6_RECVRSSBUCKETID: + OPTSET2(INP_RECVRSSBUCKETID, optval); + break; +#endif + case IPV6_V6ONLY: /* * make setsockopt(IPV6_V6ONLY) @@ -1811,8 +1825,10 @@ do { \ case IPV6_BINDANY: case IPV6_FLOWID: case IPV6_FLOWTYPE: + case IPV6_RECVFLOWID: #ifdef RSS case IPV6_RSSBUCKETID: + case IPV6_RECVRSSBUCKETID: #endif switch (optname) { @@ -1883,6 +1899,10 @@ do { \ case IPV6_FLOWTYPE: optval = in6p->inp_flowtype; break; + + case IPV6_RECVFLOWID: + optval = OPTBIT2(INP_RECVFLOWID); + break; #ifdef RSS case IPV6_RSSBUCKETID: retval = @@ -1894,6 +1914,10 @@ do { \ else error = EINVAL; break; + + case IPV6_RECVRSSBUCKETID: + optval = OPTBIT2(INP_RECVRSSBUCKETID); + break; #endif case IPV6_BINDMULTI: