summaryrefslogtreecommitdiffstats
path: root/sys/kern/uipc_accf.c
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2005-03-11 21:37:45 +0000
committerrwatson <rwatson@FreeBSD.org>2005-03-11 21:37:45 +0000
commit41a0201b3a06a7e41714b3d02bfd52f16c509c24 (patch)
tree466fdd5570689c10957f6470fa026f430c79cab9 /sys/kern/uipc_accf.c
parentb5906f493a3107ac67325ac6765fed03ad110f28 (diff)
downloadFreeBSD-src-41a0201b3a06a7e41714b3d02bfd52f16c509c24.zip
FreeBSD-src-41a0201b3a06a7e41714b3d02bfd52f16c509c24.tar.gz
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().
Diffstat (limited to 'sys/kern/uipc_accf.c')
-rw-r--r--sys/kern/uipc_accf.c41
1 files changed, 24 insertions, 17 deletions
diff --git a/sys/kern/uipc_accf.c b/sys/kern/uipc_accf.c
index 5557161..8c4e571 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);
/*-
OpenPOWER on IntegriCloud