git: f8798767219d - main - Fix IPv4 fib bsearch4() lookup array construction.
Alexander V. Chernikov
melifaro at FreeBSD.org
Sun Jan 17 20:32:36 UTC 2021
The branch main has been updated by melifaro:
URL: https://cgit.FreeBSD.org/src/commit/?id=f8798767219ddc5a6dc075b1d2c751ee910e4f10
commit f8798767219ddc5a6dc075b1d2c751ee910e4f10
Author: Alexander V. Chernikov <melifaro at FreeBSD.org>
AuthorDate: 2021-01-17 19:43:52 +0000
Commit: Alexander V. Chernikov <melifaro at FreeBSD.org>
CommitDate: 2021-01-17 20:32:26 +0000
Fix IPv4 fib bsearch4() lookup array construction.
Current code didn't properly handle the case with nested prefixes
like 10.0.0.0/24 && 10.0.0.0/25.
---
sys/netinet/in_fib_algo.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/sys/netinet/in_fib_algo.c b/sys/netinet/in_fib_algo.c
index 48e48da395fa..fd817a3fedf0 100644
--- a/sys/netinet/in_fib_algo.c
+++ b/sys/netinet/in_fib_algo.c
@@ -360,6 +360,18 @@ bsearch4_process_record(struct bsearch4_array *dst_array,
if (!add_array_entry(dst_array, &new_entry))
return (false);
}
+
+ /*
+ * Special case: adding more specific prefix at the start of
+ * the previous interval:
+ * 10.0.0.0(/24,nh=3), 10.0.0.0(/25,nh=4)
+ * Alter the last record, seeting new nexthop and mask.
+ */
+ if (br_tmp->addr4 == rib_entry->addr4) {
+ *br_tmp = *rib_entry;
+ add_array_entry(stack, rib_entry);
+ return (true);
+ }
}
if (!add_array_entry(dst_array, rib_entry))
More information about the dev-commits-src-all
mailing list