rrs created this revision.
rrs added a reviewer: hiren.
rrs added a subscriber: transport.
REVISION SUMMARY
The fast path.c code had the wrong module dependency (which is fixed in this
revision too) but it
points out a weakness in the initialization, i.e. one must have the register
function either
validate that initialization and error, or just do the initialization at that
point. I choose the
later since it does no harm.
TEST PLAN
load the old module without changing its order and make sure we don't crash
:-)
REVISION DETAIL
https://reviews.freebsd.org/D5189
AFFECTED FILES
netinet/tcp_stacks/fastpath.c
netinet/tcp_subr.c
CHANGE DETAILS
diff --git a/netinet/tcp_subr.c b/netinet/tcp_subr.c
--- a/netinet/tcp_subr.c
+++ b/netinet/tcp_subr.c
@@ -263,9 +263,20 @@
0
};
+int t_functions_inited = 0;
struct tcp_funchead t_functions;
static struct tcp_function_block *tcp_func_set_ptr = &tcp_def_funcblk;
+static void
+init_tcp_functions()
+{
+ if (t_functions_inited == 0) {
+ TAILQ_INIT(&t_functions);
+ rw_init_flags(&tcp_function_lock, "tcp_func_lock" , 0);
+ t_functions_inited = 1;
+ }
+}
+
static struct tcp_function_block *
find_tcp_functions_locked(struct tcp_function_set *fs)
{
@@ -503,6 +514,9 @@
struct tcp_function *n;
struct tcp_function_set fs;
+ if (t_functions_inited == 0) {
+ init_tcp_functions();
+ }
if ((blk->tfb_tcp_output == NULL) ||
(blk->tfb_tcp_do_segment == NULL) ||
(blk->tfb_tcp_ctloutput == NULL) ||
@@ -681,8 +695,7 @@
tcp_finwait2_timeout = TCPTV_FINWAIT2_TIMEOUT;
tcp_tcbhashsize = hashsize;
/* Setup the tcp function block list */
- TAILQ_INIT(&t_functions);
- rw_init_flags(&tcp_function_lock, "tcp_func_lock" , 0);
+ init_tcp_functions();
register_tcp_functions(&tcp_def_funcblk, M_WAITOK);
if (tcp_soreceive_stream) {
diff --git a/netinet/tcp_stacks/fastpath.c b/netinet/tcp_stacks/fastpath.c
--- a/netinet/tcp_stacks/fastpath.c
+++ b/netinet/tcp_stacks/fastpath.c
@@ -2453,4 +2453,4 @@
};
MODULE_VERSION(kern_tcpfastpaths, 1);
-DECLARE_MODULE(kern_tcpfastpaths, new_tcp_fastpaths, SI_SUB_PSEUDO,
SI_ORDER_ANY);
+DECLARE_MODULE(kern_tcpfastpaths, new_tcp_fastpaths, SI_SUB_PROTO_DOMAIN,
SI_ORDER_ANY);
EMAIL PREFERENCES
https://reviews.freebsd.org/settings/panel/emailpreferences/
To: rrs, hiren
Cc: transport
diff --git a/netinet/tcp_subr.c b/netinet/tcp_subr.c
--- a/netinet/tcp_subr.c
+++ b/netinet/tcp_subr.c
@@ -263,9 +263,20 @@
0
};
+int t_functions_inited = 0;
struct tcp_funchead t_functions;
static struct tcp_function_block *tcp_func_set_ptr = &tcp_def_funcblk;
+static void
+init_tcp_functions()
+{
+ if (t_functions_inited == 0) {
+ TAILQ_INIT(&t_functions);
+ rw_init_flags(&tcp_function_lock, "tcp_func_lock" , 0);
+ t_functions_inited = 1;
+ }
+}
+
static struct tcp_function_block *
find_tcp_functions_locked(struct tcp_function_set *fs)
{
@@ -503,6 +514,9 @@
struct tcp_function *n;
struct tcp_function_set fs;
+ if (t_functions_inited == 0) {
+ init_tcp_functions();
+ }
if ((blk->tfb_tcp_output == NULL) ||
(blk->tfb_tcp_do_segment == NULL) ||
(blk->tfb_tcp_ctloutput == NULL) ||
@@ -681,8 +695,7 @@
tcp_finwait2_timeout = TCPTV_FINWAIT2_TIMEOUT;
tcp_tcbhashsize = hashsize;
/* Setup the tcp function block list */
- TAILQ_INIT(&t_functions);
- rw_init_flags(&tcp_function_lock, "tcp_func_lock" , 0);
+ init_tcp_functions();
register_tcp_functions(&tcp_def_funcblk, M_WAITOK);
if (tcp_soreceive_stream) {
diff --git a/netinet/tcp_stacks/fastpath.c b/netinet/tcp_stacks/fastpath.c
--- a/netinet/tcp_stacks/fastpath.c
+++ b/netinet/tcp_stacks/fastpath.c
@@ -2453,4 +2453,4 @@
};
MODULE_VERSION(kern_tcpfastpaths, 1);
-DECLARE_MODULE(kern_tcpfastpaths, new_tcp_fastpaths, SI_SUB_PSEUDO, SI_ORDER_ANY);
+DECLARE_MODULE(kern_tcpfastpaths, new_tcp_fastpaths, SI_SUB_PROTO_DOMAIN, SI_ORDER_ANY);
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-transport
To unsubscribe, send any mail to "[email protected]"