From 5646ad6d271638219964e2047132db340831c1eb Mon Sep 17 00:00:00 2001 From: "Christian S.J. Peron" Date: Sat, 14 Jan 2012 22:51:34 +0000 Subject: [PATCH] Revert to the old behavior of allocating table/table entries using M_NOWAIT. Currently, the code allows for sleeping in the ioctl path to guarantee allocation. However code also handles ENOMEM gracefully, so propagate this error back to user-space, rather than sleeping while holding the global pf mutex. Reviewed by: glebius Discussed with: bz --- sys/contrib/pf/net/pf_table.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/sys/contrib/pf/net/pf_table.c b/sys/contrib/pf/net/pf_table.c index d40c95fdece1..5e1f5f1d6a0e 100644 --- a/sys/contrib/pf/net/pf_table.c +++ b/sys/contrib/pf/net/pf_table.c @@ -927,16 +927,12 @@ pfr_create_kentry(struct pfr_addr *ad, int intr) { struct pfr_kentry *ke; +#ifdef __FreeBSD__ + ke = pool_get(&V_pfr_kentry_pl, PR_NOWAIT | PR_ZERO); +#else if (intr) -#ifdef __FreeBSD__ - ke = pool_get(&V_pfr_kentry_pl, PR_NOWAIT | PR_ZERO); -#else ke = pool_get(&pfr_kentry_pl, PR_NOWAIT | PR_ZERO); -#endif else -#ifdef __FreeBSD__ - ke = pool_get(&V_pfr_kentry_pl, PR_WAITOK|PR_ZERO); -#else ke = pool_get(&pfr_kentry_pl, PR_WAITOK|PR_ZERO|PR_LIMITFAIL); #endif if (ke == NULL) @@ -2081,16 +2077,12 @@ pfr_create_ktable(struct pfr_table *tbl, long tzero, int attachruleset, struct pfr_ktable *kt; struct pf_ruleset *rs; +#ifdef __FreeBSD__ + kt = pool_get(&V_pfr_ktable_pl, PR_NOWAIT|PR_ZERO); +#else if (intr) -#ifdef __FreeBSD__ - kt = pool_get(&V_pfr_ktable_pl, PR_NOWAIT|PR_ZERO); -#else kt = pool_get(&pfr_ktable_pl, PR_NOWAIT|PR_ZERO|PR_LIMITFAIL); -#endif else -#ifdef __FreeBSD__ - kt = pool_get(&V_pfr_ktable_pl, PR_WAITOK|PR_ZERO); -#else kt = pool_get(&pfr_ktable_pl, PR_WAITOK|PR_ZERO|PR_LIMITFAIL); #endif if (kt == NULL)