From: dlg Date: Mon, 25 Jan 2021 03:40:46 +0000 (+0000) Subject: if stoeplitz is enabled, use it to provide a flowid for tcp packets. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=aa794c2ba4c927d9ef34a66486baad043e969e5e;p=openbsd if stoeplitz is enabled, use it to provide a flowid for tcp packets. drivers that implement rss and multiple rings depend on the symmetric toeplitz code, and use it to generate a key that decides with rx ring a packet lands on. if the toeplitz code is enabled, this diff has the pcb and tcp layer use the toeplitz code to generate a flowid for packets they send, which in turn is used to pick a tx ring. because the nic and the stack use the same key, the tx and rx sides end up with the same hash/flowid. at the very least this means that the same rx and tx queue pair on a particular nic are used for both sides of the connection. as the stack becomes more parallel, it will also help keep both sides of the tcp connection processing in the one place. --- diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index 12ed205c858..99402c98425 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in_pcb.c,v 1.252 2020/11/07 09:51:40 denis Exp $ */ +/* $OpenBSD: in_pcb.c,v 1.253 2021/01/25 03:40:46 dlg Exp $ */ /* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */ /* @@ -95,6 +95,11 @@ #include #endif /* IPSEC */ +#include "stoeplitz.h" +#if NSTOEPLITZ > 0 +#include +#endif + const struct in_addr zeroin_addr; union { @@ -516,6 +521,10 @@ in_pcbconnect(struct inpcb *inp, struct mbuf *nam) inp->inp_faddr = sin->sin_addr; inp->inp_fport = sin->sin_port; in_pcbrehash(inp); +#if NSTOEPLITZ > 0 + inp->inp_flowid = stoeplitz_ip4port(inp->inp_laddr.s_addr, + inp->inp_faddr.s_addr, inp->inp_lport, inp->inp_fport); +#endif #ifdef IPSEC { /* Cause an IPsec SA to be established. */ @@ -549,6 +558,7 @@ in_pcbdisconnect(struct inpcb *inp) } inp->inp_fport = 0; + inp->inp_flowid = 0; in_pcbrehash(inp); if (inp->inp_socket->so_state & SS_NOFDREF) in_pcbdetach(inp); diff --git a/sys/netinet/in_pcb.h b/sys/netinet/in_pcb.h index 4c7ae3fd18f..2f87c820f7f 100644 --- a/sys/netinet/in_pcb.h +++ b/sys/netinet/in_pcb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: in_pcb.h,v 1.120 2020/06/21 05:14:04 dlg Exp $ */ +/* $OpenBSD: in_pcb.h,v 1.121 2021/01/25 03:40:46 dlg Exp $ */ /* $NetBSD: in_pcb.h,v 1.14 1996/02/13 23:42:00 christos Exp $ */ /* @@ -148,6 +148,7 @@ struct inpcb { void *inp_upcall_arg; u_int inp_rtableid; int inp_pipex; /* pipex indication */ + uint16_t inp_flowid; }; LIST_HEAD(inpcbhead, inpcb); diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c index 27a8739081c..f2d1516c27a 100644 --- a/sys/netinet/tcp_output.c +++ b/sys/netinet/tcp_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_output.c,v 1.128 2018/11/10 18:40:34 bluhm Exp $ */ +/* $OpenBSD: tcp_output.c,v 1.129 2021/01/25 03:40:46 dlg Exp $ */ /* $NetBSD: tcp_output.c,v 1.16 1997/06/03 16:17:09 kml Exp $ */ /* @@ -69,6 +69,7 @@ */ #include "pf.h" +#include "stoeplitz.h" #include #include @@ -1037,6 +1038,10 @@ send: ip->ip_tos |= IPTOS_ECN_ECT0; #endif } +#if NSTOEPLITZ > 0 + m->m_pkthdr.ph_flowid = tp->t_inpcb->inp_flowid; + SET(m->m_pkthdr.csum_flags, M_FLOWID); +#endif error = ip_output(m, tp->t_inpcb->inp_options, &tp->t_inpcb->inp_route, (ip_mtudisc ? IP_MTUDISC : 0), NULL, tp->t_inpcb, 0); diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c index 36057b59a8d..a0b270c90e5 100644 --- a/sys/netinet6/in6_pcb.c +++ b/sys/netinet6/in6_pcb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in6_pcb.c,v 1.110 2019/11/29 16:41:01 nayden Exp $ */ +/* $OpenBSD: in6_pcb.c,v 1.111 2021/01/25 03:40:47 dlg Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -100,6 +100,7 @@ */ #include "pf.h" +#include "stoeplitz.h" #include #include @@ -119,6 +120,10 @@ #include +#if NSTOEPLITZ > 0 +#include +#endif + const struct in6_addr zeroin6_addr; struct inpcbhead * @@ -297,6 +302,10 @@ in6_pcbconnect(struct inpcb *inp, struct mbuf *nam) if (ip6_auto_flowlabel) inp->inp_flowinfo |= (htonl(ip6_randomflowlabel()) & IPV6_FLOWLABEL_MASK); +#if NSTOEPLITZ > 0 + inp->inp_flowid = stoeplitz_ip6port(&inp->inp_laddr6, + &inp->inp_faddr6, inp->inp_lport, inp->inp_fport); +#endif in_pcbrehash(inp); return (0); }