FreeBSD Bugzilla – Attachment 190574 Details for
Bug 209475
pf didn't check if enough free RAM for net.pf.states_hashsize
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
patch with mallocarray(9), printf(9) and a single fallback block
pf.c.diff (text/plain), 2.22 KB, created by
fehmi noyan isi
on 2018-02-13 11:54:04 UTC
(
hide
)
Description:
patch with mallocarray(9), printf(9) and a single fallback block
Filename:
MIME Type:
Creator:
fehmi noyan isi
Created:
2018-02-13 11:54:04 UTC
Size:
2.22 KB
patch
obsolete
>--- pf.c.original 2018-01-26 09:47:11.833994000 +1300 >+++ pf.c.fni 2018-02-14 13:42:45.055597000 +1300 >@@ -804,10 +804,21 @@ > V_pf_state_key_z = uma_zcreate("pf state keys", > sizeof(struct pf_state_key), pf_state_key_ctor, NULL, NULL, NULL, > UMA_ALIGN_PTR, 0); >- V_pf_keyhash = malloc(pf_hashsize * sizeof(struct pf_keyhash), >- M_PFHASH, M_WAITOK | M_ZERO); >- V_pf_idhash = malloc(pf_hashsize * sizeof(struct pf_idhash), >- M_PFHASH, M_WAITOK | M_ZERO); >+ >+ V_pf_keyhash = mallocarray(pf_hashsize, sizeof(struct pf_keyhash), >+ M_PFHASH, M_NOWAIT | M_ZERO); >+ V_pf_idhash = mallocarray(pf_hashsize, sizeof(struct pf_idhash), >+ M_PFHASH, M_NOWAIT | M_ZERO); >+ if (V_pf_keyhash == NULL || V_pf_idhash == NULL) { >+ printf("pf_initialize : Not enough memory for %lu bytes.\n", >+ pf_hashsize * sizeof(struct pf_keyhash)); >+ pf_hashsize = PF_HASHSIZ; >+ V_pf_keyhash = mallocarray(pf_hashsize, sizeof(struct pf_keyhash), >+ M_PFHASH, M_WAITOK | M_ZERO); >+ V_pf_idhash = mallocarray(pf_hashsize, sizeof(struct pf_idhash), >+ M_PFHASH, M_WAITOK | M_ZERO); >+ } >+ > pf_hashmask = pf_hashsize - 1; > for (i = 0, kh = V_pf_keyhash, ih = V_pf_idhash; i <= pf_hashmask; > i++, kh++, ih++) { >@@ -822,9 +833,15 @@ > V_pf_limits[PF_LIMIT_SRC_NODES].zone = V_pf_sources_z; > uma_zone_set_max(V_pf_sources_z, PFSNODE_HIWAT); > uma_zone_set_warning(V_pf_sources_z, "PF source nodes limit reached"); >- V_pf_srchash = malloc(pf_srchashsize * sizeof(struct pf_srchash), >- M_PFHASH, M_WAITOK|M_ZERO); >- pf_srchashmask = pf_srchashsize - 1; >+ if ((V_pf_srchash = mallocarray(pf_srchashsize, >+ sizeof(struct pf_srchash), M_PFHASH, M_NOWAIT | M_ZERO)) == NULL){ >+ printf("pf_initialize: Not enough memory for %lu bytes.\n", >+ pf_srchashsize * sizeof(struct pf_srchash)); >+ pf_srchashsize = (PF_HASHSIZ / 4); >+ V_pf_srchash = mallocarray(pf_srchashsize, >+ sizeof(struct pf_srchash), M_PFHASH, M_WAITOK | M_ZERO); >+ } >+ pf_srchashmask = pf_srchashsize - 1; > for (i = 0, sh = V_pf_srchash; i <= pf_srchashmask; i++, sh++) > mtx_init(&sh->lock, "pf_srchash", NULL, MTX_DEF); >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 209475
:
170810
|
176410
|
190429
|
190476
| 190574