aboutsummaryrefslogtreecommitdiff
path: root/sys/netinet6/in6_fib.c
diff options
context:
space:
mode:
authorAlexander V. Chernikov <melifaro@FreeBSD.org>2020-07-02 21:04:08 +0000
committerAlexander V. Chernikov <melifaro@FreeBSD.org>2020-07-02 21:04:08 +0000
commit6ad7446c6f3ac5636428bc4064a48fb0b65905ae (patch)
treebca4738e23bdfd4958f3c6471b7f772535dc4d4c /sys/netinet6/in6_fib.c
parentf60b4812d88581ff7932e4d9d7a50ecccce0e727 (diff)
downloadsrc-6ad7446c6f3ac5636428bc4064a48fb0b65905ae.tar.gz
src-6ad7446c6f3ac5636428bc4064a48fb0b65905ae.zip
Complete conversions from fib<4|6>_lookup_nh_<basic|ext> to fib<4|6>_lookup().
fib[46]_lookup_nh_ represents pre-epoch generation of fib api, providing less guarantees over pointer validness and requiring on-stack data copying. With no callers remaining, remove fib[46]_lookup_nh_ functions. Submitted by: Neel Chauhan <neel AT neelc DOT org> Differential Revision: https://reviews.freebsd.org/D25445
Notes
Notes: svn path=/head/; revision=362900
Diffstat (limited to 'sys/netinet6/in6_fib.c')
-rw-r--r--sys/netinet6/in6_fib.c178
1 files changed, 0 insertions, 178 deletions
diff --git a/sys/netinet6/in6_fib.c b/sys/netinet6/in6_fib.c
index 15ed3cd2f178..d93df54aa3fc 100644
--- a/sys/netinet6/in6_fib.c
+++ b/sys/netinet6/in6_fib.c
@@ -70,187 +70,9 @@ __FBSDID("$FreeBSD$");
#include <net/if_types.h>
#ifdef INET6
-static void fib6_rte_to_nh_extended(const struct nhop_object *nh,
- const struct in6_addr *dst, uint32_t flags, struct nhop6_extended *pnh6);
-static void fib6_rte_to_nh_basic(const struct nhop_object *nh, const struct in6_addr *dst,
- uint32_t flags, struct nhop6_basic *pnh6);
-
-#define ifatoia6(ifa) ((struct in6_ifaddr *)(ifa))
CHK_STRUCT_ROUTE_COMPAT(struct route_in6, ro_dst);
-
-
-static void
-fib6_rte_to_nh_basic(const struct nhop_object *nh, const struct in6_addr *dst,
- uint32_t flags, struct nhop6_basic *pnh6)
-{
-
- /* Do explicit nexthop zero unless we're copying it */
- memset(pnh6, 0, sizeof(*pnh6));
-
- if ((flags & NHR_IFAIF) != 0)
- pnh6->nh_ifp = nh->nh_aifp;
- else
- pnh6->nh_ifp = nh->nh_ifp;
-
- pnh6->nh_mtu = nh->nh_mtu;
- if (nh->nh_flags & NHF_GATEWAY) {
- /* Return address with embedded scope. */
- pnh6->nh_addr = nh->gw6_sa.sin6_addr;
- } else
- pnh6->nh_addr = *dst;
- /* Set flags */
- pnh6->nh_flags = nh->nh_flags;
-}
-
-static void
-fib6_rte_to_nh_extended(const struct nhop_object *nh, const struct in6_addr *dst,
- uint32_t flags, struct nhop6_extended *pnh6)
-{
-
- /* Do explicit nexthop zero unless we're copying it */
- memset(pnh6, 0, sizeof(*pnh6));
-
- if ((flags & NHR_IFAIF) != 0)
- pnh6->nh_ifp = nh->nh_aifp;
- else
- pnh6->nh_ifp = nh->nh_ifp;
-
- pnh6->nh_mtu = nh->nh_mtu;
- if (nh->nh_flags & NHF_GATEWAY) {
- /* Return address with embedded scope. */
- pnh6->nh_addr = nh->gw6_sa.sin6_addr;
- } else
- pnh6->nh_addr = *dst;
- /* Set flags */
- pnh6->nh_flags = nh->nh_flags;
- pnh6->nh_ia = ifatoia6(nh->nh_ifa);
-}
-
-/*
- * Performs IPv6 route table lookup on @dst. Returns 0 on success.
- * Stores basic nexthop info into provided @pnh6 structure.
- * Note that
- * - nh_ifp represents logical transmit interface (rt_ifp) by default
- * - nh_ifp represents "address" interface if NHR_IFAIF flag is passed
- * - mtu from logical transmit interface will be returned.
- * - nh_ifp cannot be safely dereferenced
- * - nh_ifp represents rt_ifp (e.g. if looking up address on
- * interface "ix0" pointer to "ix0" interface will be returned instead
- * of "lo0")
- * - howewer mtu from "transmit" interface will be returned.
- * - scope will be embedded in nh_addr
- */
-int
-fib6_lookup_nh_basic(uint32_t fibnum, const struct in6_addr *dst, uint32_t scopeid,
- uint32_t flags, uint32_t flowid, struct nhop6_basic *pnh6)
-{
- RIB_RLOCK_TRACKER;
- struct rib_head *rh;
- struct radix_node *rn;
- struct sockaddr_in6 sin6;
- struct nhop_object *nh;
-
- KASSERT((fibnum < rt_numfibs), ("fib6_lookup_nh_basic: bad fibnum"));
- rh = rt_tables_get_rnh(fibnum, AF_INET6);
- if (rh == NULL)
- return (ENOENT);
-
- /* Prepare lookup key */
- memset(&sin6, 0, sizeof(sin6));
- sin6.sin6_addr = *dst;
- sin6.sin6_len = sizeof(struct sockaddr_in6);
- /* Assume scopeid is valid and embed it directly */
- if (IN6_IS_SCOPE_LINKLOCAL(dst))
- sin6.sin6_addr.s6_addr16[1] = htons(scopeid & 0xffff);
-
- RIB_RLOCK(rh);
- rn = rh->rnh_matchaddr((void *)&sin6, &rh->head);
- if (rn != NULL && ((rn->rn_flags & RNF_ROOT) == 0)) {
- nh = RNTORT(rn)->rt_nhop;
- /* Ensure route & ifp is UP */
- if (RT_LINK_IS_UP(nh->nh_ifp)) {
- fib6_rte_to_nh_basic(nh, &sin6.sin6_addr, flags, pnh6);
- RIB_RUNLOCK(rh);
- return (0);
- }
- }
- RIB_RUNLOCK(rh);
-
- return (ENOENT);
-}
-
-/*
- * Performs IPv6 route table lookup on @dst. Returns 0 on success.
- * Stores extended nexthop info into provided @pnh6 structure.
- * Note that
- * - nh_ifp cannot be safely dereferenced unless NHR_REF is specified.
- * - in that case you need to call fib6_free_nh_ext()
- * - nh_ifp represents logical transmit interface (rt_ifp) by default
- * - nh_ifp represents "address" interface if NHR_IFAIF flag is passed
- * - mtu from logical transmit interface will be returned.
- * - scope will be embedded in nh_addr
- */
-int
-fib6_lookup_nh_ext(uint32_t fibnum, const struct in6_addr *dst,uint32_t scopeid,
- uint32_t flags, uint32_t flowid, struct nhop6_extended *pnh6)
-{
- RIB_RLOCK_TRACKER;
- struct rib_head *rh;
- struct radix_node *rn;
- struct sockaddr_in6 sin6;
- struct rtentry *rte;
- struct nhop_object *nh;
-
- KASSERT((fibnum < rt_numfibs), ("fib6_lookup_nh_ext: bad fibnum"));
- rh = rt_tables_get_rnh(fibnum, AF_INET6);
- if (rh == NULL)
- return (ENOENT);
-
- /* Prepare lookup key */
- memset(&sin6, 0, sizeof(sin6));
- sin6.sin6_len = sizeof(struct sockaddr_in6);
- sin6.sin6_addr = *dst;
- /* Assume scopeid is valid and embed it directly */
- if (IN6_IS_SCOPE_LINKLOCAL(dst))
- sin6.sin6_addr.s6_addr16[1] = htons(scopeid & 0xffff);
-
- RIB_RLOCK(rh);
- rn = rh->rnh_matchaddr((void *)&sin6, &rh->head);
- if (rn != NULL && ((rn->rn_flags & RNF_ROOT) == 0)) {
- rte = RNTORT(rn);
-#ifdef RADIX_MPATH
- rte = rt_mpath_select(rte, flowid);
- if (rte == NULL) {
- RIB_RUNLOCK(rh);
- return (ENOENT);
- }
-#endif
- nh = rte->rt_nhop;
- /* Ensure route & ifp is UP */
- if (RT_LINK_IS_UP(nh->nh_ifp)) {
- fib6_rte_to_nh_extended(nh, &sin6.sin6_addr, flags,
- pnh6);
- if ((flags & NHR_REF) != 0) {
- /* TODO: Do lwref on egress ifp's */
- }
- RIB_RUNLOCK(rh);
-
- return (0);
- }
- }
- RIB_RUNLOCK(rh);
-
- return (ENOENT);
-}
-
-void
-fib6_free_nh_ext(uint32_t fibnum, struct nhop6_extended *pnh6)
-{
-
-}
-
/*
* Looks up path in fib @fibnum specified by @dst.
* Assumes scope is deembedded and provided in @scopeid.