svn commit: r287054 - in projects/routing/sys: net netinet netpfil/ipfw
Alexander V. Chernikov
melifaro at FreeBSD.org
Sun Aug 23 18:20:31 UTC 2015
Author: melifaro
Date: Sun Aug 23 18:20:26 2015
New Revision: 287054
URL: https://svnweb.freebsd.org/changeset/base/287054
Log:
* 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.
Modified:
projects/routing/sys/net/if_ethersubr.c
projects/routing/sys/net/rt_nhops.c
projects/routing/sys/net/rt_nhops.h
projects/routing/sys/netinet/if_ether.c
projects/routing/sys/netinet/in_pcb.c
projects/routing/sys/netinet/ip_fastfwd.c
projects/routing/sys/netinet/ip_icmp.c
projects/routing/sys/netinet/ip_input.c
projects/routing/sys/netinet/ip_options.c
projects/routing/sys/netinet/ip_output.c
projects/routing/sys/netinet/tcp_subr.c
projects/routing/sys/netpfil/ipfw/ip_fw2.c
Modified: projects/routing/sys/net/if_ethersubr.c
==============================================================================
--- projects/routing/sys/net/if_ethersubr.c Sun Aug 23 18:19:25 2015 (r287053)
+++ projects/routing/sys/net/if_ethersubr.c Sun Aug 23 18:20:26 2015 (r287054)
@@ -117,7 +117,7 @@ static void ether_reassign(struct ifnet
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,
@@ -149,7 +149,7 @@ ether_output(struct ifnet *ifp, struct 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));
@@ -348,7 +348,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;
Modified: projects/routing/sys/net/rt_nhops.c
==============================================================================
--- projects/routing/sys/net/rt_nhops.c Sun Aug 23 18:19:25 2015 (r287053)
+++ projects/routing/sys/net/rt_nhops.c Sun Aug 23 18:20:26 2015 (r287054)
@@ -109,6 +109,7 @@ int fwd_attach_fib(struct fwd_module *fm
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
* 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
*
*/
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, stru
}
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
#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, str
* 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, str
*/
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, str
} 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, str
/* 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
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 *
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
} 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, st
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,
/* 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
#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
} 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
Modified: projects/routing/sys/net/rt_nhops.h
==============================================================================
--- projects/routing/sys/net/rt_nhops.h Sun Aug 23 18:19:25 2015 (r287053)
+++ projects/routing/sys/net/rt_nhops.h Sun Aug 23 18:20:26 2015 (r287054)
@@ -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
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
Modified: projects/routing/sys/netinet/if_ether.c
==============================================================================
--- projects/routing/sys/netinet/if_ether.c Sun Aug 23 18:19:25 2015 (r287053)
+++ projects/routing/sys/netinet/if_ether.c Sun Aug 23 18:20:26 2015 (r287054)
@@ -920,7 +920,7 @@ reply:
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;
/*
@@ -943,7 +943,7 @@ reply:
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"
Modified: projects/routing/sys/netinet/in_pcb.c
==============================================================================
--- projects/routing/sys/netinet/in_pcb.c Sun Aug 23 18:19:25 2015 (r287053)
+++ projects/routing/sys/netinet/in_pcb.c Sun Aug 23 18:20:26 2015 (r287054)
@@ -788,7 +788,8 @@ in_pcbladdr(struct inpcb *inp, struct in
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;
Modified: projects/routing/sys/netinet/ip_fastfwd.c
==============================================================================
--- projects/routing/sys/netinet/ip_fastfwd.c Sun Aug 23 18:19:25 2015 (r287053)
+++ projects/routing/sys/netinet/ip_fastfwd.c Sun Aug 23 18:20:26 2015 (r287054)
@@ -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 @@ passin:
* 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 @@ forwardlocal:
*/
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 @@ forwardlocal:
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 @@ passout:
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;
}
@@ -556,12 +556,12 @@ passout:
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;
}
Modified: projects/routing/sys/netinet/ip_icmp.c
==============================================================================
--- projects/routing/sys/netinet/ip_icmp.c Sun Aug 23 18:19:25 2015 (r287053)
+++ projects/routing/sys/netinet/ip_icmp.c Sun Aug 23 18:20:26 2015 (r287054)
@@ -751,7 +751,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;
Modified: projects/routing/sys/netinet/ip_input.c
==============================================================================
--- projects/routing/sys/netinet/ip_input.c Sun Aug 23 18:19:25 2015 (r287053)
+++ projects/routing/sys/netinet/ip_input.c Sun Aug 23 18:20:26 2015 (r287054)
@@ -969,7 +969,8 @@ ip_forward(struct mbuf *m, int srcrt)
dest.s_addr = 0;
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;
Modified: projects/routing/sys/netinet/ip_options.c
==============================================================================
--- projects/routing/sys/netinet/ip_options.c Sun Aug 23 18:19:25 2015 (r287053)
+++ projects/routing/sys/netinet/ip_options.c Sun Aug 23 18:20:26 2015 (r287054)
@@ -249,8 +249,8 @@ dropit:
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 @@ dropit:
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 {
Modified: projects/routing/sys/netinet/ip_output.c
==============================================================================
--- projects/routing/sys/netinet/ip_output.c Sun Aug 23 18:19:25 2015 (r287053)
+++ projects/routing/sys/netinet/ip_output.c Sun Aug 23 18:20:26 2015 (r287054)
@@ -223,7 +223,7 @@ ip_output(struct mbuf *m, struct mbuf *o
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;
uint32_t fibnum;
#ifdef IPSEC
@@ -577,13 +577,12 @@ sendit:
/* Reset everything for a new round */
/* TODO: Carefully inspect multipath cached route case */
if (nh != NULL) {
- fib4_free_nh(fibnum, nh);
+ fib4_free_nh_prepend(fibnum, nh);
nh = NULL;
}
ri = NULL;
ip = mtod(m, struct ip *);
goto again;
-
}
}
@@ -696,7 +695,7 @@ sendit:
done:
/* TODO: Carefully inspect multipath cached route case */
if (nh != NULL)
- fib4_free_nh(fibnum, nh);
+ fib4_free_nh_prepend(fibnum, nh);
return (error);
bad:
m_freem(m);
Modified: projects/routing/sys/netinet/tcp_subr.c
==============================================================================
--- projects/routing/sys/netinet/tcp_subr.c Sun Aug 23 18:19:25 2015 (r287053)
+++ projects/routing/sys/netinet/tcp_subr.c Sun Aug 23 18:20:26 2015 (r287054)
@@ -1871,8 +1871,8 @@ tcp_maxmtu(struct in_conninfo *inc, stru
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;
Modified: projects/routing/sys/netpfil/ipfw/ip_fw2.c
==============================================================================
--- projects/routing/sys/netpfil/ipfw/ip_fw2.c Sun Aug 23 18:19:25 2015 (r287053)
+++ projects/routing/sys/netpfil/ipfw/ip_fw2.c Sun Aug 23 18:20:26 2015 (r287054)
@@ -454,11 +454,11 @@ verify_path(struct in_addr src, struct i
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);
@@ -530,11 +530,11 @@ verify_path6(struct in6_addr *src, struc
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);
More information about the svn-src-projects
mailing list