Skip to content

Commit

Permalink
[fib algo][dxr] Fix division by zero.
Browse files Browse the repository at this point in the history
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

(cherry picked from commit eb3148c)
  • Loading branch information
gornjas committed Sep 18, 2021
1 parent ad2cca4 commit ec47ee7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sys/netinet/in_fib_dxr.c
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,9 @@ dxr_build(struct dxr *dxr)
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);
Expand Down

0 comments on commit ec47ee7

Please sign in to comment.