Accept filters broke kernels compiled without options INET.

Make accept filters conditional on INET support to fix.

Pointed out by: bde
Tested and assisted by: Stephen J. Kiernan <sab@vegamuse.org>
This commit is contained in:
Alfred Perlstein 2000-11-20 01:35:25 +00:00
parent 7f112b0489
commit 830fedd28f
2 changed files with 20 additions and 7 deletions

View File

@ -668,7 +668,7 @@ kern/tty_pty.c optional pty
kern/tty_snoop.c count snp
kern/tty_subr.c standard
kern/tty_tty.c standard
kern/uipc_accf.c standard
kern/uipc_accf.c optional inet
kern/uipc_domain.c standard
kern/uipc_mbuf.c standard
kern/uipc_mbuf2.c standard

View File

@ -34,6 +34,8 @@
* $FreeBSD$
*/
#include "opt_inet.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/fcntl.h>
@ -58,7 +60,9 @@
#include <machine/limits.h>
#ifdef INET
static int do_setopt_accept_filter(struct socket *so, struct sockopt *sopt);
#endif
static int filt_sorattach(struct knote *kn);
static void filt_sordetach(struct knote *kn);
@ -195,6 +199,7 @@ sodealloc(so)
if (so->so_snd.sb_hiwat)
(void)chgsbsize(so->so_cred->cr_uidinfo,
&so->so_snd.sb_hiwat, 0, RLIM_INFINITY);
#ifdef INET
if (so->so_accf != NULL) {
if (so->so_accf->so_accept_filter != NULL &&
so->so_accf->so_accept_filter->accf_destroy != NULL) {
@ -204,6 +209,7 @@ sodealloc(so)
FREE(so->so_accf->so_accept_filter_str, M_ACCF);
FREE(so->so_accf, M_ACCF);
}
#endif
crfree(so->so_cred);
zfreei(so->so_zone, so);
}
@ -988,6 +994,7 @@ sorflush(so)
sbrelease(&asb, so);
}
#ifdef INET
static int
do_setopt_accept_filter(so, sopt)
struct socket *so;
@ -1064,6 +1071,7 @@ out:
FREE(afap, M_TEMP);
return (error);
}
#endif /* INET */
/*
* Perhaps this routine, and sooptcopyout(), below, ought to come in
@ -1117,6 +1125,13 @@ sosetopt(so, sopt)
error = ENOPROTOOPT;
} else {
switch (sopt->sopt_name) {
#ifdef INET
case SO_ACCEPTFILTER:
error = do_setopt_accept_filter(so, sopt);
if (error)
goto bad;
break;
#endif
case SO_LINGER:
error = sooptcopyin(sopt, &l, sizeof l, sizeof l);
if (error)
@ -1224,12 +1239,6 @@ sosetopt(so, sopt)
break;
}
break;
case SO_ACCEPTFILTER:
error = do_setopt_accept_filter(so, sopt);
if (error)
goto bad;
break;
default:
error = ENOPROTOOPT;
break;
@ -1283,7 +1292,9 @@ sogetopt(so, sopt)
int error, optval;
struct linger l;
struct timeval tv;
#ifdef INET
struct accept_filter_arg *afap;
#endif
error = 0;
if (sopt->sopt_level != SOL_SOCKET) {
@ -1294,6 +1305,7 @@ sogetopt(so, sopt)
return (ENOPROTOOPT);
} else {
switch (sopt->sopt_name) {
#ifdef INET
case SO_ACCEPTFILTER:
if ((so->so_options & SO_ACCEPTCONN) == 0)
return (EINVAL);
@ -1308,6 +1320,7 @@ sogetopt(so, sopt)
error = sooptcopyout(sopt, afap, sizeof(*afap));
FREE(afap, M_TEMP);
break;
#endif
case SO_LINGER:
l.l_onoff = so->so_options & SO_LINGER;