* Increase nh_flags to be u16 thus reducing nhop payload to be 48 bytes
* Use NHF_ namespace for all nhop flags * Rename nhop_data -> nhop_prepend * Rename fib4_lookup_nh_extended -> fib4_lookup_nh_ext * Add "flags" argument to fib4_lookup_nh_ext() to specify whether we want returned nh_ext structure to be refcounted or not.
This commit is contained in:
parent
7de36f627e
commit
9f65116cc1
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/projects/routing/; revision=273639
@ -122,7 +122,7 @@ static void ether_reassign(struct ifnet *, struct vnet *, char *);
|
||||
|
||||
int ether_output_full(struct ifnet *ifp, struct mbuf *m,
|
||||
const struct sockaddr *dst, struct route *ro);
|
||||
int ether_output2(struct ifnet *ifp, struct mbuf *m, struct nhop_data *nh,
|
||||
int ether_output2(struct ifnet *ifp, struct mbuf *m, struct nhop_prepend *nh,
|
||||
int af);
|
||||
|
||||
static int loopback_frame(struct ifnet *ifp, struct mbuf *m, int family,
|
||||
@ -157,7 +157,7 @@ ether_output(struct ifnet *ifp, struct mbuf *m,
|
||||
const struct sockaddr *dst, struct route *ro)
|
||||
{
|
||||
if (ro != NULL && (ro->ro_flags & RT_NHOP))
|
||||
return (ether_output2(ifp, m, (struct nhop_data *)ro->ro_lle,
|
||||
return (ether_output2(ifp, m, (struct nhop_prepend *)ro->ro_lle,
|
||||
(ro->ro_flags >> 8) & 0xFF));
|
||||
|
||||
return (ether_output_full(ifp, m, dst, ro));
|
||||
@ -354,7 +354,7 @@ bad: if (m != NULL)
|
||||
* so the only reason to push packet (copy) to host is M_BCAST flag.
|
||||
*/
|
||||
int
|
||||
ether_output2(struct ifnet *ifp, struct mbuf *m, struct nhop_data *nh, int af)
|
||||
ether_output2(struct ifnet *ifp, struct mbuf *m, struct nhop_prepend *nh,int af)
|
||||
{
|
||||
int error;
|
||||
|
||||
|
@ -109,6 +109,7 @@ int fwd_attach_fib(struct fwd_module *fm, u_int fib);
|
||||
int fwd_destroy_fib(struct fwd_module *fm, u_int fib);
|
||||
#endif
|
||||
|
||||
static inline uint16_t fib_rte_to_nh_flags(int rt_flags);
|
||||
#ifdef INET
|
||||
static void fib4_rte_to_nh_extended(struct rtentry *rte, struct in_addr dst,
|
||||
struct nhop4_extended *pnh4);
|
||||
@ -145,7 +146,6 @@ MALLOC_DEFINE(M_RTFIB, "rtfib", "routing fwd");
|
||||
* Returns 0 on match, error code overwise.
|
||||
*/
|
||||
|
||||
#define NHOP_FLAGS_MASK (RTF_REJECT|RTF_BLACKHOLE)
|
||||
//#define NHOP_DIRECT
|
||||
#define RNTORT(p) ((struct rtentry *)(p))
|
||||
|
||||
@ -159,13 +159,13 @@ MALLOC_DEFINE(M_RTFIB, "rtfib", "routing fwd");
|
||||
*
|
||||
*/
|
||||
static inline void
|
||||
fib_choose_prepend(uint32_t fibnum, struct nhop_data *nh_src,
|
||||
uint32_t flowid, struct nhop_data *nh, int af)
|
||||
fib_choose_prepend(uint32_t fibnum, struct nhop_prepend *nh_src,
|
||||
uint32_t flowid, struct nhop_prepend *nh, int af)
|
||||
{
|
||||
struct nhop_multi *nh_multi;
|
||||
int idx;
|
||||
|
||||
if ((nh_src->nh_flags & NH_FLAGS_RECURSE) != 0) {
|
||||
if ((nh_src->nh_flags & NHF_RECURSE) != 0) {
|
||||
|
||||
/*
|
||||
* Recursive nexthop. Choose direct nexthop
|
||||
@ -185,7 +185,7 @@ fib_choose_prepend(uint32_t fibnum, struct nhop_data *nh_src,
|
||||
}
|
||||
|
||||
static inline void
|
||||
fib_free_nh(uint32_t fibnum, struct nhop_data *nh, int af)
|
||||
fib_free_nh_prepend(uint32_t fibnum, struct nhop_prepend *nh, int af)
|
||||
{
|
||||
|
||||
/* TODO: Do some light-weight refcounting on egress ifp's */
|
||||
@ -193,15 +193,15 @@ fib_free_nh(uint32_t fibnum, struct nhop_data *nh, int af)
|
||||
|
||||
#ifdef INET
|
||||
void
|
||||
fib4_free_nh(uint32_t fibnum, struct nhop_data *nh)
|
||||
fib4_free_nh_prepend(uint32_t fibnum, struct nhop_prepend *nh)
|
||||
{
|
||||
|
||||
fib_free_nh(fibnum, nh, AF_INET);
|
||||
fib_free_nh_prepend(fibnum, nh, AF_INET);
|
||||
}
|
||||
|
||||
void
|
||||
fib4_choose_prepend(uint32_t fibnum, struct nhop_data *nh_src,
|
||||
uint32_t flowid, struct nhop_data *nh, struct nhop4_extended *nh_ext)
|
||||
fib4_choose_prepend(uint32_t fibnum, struct nhop_prepend *nh_src,
|
||||
uint32_t flowid, struct nhop_prepend *nh, struct nhop4_extended *nh_ext)
|
||||
{
|
||||
|
||||
fib_choose_prepend(fibnum, nh_src, flowid, nh, AF_INET);
|
||||
@ -224,7 +224,7 @@ fib4_choose_prepend(uint32_t fibnum, struct nhop_data *nh_src,
|
||||
* In case of successful lookup @nh header is filled with
|
||||
* appropriate interface info and full L2 header to prepend.
|
||||
*
|
||||
* If no valid ARP record is present, NH_FLAGS_L2_INCOMPLETE flag
|
||||
* If no valid ARP record is present, NHF_L2_INCOMPLETE flag
|
||||
* is set and gateway address is stored into nh->d.gw4
|
||||
*
|
||||
* If @nh_ext is not NULL, additional nexthop data is stored there.
|
||||
@ -234,7 +234,7 @@ fib4_choose_prepend(uint32_t fibnum, struct nhop_data *nh_src,
|
||||
*/
|
||||
int
|
||||
fib4_lookup_prepend(uint32_t fibnum, struct in_addr dst, struct mbuf *m,
|
||||
struct nhop_data *nh, struct nhop4_extended *nh_ext)
|
||||
struct nhop_prepend *nh, struct nhop4_extended *nh_ext)
|
||||
{
|
||||
struct radix_node_head *rnh;
|
||||
struct radix_node *rn;
|
||||
@ -279,10 +279,10 @@ fib4_lookup_prepend(uint32_t fibnum, struct in_addr dst, struct mbuf *m,
|
||||
} else
|
||||
gw = dst;
|
||||
/* Set flags */
|
||||
flags = rte->rt_flags & NHOP_FLAGS_MASK;
|
||||
flags = fib_rte_to_nh_flags(rte->rt_flags);
|
||||
gw_sa = (struct sockaddr_in *)rt_key(rte);
|
||||
if (gw_sa->sin_addr.s_addr == 0)
|
||||
flags |= NHOP_DEFAULT;
|
||||
flags |= NHF_DEFAULT;
|
||||
|
||||
/*
|
||||
* TODO: nh L2/L3 resolve.
|
||||
@ -327,19 +327,19 @@ fib4_lookup_prepend(uint32_t fibnum, struct in_addr dst, struct mbuf *m,
|
||||
|
||||
/* Notify caller that no L2 info is linked */
|
||||
nh->nh_count = 0;
|
||||
nh->nh_flags |= NH_FLAGS_L2_INCOMPLETE;
|
||||
nh->nh_flags |= NHF_L2_INCOMPLETE;
|
||||
/* ..And save gateway address */
|
||||
nh->d.gw4 = gw;
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
fib4_sendmbuf(struct ifnet *ifp, struct mbuf *m, struct nhop_data *nh,
|
||||
fib4_sendmbuf(struct ifnet *ifp, struct mbuf *m, struct nhop_prepend *nh,
|
||||
struct in_addr dst)
|
||||
{
|
||||
int error;
|
||||
|
||||
if (nh != NULL && (nh->nh_flags & NH_FLAGS_L2_INCOMPLETE) == 0) {
|
||||
if (nh != NULL && (nh->nh_flags & NHF_L2_INCOMPLETE) == 0) {
|
||||
|
||||
/*
|
||||
* Fast path case. Most packets should
|
||||
@ -372,6 +372,19 @@ fib4_sendmbuf(struct ifnet *ifp, struct mbuf *m, struct nhop_data *nh,
|
||||
return (error);
|
||||
}
|
||||
|
||||
static inline uint16_t
|
||||
fib_rte_to_nh_flags(int rt_flags)
|
||||
{
|
||||
uint16_t res;
|
||||
|
||||
res = (rt_flags & RTF_REJECT) ? NHF_REJECT : 0;
|
||||
res |= (rt_flags & RTF_BLACKHOLE) ? NHF_BLACKHOLE : 0;
|
||||
res |= (rt_flags & (RTF_DYNAMIC|RTF_MODIFIED)) ? NHF_REDIRECT : 0;
|
||||
res |= (rt_flags & RTF_BROADCAST) ? NHF_BROADCAST : 0;
|
||||
|
||||
return (res);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
fib4_rte_to_nh_extended(struct rtentry *rte, struct in_addr dst,
|
||||
@ -392,12 +405,10 @@ fib4_rte_to_nh_extended(struct rtentry *rte, struct in_addr dst,
|
||||
pnh4->nh_src = IA_SIN(ia)->sin_addr;
|
||||
|
||||
/* Set flags */
|
||||
pnh4->nh_flags = rte->rt_flags & NHOP_FLAGS_MASK;
|
||||
if (rte->rt_flags & (RTF_DYNAMIC|RTF_MODIFIED))
|
||||
pnh4->nh_flags |= NHOP_REDIRECT;
|
||||
pnh4->nh_flags = fib_rte_to_nh_flags(rte->rt_flags);
|
||||
gw = (struct sockaddr_in *)rt_key(rte);
|
||||
if (gw->sin_addr.s_addr == 0)
|
||||
pnh4->nh_flags |= NHOP_DEFAULT;
|
||||
pnh4->nh_flags |= NHF_DEFAULT;
|
||||
}
|
||||
|
||||
|
||||
@ -415,14 +426,22 @@ fib4_rte_to_nh_basic(struct rtentry *rte, struct in_addr dst,
|
||||
} else
|
||||
pnh4->nh_addr = dst;
|
||||
/* Set flags */
|
||||
pnh4->nh_flags = rte->rt_flags & NHOP_FLAGS_MASK;
|
||||
if (rte->rt_flags & (RTF_DYNAMIC|RTF_MODIFIED))
|
||||
pnh4->nh_flags |= NHOP_REDIRECT;
|
||||
pnh4->nh_flags = fib_rte_to_nh_flags(rte->rt_flags);
|
||||
gw = (struct sockaddr_in *)rt_key(rte);
|
||||
if (gw->sin_addr.s_addr == 0)
|
||||
pnh4->nh_flags |= NHOP_DEFAULT;
|
||||
pnh4->nh_flags |= NHF_DEFAULT;
|
||||
}
|
||||
|
||||
/*
|
||||
* Performs IPv4 route table lookup on @dst. Returns 0 on success.
|
||||
* Stores nexthop info provided @pnh4 structure.
|
||||
* Note that
|
||||
* - nh_ifp cannot be safely dereferenced
|
||||
* - nh_ifp represents ifaddr 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.
|
||||
*/
|
||||
int
|
||||
fib4_lookup_nh_basic(uint32_t fibnum, struct in_addr dst, uint32_t flowid,
|
||||
struct nhop4_basic *pnh4)
|
||||
@ -459,16 +478,25 @@ fib4_lookup_nh_basic(uint32_t fibnum, struct in_addr dst, uint32_t flowid,
|
||||
return (ENOENT);
|
||||
}
|
||||
|
||||
/*
|
||||
* Performs IPv4 route table lookup on @dst. Returns 0 on success.
|
||||
* Stores extende nexthop info provided @pnh4 structure.
|
||||
* Note that
|
||||
* - nh_ifp cannot be safely dereferenced unless NHOP_LOOKUP_REF is specified.
|
||||
* - in that case you need to call fib4_free_nh_ext()
|
||||
* - nh_ifp represents logical transmit interface (rt_ifp)
|
||||
* - mtu from logical transmit interface will be returned.
|
||||
*/
|
||||
int
|
||||
fib4_lookup_nh_extended(uint32_t fibnum, struct in_addr dst, uint32_t flowid,
|
||||
struct nhop4_extended *pnh4)
|
||||
fib4_lookup_nh_ext(uint32_t fibnum, struct in_addr dst, uint32_t flowid,
|
||||
uint32_t flags, struct nhop4_extended *pnh4)
|
||||
{
|
||||
struct radix_node_head *rnh;
|
||||
struct radix_node *rn;
|
||||
struct sockaddr_in sin;
|
||||
struct rtentry *rte;
|
||||
|
||||
KASSERT((fibnum < rt_numfibs), ("fib4_lookup_nh_basic: bad fibnum"));
|
||||
KASSERT((fibnum < rt_numfibs), ("fib4_lookup_nh_ext: bad fibnum"));
|
||||
rnh = rt_tables_get_rnh(fibnum, AF_INET);
|
||||
if (rnh == NULL)
|
||||
return (ENOENT);
|
||||
@ -485,6 +513,9 @@ fib4_lookup_nh_extended(uint32_t fibnum, struct in_addr dst, uint32_t flowid,
|
||||
/* Ensure route & ifp is UP */
|
||||
if (RT_LINK_IS_UP(rte->rt_ifp)) {
|
||||
fib4_rte_to_nh_extended(rte, dst, pnh4);
|
||||
if ((flags & NHOP_LOOKUP_REF) != 0) {
|
||||
/* TODO: Do lwref on egress ifp's */
|
||||
}
|
||||
RADIX_NODE_HEAD_RUNLOCK(rnh);
|
||||
|
||||
return (0);
|
||||
@ -505,15 +536,15 @@ fib4_free_nh_ext(uint32_t fibnum, struct nhop4_extended *pnh4)
|
||||
|
||||
#ifdef INET6
|
||||
void
|
||||
fib6_free_nh(uint32_t fibnum, struct nhop_data *nh)
|
||||
fib6_free_nh_prepend(uint32_t fibnum, struct nhop_prepend *nh)
|
||||
{
|
||||
|
||||
fib_free_nh(fibnum, nh, AF_INET6);
|
||||
fib_free_nh_prepend(fibnum, nh, AF_INET6);
|
||||
}
|
||||
|
||||
void
|
||||
fib6_choose_prepend(uint32_t fibnum, struct nhop_data *nh_src,
|
||||
uint32_t flowid, struct nhop_data *nh, struct nhop6_extended *nh_ext)
|
||||
fib6_choose_prepend(uint32_t fibnum, struct nhop_prepend *nh_src,
|
||||
uint32_t flowid, struct nhop_prepend *nh, struct nhop6_extended *nh_ext)
|
||||
{
|
||||
|
||||
fib_choose_prepend(fibnum, nh_src, flowid, nh, AF_INET6);
|
||||
@ -544,10 +575,10 @@ fib6_rte_to_nh_basic(struct rtentry *rte, struct in6_addr dst,
|
||||
} else
|
||||
pnh6->nh_addr = dst;
|
||||
/* Set flags */
|
||||
pnh6->nh_flags = rte->rt_flags & NHOP_FLAGS_MASK;
|
||||
pnh6->nh_flags = fib_rte_to_nh_flags(rte->rt_flags);
|
||||
gw = (struct sockaddr_in6 *)rt_key(rte);
|
||||
if (IN6_IS_ADDR_UNSPECIFIED(&gw->sin6_addr))
|
||||
pnh6->nh_flags |= NHOP_DEFAULT;
|
||||
pnh6->nh_flags |= NHF_DEFAULT;
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -52,27 +52,29 @@ struct nhop_mpath_info {
|
||||
|
||||
/* mutator info */
|
||||
struct nhop_mutator_info;
|
||||
struct nhop_data;
|
||||
struct nhop_prepend;
|
||||
|
||||
typedef int nhop_mutate_t(struct mbuf **, struct nhop_data *nd, void *storage);
|
||||
typedef int nhop_mutate_t(struct mbuf **, struct nhop_prepend *nd, void *storage);
|
||||
struct nhop_mutator_info {
|
||||
nhop_mutate_t *func;
|
||||
char data[];
|
||||
};
|
||||
|
||||
/* Structures used for forwarding purposes */
|
||||
#define MAX_PREPEND_LEN 56 /* Max data that can be prepended */
|
||||
#define MAX_PREPEND_LEN 48 /* Max data that can be prepended */
|
||||
|
||||
/* Non-recursive nexthop */
|
||||
struct nhop_data {
|
||||
uint8_t nh_flags; /* NH flags */
|
||||
uint8_t nh_count; /* Number of nexthops or data length */
|
||||
struct nhop_prepend {
|
||||
uint16_t nh_flags; /* NH flags */
|
||||
uint8_t nh_count; /* Number of nexthops or data length */
|
||||
uint8_t spare0;
|
||||
uint16_t nh_mtu; /* given nhop MTU */
|
||||
uint16_t lifp_idx; /* Logical interface index */
|
||||
union {
|
||||
uint16_t ifp_idx; /* Transmit interface index */
|
||||
uint16_t nhop_idx; /* L2 multipath nhop index */
|
||||
} i;
|
||||
uint16_t spare1[3];
|
||||
union {
|
||||
char data[MAX_PREPEND_LEN]; /* data to prepend */
|
||||
#ifdef INET
|
||||
@ -83,11 +85,19 @@ struct nhop_data {
|
||||
#endif
|
||||
} d;
|
||||
};
|
||||
|
||||
/* Internal flags */
|
||||
#define NH_FLAGS_RECURSE 0x01 /* Nexthop structure is recursive */
|
||||
#define NH_FLAGS_L2_NHOP 0x02 /* L2 interface has to be selected */
|
||||
#define NH_FLAGS_L2_ME 0x04 /* dst L2 address is our address */
|
||||
#define NH_FLAGS_L2_INCOMPLETE 0x08 /* L2 header not prepended */
|
||||
#define NHF_RECURSE 0x0001 /* Nexthop structure is recursive */
|
||||
#define NHF_L2_NHOP 0x0002 /* L2 interface has to be selected */
|
||||
#define NHF_L2_ME 0x0004 /* dst L2 address is our address */
|
||||
#define NHF_L2_INCOMPLETE 0x0008 /* L2 header not prepended */
|
||||
|
||||
/* External flags */
|
||||
#define NHF_REJECT 0x0010 /* RTF_REJECT */
|
||||
#define NHF_BLACKHOLE 0x0020 /* RTF_BLACKHOLE */
|
||||
#define NHF_REDIRECT 0x0040 /* RTF_DYNAMIC|RTF_MODIFIED */
|
||||
#define NHF_DEFAULT 0x0080 /* Default route */
|
||||
#define NHF_BROADCAST 0x0100 /* RTF_BROADCAST */
|
||||
|
||||
#define NH_LIFP(nh) ifnet_byindex_locked((nh)->lifp_idx)
|
||||
#define NH_TIFP(nh) ifnet_byindex_locked((nh)->i.ifp_idx)
|
||||
@ -114,7 +124,7 @@ struct nhops_descr {
|
||||
|
||||
|
||||
#if 0
|
||||
typedef int nhop_resolve_t(struct sockaddr *dst, u_int fib, struct nhop_data *nd, struct nhop_info *nf);
|
||||
typedef int nhop_resolve_t(struct sockaddr *dst, u_int fib, struct nhop_prepend *nd, struct nhop_info *nf);
|
||||
|
||||
|
||||
|
||||
@ -174,14 +184,14 @@ struct nhop64_extended {
|
||||
};
|
||||
|
||||
struct route_info {
|
||||
struct nhop_data *ri_nh; /* Desired nexthop to use */
|
||||
struct nhop_prepend *ri_nh; /* Desired nexthop to use */
|
||||
struct nhop64_basic *ri_nh_info; /* Get selected route info */
|
||||
uint16_t ri_mtu;
|
||||
uint16_t spare[3];
|
||||
};
|
||||
|
||||
struct route_compat {
|
||||
struct nhop_data *ro_nh;
|
||||
struct nhop_prepend *ro_nh;
|
||||
void *spare0;
|
||||
void *spare1;
|
||||
int ro_flags;
|
||||
@ -192,27 +202,23 @@ int fib4_lookup_nh_basic(uint32_t fibnum, struct in_addr dst, uint32_t flowid,
|
||||
int fib6_lookup_nh_basic(uint32_t fibnum, struct in6_addr dst, uint32_t flowid,
|
||||
struct nhop6_basic *pnh6);
|
||||
|
||||
int fib4_lookup_nh_extended(uint32_t fibnum, struct in_addr dst,
|
||||
uint32_t flowid, struct nhop4_extended *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
|
||||
|
||||
void fib4_free_nh(uint32_t fibnum, struct nhop_data *nh);
|
||||
void fib4_choose_prepend(uint32_t fibnum, struct nhop_data *nh_src,
|
||||
uint32_t flowid, struct nhop_data *nh, struct nhop4_extended *nh_ext);
|
||||
void fib4_free_nh_prepend(uint32_t fibnum, struct nhop_prepend *nh);
|
||||
void fib4_choose_prepend(uint32_t fibnum, struct nhop_prepend *nh_src,
|
||||
uint32_t flowid, struct nhop_prepend *nh, struct nhop4_extended *nh_ext);
|
||||
int fib4_lookup_prepend(uint32_t fibnum, struct in_addr dst, struct mbuf *m,
|
||||
struct nhop_data *nh, struct nhop4_extended *nh_ext);
|
||||
struct nhop_prepend *nh, struct nhop4_extended *nh_ext);
|
||||
|
||||
int fib4_sendmbuf(struct ifnet *ifp, struct mbuf *m, struct nhop_data *nh,
|
||||
int fib4_sendmbuf(struct ifnet *ifp, struct mbuf *m, struct nhop_prepend *nh,
|
||||
struct in_addr dst);
|
||||
|
||||
void fib6_free_nh(uint32_t fibnum, struct nhop_data *nh);
|
||||
void fib6_choose_prepend(uint32_t fibnum, struct nhop_data *nh_src,
|
||||
uint32_t flowid, struct nhop_data *nh, struct nhop6_extended *nh_ext);
|
||||
|
||||
#define NHOP_REJECT 0x08 /* RTF_REJECT */
|
||||
#define NHOP_BLACKHOLE 0x1000 /* RTF_BLACKHOLE */
|
||||
#define NHOP_REDIRECT 0x10 /* RTF_DYNAMIC|RTF_MODIFIED */
|
||||
#define NHOP_DEFAULT 0x80 /* Default route */
|
||||
void fib6_free_nh_prepend(uint32_t fibnum, struct nhop_prepend *nh);
|
||||
void fib6_choose_prepend(uint32_t fibnum, struct nhop_prepend *nh_src,
|
||||
uint32_t flowid, struct nhop_prepend *nh, struct nhop6_extended *nh_ext);
|
||||
|
||||
#define FWD_INET 0
|
||||
#define FWD_INET6 1
|
||||
|
@ -887,7 +887,7 @@ in_arpinput(struct mbuf *m)
|
||||
|
||||
sin.sin_addr = itaddr;
|
||||
/* XXX MRT use table 0 for arp reply */
|
||||
if (fib4_lookup_nh_extended(0, itaddr, 0, &nh_ext) != 0)
|
||||
if (fib4_lookup_nh_ext(0, itaddr, 0, 0, &nh_ext) != 0)
|
||||
goto drop;
|
||||
|
||||
/*
|
||||
@ -910,7 +910,7 @@ in_arpinput(struct mbuf *m)
|
||||
sin.sin_addr = isaddr;
|
||||
|
||||
/* XXX MRT use table 0 for arp checks */
|
||||
if (fib4_lookup_nh_extended(0, isaddr, 0, &nh_ext) != 0)
|
||||
if (fib4_lookup_nh_ext(0, isaddr, 0, 0, &nh_ext) != 0)
|
||||
goto drop;
|
||||
if (nh_ext.nh_ifp != ifp) {
|
||||
ARP_LOG(LOG_INFO, "proxy: ignoring request"
|
||||
|
@ -782,7 +782,8 @@ in_pcbladdr(struct inpcb *inp, struct in_addr *faddr, struct in_addr *laddr,
|
||||
pnh4 = &nh_ext;
|
||||
memset(&nh_ext, 0, sizeof(nh_ext));
|
||||
if ((inp->inp_socket->so_options & SO_DONTROUTE) == 0)
|
||||
error = fib4_lookup_nh_extended(fibnum, *faddr, 0, &nh_ext);
|
||||
error = fib4_lookup_nh_ext(fibnum, *faddr, 0, NHOP_LOOKUP_REF,
|
||||
&nh_ext);
|
||||
if (error != 0) {
|
||||
pnh4 = NULL;
|
||||
error = 0;
|
||||
|
@ -128,7 +128,7 @@ ip_fastforward(struct mbuf *m)
|
||||
{
|
||||
struct ip *ip;
|
||||
struct mbuf *m0 = NULL;
|
||||
struct nhop_data nhd, *pnhd;
|
||||
struct nhop_prepend nhd, *pnhd;
|
||||
struct ifnet *ifp;
|
||||
struct in_addr odest, dest;
|
||||
uint16_t sum, ip_len, ip_off;
|
||||
@ -395,7 +395,7 @@ ip_fastforward(struct mbuf *m)
|
||||
* for either the all-ones or all-zero subnet addresses on
|
||||
* locally attached networks.
|
||||
*/
|
||||
if ((nhd.nh_flags & (NHOP_BLACKHOLE|RTF_BROADCAST)) != 0)
|
||||
if ((nhd.nh_flags & (NHF_BLACKHOLE|NHF_BROADCAST)) != 0)
|
||||
goto drop;
|
||||
|
||||
/*
|
||||
@ -434,7 +434,7 @@ ip_fastforward(struct mbuf *m)
|
||||
*/
|
||||
m->m_flags |= M_FASTFWD_OURS;
|
||||
if (pnhd != NULL)
|
||||
fib4_free_nh(fibnum, pnhd);
|
||||
fib4_free_nh_prepend(fibnum, pnhd);
|
||||
return m;
|
||||
}
|
||||
/*
|
||||
@ -446,7 +446,7 @@ ip_fastforward(struct mbuf *m)
|
||||
m_tag_delete(m, fwd_tag);
|
||||
m->m_flags &= ~M_IP_NEXTHOP;
|
||||
}
|
||||
fib4_free_nh(fibnum, pnhd);
|
||||
fib4_free_nh_prepend(fibnum, pnhd);
|
||||
|
||||
|
||||
if (fib4_lookup_prepend(fibnum, dest, m, &nhd, NULL) != 0) {
|
||||
@ -476,7 +476,7 @@ ip_fastforward(struct mbuf *m)
|
||||
goto consumed;
|
||||
}
|
||||
#endif
|
||||
if ((nhd.nh_flags & NHOP_REJECT) != 0) {
|
||||
if ((nhd.nh_flags & NHF_REJECT) != 0) {
|
||||
icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_HOST, 0, 0);
|
||||
goto consumed;
|
||||
}
|
||||
@ -568,12 +568,12 @@ ip_fastforward(struct mbuf *m)
|
||||
IPSTAT_INC(ips_fastforward);
|
||||
}
|
||||
consumed:
|
||||
fib4_free_nh(fibnum, &nhd);
|
||||
fib4_free_nh_prepend(fibnum, &nhd);
|
||||
return NULL;
|
||||
drop:
|
||||
if (m)
|
||||
m_freem(m);
|
||||
if (pnhd != NULL)
|
||||
fib4_free_nh(fibnum, pnhd);
|
||||
fib4_free_nh_prepend(fibnum, pnhd);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -804,7 +804,7 @@ icmp_reflect(struct mbuf *m)
|
||||
* When we don't have a route back to the packet source, stop here
|
||||
* and drop the packet.
|
||||
*/
|
||||
if (fib4_lookup_nh_extended(M_GETFIB(m), ip->ip_dst, 0, &nh_ext) != 0) {
|
||||
if (fib4_lookup_nh_ext(M_GETFIB(m), ip->ip_dst, 0, 0, &nh_ext) != 0) {
|
||||
m_freem(m);
|
||||
ICMPSTAT_INC(icps_noroute);
|
||||
goto done;
|
||||
|
@ -1533,7 +1533,7 @@ ip_forward(struct mbuf *m, int srcrt)
|
||||
if (!srcrt && V_ipsendredirects &&
|
||||
pnh4 != NULL && nh4.nh_ifp == m->m_pkthdr.rcvif) {
|
||||
|
||||
if ((nh4.nh_flags & (NHOP_REDIRECT|NHOP_DEFAULT)) == 0) {
|
||||
if ((nh4.nh_flags & (NHF_REDIRECT|NHF_DEFAULT)) == 0) {
|
||||
dest = nh4.nh_addr;
|
||||
/*Router requirements says to only send host redirects*/
|
||||
type = ICMP_REDIRECT;
|
||||
|
@ -249,8 +249,8 @@ ip_dooptions(struct mbuf *m, int pass)
|
||||
ifa_free(&ia->ia_ifa);
|
||||
} else {
|
||||
/* XXX MRT 0 for routing */
|
||||
if (fib4_lookup_nh_extended(M_GETFIB(m),
|
||||
ipaddr.sin_addr, 0, &nh_ext) != 0) {
|
||||
if (fib4_lookup_nh_ext(M_GETFIB(m),
|
||||
ipaddr.sin_addr, 0, 0, &nh_ext) != 0) {
|
||||
type = ICMP_UNREACH;
|
||||
code = ICMP_UNREACH_SRCFAIL;
|
||||
goto bad;
|
||||
@ -297,8 +297,8 @@ ip_dooptions(struct mbuf *m, int pass)
|
||||
memcpy(cp + off, &(IA_SIN(ia)->sin_addr),
|
||||
sizeof(struct in_addr));
|
||||
ifa_free(&ia->ia_ifa);
|
||||
} else if (fib4_lookup_nh_extended(M_GETFIB(m),
|
||||
ipaddr.sin_addr, 0, &nh_ext) == 0) {
|
||||
} else if (fib4_lookup_nh_ext(M_GETFIB(m),
|
||||
ipaddr.sin_addr, 0, 0, &nh_ext) == 0) {
|
||||
memcpy(cp + off, &nh_ext.nh_src,
|
||||
sizeof(struct in_addr));
|
||||
} else {
|
||||
|
@ -132,7 +132,7 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route_info *ri, int flags,
|
||||
struct in_ifaddr *ia;
|
||||
int isbroadcast;
|
||||
uint16_t ip_len, ip_off;
|
||||
struct nhop_data local_nh, *nh;
|
||||
struct nhop_prepend local_nh, *nh;
|
||||
struct nhop4_extended nhe, *pnhe;
|
||||
struct in_addr odst;
|
||||
struct m_tag *fwd_tag = NULL;
|
||||
@ -244,7 +244,7 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route_info *ri, int flags,
|
||||
#endif
|
||||
|
||||
if (nh != NULL) {
|
||||
fib4_free_nh(fibnum, nh);
|
||||
fib4_free_nh_prepend(fibnum, nh);
|
||||
nh = NULL;
|
||||
}
|
||||
|
||||
@ -567,7 +567,7 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route_info *ri, int flags,
|
||||
}
|
||||
if (needfiblookup) {
|
||||
if (ri == NULL && nh != NULL) {
|
||||
fib4_free_nh(fibnum, nh);
|
||||
fib4_free_nh_prepend(fibnum, nh);
|
||||
nh = NULL;
|
||||
}
|
||||
ri = NULL;
|
||||
@ -716,7 +716,7 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route_info *ri, int flags,
|
||||
|
||||
done:
|
||||
if (ri == NULL && nh != NULL)
|
||||
fib4_free_nh(fibnum, nh);
|
||||
fib4_free_nh_prepend(fibnum, nh);
|
||||
return (error);
|
||||
bad:
|
||||
m_freem(m);
|
||||
|
@ -1804,8 +1804,8 @@ tcp_maxmtu(struct in_conninfo *inc, struct tcp_ifcap *cap)
|
||||
return (0);
|
||||
|
||||
memset(&nh_ext, 0, sizeof(nh_ext));
|
||||
error = fib4_lookup_nh_extended(inc->inc_fibnum, inc->inc_faddr, 0,
|
||||
&nh_ext);
|
||||
error = fib4_lookup_nh_ext(inc->inc_fibnum, inc->inc_faddr, 0,
|
||||
NHOP_LOOKUP_REF, &nh_ext);
|
||||
if (error == 0) {
|
||||
maxmtu = nh_ext.nh_mtu;
|
||||
|
||||
|
@ -451,11 +451,11 @@ verify_path(struct in_addr src, struct ifnet *ifp, u_int fib)
|
||||
return (0);
|
||||
|
||||
/* if no ifp provided, check if rtentry is not default route */
|
||||
if (ifp == NULL && (nh4.nh_flags & NHOP_DEFAULT) != 0)
|
||||
if (ifp == NULL && (nh4.nh_flags & NHF_DEFAULT) != 0)
|
||||
return (0);
|
||||
|
||||
/* or if this is a blackhole/reject route */
|
||||
if (ifp == NULL && (nh4.nh_flags & (NHOP_REJECT|NHOP_BLACKHOLE)) != 0)
|
||||
if (ifp == NULL && (nh4.nh_flags & (NHF_REJECT|NHF_BLACKHOLE)) != 0)
|
||||
return (0);
|
||||
|
||||
return (1);
|
||||
@ -523,11 +523,11 @@ verify_path6(struct in6_addr *src, struct ifnet *ifp, u_int fib)
|
||||
return (0);
|
||||
|
||||
/* if no ifp provided, check if rtentry is not default route */
|
||||
if (ifp == NULL && (nh6.nh_flags & NHOP_DEFAULT) != 0)
|
||||
if (ifp == NULL && (nh6.nh_flags & NHF_DEFAULT) != 0)
|
||||
return (0);
|
||||
|
||||
/* or if this is a blackhole/reject route */
|
||||
if (ifp == NULL && (nh6.nh_flags & (NHOP_REJECT|NHOP_BLACKHOLE)) != 0)
|
||||
if (ifp == NULL && (nh6.nh_flags & (NHF_REJECT|NHF_BLACKHOLE)) != 0)
|
||||
return (0);
|
||||
|
||||
return (1);
|
||||
|
Loading…
Reference in New Issue
Block a user