Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F146158204
D19152.id53813.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D19152.id53813.diff
View Options
Index: sys/netinet/tcp_subr.c
===================================================================
--- sys/netinet/tcp_subr.c
+++ sys/netinet/tcp_subr.c
@@ -262,21 +262,10 @@
.tfb_tcp_fb_fini = tcp_default_fb_fini,
};
-int t_functions_inited = 0;
static int tcp_fb_cnt = 0;
struct tcp_funchead t_functions;
static struct tcp_function_block *tcp_func_set_ptr = &tcp_def_funcblk;
-static void
-init_tcp_functions(void)
-{
- 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)
{
@@ -564,13 +553,10 @@
bzero(&tfi, sizeof(tfi));
tfi.tfi_refcnt = f->tf_fb->tfb_refcnt;
tfi.tfi_id = f->tf_fb->tfb_id;
- (void)strncpy(tfi.tfi_alias, f->tf_name,
- TCP_FUNCTION_NAME_LEN_MAX);
- tfi.tfi_alias[TCP_FUNCTION_NAME_LEN_MAX - 1] = '\0';
- (void)strncpy(tfi.tfi_name,
- f->tf_fb->tfb_tcp_block_name,
- TCP_FUNCTION_NAME_LEN_MAX);
- tfi.tfi_name[TCP_FUNCTION_NAME_LEN_MAX - 1] = '\0';
+ (void)strlcpy(tfi.tfi_alias, f->tf_name,
+ sizeof(tfi.tfi_alias));
+ (void)strlcpy(tfi.tfi_name,
+ f->tf_fb->tfb_tcp_block_name, sizeof(tfi.tfi_name));
error = SYSCTL_OUT(req, &tfi, sizeof(tfi));
/*
* Don't stop on error, as that is the
@@ -786,10 +772,9 @@
KASSERT(names != NULL && *num_names > 0,
("%s: Called with 0-length name list", __func__));
KASSERT(names != NULL, ("%s: Called with NULL name list", __func__));
+ KASSERT(rw_initialized(&tcp_function_lock),
+ ("%s: called too early", __func__));
- 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) ||
@@ -833,9 +818,8 @@
}
n->tf_fb = blk;
- (void)strncpy(fs.function_set_name, names[i],
- TCP_FUNCTION_NAME_LEN_MAX);
- fs.function_set_name[TCP_FUNCTION_NAME_LEN_MAX - 1] = '\0';
+ (void)strlcpy(fs.function_set_name, names[i],
+ sizeof(fs.function_set_name));
rw_wlock(&tcp_function_lock);
if (find_tcp_functions_locked(&fs) != NULL) {
/* Duplicate name space not allowed */
@@ -844,8 +828,7 @@
error = EALREADY;
goto cleanup;
}
- (void)strncpy(n->tf_name, names[i], TCP_FUNCTION_NAME_LEN_MAX);
- n->tf_name[TCP_FUNCTION_NAME_LEN_MAX - 1] = '\0';
+ (void)strlcpy(n->tf_name, names[i], sizeof(n->tf_name));
TAILQ_INSERT_TAIL(&t_functions, n, tf_next);
tcp_fb_cnt++;
rw_wunlock(&tcp_function_lock);
@@ -932,8 +915,8 @@
bool force)
{
struct tcp_function *f;
-
- if (strcmp(blk->tfb_tcp_block_name, "default") == 0) {
+
+ if (blk == &tcp_def_funcblk) {
/* You can't un-register the default */
return (EPERM);
}
@@ -1099,8 +1082,10 @@
tcp_rexmit_slop = TCPTV_CPU_VAR;
tcp_finwait2_timeout = TCPTV_FINWAIT2_TIMEOUT;
tcp_tcbhashsize = hashsize;
+
/* Setup the tcp function block list */
- init_tcp_functions();
+ TAILQ_INIT(&t_functions);
+ rw_init(&tcp_function_lock, "tcp_func_lock");
register_tcp_functions(&tcp_def_funcblk, M_WAITOK);
#ifdef TCP_BLACKBOX
/* Initialize the TCP logging data. */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Mar 1, 7:55 AM (34 m, 41 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29104760
Default Alt Text
D19152.id53813.diff (3 KB)
Attached To
Mode
D19152: Various cleanups to the management of multiple TCP stacks.
Attached
Detach File
Event Timeline
Log In to Comment