diff options
author | Robert Watson <rwatson@FreeBSD.org> | 2005-03-11 21:37:45 +0000 |
---|---|---|
committer | Robert Watson <rwatson@FreeBSD.org> | 2005-03-11 21:37:45 +0000 |
commit | 64c238075f5e84c9a790683b46a711bdc9409107 (patch) | |
tree | 466fdd5570689c10957f6470fa026f430c79cab9 /sys/kern/uipc_accf.c | |
parent | e7d0dbaeeaa80c2c4b97e7ccefea4cb5245c47b9 (diff) | |
download | src-64c238075f5e84c9a790683b46a711bdc9409107.tar.gz src-64c238075f5e84c9a790683b46a711bdc9409107.zip |
First step in simplifying accept filter socket option logic in the
post-SMPng world order. Centralize handling of the socket option
clear case in do_setopt_accept_filter().
Notes
Notes:
svn path=/head/; revision=143427
Diffstat (limited to 'sys/kern/uipc_accf.c')
-rw-r--r-- | sys/kern/uipc_accf.c | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/sys/kern/uipc_accf.c b/sys/kern/uipc_accf.c index 5557161f6d91..8c4e57192f5d 100644 --- a/sys/kern/uipc_accf.c +++ b/sys/kern/uipc_accf.c @@ -1,5 +1,6 @@ /*- * Copyright (c) 2000 Paycounter, Inc. + * Copyright (c) 2005 Robert N. M. Watson * Author: Alfred Perlstein <alfred@paycounter.com>, <alfred@FreeBSD.org> * All rights reserved. * @@ -169,33 +170,23 @@ do_setopt_accept_filter(struct socket *so, struct sockopt *sopt) struct so_accf *newaf; int error = 0; - newaf = NULL; - afap = NULL; - /* - * XXXRW: Configuring accept filters should be an atomic test-and-set - * operation to prevent races during setup and attach. There may be - * more general issues of racing and ordering here that are not yet - * addressed by locking. + * Handle the simple delete case first. */ - /* do not set/remove accept filters on non listen sockets */ - SOCK_LOCK(so); - if ((so->so_options & SO_ACCEPTCONN) == 0) { - SOCK_UNLOCK(so); - return (EINVAL); - } - - /* removing the filter */ if (sopt == NULL) { + SOCK_LOCK(so); + if ((so->so_options & SO_ACCEPTCONN) == 0) { + SOCK_UNLOCK(so); + return (EINVAL); + } if (so->so_accf != NULL) { struct so_accf *af = so->so_accf; if (af->so_accept_filter != NULL && af->so_accept_filter->accf_destroy != NULL) { af->so_accept_filter->accf_destroy(so); } - if (af->so_accept_filter_str != NULL) { + if (af->so_accept_filter_str != NULL) FREE(af->so_accept_filter_str, M_ACCF); - } FREE(af, M_ACCF); so->so_accf = NULL; } @@ -203,6 +194,22 @@ do_setopt_accept_filter(struct socket *so, struct sockopt *sopt) SOCK_UNLOCK(so); return (0); } + + newaf = NULL; + afap = NULL; + + /* + * XXXRW: Configuring accept filters should be an atomic test-and-set + * operation to prevent races during setup and attach. There may be + * more general issues of racing and ordering here that are not yet + * addressed by locking. + */ + /* do not set/remove accept filters on non listen sockets */ + SOCK_LOCK(so); + if ((so->so_options & SO_ACCEPTCONN) == 0) { + SOCK_UNLOCK(so); + return (EINVAL); + } SOCK_UNLOCK(so); /*- |