if stoeplitz is enabled by a driver (eg, ix, mcx, etc), this uses it in
the tcp code to set the flowid on packets. this encourages both the tx
and rx side of a tcp connection to get processed in the same places.
ok?
Index: netinet/in_pcb.c
===================================================================
RCS file: /cvs/src/sys/netinet/in_pcb.c,v
retrieving revision 1.252
diff -u -p -r1.252 in_pcb.c
--- netinet/in_pcb.c 7 Nov 2020 09:51:40 -0000 1.252
+++ netinet/in_pcb.c 3 Jan 2021 02:12:45 -0000
@@ -95,6 +95,11 @@
#include <netinet/ip_esp.h>
#endif /* IPSEC */
+#include "stoeplitz.h"
+#if NSTOEPLITZ > 0
+#include <net/toeplitz.h>
+#endif
+
const struct in_addr zeroin_addr;
union {
@@ -516,6 +521,10 @@ in_pcbconnect(struct inpcb *inp, struct
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);
Index: netinet/in_pcb.h
===================================================================
RCS file: /cvs/src/sys/netinet/in_pcb.h,v
retrieving revision 1.120
diff -u -p -r1.120 in_pcb.h
--- netinet/in_pcb.h 21 Jun 2020 05:14:04 -0000 1.120
+++ netinet/in_pcb.h 3 Jan 2021 02:12:45 -0000
@@ -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);
Index: netinet/tcp_output.c
===================================================================
RCS file: /cvs/src/sys/netinet/tcp_output.c,v
retrieving revision 1.128
diff -u -p -r1.128 tcp_output.c
--- netinet/tcp_output.c 10 Nov 2018 18:40:34 -0000 1.128
+++ netinet/tcp_output.c 3 Jan 2021 02:12:45 -0000
@@ -69,6 +69,7 @@
*/
#include "pf.h"
+#include "stoeplitz.h"
#include <sys/param.h>
#include <sys/systm.h>
@@ -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);
Index: netinet6/in6_pcb.c
===================================================================
RCS file: /cvs/src/sys/netinet6/in6_pcb.c,v
retrieving revision 1.110
diff -u -p -r1.110 in6_pcb.c
--- netinet6/in6_pcb.c 29 Nov 2019 16:41:01 -0000 1.110
+++ netinet6/in6_pcb.c 3 Jan 2021 02:12:45 -0000
@@ -100,6 +100,7 @@
*/
#include "pf.h"
+#include "stoeplitz.h"
#include <sys/param.h>
#include <sys/systm.h>
@@ -119,6 +120,10 @@
#include <netinet6/in6_var.h>
+#if NSTOEPLITZ > 0
+#include <net/toeplitz.h>
+#endif
+
const struct in6_addr zeroin6_addr;
struct inpcbhead *
@@ -297,6 +302,10 @@ in6_pcbconnect(struct inpcb *inp, struct
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);
}