svn commit: r287052 - in projects/routing/sys: net netinet
Alexander V. Chernikov
melifaro at FreeBSD.org
Sun Aug 23 18:18:46 UTC 2015
Author: melifaro
Date: Sun Aug 23 18:18:44 2015
New Revision: 287052
URL: https://svnweb.freebsd.org/changeset/base/287052
Log:
Convert last piece of ip_forward to use new rouing api.
Modified:
projects/routing/sys/net/rt_nhops.c
projects/routing/sys/net/rt_nhops.h
projects/routing/sys/netinet/ip_input.c
Modified: projects/routing/sys/net/rt_nhops.c
==============================================================================
--- projects/routing/sys/net/rt_nhops.c Sun Aug 23 18:18:08 2015 (r287051)
+++ projects/routing/sys/net/rt_nhops.c Sun Aug 23 18:18:44 2015 (r287052)
@@ -393,6 +393,8 @@ fib4_rte_to_nh_extended(struct rtentry *
/* Set flags */
pnh4->nh_flags = rte->rt_flags & NHOP_FLAGS_MASK;
+ if (rte->rt_flags & (RTF_DYNAMIC|RTF_MODIFIED))
+ pnh4->nh_flags |= NHOP_REDIRECT;
gw = (struct sockaddr_in *)rt_key(rte);
if (gw->sin_addr.s_addr == 0)
pnh4->nh_flags |= NHOP_DEFAULT;
@@ -414,6 +416,8 @@ fib4_rte_to_nh_basic(struct rtentry *rte
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;
gw = (struct sockaddr_in *)rt_key(rte);
if (gw->sin_addr.s_addr == 0)
pnh4->nh_flags |= NHOP_DEFAULT;
Modified: projects/routing/sys/net/rt_nhops.h
==============================================================================
--- projects/routing/sys/net/rt_nhops.h Sun Aug 23 18:18:08 2015 (r287051)
+++ projects/routing/sys/net/rt_nhops.h Sun Aug 23 18:18:44 2015 (r287052)
@@ -209,8 +209,9 @@ void fib6_free_nh(uint32_t fibnum, struc
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 RTF_REJECT
-#define NHOP_BLACKHOLE RTF_BLACKHOLE
+#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 */
#define FWD_INET 0
Modified: projects/routing/sys/netinet/ip_input.c
==============================================================================
--- projects/routing/sys/netinet/ip_input.c Sun Aug 23 18:18:08 2015 (r287051)
+++ projects/routing/sys/netinet/ip_input.c Sun Aug 23 18:18:44 2015 (r287052)
@@ -874,7 +874,6 @@ ip_forward(struct mbuf *m, int srcrt)
struct mbuf *mcopy;
struct in_addr dest;
struct nhop4_basic nh4, *pnh4;
- struct route ro;
struct route_info ri;
int error, type = 0, code = 0, mtu = 0;
@@ -970,25 +969,11 @@ ip_forward(struct mbuf *m, int srcrt)
dest.s_addr = 0;
if (!srcrt && V_ipsendredirects &&
pnh4 != NULL && nh4.nh_ifp == m->m_pkthdr.rcvif) {
- struct rtentry *rt;
-
- rt = ro.ro_rt;
-
- if (rt && (rt->rt_flags & (RTF_DYNAMIC|RTF_MODIFIED)) == 0 &&
- satosin(rt_key(rt))->sin_addr.s_addr != 0) {
-#define RTA(rt) ((struct in_ifaddr *)(rt->rt_ifa))
- u_long src = ntohl(ip->ip_src.s_addr);
-
- if (RTA(rt) &&
- (src & RTA(rt)->ia_subnetmask) == RTA(rt)->ia_subnet) {
- if (rt->rt_flags & RTF_GATEWAY)
- dest.s_addr = satosin(rt->rt_gateway)->sin_addr.s_addr;
- else
- dest.s_addr = ip->ip_dst.s_addr;
- /* Router requirements says to only send host redirects */
- type = ICMP_REDIRECT;
- code = ICMP_REDIRECT_HOST;
- }
+ if ((nh4.nh_flags & (NHOP_REDIRECT|NHOP_DEFAULT)) == 0) {
+ dest = nh4.nh_addr;
+ /*Router requirements says to only send host redirects*/
+ type = ICMP_REDIRECT;
+ code = ICMP_REDIRECT_HOST;
}
}
More information about the svn-src-projects
mailing list