Date: Thu, 23 May 2024 05:37:23 GMT From: Marko Zec <zec@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 78ae540decdc - releng/14.1 - fib_dxr: log malloc() failures. Message-ID: <202405230537.44N5bNlU047776@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch releng/14.1 has been updated by zec: URL: https://cgit.FreeBSD.org/src/commit/?id=78ae540decdc4e2a2e5d2f05b1c13bd34b68a278 commit 78ae540decdc4e2a2e5d2f05b1c13bd34b68a278 Author: Marko Zec <zec@FreeBSD.org> AuthorDate: 2024-05-06 18:21:55 +0000 Commit: Marko Zec <zec@FreeBSD.org> CommitDate: 2024-05-23 04:25:27 +0000 fib_dxr: log malloc() failures. MFC after: 1 week Approved by: re (cperciva) (cherry picked from commit e9927f4e6129271843985d994aab9edf7299aaa0) --- sys/netinet/in_fib_dxr.c | 45 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/sys/netinet/in_fib_dxr.c b/sys/netinet/in_fib_dxr.c index 94f066bdf982..c4815a64b260 100644 --- a/sys/netinet/in_fib_dxr.c +++ b/sys/netinet/in_fib_dxr.c @@ -1118,8 +1118,10 @@ dxr_init(uint32_t fibnum, struct fib_data *fd, void *old_data, void **data) struct dxr *dxr; dxr = malloc(sizeof(*dxr), M_DXRAUX, M_NOWAIT); - if (dxr == NULL) + if (dxr == NULL) { + FIB_PRINTF(LOG_NOTICE, fd, "Unable to allocate DXR struct"); return (FLM_REBUILD); + } /* Check whether we may reuse the old auxiliary structures */ if (old_dxr != NULL && old_dxr->aux != NULL) { @@ -1213,16 +1215,41 @@ dxr_dump_end(void *data, struct fib_dp *dp) dxr_build(dxr); da = dxr->aux; - if (da == NULL) + if (da == NULL) { + /* malloc(, M_DXRAUX, M_NOWAIT) failed, retry later */ + FIB_PRINTF(LOG_NOTICE, dxr->fd, + "Unable to allocate DXR aux struct"); return (FLM_REBUILD); + } - /* Structural limit exceeded, hard error */ - if (da->rtbl_top >= BASE_MAX) + if (da->range_tbl == NULL) { + /* malloc(, M_DXRAUX, M_NOWAIT) failed, retry later */ + FIB_PRINTF(LOG_NOTICE, dxr->fd, + "Unable to allocate DXR range table"); + return (FLM_REBUILD); + } + +#ifdef DXR2 + if (da->x_tbl == NULL) { + /* malloc(, M_DXRAUX, M_NOWAIT) failed, retry later */ + FIB_PRINTF(LOG_NOTICE, dxr->fd, + "Unable to allocate DXR extension table"); + return (FLM_REBUILD); + } +#endif + + if (da->rtbl_top >= BASE_MAX) { + /* Structural limit exceeded, hard error */ + FIB_PRINTF(LOG_ERR, dxr->fd, "DXR structural limit exceeded"); return (FLM_ERROR); + } - /* A malloc(,, M_NOWAIT) failed somewhere, retry later */ - if (dxr->d == NULL) + if (dxr->d == NULL) { + /* malloc(, M_DXRLPM, M_NOWAIT) failed, retry later */ + FIB_PRINTF(LOG_NOTICE, dxr->fd, + "Unable to allocate DXR lookup table"); return (FLM_REBUILD); + } dp->f = choose_lookup_fn(da); dp->arg = dxr; @@ -1311,13 +1338,17 @@ dxr_change_rib_batch(struct rib_head *rnh, struct fib_change_queue *q, /* Structural limit exceeded, hard error */ if (da->rtbl_top >= BASE_MAX) { + /* Structural limit exceeded, hard error */ dxr_destroy(new_dxr); + FIB_PRINTF(LOG_ERR, dxr->fd, "DXR structural limit exceeded"); return (FLM_ERROR); } - /* A malloc(,, M_NOWAIT) failed somewhere, retry later */ if (new_dxr->d == NULL) { + /* malloc(, M_DXRLPM, M_NOWAIT) failed, retry later */ dxr_destroy(new_dxr); + FIB_PRINTF(LOG_NOTICE, dxr->fd, + "Unable to allocate DXR lookup table"); return (FLM_REBUILD); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202405230537.44N5bNlU047776>