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

Function in_hasrtprefix

freebsd/netinet/in.c:897–931  ·  view source on GitHub ↗

* Check if we have a route for the given prefix already. */

Source from the content-addressed store, hash-verified

895 * Check if we have a route for the given prefix already.
896 */
897static bool
898in_hasrtprefix(struct in_ifaddr *target)
899{
900 struct rm_priotracker in_ifa_tracker;
901 struct in_ifaddr *ia;
902 struct in_addr prefix, mask, p, m;
903 bool result = false;
904
905 ia_getrtprefix(target, &prefix, &mask);
906
907 IN_IFADDR_RLOCK(&in_ifa_tracker);
908 /* Look for an existing address with the same prefix, mask, and fib */
909 CK_STAILQ_FOREACH(ia, &V_in_ifaddrhead, ia_link) {
910 ia_getrtprefix(ia, &p, &m);
911
912 if (prefix.s_addr != p.s_addr ||
913 mask.s_addr != m.s_addr)
914 continue;
915
916 if (target->ia_ifp->if_fib != ia->ia_ifp->if_fib)
917 continue;
918
919 /*
920 * If we got a matching prefix route inserted by other
921 * interface address, we are done here.
922 */
923 if (ia->ia_flags & IFA_ROUTE) {
924 result = true;
925 break;
926 }
927 }
928 IN_IFADDR_RUNLOCK(&in_ifa_tracker);
929
930 return (result);
931}
932
933int
934in_addprefix(struct in_ifaddr *target)

Callers 1

in_addprefixFunction · 0.85

Calls 1

ia_getrtprefixFunction · 0.85

Tested by

no test coverage detected