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

Function rn_lookup

freebsd/net/radix.c:211–250  ·  view source on GitHub ↗

* Search for exact match in given @head. * Assume host bits are cleared in @v_arg if @m_arg is not NULL * Note that prefixes with /32 or /128 masks are treated differently * from host routes. */

Source from the content-addressed store, hash-verified

209 * from host routes.
210 */
211struct radix_node *
212rn_lookup(void *v_arg, void *m_arg, struct radix_head *head)
213{
214 struct radix_node *x;
215 caddr_t netmask;
216
217 if (m_arg != NULL) {
218 /*
219 * Most common case: search exact prefix/mask
220 */
221 x = rn_addmask(m_arg, head->rnh_masks, 1,
222 head->rnh_treetop->rn_offset);
223 if (x == NULL)
224 return (NULL);
225 netmask = x->rn_key;
226
227 x = rn_match(v_arg, head);
228
229 while (x != NULL && x->rn_mask != netmask)
230 x = x->rn_dupedkey;
231
232 return (x);
233 }
234
235 /*
236 * Search for host address.
237 */
238 if ((x = rn_match(v_arg, head)) == NULL)
239 return (NULL);
240
241 /* Check if found key is the same */
242 if (LEN(x->rn_key) != LEN(v_arg) || bcmp(x->rn_key, v_arg, LEN(v_arg)))
243 return (NULL);
244
245 /* Check if this is not host route */
246 if (x->rn_mask != NULL)
247 return (NULL);
248
249 return (x);
250}
251
252static int
253rn_satisfies_leaf(char *trial, struct radix_node *leaf, int skip)

Callers 1

pfr_lookup_addrFunction · 0.85

Calls 2

rn_addmaskFunction · 0.85
rn_matchFunction · 0.85

Tested by

no test coverage detected