Author: rrs
Date: Tue Feb 23 17:53:39 2016
New Revision: 295927
URL: https://svnweb.freebsd.org/changeset/base/295927

Log:
  This fixes the fastpath code to have a better module initialization sequence 
when
  included in loader.conf. It also fixes it so that no matter if some one 
incorrectly
  specifies a load order, the lists and such will be initialized on demand at 
that
  time so no one can make that mistake.
  
  Reviewed by:  hiren
  Differential Revision:        D5189

Modified:
  head/sys/netinet/tcp_stacks/fastpath.c
  head/sys/netinet/tcp_subr.c

Modified: head/sys/netinet/tcp_stacks/fastpath.c
==============================================================================
--- head/sys/netinet/tcp_stacks/fastpath.c      Tue Feb 23 16:01:34 2016        
(r295926)
+++ head/sys/netinet/tcp_stacks/fastpath.c      Tue Feb 23 17:53:39 2016        
(r295927)
@@ -2453,4 +2453,4 @@ static moduledata_t new_tcp_fastpaths = 
 };
 
 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);

Modified: head/sys/netinet/tcp_subr.c
==============================================================================
--- head/sys/netinet/tcp_subr.c Tue Feb 23 16:01:34 2016        (r295926)
+++ head/sys/netinet/tcp_subr.c Tue Feb 23 17:53:39 2016        (r295927)
@@ -263,9 +263,20 @@ static struct tcp_function_block tcp_def
        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 @@ register_tcp_functions(struct tcp_functi
        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_init(void)
        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) {
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to