svn commit: r237363 - projects/pf/head/sys/contrib/pf/net
Gleb Smirnoff
glebius at FreeBSD.org
Thu Jun 21 09:08:12 UTC 2012
Author: glebius
Date: Thu Jun 21 09:08:11 2012
New Revision: 237363
URL: http://svn.freebsd.org/changeset/base/237363
Log:
Fix couple off-by-ones when traversing source nodes hash.
Modified:
projects/pf/head/sys/contrib/pf/net/pf.c
projects/pf/head/sys/contrib/pf/net/pf_ioctl.c
projects/pf/head/sys/contrib/pf/net/pfvar.h
Modified: projects/pf/head/sys/contrib/pf/net/pf.c
==============================================================================
--- projects/pf/head/sys/contrib/pf/net/pf.c Thu Jun 21 08:55:07 2012 (r237362)
+++ projects/pf/head/sys/contrib/pf/net/pf.c Thu Jun 21 09:08:11 2012 (r237363)
@@ -744,7 +744,7 @@ pf_initialize()
V_pf_srchash = malloc((PF_HASHSIZ / 4) * sizeof(struct pf_srchash),
M_PFHASH, M_WAITOK|M_ZERO);
V_pf_srchashmask = (PF_HASHSIZ / 4) - 1;
- for (i = 0, sh = V_pf_srchash; i < V_pf_srchashmask; i++, sh++)
+ for (i = 0, sh = V_pf_srchash; i <= V_pf_srchashmask; i++, sh++)
mtx_init(&sh->lock, "pf_srchash", NULL, MTX_DEF);
/* ALTQ */
@@ -1397,7 +1397,7 @@ pf_purge_expired_src_nodes()
struct pf_src_node *cur, *next;
int i;
- for (i = 0, sh = V_pf_srchash; i < V_pf_srchashmask; i++, sh++) {
+ for (i = 0, sh = V_pf_srchash; i <= V_pf_srchashmask; i++, sh++) {
PF_HASHROW_LOCK(sh);
LIST_FOREACH_SAFE(cur, &sh->nodes, entry, next)
if (cur->states <= 0 && cur->expire <= time_uptime) {
Modified: projects/pf/head/sys/contrib/pf/net/pf_ioctl.c
==============================================================================
--- projects/pf/head/sys/contrib/pf/net/pf_ioctl.c Thu Jun 21 08:55:07 2012 (r237362)
+++ projects/pf/head/sys/contrib/pf/net/pf_ioctl.c Thu Jun 21 09:08:11 2012 (r237363)
@@ -136,8 +136,6 @@ static int pf_addr_setup(struct pf_rul
static void pf_addr_copyout(struct pf_addr_wrap *);
VNET_DEFINE(struct pf_rule, pf_default_rule);
-VNET_DEFINE(struct sx, pf_consistency_lock);
-#define V_pf_consistency_lock VNET(pf_consistency_lock)
#ifdef ALTQ
static VNET_DEFINE(int, pf_altq_running);
@@ -227,22 +225,6 @@ export_pflow_t *export_pflow_ptr = NUL
/* pflog */
pflog_packet_t *pflog_packet_ptr = NULL;
-static void
-init_pf_mutex(void)
-{
-
- rw_init(&pf_rules_lock, "pf rulesets");
- sx_init(&V_pf_consistency_lock, "pfioctl");
-}
-
-static void
-destroy_pf_mutex(void)
-{
-
- rw_destroy(&pf_rules_lock);
- sx_destroy(&V_pf_consistency_lock);
-}
-
static int
pfattach(void)
{
@@ -1110,8 +1092,6 @@ pfioctl(struct cdev *dev, u_long cmd, ca
return (EACCES);
}
- sx_xlock(&V_pf_consistency_lock);
-
switch (cmd) {
case DIOCSTART:
PF_RULES_WLOCK();
@@ -3288,7 +3268,6 @@ DIOCCHANGEADDR_error:
break;
}
fail:
- sx_xunlock(&V_pf_consistency_lock);
CURVNET_RESTORE();
return (error);
@@ -3744,7 +3723,8 @@ pf_load(void)
}
VNET_LIST_RUNLOCK();
- init_pf_mutex();
+ rw_init(&pf_rules_lock, "pf rulesets");
+
pf_dev = make_dev(&pf_cdevsw, 0, 0, 0, 0600, PF_NAME);
if ((error = pfattach()) != 0)
return (error);
@@ -3785,7 +3765,7 @@ pf_unload(void)
pf_cleanup();
PF_RULES_WUNLOCK();
destroy_dev(pf_dev);
- destroy_pf_mutex();
+ rw_destroy(&pf_rules_lock);
return (error);
}
Modified: projects/pf/head/sys/contrib/pf/net/pfvar.h
==============================================================================
--- projects/pf/head/sys/contrib/pf/net/pfvar.h Thu Jun 21 08:55:07 2012 (r237362)
+++ projects/pf/head/sys/contrib/pf/net/pfvar.h Thu Jun 21 09:08:11 2012 (r237363)
@@ -39,7 +39,6 @@
#include <sys/queue.h>
#include <sys/tree.h>
#include <sys/lock.h>
-#include <sys/sx.h>
#include <net/radix.h>
#include <net/route.h>
More information about the svn-src-projects
mailing list