From nobody Tue May 07 15:12:49 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VYhbj23j4z5J1hW; Tue, 07 May 2024 15:12:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VYhbj1GMnz4JPv; Tue, 7 May 2024 15:12:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1715094769; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=LfD06IsD9WstvjDjlPbL2Tw8OCQTV8elW7rZ6EraNtI=; b=ByelabPx2lRkpbHsiLFSgGIRZuuQFQtB4Zi+drtcstcAWrCBtPTfRafe0RSwmhjvDQzjJc 4CH6kF7oHY6SGmFB2LeX/pLgQ50qjcHMW8//nV2fPzqbMrwE6uRF/vc6lfxpW4wAJtgZhn mUIBL8w41jr15StfYNbXoEE+Tc/xVb6FnI1ox9Znu6oEHeXwVCaN7B7t5y27iF/5xA1CON TRo/BlbFFfGfx05yGC16MWtLiJnNNp8FN4y8v1qBYKU+L0VS0Wd+gFI5iD0j8BXV/WgruT gISnYo0safjpvx9iRmD7JNFbtWJgUJ1OwLLZpY8PHucTu7VsnNs+YinkuYlSZQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1715094769; a=rsa-sha256; cv=none; b=ewtm9f4zCUmkiOBLYj02DXCRayMNOffcjtc3vv/V29ADi18Ix2UT9v1eFZVYaa5+IzDhLc 0+KOs18P/sd/21sE3Da/sUYgtIFTcFECrYbayHJHn3sMrkghzrDxrccVJDkf6dS3PtVrrj j7PzVeQ7xRx+CCFDeY+hwTrc2zmbL8ic5Rjox1QbWIats5gtbvY4dmziVdIXZqTRtK9hcr qAQzyoZhgglr3a9hbXmacD3sdj/2M7To6kH1JvaK8IwabQdMwqW4Pa12LwxploaMvnxbYu 4pU5TsZVcH1zjDQb5+76xP/Aa3hadpaGY8e1omgoGkiNqFPYc8E34CT+jIiS0Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1715094769; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=LfD06IsD9WstvjDjlPbL2Tw8OCQTV8elW7rZ6EraNtI=; b=luisd2FhgJBAYjcbVKLkYcwE6Gwaek7G30biMiUjAx3OdNaEKkhcAJuVE1Cwqgs4xVVl0w PKxSUcePetOvUAV4dnsNtWia+NTT2Z+fxE4axT4CRHfa6el1PCeaGdqhvyaZeam1j27XX/ eCr+1ICIlLligmXDcNS3psN97NUvAkT3fdHC+74toeeAqbv2MOsXwrrtz2eIpaPn5yvZS/ WPh9PKChRJ6WQHq6lkIR6LDEPmGEWM4hA4m9L8TkVp02RRiwijQKB+iWydqrOWkJcSOOfe aDASu3HEuYwUAoxZs+BG/zrFPDi3FSxDD5A8t5rNMDLG1vNJV1ibY5SzqZUN1g== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VYhbj0sxGzmkL; Tue, 7 May 2024 15:12:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 447FCnxD063717; Tue, 7 May 2024 15:12:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 447FCnCL063714; Tue, 7 May 2024 15:12:49 GMT (envelope-from git) Date: Tue, 7 May 2024 15:12:49 GMT Message-Id: <202405071512.447FCnCL063714@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Marko Zec Subject: git: ed541e201a05 - main - fib_dxr: move the bulko of malloc() failure logging into dxr_build() List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: zec X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ed541e201a05d1cea2f87e53289cbd7fd240b486 Auto-Submitted: auto-generated The branch main has been updated by zec: URL: https://cgit.FreeBSD.org/src/commit/?id=ed541e201a05d1cea2f87e53289cbd7fd240b486 commit ed541e201a05d1cea2f87e53289cbd7fd240b486 Author: Marko Zec AuthorDate: 2024-05-07 15:11:30 +0000 Commit: Marko Zec CommitDate: 2024-05-07 15:11:30 +0000 fib_dxr: move the bulko of malloc() failure logging into dxr_build() --- sys/netinet/in_fib_dxr.c | 77 +++++++++++++++++++----------------------------- 1 file changed, 30 insertions(+), 47 deletions(-) diff --git a/sys/netinet/in_fib_dxr.c b/sys/netinet/in_fib_dxr.c index 3015564953c6..3b2dc837d50b 100644 --- a/sys/netinet/in_fib_dxr.c +++ b/sys/netinet/in_fib_dxr.c @@ -497,8 +497,11 @@ chunk_ref(struct dxr_aux *da, uint32_t chunk) da->range_tbl = realloc(da->range_tbl, sizeof(*da->range_tbl) * da->rtbl_size + FRAGS_PREF_SHORT, M_DXRAUX, M_NOWAIT); - if (da->range_tbl == NULL) + if (da->range_tbl == NULL) { + FIB_PRINTF(LOG_NOTICE, da->fd, + "Unable to allocate DXR range table"); return (1); + } } return (0); @@ -632,8 +635,11 @@ trie_ref(struct dxr_aux *da, uint32_t index) da->xtbl_size += XTBL_SIZE_INCR; da->x_tbl = realloc(da->x_tbl, sizeof(*da->x_tbl) * da->xtbl_size, M_DXRAUX, M_NOWAIT); - if (da->x_tbl == NULL) + if (da->x_tbl == NULL) { + FIB_PRINTF(LOG_NOTICE, da->fd, + "Unable to allocate DXR extension table"); return (-1); + } } return(tp->td_index); } @@ -873,8 +879,11 @@ dxr_build(struct dxr *dxr) if (da == NULL) { da = malloc(sizeof(*dxr->aux), M_DXRAUX, M_NOWAIT); - if (da == NULL) + if (da == NULL) { + FIB_PRINTF(LOG_NOTICE, dxr->fd, + "Unable to allocate DXR aux struct"); return; + } dxr->aux = da; da->fibnum = dxr->fibnum; da->refcnt = 1; @@ -894,16 +903,22 @@ dxr_build(struct dxr *dxr) if (da->range_tbl == NULL) { da->range_tbl = malloc(sizeof(*da->range_tbl) * da->rtbl_size + FRAGS_PREF_SHORT, M_DXRAUX, M_NOWAIT); - if (da->range_tbl == NULL) + if (da->range_tbl == NULL) { + FIB_PRINTF(LOG_NOTICE, da->fd, + "Unable to allocate DXR range table"); return; + } range_rebuild = 1; } #ifdef DXR2 if (da->x_tbl == NULL) { da->x_tbl = malloc(sizeof(*da->x_tbl) * da->xtbl_size, M_DXRAUX, M_NOWAIT); - if (da->x_tbl == NULL) + if (da->x_tbl == NULL) { + FIB_PRINTF(LOG_NOTICE, da->fd, + "Unable to allocate DXR extension table"); return; + } trie_rebuild = 1; } #endif @@ -1039,8 +1054,11 @@ dxr2_try_squeeze: #endif dxr->d = malloc(dxr_tot_size, M_DXRLPM, M_NOWAIT); - if (dxr->d == NULL) + if (dxr->d == NULL) { + FIB_PRINTF(LOG_NOTICE, da->fd, + "Unable to allocate DXR lookup table"); return; + } #ifdef DXR2 memcpy(dxr->d, da->d_tbl, d_size); dxr->x = ((char *) dxr->d) + d_size; @@ -1119,7 +1137,8 @@ dxr_init(uint32_t fibnum, struct fib_data *fd, void *old_data, void **data) dxr = malloc(sizeof(*dxr), M_DXRAUX, M_NOWAIT); if (dxr == NULL) { - FIB_PRINTF(LOG_NOTICE, fd, "Unable to allocate DXR struct"); + FIB_PRINTF(LOG_NOTICE, fd, + "Unable to allocate DXR container struct"); return (FLM_REBUILD); } @@ -1212,41 +1231,11 @@ dxr_dump_end(void *data, struct fib_dp *dp) dxr_build(dxr); da = dxr->aux; - if (da == NULL) { - /* malloc(, M_DXRAUX, M_NOWAIT) failed, retry later */ - FIB_PRINTF(LOG_NOTICE, dxr->fd, - "Unable to allocate DXR aux struct"); + if (da == NULL || dxr->d == NULL) return (FLM_REBUILD); - } - 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"); + if (da->rtbl_top >= BASE_MAX) return (FLM_ERROR); - } - - 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; @@ -1334,18 +1323,11 @@ dxr_change_rib_batch(struct rib_head *rnh, struct fib_change_queue *q, dxr_build(new_dxr); /* 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"); + if (da->rtbl_top >= BASE_MAX) return (FLM_ERROR); - } 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); } @@ -1357,6 +1339,7 @@ dxr_change_rib_batch(struct rib_head *rnh, struct fib_change_queue *q, return (FLM_SUCCESS); } + FIB_PRINTF(LOG_NOTICE, dxr->fd, "fib_set_datapath_ptr() failed"); dxr_destroy(new_dxr); return (FLM_REBUILD); }