diff --git a/sys/contrib/dpdk_rte_lpm/dpdk_lpm6.c b/sys/contrib/dpdk_rte_lpm/dpdk_lpm6.c index 250e3e1bde4a..17d35c16346d 100644 --- a/sys/contrib/dpdk_rte_lpm/dpdk_lpm6.c +++ b/sys/contrib/dpdk_rte_lpm/dpdk_lpm6.c @@ -1,487 +1,487 @@ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * * Copyright (c) 2020 Alexander V. Chernikov * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); #include "opt_inet6.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define RTDEBUG #include "rte_lpm6.h" #define LPM6_MIN_TBL8 8 /* 2 pages of memory */ #define LPM6_MAX_TBL8 65536 * 16 /* 256M */ struct fib_algo_calldata { void *lookup; void *arg; }; struct dpdk_lpm6_data { struct rte_lpm6 *lpm6; uint64_t routes_added; uint64_t routes_failed; uint32_t number_tbl8s; uint32_t fibnum; uint8_t hit_tables; struct fib_data *fd; }; static struct nhop_object * lookup_ptr_ll(const struct rte_lpm6 *lpm6, const struct in6_addr *dst6, uint32_t scopeid) { const struct rte_lpm6_external *rte_ext; rte_ext = (const struct rte_lpm6_external *)lpm6; return (fib6_radix_lookup_nh(rte_ext->fibnum, dst6, scopeid)); } /* * Main datapath routing */ static struct nhop_object * lookup_ptr(void *algo_data, const struct flm_lookup_key key, uint32_t scopeid) { const struct rte_lpm6 *lpm6; const struct rte_lpm6_external *rte_ext; const struct in6_addr *addr6; uint32_t nhidx = 0; int ret; lpm6 = (const struct rte_lpm6 *)algo_data; addr6 = key.addr6; rte_ext = (const struct rte_lpm6_external *)lpm6; if (!IN6_IS_SCOPE_LINKLOCAL(addr6)) { ret = rte_lpm6_lookup(lpm6, (const uint8_t *)addr6, &nhidx); if (ret == 0) { /* Success! */ return (rte_ext->nh_idx[nhidx]); } else { /* Not found. Check default route */ if (rte_ext->default_idx > 0) return (rte_ext->nh_idx[rte_ext->default_idx]); else return (NULL); } } else { /* LL */ return (lookup_ptr_ll(lpm6, addr6, scopeid)); } } static uint8_t rte6_get_pref(const struct rib_rtable_info *rinfo) { if (rinfo->num_prefixes < 10) return (1); else if (rinfo->num_prefixes < 1000) return (rinfo->num_prefixes / 10); - else if (rinfo->num_prefixes < 500000) - return (100 + rinfo->num_prefixes / 3334); + else if (rinfo->num_prefixes < 100000) + return (100 + rinfo->num_prefixes / 667); else return (250); } static enum flm_op_result handle_default_change(struct dpdk_lpm6_data *dd, struct rib_cmd_info *rc) { struct rte_lpm6_external *rte_ext; rte_ext = (struct rte_lpm6_external *)dd->lpm6; if (rc->rc_cmd != RTM_DELETE) { /* Reference new */ uint32_t nhidx = fib_get_nhop_idx(dd->fd, rc->rc_nh_new); if (nhidx == 0) return (FLM_REBUILD); rte_ext->default_idx = nhidx; } else { /* No default route */ rte_ext->default_idx = 0; } return (FLM_SUCCESS); } static enum flm_op_result handle_ll_change(struct dpdk_lpm6_data *dd, struct rib_cmd_info *rc, const struct in6_addr addr6, int plen, uint32_t scopeid) { return (FLM_SUCCESS); } static struct rte_lpm6_rule * pack_parent_rule(struct dpdk_lpm6_data *dd, const struct in6_addr *addr6, char *buffer) { struct rte_lpm6_rule *lsp_rule = NULL; struct route_nhop_data rnd; struct rtentry *rt; int plen; rt = fib6_lookup_rt(dd->fibnum, addr6, 0, NHR_UNLOCKED, &rnd); /* plen = 0 means default route and it's out of scope */ if (rt != NULL) { uint32_t scopeid; struct in6_addr new_addr6; rt_get_inet6_prefix_plen(rt, &new_addr6, &plen, &scopeid); if (plen > 0) { uint32_t nhidx = fib_get_nhop_idx(dd->fd, rnd.rnd_nhop); if (nhidx == 0) { /* * shouldn't happen as we already have parent route. * It will trigger rebuild automatically. */ return (NULL); } lsp_rule = fill_rule6(buffer, (uint8_t *)&new_addr6, plen, nhidx); } } return (lsp_rule); } static enum flm_op_result handle_gu_change(struct dpdk_lpm6_data *dd, const struct rib_cmd_info *rc, const struct in6_addr *addr6, int plen) { int ret; char abuf[INET6_ADDRSTRLEN]; inet_ntop(AF_INET6, addr6, abuf, sizeof(abuf)); /* So we get sin6, plen and nhidx */ if (rc->rc_cmd != RTM_DELETE) { /* * Addition or change. Save nhop in the internal table * and get index. */ uint32_t nhidx = fib_get_nhop_idx(dd->fd, rc->rc_nh_new); if (nhidx == 0) { FIB_PRINTF(LOG_INFO, dd->fd, "nhop limit reached, need rebuild"); return (FLM_REBUILD); } ret = rte_lpm6_add(dd->lpm6, (const uint8_t *)addr6, plen, nhidx, (rc->rc_cmd == RTM_ADD) ? 1 : 0); FIB_PRINTF(LOG_DEBUG, dd->fd, "DPDK GU: %s %s/%d nhop %u = %d", (rc->rc_cmd == RTM_ADD) ? "ADD" : "UPDATE", abuf, plen, nhidx, ret); } else { /* * Need to lookup parent. Assume deletion happened already */ char buffer[RTE_LPM6_RULE_SIZE]; struct rte_lpm6_rule *lsp_rule = NULL; lsp_rule = pack_parent_rule(dd, addr6, buffer); ret = rte_lpm6_delete(dd->lpm6, (const uint8_t *)addr6, plen, lsp_rule); FIB_PRINTF(LOG_DEBUG, dd->fd, "DPDK GU: %s %s/%d nhop ? = %d", "DEL", abuf, plen, ret); } if (ret != 0) { FIB_PRINTF(LOG_INFO, dd->fd, "error: %d", ret); if (ret == -ENOSPC) return (FLM_REBUILD); return (FLM_ERROR); } return (FLM_SUCCESS); } static enum flm_op_result handle_any_change(struct dpdk_lpm6_data *dd, struct rib_cmd_info *rc) { enum flm_op_result ret; struct in6_addr addr6; uint32_t scopeid; int plen; rt_get_inet6_prefix_plen(rc->rc_rt, &addr6, &plen, &scopeid); if (IN6_IS_SCOPE_LINKLOCAL(&addr6)) ret = handle_ll_change(dd, rc, addr6, plen, scopeid); else if (plen == 0) ret = handle_default_change(dd, rc); else ret = handle_gu_change(dd, rc, &addr6, plen); if (ret != 0) FIB_PRINTF(LOG_INFO, dd->fd, "error handling route"); return (ret); } static enum flm_op_result handle_rtable_change_cb(struct rib_head *rnh, struct rib_cmd_info *rc, void *_data) { struct dpdk_lpm6_data *dd; dd = (struct dpdk_lpm6_data *)_data; return (handle_any_change(dd, rc)); } static void destroy_dd(struct dpdk_lpm6_data *dd) { FIB_PRINTF(LOG_INFO, dd->fd, "destroy dd %p", dd); if (dd->lpm6 != NULL) rte_lpm6_free(dd->lpm6); free(dd, M_TEMP); } static void destroy_table(void *_data) { destroy_dd((struct dpdk_lpm6_data *)_data); } static enum flm_op_result add_route_cb(struct rtentry *rt, void *_data) { struct dpdk_lpm6_data *dd = (struct dpdk_lpm6_data *)_data; struct in6_addr addr6; struct nhop_object *nh; uint32_t scopeid; int plen; int ret; rt_get_inet6_prefix_plen(rt, &addr6, &plen, &scopeid); nh = rt_get_raw_nhop(rt); if (IN6_IS_SCOPE_LINKLOCAL(&addr6)) { /* * We don't operate on LL directly, however * reference them to maintain guarantee on * ability to refcount nhops in epoch. */ fib_get_nhop_idx(dd->fd, nh); return (FLM_SUCCESS); } char abuf[INET6_ADDRSTRLEN]; inet_ntop(AF_INET6, &addr6, abuf, sizeof(abuf)); FIB_PRINTF(LOG_DEBUG, dd->fd, "Operating on %s/%d", abuf, plen); if (plen == 0) { struct rib_cmd_info rc = { .rc_cmd = RTM_ADD, .rc_nh_new = nh, }; FIB_PRINTF(LOG_DEBUG, dd->fd, "Adding default route"); return (handle_default_change(dd, &rc)); } uint32_t nhidx = fib_get_nhop_idx(dd->fd, nh); if (nhidx == 0) { FIB_PRINTF(LOG_INFO, dd->fd, "unable to get nhop index"); return (FLM_REBUILD); } ret = rte_lpm6_add(dd->lpm6, (const uint8_t *)&addr6, plen, nhidx, 1); FIB_PRINTF(LOG_DEBUG, dd->fd, "ADD %p %s/%d nh %u = %d", dd->lpm6, abuf, plen, nhidx, ret); if (ret != 0) { FIB_PRINTF(LOG_INFO, dd->fd, "rte_lpm6_add() returned %d", ret); if (ret == -ENOSPC) { dd->hit_tables = 1; return (FLM_REBUILD); } dd->routes_failed++; return (FLM_ERROR); } else dd->routes_added++; return (FLM_SUCCESS); } static enum flm_op_result check_dump_success(void *_data, struct fib_dp *dp) { struct dpdk_lpm6_data *dd; dd = (struct dpdk_lpm6_data *)_data; FIB_PRINTF(LOG_INFO, dd->fd, "scan completed. added: %zu failed: %zu", dd->routes_added, dd->routes_failed); if (dd->hit_tables || dd->routes_failed > 0) return (FLM_REBUILD); FIB_PRINTF(LOG_INFO, dd->fd, "DPDK lookup engine synced with IPv6 RIB id %u, %zu routes", dd->fibnum, dd->routes_added); dp->f = lookup_ptr; dp->arg = dd->lpm6; return (FLM_SUCCESS); } static void estimate_scale(const struct dpdk_lpm6_data *dd_src, struct dpdk_lpm6_data *dd) { /* XXX: update at 75% capacity */ if (dd_src->hit_tables) dd->number_tbl8s = dd_src->number_tbl8s * 2; else dd->number_tbl8s = dd_src->number_tbl8s; /* TODO: look into the appropriate RIB to adjust */ } static struct dpdk_lpm6_data * build_table(struct dpdk_lpm6_data *dd_prev, struct fib_data *fd) { struct dpdk_lpm6_data *dd; struct rte_lpm6 *lpm6; dd = malloc(sizeof(struct dpdk_lpm6_data), M_TEMP, M_NOWAIT | M_ZERO); if (dd == NULL) { FIB_PRINTF(LOG_INFO, fd, "Unable to allocate base datastructure"); return (NULL); } dd->fibnum = dd_prev->fibnum; dd->fd = fd; estimate_scale(dd_prev, dd); struct rte_lpm6_config cfg = {.number_tbl8s = dd->number_tbl8s}; lpm6 = rte_lpm6_create("test", 0, &cfg); if (lpm6 == NULL) { FIB_PRINTF(LOG_INFO, fd, "unable to create lpm6"); free(dd, M_TEMP); return (NULL); } dd->lpm6 = lpm6; struct rte_lpm6_external *ext = (struct rte_lpm6_external *)lpm6; ext->nh_idx = fib_get_nhop_array(dd->fd); FIB_PRINTF(LOG_INFO, fd, "allocated %u tbl8s", dd->number_tbl8s); return (dd); } static enum flm_op_result init_table(uint32_t fibnum, struct fib_data *fd, void *_old_data, void **data) { struct dpdk_lpm6_data *dd, dd_base; if (_old_data == NULL) { bzero(&dd_base, sizeof(struct dpdk_lpm6_data)); dd_base.fibnum = fibnum; /* TODO: get rib statistics */ dd_base.number_tbl8s = LPM6_MIN_TBL8; dd = &dd_base; } else { FIB_PRINTF(LOG_INFO, fd, "Starting with old data"); dd = (struct dpdk_lpm6_data *)_old_data; } /* Guaranteed to be in epoch */ dd = build_table(dd, fd); if (dd == NULL) { FIB_PRINTF(LOG_INFO, fd, "table creation failed"); return (FLM_REBUILD); } *data = dd; return (FLM_SUCCESS); } static struct fib_lookup_module dpdk_lpm6 = { .flm_name = "dpdk_lpm6", .flm_family = AF_INET6, .flm_init_cb = init_table, .flm_destroy_cb = destroy_table, .flm_dump_rib_item_cb = add_route_cb, .flm_dump_end_cb = check_dump_success, .flm_change_rib_item_cb = handle_rtable_change_cb, .flm_get_pref = rte6_get_pref, }; static int lpm6_modevent(module_t mod, int type, void *unused) { int error = 0; switch (type) { case MOD_LOAD: fib_module_register(&dpdk_lpm6); break; case MOD_UNLOAD: error = fib_module_unregister(&dpdk_lpm6); break; default: error = EOPNOTSUPP; break; } return (error); } static moduledata_t lpm6mod = { "dpdk_lpm6", lpm6_modevent, 0 }; DECLARE_MODULE(lpm6mod, lpm6mod, SI_SUB_PSEUDO, SI_ORDER_ANY); MODULE_VERSION(lpm6mod, 1); diff --git a/sys/netinet6/in6_fib_algo.c b/sys/netinet6/in6_fib_algo.c index c9df9387af37..04d194273168 100644 --- a/sys/netinet6/in6_fib_algo.c +++ b/sys/netinet6/in6_fib_algo.c @@ -1,361 +1,361 @@ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * * Copyright (c) 2020 Alexander V. Chernikov * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); #include "opt_inet6.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* * Lockless radix lookup algo. * * Compiles immutable radix from the current routing table. * Used with small amount of routes (<1000). * As datastructure is immutable, it gets rebuild on each rtable change. * */ #define KEY_LEN_INET6 (offsetof(struct sa_in6, sin6_addr) + sizeof(struct in6_addr)) #define OFF_LEN_INET6 (8 * offsetof(struct sa_in6, sin6_addr)) struct sa_in6 { uint8_t sin6_len; uint8_t sin6_family; uint8_t pad[6]; struct in6_addr sin6_addr; }; struct radix6_addr_entry { struct radix_node rn[2]; struct sa_in6 addr; struct nhop_object *nhop; }; #define LRADIX6_ITEM_SZ roundup2(sizeof(struct radix6_addr_entry), CACHE_LINE_SIZE) struct lradix6_data { struct radix_node_head *rnh; struct fib_data *fd; void *mem; // raw radix_mem pointer to free void *radix_mem; uint32_t alloc_items; uint32_t num_items; }; static struct nhop_object * lradix6_lookup(void *algo_data, const struct flm_lookup_key key, uint32_t scopeid) { struct radix_node_head *rnh = (struct radix_node_head *)algo_data; struct radix6_addr_entry *ent; struct sa_in6 addr6 = { .sin6_len = KEY_LEN_INET6, .sin6_addr = *key.addr6, }; if (IN6_IS_SCOPE_LINKLOCAL(key.addr6)) addr6.sin6_addr.s6_addr16[1] = htons(scopeid & 0xffff); ent = (struct radix6_addr_entry *)(rn_match(&addr6, &rnh->rh)); if (ent != NULL) return (ent->nhop); return (NULL); } static uint8_t lradix6_get_pref(const struct rib_rtable_info *rinfo) { if (rinfo->num_prefixes < 10) return (255); - else if (rinfo->num_prefixes < 100000) - return (255 - rinfo->num_prefixes / 394); + else if (rinfo->num_prefixes < 10000) + return (255 - rinfo->num_prefixes / 40); else return (1); } static enum flm_op_result lradix6_init(uint32_t fibnum, struct fib_data *fd, void *_old_data, void **_data) { struct lradix6_data *lr; struct rib_rtable_info rinfo; uint32_t count; void *mem; lr = malloc(sizeof(struct lradix6_data), M_RTABLE, M_NOWAIT | M_ZERO); if (lr == NULL || !rn_inithead((void **)&lr->rnh, OFF_LEN_INET6)) return (FLM_REBUILD); fib_get_rtable_info(fib_get_rh(fd), &rinfo); count = rinfo.num_prefixes * 11 / 10; // count+1 adds at least 1 cache line mem = malloc((count + 1) * LRADIX6_ITEM_SZ, M_RTABLE, M_NOWAIT | M_ZERO); if (mem == NULL) return (FLM_REBUILD); lr->mem = mem; lr->radix_mem = (void *)roundup2((uintptr_t)mem, CACHE_LINE_SIZE); lr->alloc_items = count; lr->fd = fd; *_data = lr; return (FLM_SUCCESS); } static void lradix6_destroy(void *_data) { struct lradix6_data *lr = (struct lradix6_data *)_data; if (lr->rnh != NULL) rn_detachhead((void **)&lr->rnh); if (lr->mem != NULL) free(lr->mem, M_RTABLE); free(lr, M_RTABLE); } static enum flm_op_result lradix6_add_route_cb(struct rtentry *rt, void *_data) { struct lradix6_data *lr = (struct lradix6_data *)_data; struct radix6_addr_entry *ae; struct sockaddr_in6 *rt_dst, *rt_mask; struct sa_in6 mask; struct radix_node *rn; struct nhop_object *nh; nh = rt_get_raw_nhop(rt); if (lr->num_items >= lr->alloc_items) return (FLM_REBUILD); ae = (struct radix6_addr_entry *)((char *)lr->radix_mem + lr->num_items * LRADIX6_ITEM_SZ); lr->num_items++; ae->nhop = nh; rt_dst = (struct sockaddr_in6 *)rt_key(rt); rt_mask = (struct sockaddr_in6 *)rt_mask(rt); ae->addr.sin6_len = KEY_LEN_INET6; ae->addr.sin6_addr = rt_dst->sin6_addr; if (rt_mask != NULL) { bzero(&mask, sizeof(mask)); mask.sin6_len = KEY_LEN_INET6; mask.sin6_addr = rt_mask->sin6_addr; rt_mask = (struct sockaddr_in6 *)&mask; } rn = lr->rnh->rnh_addaddr((struct sockaddr *)&ae->addr, (struct sockaddr *)rt_mask, &lr->rnh->rh, ae->rn); if (rn == NULL) return (FLM_REBUILD); return (FLM_SUCCESS); } static enum flm_op_result lradix6_end_dump(void *_data, struct fib_dp *dp) { struct lradix6_data *lr = (struct lradix6_data *)_data; dp->f = lradix6_lookup; dp->arg = lr->rnh; return (FLM_SUCCESS); } static enum flm_op_result lradix6_change_cb(struct rib_head *rnh, struct rib_cmd_info *rc, void *_data) { return (FLM_REBUILD); } struct fib_lookup_module flm_radix6_lockless = { .flm_name = "radix6_lockless", .flm_family = AF_INET6, .flm_init_cb = lradix6_init, .flm_destroy_cb = lradix6_destroy, .flm_dump_rib_item_cb = lradix6_add_route_cb, .flm_dump_end_cb = lradix6_end_dump, .flm_change_rib_item_cb = lradix6_change_cb, .flm_get_pref = lradix6_get_pref, }; /* * Fallback lookup algorithm. * This is a simple wrapper around system radix. */ struct radix6_data { struct fib_data *fd; struct rib_head *rh; }; static struct nhop_object * radix6_lookup(void *algo_data, const struct flm_lookup_key key, uint32_t scopeid) { RIB_RLOCK_TRACKER; struct rib_head *rh = (struct rib_head *)algo_data; struct radix_node *rn; struct nhop_object *nh; /* Prepare lookup key */ struct sockaddr_in6 sin6 = { .sin6_family = AF_INET6, .sin6_len = sizeof(struct sockaddr_in6), .sin6_addr = *key.addr6, }; if (IN6_IS_SCOPE_LINKLOCAL(key.addr6)) sin6.sin6_addr.s6_addr16[1] = htons(scopeid & 0xffff); nh = NULL; RIB_RLOCK(rh); rn = rn_match((void *)&sin6, &rh->head); if (rn != NULL && ((rn->rn_flags & RNF_ROOT) == 0)) nh = (RNTORT(rn))->rt_nhop; RIB_RUNLOCK(rh); return (nh); } struct nhop_object * fib6_radix_lookup_nh(uint32_t fibnum, const struct in6_addr *dst6, uint32_t scopeid) { struct rib_head *rh = rh = rt_tables_get_rnh(fibnum, AF_INET6); const struct flm_lookup_key key = { .addr6 = dst6 }; if (rh == NULL) return (NULL); return (radix6_lookup(rh, key, scopeid)); } static uint8_t radix6_get_pref(const struct rib_rtable_info *rinfo) { return (50); } static enum flm_op_result radix6_init(uint32_t fibnum, struct fib_data *fd, void *_old_data, void **_data) { struct radix6_data *r6; r6 = malloc(sizeof(struct radix6_data), M_RTABLE, M_NOWAIT | M_ZERO); if (r6 == NULL) return (FLM_REBUILD); r6->fd = fd; r6->rh = fib_get_rh(fd); *_data = r6; return (FLM_SUCCESS); } static void radix6_destroy(void *_data) { free(_data, M_RTABLE); } static enum flm_op_result radix6_add_route_cb(struct rtentry *rt, void *_data) { return (FLM_SUCCESS); } static enum flm_op_result radix6_end_dump(void *_data, struct fib_dp *dp) { struct radix6_data *r6 = (struct radix6_data *)_data; dp->f = radix6_lookup; dp->arg = r6->rh; return (FLM_SUCCESS); } static enum flm_op_result radix6_change_cb(struct rib_head *rnh, struct rib_cmd_info *rc, void *_data) { return (FLM_SUCCESS); } struct fib_lookup_module flm_radix6 = { .flm_name = "radix6", .flm_family = AF_INET6, .flm_init_cb = radix6_init, .flm_destroy_cb = radix6_destroy, .flm_dump_rib_item_cb = radix6_add_route_cb, .flm_dump_end_cb = radix6_end_dump, .flm_change_rib_item_cb = radix6_change_cb, .flm_get_pref = radix6_get_pref, }; static void fib6_algo_init(void) { fib_module_register(&flm_radix6_lockless); fib_module_register(&flm_radix6); } SYSINIT(fib6_algo_init, SI_SUB_PROTO_DOMAIN, SI_ORDER_THIRD, fib6_algo_init, NULL);