From owner-svn-src-projects@FreeBSD.ORG Thu Jun 21 09:08:12 2012 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 34F131065673; Thu, 21 Jun 2012 09:08:12 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 20CAE8FC1F; Thu, 21 Jun 2012 09:08:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5L98BqV000885; Thu, 21 Jun 2012 09:08:11 GMT (envelope-from glebius@svn.freebsd.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5L98BG5000881; Thu, 21 Jun 2012 09:08:11 GMT (envelope-from glebius@svn.freebsd.org) Message-Id: <201206210908.q5L98BG5000881@svn.freebsd.org> From: Gleb Smirnoff Date: Thu, 21 Jun 2012 09:08:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237363 - projects/pf/head/sys/contrib/pf/net X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jun 2012 09:08:12 -0000 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 #include #include -#include #include #include