Simplify API: use new NHOP_LOOKUP_AIFP flag to select what ifp
we need to return. Rename fib[64]_lookup_nh_basic to fib[64]_lookup_nh, add flags fields for all relevant functions.
This commit is contained in:
parent
df629abf3e
commit
f9723c7705
sys
contrib/ipfilter/netinet
net
netinet
netinet6
netpfil
@ -958,7 +958,7 @@ ipf_verifysrc(fin)
|
||||
struct nhop4_basic nh4;
|
||||
|
||||
memset(&nh4, 0, sizeof(nh4));
|
||||
if (fib4_lookup_nh_basic(RT_DEFAULT_FIB, fin->fin_src, 0, &nh4) != 0)
|
||||
if (fib4_lookup_nh(RT_DEFAULT_FIB, fin->fin_src, 0, 0, &nh4) != 0)
|
||||
return (0);
|
||||
|
||||
return (fin->fin_ifp == nh4.nh_ifp);
|
||||
|
@ -574,7 +574,7 @@ stf_checkaddr4(sc, in, inifp)
|
||||
if (sc && (STF2IFP(sc)->if_flags & IFF_LINK2) == 0 && inifp) {
|
||||
struct nhop4_basic nh4;
|
||||
|
||||
if (fib4_lookup_nh_basic(sc->sc_fibnum, *in, 0, &nh4) != 0)
|
||||
if (fib4_lookup_nh(sc->sc_fibnum, *in, 0, 0, &nh4) != 0)
|
||||
return (-1);
|
||||
if (nh4.nh_ifp != inifp)
|
||||
return (-1);
|
||||
|
@ -123,22 +123,22 @@ static inline uint16_t fib_rte_to_nh_flags(int rt_flags);
|
||||
static void rib4_rte_to_nh_extended(struct rtentry *rte, struct in_addr dst,
|
||||
struct rt4_extended *prt4);
|
||||
static void fib4_rte_to_nh_extended(struct rtentry *rte, struct in_addr dst,
|
||||
struct nhop4_extended *pnh4);
|
||||
static void fib4_rte_to_nh_basic(struct rtentry *rte, struct in_addr dst,
|
||||
struct nhop4_basic *pnh4);
|
||||
uint32_t flags, struct nhop4_extended *pnh4);
|
||||
static void fib4_rte_to_nh(struct rtentry *rte, struct in_addr dst,
|
||||
uint32_t flags, struct nhop4_basic *pnh4);
|
||||
#endif
|
||||
#ifdef INET6
|
||||
static void fib6_rte_to_nh_extended(struct rtentry *rte, struct in6_addr *dst,
|
||||
struct nhop6_extended *pnh6);
|
||||
static void fib6_rte_to_nh_basic(struct rtentry *rte, struct in6_addr *dst,
|
||||
struct nhop6_basic *pnh6);
|
||||
uint32_t flags, struct nhop6_extended *pnh6);
|
||||
static void fib6_rte_to_nh(struct rtentry *rte, struct in6_addr *dst,
|
||||
uint32_t flags, struct nhop6_basic *pnh6);
|
||||
static int fib6_storelladdr(struct ifnet *ifp, struct in6_addr *dst,
|
||||
int mm_flags, u_char *desten);
|
||||
static uint16_t fib6_get_ifa(struct rtentry *rte);
|
||||
static int fib6_lla_to_nh_basic(struct in6_addr *dst, uint32_t scopeid,
|
||||
struct nhop6_basic *pnh6);
|
||||
uint32_t flags, struct nhop6_basic *pnh6);
|
||||
static int fib6_lla_to_nh_extended(struct in6_addr *dst, uint32_t scopeid,
|
||||
struct nhop6_extended *pnh6);
|
||||
uint32_t flags, struct nhop6_extended *pnh6);
|
||||
static int fib6_lla_to_nh(struct in6_addr *dst, uint32_t scopeid,
|
||||
struct nhop_prepend *nh, struct ifnet **lifp);
|
||||
#endif
|
||||
@ -321,7 +321,7 @@ fib4_lookup_prepend(uint32_t fibnum, struct in_addr dst, struct mbuf *m,
|
||||
|
||||
if (nh_ext != NULL) {
|
||||
/* Fill in extended info */
|
||||
fib4_rte_to_nh_extended(rte, dst, nh_ext);
|
||||
fib4_rte_to_nh_extended(rte, dst, 0, nh_ext);
|
||||
}
|
||||
|
||||
RIB_RUNLOCK(rh);
|
||||
@ -413,12 +413,15 @@ fib_rte_to_nh_flags(int rt_flags)
|
||||
}
|
||||
|
||||
static void
|
||||
fib4_rte_to_nh_basic(struct rtentry *rte, struct in_addr dst,
|
||||
struct nhop4_basic *pnh4)
|
||||
fib4_rte_to_nh(struct rtentry *rte, struct in_addr dst,
|
||||
uint32_t flags, struct nhop4_basic *pnh4)
|
||||
{
|
||||
struct sockaddr_in *gw;
|
||||
|
||||
pnh4->nh_ifp = rte->rt_ifa->ifa_ifp;
|
||||
if ((flags & NHOP_LOOKUP_AIFP) == 0)
|
||||
pnh4->nh_ifp = rte->rt_ifp;
|
||||
else
|
||||
pnh4->nh_ifp = rte->rt_ifa->ifa_ifp;
|
||||
pnh4->nh_mtu = min(rte->rt_mtu, rte->rt_ifp->if_mtu);
|
||||
if (rte->rt_flags & RTF_GATEWAY) {
|
||||
gw = (struct sockaddr_in *)rte->rt_gateway;
|
||||
@ -435,12 +438,15 @@ fib4_rte_to_nh_basic(struct rtentry *rte, struct in_addr dst,
|
||||
|
||||
static void
|
||||
fib4_rte_to_nh_extended(struct rtentry *rte, struct in_addr dst,
|
||||
struct nhop4_extended *pnh4)
|
||||
uint32_t flags, struct nhop4_extended *pnh4)
|
||||
{
|
||||
struct sockaddr_in *gw;
|
||||
struct in_ifaddr *ia;
|
||||
|
||||
pnh4->nh_ifp = rte->rt_ifa->ifa_ifp;
|
||||
if ((flags & NHOP_LOOKUP_AIFP) == 0)
|
||||
pnh4->nh_ifp = rte->rt_ifp;
|
||||
else
|
||||
pnh4->nh_ifp = rte->rt_ifa->ifa_ifp;
|
||||
pnh4->nh_mtu = min(rte->rt_mtu, rte->rt_ifp->if_mtu);
|
||||
if (rte->rt_flags & RTF_GATEWAY) {
|
||||
gw = (struct sockaddr_in *)rte->rt_gateway;
|
||||
@ -502,8 +508,8 @@ rib4_rte_to_nh_extended(struct rtentry *rte, struct in_addr dst,
|
||||
* - howewer mtu from "transmit" interface will be returned.
|
||||
*/
|
||||
int
|
||||
fib4_lookup_nh_basic(uint32_t fibnum, struct in_addr dst, uint32_t flowid,
|
||||
struct nhop4_basic *pnh4)
|
||||
fib4_lookup_nh(uint32_t fibnum, struct in_addr dst, uint32_t flowid,
|
||||
uint32_t flags, struct nhop4_basic *pnh4)
|
||||
{
|
||||
struct rib_head *rh;
|
||||
struct radix_node *rn;
|
||||
@ -511,7 +517,7 @@ fib4_lookup_nh_basic(uint32_t fibnum, struct in_addr dst, uint32_t flowid,
|
||||
struct rtentry *rte;
|
||||
RIB_LOCK_READER;
|
||||
|
||||
KASSERT((fibnum < rt_numfibs), ("fib4_lookup_nh_basic: bad fibnum"));
|
||||
KASSERT((fibnum < rt_numfibs), ("fib4_lookup_nh: bad fibnum"));
|
||||
rh = rt_tables_get_rnh(fibnum, AF_INET);
|
||||
if (rh == NULL)
|
||||
return (ENOENT);
|
||||
@ -527,7 +533,7 @@ fib4_lookup_nh_basic(uint32_t fibnum, struct in_addr dst, uint32_t flowid,
|
||||
rte = RNTORT(rn);
|
||||
/* Ensure route & ifp is UP */
|
||||
if (RT_LINK_IS_UP(rte->rt_ifp)) {
|
||||
fib4_rte_to_nh_basic(rte, dst, pnh4);
|
||||
fib4_rte_to_nh(rte, dst, flags, pnh4);
|
||||
RIB_RUNLOCK(rh);
|
||||
|
||||
return (0);
|
||||
@ -538,43 +544,6 @@ fib4_lookup_nh_basic(uint32_t fibnum, struct in_addr dst, uint32_t flowid,
|
||||
return (ENOENT);
|
||||
}
|
||||
|
||||
int
|
||||
fib4_lookup_nh_ifp(uint32_t fibnum, struct in_addr dst, uint32_t flowid,
|
||||
struct nhop4_basic *pnh4)
|
||||
{
|
||||
struct rib_head *rh;
|
||||
struct radix_node *rn;
|
||||
struct sockaddr_in sin;
|
||||
struct rtentry *rte;
|
||||
RIB_LOCK_READER;
|
||||
|
||||
KASSERT((fibnum < rt_numfibs), ("fib4_lookup_nh_ifp: bad fibnum"));
|
||||
rh = rt_tables_get_rnh(fibnum, AF_INET);
|
||||
if (rh == NULL)
|
||||
return (ENOENT);
|
||||
|
||||
/* Prepare lookup key */
|
||||
memset(&sin, 0, sizeof(sin));
|
||||
sin.sin_len = sizeof(struct sockaddr_in);
|
||||
sin.sin_addr = dst;
|
||||
|
||||
RIB_RLOCK(rh);
|
||||
rn = rh->rnh_matchaddr((void *)&sin, &rh->head);
|
||||
if (rn != NULL && ((rn->rn_flags & RNF_ROOT) == 0)) {
|
||||
rte = RNTORT(rn);
|
||||
/* Ensure route & ifp is UP */
|
||||
if (RT_LINK_IS_UP(rte->rt_ifp)) {
|
||||
fib4_rte_to_nh_basic(rte, dst, pnh4);
|
||||
RIB_RUNLOCK(rh);
|
||||
pnh4->nh_ifp = rte->rt_ifp;
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
RIB_RUNLOCK(rh);
|
||||
|
||||
return (ENOENT);
|
||||
}
|
||||
|
||||
/*
|
||||
* Performs IPv4 route table lookup on @dst. Returns 0 on success.
|
||||
* Stores extende nexthop info provided @pnh4 structure.
|
||||
@ -610,7 +579,7 @@ fib4_lookup_nh_ext(uint32_t fibnum, struct in_addr dst, uint32_t flowid,
|
||||
rte = RNTORT(rn);
|
||||
/* Ensure route & ifp is UP */
|
||||
if (RT_LINK_IS_UP(rte->rt_ifp)) {
|
||||
fib4_rte_to_nh_extended(rte, dst, pnh4);
|
||||
fib4_rte_to_nh_extended(rte, dst, flags, pnh4);
|
||||
if ((flags & NHOP_LOOKUP_REF) != 0) {
|
||||
/* TODO: Do lwref on egress ifp's */
|
||||
}
|
||||
@ -946,7 +915,7 @@ fib6_get_ifa(struct rtentry *rte)
|
||||
|
||||
static int
|
||||
fib6_lla_to_nh_basic(struct in6_addr *dst, uint32_t scopeid,
|
||||
struct nhop6_basic *pnh6)
|
||||
uint32_t flags, struct nhop6_basic *pnh6)
|
||||
{
|
||||
struct ifnet *ifp;
|
||||
|
||||
@ -957,8 +926,13 @@ fib6_lla_to_nh_basic(struct in6_addr *dst, uint32_t scopeid,
|
||||
/* Do explicit nexthop zero unless we're copying it */
|
||||
memset(pnh6, 0, sizeof(*pnh6));
|
||||
|
||||
pnh6->nh_ifp = ifp;
|
||||
pnh6->nh_mtu = IN6_LINKMTU(ifp);
|
||||
pnh6->nh_ifp = ifp;
|
||||
if ((flags & NHOP_LOOKUP_AIFP)!=0 && in6_ifawithifp_lla(ifp, dst) != 0){
|
||||
if ((ifp = V_loif) != NULL)
|
||||
pnh6->nh_ifp = ifp;
|
||||
}
|
||||
|
||||
/* No flags set */
|
||||
pnh6->nh_addr = *dst;
|
||||
|
||||
@ -967,7 +941,7 @@ fib6_lla_to_nh_basic(struct in6_addr *dst, uint32_t scopeid,
|
||||
|
||||
static int
|
||||
fib6_lla_to_nh_extended(struct in6_addr *dst, uint32_t scopeid,
|
||||
struct nhop6_extended *pnh6)
|
||||
uint32_t flags, struct nhop6_extended *pnh6)
|
||||
{
|
||||
struct ifnet *ifp;
|
||||
|
||||
@ -978,8 +952,12 @@ fib6_lla_to_nh_extended(struct in6_addr *dst, uint32_t scopeid,
|
||||
/* Do explicit nexthop zero unless we're copying it */
|
||||
memset(pnh6, 0, sizeof(*pnh6));
|
||||
|
||||
pnh6->nh_ifp = ifp;
|
||||
pnh6->nh_mtu = IN6_LINKMTU(ifp);
|
||||
pnh6->nh_ifp = ifp;
|
||||
if ((flags & NHOP_LOOKUP_AIFP)!=0 && in6_ifawithifp_lla(ifp, dst) != 0){
|
||||
if ((ifp = V_loif) != NULL)
|
||||
pnh6->nh_ifp = ifp;
|
||||
}
|
||||
/* No flags set */
|
||||
pnh6->nh_addr = *dst;
|
||||
|
||||
@ -988,7 +966,7 @@ fib6_lla_to_nh_extended(struct in6_addr *dst, uint32_t scopeid,
|
||||
|
||||
static int
|
||||
rib6_lla_to_nh_extended(struct in6_addr *dst, uint32_t scopeid,
|
||||
struct rt6_extended *prt6)
|
||||
uint32_t flags, struct rt6_extended *prt6)
|
||||
{
|
||||
struct ifnet *ifp;
|
||||
|
||||
@ -1047,15 +1025,18 @@ fib6_lla_to_nh(struct in6_addr *dst, uint32_t scopeid,
|
||||
|
||||
|
||||
static void
|
||||
fib6_rte_to_nh_basic(struct rtentry *rte, struct in6_addr *dst,
|
||||
struct nhop6_basic *pnh6)
|
||||
fib6_rte_to_nh(struct rtentry *rte, struct in6_addr *dst,
|
||||
uint32_t flags, struct nhop6_basic *pnh6)
|
||||
{
|
||||
struct sockaddr_in6 *gw;
|
||||
|
||||
/* Do explicit nexthop zero unless we're copying it */
|
||||
memset(pnh6, 0, sizeof(*pnh6));
|
||||
|
||||
pnh6->nh_ifp = ifnet_byindex(fib6_get_ifa(rte));
|
||||
if ((flags & NHOP_LOOKUP_AIFP) == 0)
|
||||
pnh6->nh_ifp = rte->rt_ifp;
|
||||
else
|
||||
pnh6->nh_ifp = ifnet_byindex(fib6_get_ifa(rte));
|
||||
|
||||
pnh6->nh_mtu = min(rte->rt_mtu, IN6_LINKMTU(rte->rt_ifp));
|
||||
if (rte->rt_flags & RTF_GATEWAY) {
|
||||
@ -1073,7 +1054,7 @@ fib6_rte_to_nh_basic(struct rtentry *rte, struct in6_addr *dst,
|
||||
|
||||
static void
|
||||
fib6_rte_to_nh_extended(struct rtentry *rte, struct in6_addr *dst,
|
||||
struct nhop6_extended *pnh6)
|
||||
uint32_t flags, struct nhop6_extended *pnh6)
|
||||
{
|
||||
struct sockaddr_in6 *gw;
|
||||
struct in6_ifaddr *ia;
|
||||
@ -1081,7 +1062,11 @@ fib6_rte_to_nh_extended(struct rtentry *rte, struct in6_addr *dst,
|
||||
/* Do explicit nexthop zero unless we're copying it */
|
||||
memset(pnh6, 0, sizeof(*pnh6));
|
||||
|
||||
pnh6->nh_ifp = ifnet_byindex(fib6_get_ifa(rte));
|
||||
if ((flags & NHOP_LOOKUP_AIFP) == 0)
|
||||
pnh6->nh_ifp = rte->rt_ifp;
|
||||
else
|
||||
pnh6->nh_ifp = ifnet_byindex(fib6_get_ifa(rte));
|
||||
|
||||
pnh6->nh_mtu = min(rte->rt_mtu, IN6_LINKMTU(rte->rt_ifp));
|
||||
if (rte->rt_flags & RTF_GATEWAY) {
|
||||
gw = (struct sockaddr_in6 *)rte->rt_gateway;
|
||||
@ -1104,7 +1089,7 @@ fib6_rte_to_nh_extended(struct rtentry *rte, struct in6_addr *dst,
|
||||
bitcount32((x).__u6_addr.__u6_addr32[3])
|
||||
static void
|
||||
rib6_rte_to_nh_extended(struct rtentry *rte, struct in6_addr *dst,
|
||||
struct rt6_extended *prt6)
|
||||
uint32_t flags, struct rt6_extended *prt6)
|
||||
{
|
||||
struct sockaddr_in6 *gw;
|
||||
|
||||
@ -1130,8 +1115,8 @@ rib6_rte_to_nh_extended(struct rtentry *rte, struct in6_addr *dst,
|
||||
}
|
||||
|
||||
int
|
||||
fib6_lookup_nh_ifp(uint32_t fibnum, struct in6_addr *dst, uint32_t scopeid,
|
||||
uint32_t flowid, struct nhop6_basic *pnh6)
|
||||
fib6_lookup_nh(uint32_t fibnum, struct in6_addr *dst, uint32_t scopeid,
|
||||
uint32_t flowid, uint32_t flags, struct nhop6_basic *pnh6)
|
||||
{
|
||||
struct rib_head *rh;
|
||||
struct radix_node *rn;
|
||||
@ -1141,11 +1126,10 @@ fib6_lookup_nh_ifp(uint32_t fibnum, struct in6_addr *dst, uint32_t scopeid,
|
||||
|
||||
if (IN6_IS_SCOPE_LINKLOCAL(dst)) {
|
||||
/* Do not lookup link-local addresses in rtable */
|
||||
/* XXX: Check if dst is local */
|
||||
return (fib6_lla_to_nh_basic(dst, scopeid, pnh6));
|
||||
return (fib6_lla_to_nh_basic(dst, scopeid, flags, pnh6));
|
||||
}
|
||||
|
||||
KASSERT((fibnum < rt_numfibs), ("fib6_lookup_nh_basic: bad fibnum"));
|
||||
KASSERT((fibnum < rt_numfibs), ("fib6_lookup_nh: bad fibnum"));
|
||||
rh = rt_tables_get_rnh(fibnum, AF_INET6);
|
||||
if (rh == NULL)
|
||||
return (ENOENT);
|
||||
@ -1162,50 +1146,7 @@ fib6_lookup_nh_ifp(uint32_t fibnum, struct in6_addr *dst, uint32_t scopeid,
|
||||
rte = RNTORT(rn);
|
||||
/* Ensure route & ifp is UP */
|
||||
if (RT_LINK_IS_UP(rte->rt_ifp)) {
|
||||
fib6_rte_to_nh_basic(rte, dst, pnh6);
|
||||
pnh6->nh_ifp = rte->rt_ifp;
|
||||
RIB_RUNLOCK(rh);
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
RIB_RUNLOCK(rh);
|
||||
|
||||
return (ENOENT);
|
||||
}
|
||||
|
||||
int
|
||||
fib6_lookup_nh_basic(uint32_t fibnum, struct in6_addr *dst, uint32_t scopeid,
|
||||
uint32_t flowid, struct nhop6_basic *pnh6)
|
||||
{
|
||||
struct rib_head *rh;
|
||||
struct radix_node *rn;
|
||||
struct sockaddr_in6 sin6;
|
||||
struct rtentry *rte;
|
||||
RIB_LOCK_READER;
|
||||
|
||||
if (IN6_IS_SCOPE_LINKLOCAL(dst)) {
|
||||
/* Do not lookup link-local addresses in rtable */
|
||||
return (fib6_lla_to_nh_basic(dst, scopeid, pnh6));
|
||||
}
|
||||
|
||||
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_scope_id = scopeid;
|
||||
sa6_embedscope(&sin6, 0);
|
||||
|
||||
RIB_RLOCK(rh);
|
||||
rn = rh->rnh_matchaddr((void *)&sin6, &rh->head);
|
||||
if (rn != NULL && ((rn->rn_flags & RNF_ROOT) == 0)) {
|
||||
rte = RNTORT(rn);
|
||||
/* Ensure route & ifp is UP */
|
||||
if (RT_LINK_IS_UP(rte->rt_ifp)) {
|
||||
fib6_rte_to_nh_basic(rte, dst, pnh6);
|
||||
fib6_rte_to_nh(rte, dst, flags, pnh6);
|
||||
RIB_RUNLOCK(rh);
|
||||
return (0);
|
||||
}
|
||||
@ -1237,7 +1178,7 @@ fib6_lookup_nh_ext(uint32_t fibnum, struct in6_addr *dst, uint32_t scopeid,
|
||||
if (IN6_IS_SCOPE_LINKLOCAL(dst)) {
|
||||
/* Do not lookup link-local addresses in rtable */
|
||||
/* XXX: Do lwref on egress ifp */
|
||||
return (fib6_lla_to_nh_extended(dst, scopeid, pnh6));
|
||||
return (fib6_lla_to_nh_extended(dst, scopeid, flags, pnh6));
|
||||
}
|
||||
|
||||
KASSERT((fibnum < rt_numfibs), ("fib4_lookup_nh_ext: bad fibnum"));
|
||||
@ -1258,7 +1199,7 @@ fib6_lookup_nh_ext(uint32_t fibnum, struct in6_addr *dst, uint32_t scopeid,
|
||||
rte = RNTORT(rn);
|
||||
/* Ensure route & ifp is UP */
|
||||
if (RT_LINK_IS_UP(rte->rt_ifp)) {
|
||||
fib6_rte_to_nh_extended(rte, dst, pnh6);
|
||||
fib6_rte_to_nh_extended(rte, dst, flags, pnh6);
|
||||
if ((flags & NHOP_LOOKUP_REF) != 0) {
|
||||
/* TODO: Do lwref on egress ifp's */
|
||||
}
|
||||
@ -1291,7 +1232,7 @@ rib6_lookup_nh_ext(uint32_t fibnum, struct in6_addr *dst, uint32_t scopeid,
|
||||
if (IN6_IS_SCOPE_LINKLOCAL(dst)) {
|
||||
/* Do not lookup link-local addresses in rtable */
|
||||
/* XXX: Do lwref on egress ifp */
|
||||
return (rib6_lla_to_nh_extended(dst, scopeid, prt6));
|
||||
return (rib6_lla_to_nh_extended(dst, scopeid, flags, prt6));
|
||||
}
|
||||
|
||||
KASSERT((fibnum < rt_numfibs), ("rib6_lookup_nh_ext: bad fibnum"));
|
||||
@ -1312,7 +1253,7 @@ rib6_lookup_nh_ext(uint32_t fibnum, struct in6_addr *dst, uint32_t scopeid,
|
||||
rte = RNTORT(rn);
|
||||
/* Ensure route & ifp is UP */
|
||||
if (RT_LINK_IS_UP(rte->rt_ifp)) {
|
||||
rib6_rte_to_nh_extended(rte, dst, prt6);
|
||||
rib6_rte_to_nh_extended(rte, dst, flags, prt6);
|
||||
if ((flags & NHOP_LOOKUP_REF) != 0) {
|
||||
/* TODO: Do lwref on egress ifp's */
|
||||
}
|
||||
|
@ -216,23 +216,21 @@ struct route_info {
|
||||
uint32_t scopeid; /* Desired scope id to use */
|
||||
};
|
||||
|
||||
int fib4_lookup_nh_ifp(uint32_t fibnum, struct in_addr dst, uint32_t flowid,
|
||||
struct nhop4_basic *pnh4);
|
||||
int fib4_lookup_nh_basic(uint32_t fibnum, struct in_addr dst, uint32_t flowid,
|
||||
struct nhop4_basic *pnh4);
|
||||
#define NHOP_LOOKUP_REF 0x01 /* reference objects in passed structure */
|
||||
#define NHOP_LOOKUP_AIFP 0x02 /* return route "address" interface */
|
||||
|
||||
int fib4_lookup_nh(uint32_t fibnum, struct in_addr dst, uint32_t flowid,
|
||||
uint32_t flags, struct nhop4_basic *pnh4);
|
||||
int fib4_lookup_nh_ext(uint32_t fibnum, struct in_addr dst,
|
||||
uint32_t flowid, uint32_t flags, struct nhop4_extended *pnh4);
|
||||
void fib4_free_nh_ext(uint32_t fibnum, struct nhop4_extended *pnh4);
|
||||
#define NHOP_LOOKUP_REF 0x01
|
||||
int rib4_lookup_nh_ext(uint32_t fibnum, struct in_addr dst, uint32_t flowid,
|
||||
uint32_t flags, struct rt4_extended *prt4);
|
||||
void rib4_free_nh_ext(uint32_t fibnum, struct rt4_extended *prt4);
|
||||
|
||||
|
||||
int fib6_lookup_nh_ifp(uint32_t fibnum, struct in6_addr *dst, uint32_t scopeid,
|
||||
uint32_t flowid, struct nhop6_basic *pnh6);
|
||||
int fib6_lookup_nh_basic(uint32_t fibnum, struct in6_addr *dst,
|
||||
uint32_t scopeid, uint32_t flowid, struct nhop6_basic *pnh6);
|
||||
int fib6_lookup_nh(uint32_t fibnum, struct in6_addr *dst, uint32_t scopeid,
|
||||
uint32_t flowid, uint32_t flags, struct nhop6_basic *pnh6);
|
||||
int fib6_lookup_nh_ext(uint32_t fibnum, struct in6_addr *dst,
|
||||
uint32_t scopeid, uint32_t flowid, uint32_t flags,
|
||||
struct nhop6_extended *pnh6);
|
||||
|
@ -1024,7 +1024,7 @@ in_lltable_rtcheck(struct ifnet *ifp, u_int flags, const struct sockaddr *l3addr
|
||||
("sin_family %d", l3addr->sa_family));
|
||||
|
||||
dst = ((struct sockaddr_in *)l3addr)->sin_addr;
|
||||
if (fib4_lookup_nh_ifp(ifp->if_fib, dst, 0, &nh4) != 0)
|
||||
if (fib4_lookup_nh(ifp->if_fib, dst, 0, 0, &nh4) != 0)
|
||||
return (EINVAL);
|
||||
|
||||
/*
|
||||
|
@ -193,7 +193,7 @@ gif_validate4(const struct ip *ip, struct gif_softc *sc, struct ifnet *ifp)
|
||||
|
||||
fibnum = sc->gif_fibnum;
|
||||
|
||||
if (fib4_lookup_nh_basic(fibnum, ip->ip_src, 0, &nh4) != 0)
|
||||
if (fib4_lookup_nh(fibnum, ip->ip_src, 0, 0, &nh4) != 0)
|
||||
return (0);
|
||||
if (nh4.nh_ifp != ifp)
|
||||
return (0);
|
||||
|
@ -1898,8 +1898,8 @@ inp_lookup_mcast_ifp(const struct inpcb *inp,
|
||||
} else {
|
||||
struct nhop4_basic nh4;
|
||||
|
||||
if (fib4_lookup_nh_basic(inp ? inp->inp_inc.inc_fibnum : 0,
|
||||
gsin->sin_addr, 0, &nh4) != 0) {
|
||||
if (fib4_lookup_nh(inp ? inp->inp_inc.inc_fibnum : 0,
|
||||
gsin->sin_addr, 0, 0, &nh4) != 0) {
|
||||
return (nh4.nh_ifp);
|
||||
} else {
|
||||
struct in_ifaddr *ia;
|
||||
|
@ -1466,7 +1466,8 @@ ip_forward(struct mbuf *m, int srcrt)
|
||||
#endif
|
||||
|
||||
pnh4 = &nh4;
|
||||
if (fib4_lookup_nh_basic(M_GETFIB(m), ip->ip_dst, 0, &nh4) != 0)
|
||||
if (fib4_lookup_nh(M_GETFIB(m), ip->ip_dst, 0, NHOP_LOOKUP_AIFP,
|
||||
&nh4) != 0)
|
||||
pnh4 = NULL;
|
||||
#ifndef IPSEC
|
||||
/*
|
||||
|
@ -2401,7 +2401,7 @@ icmp6_redirect_input(struct mbuf *m, int off)
|
||||
/* ip6->ip6_src must be equal to gw for icmp6->icmp6_reddst */
|
||||
struct nhop6_basic nh6;
|
||||
|
||||
if (fib6_lookup_nh_basic(RT_DEFAULT_FIB, &reddst6, 0, 0, &nh6)==0) {
|
||||
if (fib6_lookup_nh(RT_DEFAULT_FIB, &reddst6, 0, 0, 0, &nh6)==0) {
|
||||
/* XXX: Think about AF_LINK GW */
|
||||
if ((nh6.nh_flags & NHF_GATEWAY) == 0) {
|
||||
nd6log((LOG_ERR,
|
||||
|
@ -2188,7 +2188,7 @@ in6_lltable_rtcheck(struct ifnet *ifp,
|
||||
/* Our local addresses are always only installed on the default FIB. */
|
||||
|
||||
in6_splitscope(&((struct sockaddr_in6 *)l3addr)->sin6_addr, &dst, &scopeid);
|
||||
error = fib6_lookup_nh_ifp(RT_DEFAULT_FIB, &dst, scopeid, 0, &nh6);
|
||||
error = fib6_lookup_nh(RT_DEFAULT_FIB, &dst, scopeid, 0, 0, &nh6);
|
||||
if (error != 0 || ((nh6.nh_flags & NHF_GATEWAY) != 0) || nh6.nh_ifp != ifp) {
|
||||
struct ifaddr *ifa;
|
||||
/*
|
||||
|
@ -203,7 +203,7 @@ gif_validate6(const struct ip6_hdr *ip6, struct gif_softc *sc,
|
||||
fibnum = sc->gif_fibnum;
|
||||
in6_splitscope(&ip6->ip6_src, &src, &scopeid);
|
||||
|
||||
if (fib6_lookup_nh_basic(fibnum, &src, scopeid, 0, &nh6) != 0)
|
||||
if (fib6_lookup_nh(fibnum, &src, scopeid, 0, 0, &nh6) != 0)
|
||||
return (0);
|
||||
if (nh6.nh_ifp != ifp)
|
||||
return (0);
|
||||
|
@ -1786,7 +1786,7 @@ in6p_lookup_mcast_ifp(const struct inpcb *in6p,
|
||||
|
||||
in6_splitscope(&gsin6->sin6_addr, &dst, &scopeid);
|
||||
fibnum = in6p ? in6p->inp_inc.inc_fibnum : RT_DEFAULT_FIB;
|
||||
if (fib6_lookup_nh_ifp(fibnum, &dst, scopeid, 0, &nh6) != 0)
|
||||
if (fib6_lookup_nh(fibnum, &dst, scopeid, 0, 0, &nh6) != 0)
|
||||
return (NULL);
|
||||
|
||||
return (nh6.nh_ifp);
|
||||
|
@ -797,7 +797,7 @@ in6_selectif(uint32_t fibnum, struct sockaddr_in6 *dstsock,
|
||||
* XXX: Embedded form?
|
||||
*/
|
||||
in6_splitscope(&sin6_next->sin6_addr, &dst, &scopeid);
|
||||
if (fib6_lookup_nh_basic(fibnum, &dst, scopeid, 0, &nh6) != 0) {
|
||||
if (fib6_lookup_nh(fibnum, &dst, scopeid, 0, 0, &nh6) != 0) {
|
||||
error = EHOSTUNREACH;
|
||||
goto done;
|
||||
}
|
||||
@ -815,7 +815,7 @@ in6_selectif(uint32_t fibnum, struct sockaddr_in6 *dstsock,
|
||||
}
|
||||
|
||||
/* Do route lookup */
|
||||
if (fib6_lookup_nh_basic(fibnum, &dst, scopeid, 0, &nh6) != 0) {
|
||||
if (fib6_lookup_nh(fibnum, &dst, scopeid, 0, 0, &nh6) != 0) {
|
||||
error = EHOSTUNREACH;
|
||||
goto done;
|
||||
}
|
||||
@ -829,8 +829,6 @@ in6_selectif(uint32_t fibnum, struct sockaddr_in6 *dstsock,
|
||||
* (this may happen when we are sending a packet to one of
|
||||
* our own addresses.)
|
||||
*
|
||||
* XXX: basic_ means we return "proper" interface address.
|
||||
*
|
||||
*/
|
||||
if (opts && opts->ip6po_pktinfo && opts->ip6po_pktinfo->ipi6_ifindex) {
|
||||
if (!(ifp->if_flags & IFF_LOOPBACK) &&
|
||||
|
@ -1868,8 +1868,8 @@ do { \
|
||||
* the outgoing interface.
|
||||
* TODO: embedded, Multipath
|
||||
*/
|
||||
if (fib6_lookup_nh_basic(so->so_fibnum,
|
||||
&in6p->in6p_faddr, 0, 0, &nh6) != 0) {
|
||||
if (fib6_lookup_nh(so->so_fibnum,
|
||||
&in6p->in6p_faddr, 0, 0, 0, &nh6) != 0) {
|
||||
error = EHOSTUNREACH;
|
||||
break;
|
||||
}
|
||||
|
@ -440,7 +440,7 @@ verify_path(struct in_addr src, struct ifnet *ifp, u_int fib)
|
||||
#else
|
||||
struct nhop4_basic nh4;
|
||||
|
||||
if (fib4_lookup_nh_basic(fib, src, 0, &nh4) != 0)
|
||||
if (fib4_lookup_nh(fib, src, 0, NHOP_LOOKUP_AIFP, &nh4) != 0)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
@ -519,7 +519,7 @@ verify_path6(struct in6_addr *src, struct ifnet *ifp, u_int fib)
|
||||
struct nhop6_basic nh6;
|
||||
|
||||
/* XXX: unembed scope? */
|
||||
if (fib6_lookup_nh_basic(fib, src, 0, 0, &nh6) != 0)
|
||||
if (fib6_lookup_nh(fib, src, 0, 0, NHOP_LOOKUP_AIFP, &nh6) != 0)
|
||||
return (0);
|
||||
|
||||
/* If ifp is provided, check for equality with route table. */
|
||||
|
@ -2915,15 +2915,14 @@ pf_calc_mss(struct pf_addr *addr, sa_family_t af, int rtableid, u_int16_t offer)
|
||||
#ifdef INET
|
||||
case AF_INET:
|
||||
hlen = sizeof(struct ip);
|
||||
if (fib4_lookup_nh_basic(rtableid, addr->v4, 0, &nh.u.nh4) == 0)
|
||||
if (fib4_lookup_nh(rtableid, addr->v4, 0, 0, &nh.u.nh4) == 0)
|
||||
mss = nh.u.nh4.nh_mtu - hlen - sizeof(struct tcphdr);
|
||||
break;
|
||||
#endif /* INET */
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
hlen = sizeof(struct ip6_hdr);
|
||||
if (fib6_lookup_nh_basic(rtableid, &addr->v6, 0, 0, &nh.u.nh6)
|
||||
== 0)
|
||||
if (fib6_lookup_nh(rtableid, &addr->v6, 0, 0, 0, &nh.u.nh6)==0)
|
||||
mss = nh.u.nh6.nh_mtu - hlen - sizeof(struct tcphdr);
|
||||
break;
|
||||
#endif /* INET6 */
|
||||
@ -5100,14 +5099,13 @@ pf_routable(struct pf_addr *addr, sa_family_t af, struct pfi_kif *kif,
|
||||
*/
|
||||
if (IN6_IS_SCOPE_EMBED(&addr->v6))
|
||||
return (1);
|
||||
if (fib6_lookup_nh_basic(rtableid, &addr->v6, 0, 0, &nh.u.nh6)
|
||||
!= 0)
|
||||
if (fib6_lookup_nh(rtableid, &addr->v6, 0, 0, 0, &nh.u.nh6)!=0)
|
||||
return (0);
|
||||
break;
|
||||
#endif
|
||||
#ifdef INET
|
||||
case AF_INET:
|
||||
if (fib4_lookup_nh_basic(rtableid, addr->v4, 0, &nh.u.nh4) != 0)
|
||||
if (fib4_lookup_nh(rtableid, addr->v4, 0, 0, &nh.u.nh4) != 0)
|
||||
return (0);
|
||||
break;
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user