With the planned removal of GIANT (sysctl uses GIANT), make future-proof
ipfilter by making it sysctl locking mpsafe. Reviewed by: kaktus Differential Revision: https://reviews.freebsd.org/D23839
This commit is contained in:
parent
acb8858f05
commit
a0df113ce2
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=358356
@ -84,23 +84,23 @@ static int ipfwrite __P((dev_t, struct uio *, int));
|
||||
SYSCTL_DECL(_net_inet);
|
||||
#define SYSCTL_IPF(parent, nbr, name, access, ptr, val, descr) \
|
||||
SYSCTL_OID(parent, nbr, name, \
|
||||
CTLTYPE_INT | CTLFLAG_VNET | CTLFLAG_NEEDGIANT | access, \
|
||||
CTLTYPE_INT | CTLFLAG_VNET | CTLFLAG_MPSAFE | access, \
|
||||
ptr, val, sysctl_ipf_int, "I", descr)
|
||||
#define SYSCTL_DYN_IPF_NAT(parent, nbr, name, access,ptr, val, descr) \
|
||||
SYSCTL_ADD_OID(&ipf_clist, SYSCTL_STATIC_CHILDREN(parent), nbr, name, \
|
||||
CTLFLAG_DYN | CTLTYPE_INT | CTLFLAG_VNET | CTLFLAG_NEEDGIANT |access, \
|
||||
CTLFLAG_DYN | CTLTYPE_INT | CTLFLAG_VNET | CTLFLAG_MPSAFE |access, \
|
||||
ptr, val, sysctl_ipf_int_nat, "I", descr)
|
||||
#define SYSCTL_DYN_IPF_STATE(parent, nbr, name, access,ptr, val, descr) \
|
||||
SYSCTL_ADD_OID(&ipf_clist, SYSCTL_STATIC_CHILDREN(parent), nbr, name, \
|
||||
CTLFLAG_DYN | CTLTYPE_INT | CTLFLAG_VNET | CTLFLAG_NEEDGIANT | access, \
|
||||
CTLFLAG_DYN | CTLTYPE_INT | CTLFLAG_VNET | CTLFLAG_MPSAFE | access, \
|
||||
ptr, val, sysctl_ipf_int_state, "I", descr)
|
||||
#define SYSCTL_DYN_IPF_FRAG(parent, nbr, name, access,ptr, val, descr) \
|
||||
SYSCTL_ADD_OID(&ipf_clist, SYSCTL_STATIC_CHILDREN(parent), nbr, name, \
|
||||
CTLFLAG_DYN | CTLTYPE_INT | CTLFLAG_VNET | CTLFLAG_NEEDGIANT | access, \
|
||||
CTLFLAG_DYN | CTLTYPE_INT | CTLFLAG_VNET | CTLFLAG_MPSAFE | access, \
|
||||
ptr, val, sysctl_ipf_int_frag, "I", descr)
|
||||
#define SYSCTL_DYN_IPF_AUTH(parent, nbr, name, access,ptr, val, descr) \
|
||||
SYSCTL_ADD_OID(&ipf_clist, SYSCTL_STATIC_CHILDREN(parent), nbr, name, \
|
||||
CTLFLAG_DYN | CTLTYPE_INT | CTLFLAG_VNET | CTLFLAG_NEEDGIANT | access, \
|
||||
CTLFLAG_DYN | CTLTYPE_INT | CTLFLAG_VNET | CTLFLAG_MPSAFE | access, \
|
||||
ptr, val, sysctl_ipf_int_auth, "I", descr)
|
||||
static struct sysctl_ctx_list ipf_clist;
|
||||
#define CTLFLAG_OFF 0x00800000 /* IPFilter must be disabled */
|
||||
@ -343,13 +343,14 @@ sysctl_ipf_int ( SYSCTL_HANDLER_ARGS )
|
||||
{
|
||||
int error = 0;
|
||||
|
||||
WRITE_ENTER(&V_ipfmain.ipf_mutex);
|
||||
if (arg1)
|
||||
error = SYSCTL_OUT(req, arg1, sizeof(int));
|
||||
else
|
||||
error = SYSCTL_OUT(req, &arg2, sizeof(int));
|
||||
|
||||
if (error || !req->newptr)
|
||||
return (error);
|
||||
goto sysctl_error;
|
||||
|
||||
if (!arg1)
|
||||
error = EPERM;
|
||||
@ -359,6 +360,9 @@ sysctl_ipf_int ( SYSCTL_HANDLER_ARGS )
|
||||
else
|
||||
error = SYSCTL_IN(req, arg1, sizeof(int));
|
||||
}
|
||||
|
||||
sysctl_error:
|
||||
RWLOCK_EXIT(&V_ipfmain.ipf_mutex);
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user