From 21cfeb43727cfbd20999be9ace99e24b1887014a Mon Sep 17 00:00:00 2001 From: fengbojiang Date: Thu, 23 Sep 2021 15:16:09 +0800 Subject: [PATCH] Support extra tcp stacks, rack and bbr. --- freebsd/netinet/tcp_hpts.c | 6 ++++++ freebsd/netinet/tcp_stacks/bbr.c | 5 +++++ freebsd/netinet/tcp_stacks/rack.c | 5 +++++ lib/Makefile | 30 +++++++++++++++++++++++++++++- 4 files changed, 45 insertions(+), 1 deletion(-) diff --git a/freebsd/netinet/tcp_hpts.c b/freebsd/netinet/tcp_hpts.c index fd8b66b9c..ad0857122 100644 --- a/freebsd/netinet/tcp_hpts.c +++ b/freebsd/netinet/tcp_hpts.c @@ -188,11 +188,15 @@ __FBSDID("$FreeBSD$"); #endif MALLOC_DEFINE(M_TCPHPTS, "tcp_hpts", "TCP hpts"); +#ifndef FSTACK #ifdef RSS static int tcp_bind_threads = 1; #else static int tcp_bind_threads = 2; #endif +#else +static int tcp_bind_threads = 1; +#endif TUNABLE_INT("net.inet.tcp.bind_hptss", &tcp_bind_threads); static struct tcp_hptsi tcp_pace; @@ -1971,6 +1975,7 @@ tcp_init_hptsi(void *st) if (intr_event_bind(hpts->ie, i) == 0) bound++; } else if (tcp_bind_threads == 2) { +#ifndef FSTACK pc = pcpu_find(i); domain = pc->pc_domain; CPU_COPY(&cpuset_domain[domain], &cs); @@ -1981,6 +1986,7 @@ tcp_init_hptsi(void *st) hpts_domains[domain].cpu[count] = i; hpts_domains[domain].count++; } +#endif } tv.tv_sec = 0; tv.tv_usec = hpts->p_hpts_sleep_time * HPTS_TICKS_PER_USEC; diff --git a/freebsd/netinet/tcp_stacks/bbr.c b/freebsd/netinet/tcp_stacks/bbr.c index 49ed7e992..27da9a173 100644 --- a/freebsd/netinet/tcp_stacks/bbr.c +++ b/freebsd/netinet/tcp_stacks/bbr.c @@ -147,6 +147,11 @@ struct sysctl_oid *bbr_sysctl_root; /*#define BBR_INVARIANT 1*/ +#ifdef FSTACK +#define MODNAME tcp_bbr +#define STACKNAME bbr +#endif + /* * initial window */ diff --git a/freebsd/netinet/tcp_stacks/rack.c b/freebsd/netinet/tcp_stacks/rack.c index 104468bee..342ecf4c0 100644 --- a/freebsd/netinet/tcp_stacks/rack.c +++ b/freebsd/netinet/tcp_stacks/rack.c @@ -139,6 +139,11 @@ struct sysctl_oid *rack_sysctl_root; #define CUM_ACKED 1 #define SACKED 2 +#ifdef FSTACK +#define MODNAME tcp_rack +#define STACKNAME rack +#endif + /* * The RACK module incorporates a number of * TCP ideas that have been put out into the IETF diff --git a/lib/Makefile b/lib/Makefile index 3b190fb97..7afbcaa04 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -27,12 +27,20 @@ HOST_OS:=$(shell uname -s) DEBUG=-O0 -gdwarf-2 -g3 -Wno-format-truncation FF_KNI=1 + #FF_FLOW_ISOLATE=1 + +# NETGRAPH drivers ipfw #FF_NETGRAPH=1 #FF_IPFW=1 + #FF_USE_PAGE_ARRAY=1 + FF_INET6=1 +# TCPHPTS drivers rack and bbr +FF_TCPHPTS=1 +FF_EXTRA_TCP_STACKS=1 include ${TOPDIR}/mk/kern.pre.mk @@ -88,6 +96,10 @@ HOST_CFLAGS+= -DINET6 CFLAGS+= -DINET6 endif +ifdef FF_TCPHPTS +CFLAGS+= -DTCPHPTS -DRATELIMIT +endif + HOST_C= ${CC} -c $(HOST_CFLAGS) ${HOST_INCLUDES} ${WERROR} ${PROF} $< @@ -171,6 +183,9 @@ VPATH+= $S/netinet/cc ifdef FF_INET6 VPATH+= $S/netinet6 endif +ifdef FF_EXTRA_TCP_STACKS +VPATH+= $S/netinet/tcp_stacks +endif VPATH+= $S/netipsec ifdef FF_IPFW VPATH+= $S/netpfil/ipfw @@ -489,6 +504,19 @@ NETINET6_SRCS+= \ #ip6_ipsec.c #sctp6_usrreq.c #in6_rss.c + +ifdef FF_EXTRA_TCP_STACKS +EXTRA_TCP_STACKS_SRCS+= \ + subr_filter.c \ + tcp_hpts.c \ + tcp_ratelimit.c \ + arc4random_uniform.c \ + sack_filter.c \ + rack_bbr_common.c \ + rack.c \ + bbr.c +endif + ifndef FF_KNI FF_HOST_SRCS+= \ ff_dpdk_kni.c @@ -568,7 +596,7 @@ MSRCS+= $(patsubst %.m,%.c,${OPENCRYPTO_MSRCS}) ASM_SRCS = ${CRYPTO_ASM_SRCS} SRCS= ${FF_SRCS} ${CRYPTO_SRCS} ${KERN_SRCS} ${LIBKERN_SRCS} ${MACHINE_SRCS} -SRCS+= ${MSRCS} ${NET_SRCS} ${NETGRAPH_SRCS} ${NETINET_SRCS} ${NETINET6_SRCS} +SRCS+= ${MSRCS} ${NET_SRCS} ${NETGRAPH_SRCS} ${NETINET_SRCS} ${NETINET6_SRCS} ${EXTRA_TCP_STACKS_SRCS} SRCS+= ${NETIPSEC_SRCS} ${NETIPFW_SRCS} ${OPENCRYPTO_SRCS} ${VM_SRCS} # If witness is enabled.