MCPcopy Create free account
hub / github.com/F-Stack/f-stack / fib4_lookup_rt

Function fib4_lookup_rt

freebsd/netinet/in_fib.c:280–314  ·  view source on GitHub ↗

* Function returning prefix match data along with the nexthop data. * Intended to be used by the control plane code. * Supported flags: * NHR_UNLOCKED: do not lock radix during lookup. * Returns pointer to rtentry and raw nexthop in @rnd. Both rtentry * and nexthop are safe to use within current epoch. Note: * Note: rnd_nhop can actually be the nexthop group. */

Source from the content-addressed store, hash-verified

278 * Note: rnd_nhop can actually be the nexthop group.
279 */
280struct rtentry *
281fib4_lookup_rt(uint32_t fibnum, struct in_addr dst, uint32_t scopeid,
282 uint32_t flags, struct route_nhop_data *rnd)
283{
284 RIB_RLOCK_TRACKER;
285 struct rib_head *rh;
286 struct radix_node *rn;
287 struct rtentry *rt;
288
289 KASSERT((fibnum < rt_numfibs), ("fib4_lookup_rt: bad fibnum"));
290 rh = rt_tables_get_rnh(fibnum, AF_INET);
291 if (rh == NULL)
292 return (NULL);
293
294 /* Prepare lookup key */
295 struct sockaddr_in sin4 = {
296 .sin_family = AF_INET,
297 .sin_len = sizeof(struct sockaddr_in),
298 .sin_addr = dst,
299 };
300
301 rt = NULL;
302 if (!(flags & NHR_UNLOCKED))
303 RIB_RLOCK(rh);
304 rn = rh->rnh_matchaddr((void *)&sin4, &rh->head);
305 if (rn != NULL && ((rn->rn_flags & RNF_ROOT) == 0)) {
306 rt = (struct rtentry *)rn;
307 rnd->rnd_nhop = rt->rt_nhop;
308 rnd->rnd_weight = rt->rt_weight;
309 }
310 if (!(flags & NHR_UNLOCKED))
311 RIB_RUNLOCK(rh);
312
313 return (rt);
314}
315
316struct nhop_object *
317fib4_lookup_debugnet(uint32_t fibnum, struct in_addr dst, uint32_t scopeid,

Callers 4

get_parent_ruleFunction · 0.85
ta_find_kfib_tentryFunction · 0.85
fib4_lookup_debugnetFunction · 0.85
hash_insertFunction · 0.85

Calls 1

rt_tables_get_rnhFunction · 0.85

Tested by

no test coverage detected