From owner-svn-src-all@freebsd.org Sun Dec 1 18:05:04 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3E84D1B36F3; Sun, 1 Dec 2019 18:05:04 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47Qx3h0xTbz44qW; Sun, 1 Dec 2019 18:05:04 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 037081A859; Sun, 1 Dec 2019 18:05:04 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xB1I532x028003; Sun, 1 Dec 2019 18:05:03 GMT (envelope-from tuexen@FreeBSD.org) Received: (from tuexen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xB1I52J4027996; Sun, 1 Dec 2019 18:05:02 GMT (envelope-from tuexen@FreeBSD.org) Message-Id: <201912011805.xB1I52J4027996@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tuexen set sender to tuexen@FreeBSD.org using -f From: Michael Tuexen Date: Sun, 1 Dec 2019 18:05:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r355266 - in head/sys: dev/cxgbe/tom netinet X-SVN-Group: head X-SVN-Commit-Author: tuexen X-SVN-Commit-Paths: in head/sys: dev/cxgbe/tom netinet X-SVN-Commit-Revision: 355266 X-SVN-Commit-Repository: base 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.29 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, 01 Dec 2019 18:05:04 -0000 Author: tuexen Date: Sun Dec 1 18:05:02 2019 New Revision: 355266 URL: https://svnweb.freebsd.org/changeset/base/355266 Log: In order for the TCP Handshake to support ECN++, and further ECN-related improvements, the ECN bits need to be exposed to the TCP SYNcache. This change is a minimal modification to the function headers, without any functional change intended. Submitted by: Richard Scheffenegger Reviewed by: rgrimes@, rrs@, tuexen@ Differential Revision: https://reviews.freebsd.org/D22436 Modified: head/sys/dev/cxgbe/tom/t4_listen.c head/sys/netinet/tcp_input.c head/sys/netinet/tcp_syncache.c head/sys/netinet/tcp_syncache.h head/sys/netinet/toecore.c head/sys/netinet/toecore.h Modified: head/sys/dev/cxgbe/tom/t4_listen.c ============================================================================== --- head/sys/dev/cxgbe/tom/t4_listen.c Sun Dec 1 17:35:36 2019 (r355265) +++ head/sys/dev/cxgbe/tom/t4_listen.c Sun Dec 1 18:05:02 2019 (r355266) @@ -988,7 +988,7 @@ t4opt_to_tcpopt(const struct tcp_options *t4opt, struc static void pass_accept_req_to_protohdrs(struct adapter *sc, const struct mbuf *m, - struct in_conninfo *inc, struct tcphdr *th) + struct in_conninfo *inc, struct tcphdr *th, uint8_t *iptos) { const struct cpl_pass_accept_req *cpl = mtod(m, const void *); const struct ether_header *eh; @@ -1005,6 +1005,21 @@ pass_accept_req_to_protohdrs(struct adapter *sc, const tcp = (const void *)(l3hdr + G_IP_HDR_LEN(hlen)); } + /* extract TOS (DiffServ + ECN) byte for AccECN */ + if (iptos) { + if (((struct ip *)l3hdr)->ip_v == IPVERSION) { + const struct ip *ip = (const void *)l3hdr; + *iptos = ip->ip_tos; + } +#ifdef INET6 + else + if (((struct ip *)l3hdr)->ip_v == (IPV6_VERSION >> 4)) { + const struct ip6_hdr *ip6 = (const void *)l3hdr; + *iptos = (ntohl(ip6->ip6_flow) >> 20) & 0xff; + } +#endif /* INET */ + } + if (inc) { bzero(inc, sizeof(*inc)); inc->inc_fport = tcp->th_sport; @@ -1150,6 +1165,7 @@ do_pass_accept_req(struct sge_iq *iq, const struct rss unsigned int opcode = G_CPL_OPCODE(be32toh(OPCODE_TID(cpl))); #endif struct offload_settings settings; + uint8_t iptos; KASSERT(opcode == CPL_PASS_ACCEPT_REQ, ("%s: unexpected opcode 0x%x", __func__, opcode)); @@ -1208,7 +1224,7 @@ found: if (lctx->vnet != ifp->if_vnet) REJECT_PASS_ACCEPT_REQ(true); - pass_accept_req_to_protohdrs(sc, m, &inc, &th); + pass_accept_req_to_protohdrs(sc, m, &inc, &th, &iptos); if (inc.inc_flags & INC_ISIPV6) { /* Don't offload if the ifcap isn't enabled */ @@ -1284,7 +1300,7 @@ found: * syncache_add. Note that syncache_add releases the pcb lock. */ t4opt_to_tcpopt(&cpl->tcpopt, &to); - toe_syncache_add(&inc, &to, &th, inp, tod, synqe); + toe_syncache_add(&inc, &to, &th, inp, tod, synqe, iptos); if (atomic_load_int(&synqe->ok_to_respond) > 0) { uint64_t opt0; @@ -1350,9 +1366,10 @@ synqe_to_protohdrs(struct adapter *sc, struct synq_ent struct tcphdr *th, struct tcpopt *to) { uint16_t tcp_opt = be16toh(cpl->tcp_opt); + uint8_t iptos; /* start off with the original SYN */ - pass_accept_req_to_protohdrs(sc, synqe->syn, inc, th); + pass_accept_req_to_protohdrs(sc, synqe->syn, inc, th, &iptos); /* modify parts to make it look like the ACK to our SYN|ACK */ th->th_flags = TH_ACK; Modified: head/sys/netinet/tcp_input.c ============================================================================== --- head/sys/netinet/tcp_input.c Sun Dec 1 17:35:36 2019 (r355265) +++ head/sys/netinet/tcp_input.c Sun Dec 1 18:05:02 2019 (r355266) @@ -1282,7 +1282,7 @@ tfo_socket_result: #endif TCP_PROBE3(debug__input, tp, th, m); tcp_dooptions(&to, optp, optlen, TO_SYN); - if (syncache_add(&inc, &to, th, inp, &so, m, NULL, NULL)) + if (syncache_add(&inc, &to, th, inp, &so, m, NULL, NULL, iptos)) goto tfo_socket_result; /* Modified: head/sys/netinet/tcp_syncache.c ============================================================================== --- head/sys/netinet/tcp_syncache.c Sun Dec 1 17:35:36 2019 (r355265) +++ head/sys/netinet/tcp_syncache.c Sun Dec 1 18:05:02 2019 (r355266) @@ -1369,7 +1369,7 @@ syncache_tfo_expand(struct syncache *sc, struct socket int syncache_add(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th, struct inpcb *inp, struct socket **lsop, struct mbuf *m, void *tod, - void *todctx) + void *todctx, uint8_t iptos) { struct tcpcb *tp; struct socket *so; Modified: head/sys/netinet/tcp_syncache.h ============================================================================== --- head/sys/netinet/tcp_syncache.h Sun Dec 1 17:35:36 2019 (r355265) +++ head/sys/netinet/tcp_syncache.h Sun Dec 1 18:05:02 2019 (r355266) @@ -45,7 +45,7 @@ int syncache_expand(struct in_conninfo *, struct tcpo struct tcphdr *, struct socket **, struct mbuf *); int syncache_add(struct in_conninfo *, struct tcpopt *, struct tcphdr *, struct inpcb *, struct socket **, struct mbuf *, - void *, void *); + void *, void *, uint8_t); void syncache_chkrst(struct in_conninfo *, struct tcphdr *, struct mbuf *); void syncache_badack(struct in_conninfo *); int syncache_pcblist(struct sysctl_req *); Modified: head/sys/netinet/toecore.c ============================================================================== --- head/sys/netinet/toecore.c Sun Dec 1 17:35:36 2019 (r355265) +++ head/sys/netinet/toecore.c Sun Dec 1 18:05:02 2019 (r355266) @@ -346,13 +346,13 @@ unregister_toedev(struct toedev *tod) void toe_syncache_add(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th, - struct inpcb *inp, void *tod, void *todctx) + struct inpcb *inp, void *tod, void *todctx, uint8_t iptos) { struct socket *lso = inp->inp_socket; INP_WLOCK_ASSERT(inp); - syncache_add(inc, to, th, inp, &lso, NULL, tod, todctx); + syncache_add(inc, to, th, inp, &lso, NULL, tod, todctx, iptos); } int Modified: head/sys/netinet/toecore.h ============================================================================== --- head/sys/netinet/toecore.h Sun Dec 1 17:35:36 2019 (r355265) +++ head/sys/netinet/toecore.h Sun Dec 1 18:05:02 2019 (r355266) @@ -135,7 +135,7 @@ int toe_l2_resolve(struct toedev *, struct ifnet *, st void toe_connect_failed(struct toedev *, struct inpcb *, int); void toe_syncache_add(struct in_conninfo *, struct tcpopt *, struct tcphdr *, - struct inpcb *, void *, void *); + struct inpcb *, void *, void *, uint8_t); int toe_syncache_expand(struct in_conninfo *, struct tcpopt *, struct tcphdr *, struct socket **);