summaryrefslogtreecommitdiffstats
path: root/sys/kern/uipc_accf.c
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2005-03-12 12:57:18 +0000
committerrwatson <rwatson@FreeBSD.org>2005-03-12 12:57:18 +0000
commit20482cce4b243e3d1213d9b49edd0bae22d03c37 (patch)
tree96b20d6137424fc90e47ffae6421a1b82d8b4fce /sys/kern/uipc_accf.c
parent658ce1812571cfee3a3f4f0ab0edc7adb4d128a7 (diff)
downloadFreeBSD-src-20482cce4b243e3d1213d9b49edd0bae22d03c37.zip
FreeBSD-src-20482cce4b243e3d1213d9b49edd0bae22d03c37.tar.gz
Move the logic implementing retrieval of the SO_ACCEPTFILTER socket option
from uipc_socket.c to uipc_accf.c in do_getopt_accept_filter(), so that it now matches do_setopt_accept_filter(). Slightly reformulate the logic to match the optimistic allocation of storage for the argument in advance, and slightly expand the coverage of the socket lock.
Diffstat (limited to 'sys/kern/uipc_accf.c')
-rw-r--r--sys/kern/uipc_accf.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/sys/kern/uipc_accf.c b/sys/kern/uipc_accf.c
index 1a0a41c..8991120 100644
--- a/sys/kern/uipc_accf.c
+++ b/sys/kern/uipc_accf.c
@@ -163,6 +163,33 @@ accept_filt_generic_mod_event(module_t mod, int event, void *data)
}
int
+do_getopt_accept_filter(struct socket *so, struct sockopt *sopt)
+{
+ struct accept_filter_arg *afap;
+ int error;
+
+ error = 0;
+ MALLOC(afap, struct accept_filter_arg *, sizeof(*afap), M_TEMP,
+ M_WAITOK | M_ZERO);
+ SOCK_LOCK(so);
+ if ((so->so_options & SO_ACCEPTCONN) == 0) {
+ error = EINVAL;
+ goto out;
+ }
+ if ((so->so_options & SO_ACCEPTFILTER) == 0)
+ goto out;
+ strcpy(afap->af_name, so->so_accf->so_accept_filter->accf_name);
+ if (so->so_accf->so_accept_filter_str != NULL)
+ strcpy(afap->af_arg, so->so_accf->so_accept_filter_str);
+out:
+ SOCK_UNLOCK(so);
+ if (error == 0)
+ error = sooptcopyout(sopt, afap, sizeof(*afap));
+ FREE(afap, M_TEMP);
+ return (error);
+}
+
+int
do_setopt_accept_filter(struct socket *so, struct sockopt *sopt)
{
struct accept_filter_arg *afap;
OpenPOWER on IntegriCloud