From 4d7d13867dca6dcd179a71abf9f71720dcae1541 Mon Sep 17 00:00:00 2001 From: chenjiasheng Date: Fri, 25 Nov 2022 17:10:18 +0800 Subject: [PATCH] routing: fix support for default gateway see: https://github.com/OpenFastPath/ofp/pull/272 --- src/ofp_rt_mtrie_lookup.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ofp_rt_mtrie_lookup.c b/src/ofp_rt_mtrie_lookup.c index fec270b0..e51d03fe 100644 --- a/src/ofp_rt_mtrie_lookup.c +++ b/src/ofp_rt_mtrie_lookup.c @@ -587,11 +587,15 @@ ofp_rtl_remove(struct ofp_rtl_tree *tree, uint32_t addr_be, uint32_t masklen) struct ofp_nh_entry *ofp_rtl_search(struct ofp_rtl_tree *tree, uint32_t addr_be) { - struct ofp_nh_entry *nh = NULL; struct ofp_rtl_node *elem, *node = tree->root; + struct ofp_nh_entry *nh = &node->data[0]; uint32_t addr = odp_be_to_cpu_32(addr_be); uint32_t low = 0, high = IPV4_FIRST_LEVEL; + if (!(nh->flags & OFP_RTL_FLAGS_GATEWAY)) { + nh = NULL; + } + for (; high <= IPV4_LENGTH ; low = high, high += IPV4_LEVEL) { elem = find_node(node, addr, low, high);