diff options
| -rw-r--r-- | usr.sbin/eigrpd/rde_dual.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/usr.sbin/eigrpd/rde_dual.c b/usr.sbin/eigrpd/rde_dual.c index 3134e9558a9..b1df17ecaf9 100644 --- a/usr.sbin/eigrpd/rde_dual.c +++ b/usr.sbin/eigrpd/rde_dual.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_dual.c,v 1.8 2015/10/25 00:39:14 renato Exp $ */ +/* $OpenBSD: rde_dual.c,v 1.9 2015/10/25 00:42:02 renato Exp $ */ /* * Copyright (c) 2015 Renato Westphal <renato@openbsd.org> @@ -328,13 +328,18 @@ eigrp_real_delay(uint32_t delay) uint32_t eigrp_composite_bandwidth(uint32_t bandwidth) { - return ((EIGRP_SCALING_FACTOR * (uint32_t)10000000) / bandwidth); + /* truncate before applying the scaling factor */ + bandwidth = 10000000 / bandwidth; + return (EIGRP_SCALING_FACTOR * bandwidth); } -/* the formula is the same but let's focus on keeping the code readable */ uint32_t eigrp_real_bandwidth(uint32_t bandwidth) { + /* + * apply the scaling factor before the division and only then truncate. + * this is to keep consistent with what cisco does. + */ return ((EIGRP_SCALING_FACTOR * (uint32_t)10000000) / bandwidth); } |
