git: eb3148cc4d25 - main - [fib algo][dxr] Fix division by zero.

Marko Zec zec at FreeBSD.org
Thu Sep 16 14:43:55 UTC 2021


The branch main has been updated by zec:

URL: https://cgit.FreeBSD.org/src/commit/?id=eb3148cc4d256c20b5c7c9052539139b6f57f58b

commit eb3148cc4d256c20b5c7c9052539139b6f57f58b
Author:     Marko Zec <zec at FreeBSD.org>
AuthorDate: 2021-09-16 14:34:05 +0000
Commit:     Marko Zec <zec at FreeBSD.org>
CommitDate: 2021-09-16 14:34:05 +0000

    [fib algo][dxr] Fix division by zero.
    
    A division by zero would occur if DXR would be activated on a vnet
    with no IP addresses configured on any interfaces.
    
    PR:             257965
    MFC after:      3 days
    Reported by:    Raul Munoz
---
 sys/netinet/in_fib_dxr.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sys/netinet/in_fib_dxr.c b/sys/netinet/in_fib_dxr.c
index 3c4e5700cd6c..3aa357cadedc 100644
--- a/sys/netinet/in_fib_dxr.c
+++ b/sys/netinet/in_fib_dxr.c
@@ -982,7 +982,9 @@ dxr2_try_squeeze:
 	FIB_PRINTF(LOG_INFO, da->fd, "D%dR, %d prefixes, %d nhops (max)",
 	    DXR_D, rinfo.num_prefixes, rinfo.num_nhops);
 #endif
-	i = dxr_tot_size * 100 / rinfo.num_prefixes;
+	i = dxr_tot_size * 100;
+	if (rinfo.num_prefixes)
+		i /= rinfo.num_prefixes;
 	FIB_PRINTF(LOG_INFO, da->fd, "%d.%02d KBytes, %d.%02d Bytes/prefix",
 	    dxr_tot_size / 1024, dxr_tot_size * 100 / 1024 % 100,
 	    i / 100, i % 100);


More information about the dev-commits-src-all mailing list