summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorRenato Botelho <renato@netgate.com>2015-08-17 13:53:04 -0300
committerRenato Botelho <renato@netgate.com>2015-08-17 13:53:04 -0300
commitcd974c33ee2686b51a072a0938c0e5dc45729e00 (patch)
tree64e83110daf01492794865ad6727b0635a6d406e /sys
parentf59b244dc6ec16616ed00a9cf33b4d1fcc839a36 (diff)
downloadFreeBSD-src-cd974c33ee2686b51a072a0938c0e5dc45729e00.zip
FreeBSD-src-cd974c33ee2686b51a072a0938c0e5dc45729e00.tar.gz
Importing pfSense patch route-to_without_gw.diff
Diffstat (limited to 'sys')
-rw-r--r--sys/netinet/ip_output.c36
1 files changed, 21 insertions, 15 deletions
diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c
index 954785d..2db4578 100644
--- a/sys/netinet/ip_output.c
+++ b/sys/netinet/ip_output.c
@@ -123,7 +123,7 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags,
struct ifnet *ifp = NULL; /* keep compiler happy */
struct mbuf *m0;
int hlen = sizeof (struct ip);
- int mtu;
+ int mtu = 0;
int n; /* scratchpad */
int error = 0;
struct sockaddr_in *dst;
@@ -136,9 +136,8 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags,
struct in_addr odst;
struct m_tag *fwd_tag = NULL;
int have_ia_ref;
-#ifdef IPSEC
- int no_route_but_check_spd = 0;
-#endif
+ int no_route_but_check = 0;
+
M_ASSERTPKTHDR(m);
if (inp != NULL) {
@@ -292,10 +291,11 @@ again:
* There is no route for this packet, but it is
* possible that a matching SPD entry exists.
*/
- no_route_but_check_spd = 1;
mtu = 0; /* Silence GCC warning. */
- goto sendit;
#endif
+ no_route_but_check = 1;
+ goto sendit;
+
IPSTAT_INC(ips_noroute);
error = EHOSTUNREACH;
goto bad;
@@ -491,28 +491,34 @@ sendit:
default:
break; /* Continue with packet processing. */
}
- /*
- * Check if there was a route for this packet; return error if not.
- */
- if (no_route_but_check_spd) {
- IPSTAT_INC(ips_noroute);
- error = EHOSTUNREACH;
- goto bad;
- }
/* Update variables that are affected by ipsec4_output(). */
ip = mtod(m, struct ip *);
hlen = ip->ip_hl << 2;
#endif /* IPSEC */
/* Jump over all PFIL processing if hooks are not active. */
- if (!PFIL_HOOKED(&V_inet_pfil_hook))
+ if (!PFIL_HOOKED(&V_inet_pfil_hook)) {
+ if (no_route_but_check) {
+ IPSTAT_INC(ips_noroute);
+ error = EHOSTUNREACH;
+ goto bad;
+ }
goto passout;
+ }
+
+ if (ifp == NULL)
+ ifp = V_loif;
/* Run through list of hooks for output packets. */
odst.s_addr = ip->ip_dst.s_addr;
error = pfil_run_hooks(&V_inet_pfil_hook, &m, ifp, PFIL_OUT, inp);
if (error != 0 || m == NULL)
goto done;
+ if (no_route_but_check) {
+ IPSTAT_INC(ips_noroute);
+ error = EHOSTUNREACH;
+ goto bad;
+ }
ip = mtod(m, struct ip *);
OpenPOWER on IntegriCloud