Projet

Général

Profil

Télécharger (2,19 ko) Statistiques
| Branche: | Révision:

univnautes-tools / patches / stable / 10 / route-to_without_gw.diff @ 4ab3b90b

1
diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c
2
index 69832d4..53e3990 100644
3
--- a/sys/netinet/ip_output.c
4
+++ b/sys/netinet/ip_output.c
5
@@ -123,7 +123,7 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags,
6
 	struct ifnet *ifp = NULL;	/* keep compiler happy */
7
 	struct mbuf *m0;
8
 	int hlen = sizeof (struct ip);
9
-	int mtu;
10
+	int mtu = 0;
11
 	int n;	/* scratchpad */
12
 	int error = 0;
13
 	struct sockaddr_in *dst;
14
@@ -134,10 +134,9 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags,
15
 	struct route iproute;
16
 	struct rtentry *rte;	/* cache for ro->ro_rt */
17
 	struct in_addr odst;
18
+	int no_route_but_check = 0;
19
 	struct m_tag *fwd_tag = NULL;
20
-#ifdef IPSEC
21
-	int no_route_but_check_spd = 0;
22
-#endif
23
+
24
 	M_ASSERTPKTHDR(m);
25
 
26
 	if (inp != NULL) {
27
@@ -286,10 +285,11 @@ again:
28
 			 * There is no route for this packet, but it is
29
 			 * possible that a matching SPD entry exists.
30
 			 */
31
-			no_route_but_check_spd = 1;
32
 			mtu = 0; /* Silence GCC warning. */
33
-			goto sendit;
34
 #endif
35
+			no_route_but_check = 1;
36
+			goto sendit;
37
+
38
 			IPSTAT_INC(ips_noroute);
39
 			error = EHOSTUNREACH;
40
 			goto bad;
41
@@ -485,28 +485,34 @@ sendit:
42
 	default:
43
 		break;	/* Continue with packet processing. */
44
 	}
45
-	/*
46
-	 * Check if there was a route for this packet; return error if not.
47
-	 */
48
-	if (no_route_but_check_spd) {
49
-		IPSTAT_INC(ips_noroute);
50
-		error = EHOSTUNREACH;
51
-		goto bad;
52
-	}
53
 	/* Update variables that are affected by ipsec4_output(). */
54
 	ip = mtod(m, struct ip *);
55
 	hlen = ip->ip_hl << 2;
56
 #endif /* IPSEC */
57
 
58
 	/* Jump over all PFIL processing if hooks are not active. */
59
-	if (!PFIL_HOOKED(&V_inet_pfil_hook))
60
+	if (!PFIL_HOOKED(&V_inet_pfil_hook)) {
61
+		if (no_route_but_check) {
62
+			IPSTAT_INC(ips_noroute);
63
+			error = EHOSTUNREACH;
64
+			goto bad;
65
+		}
66
 		goto passout;
67
+	}
68
+
69
+	if (ifp == NULL)
70
+		ifp = V_loif;
71
 
72
 	/* Run through list of hooks for output packets. */
73
 	odst.s_addr = ip->ip_dst.s_addr;
74
 	error = pfil_run_hooks(&V_inet_pfil_hook, &m, ifp, PFIL_OUT, inp);
75
 	if (error != 0 || m == NULL)
76
 		goto done;
77
+	if (no_route_but_check) {
78
+		IPSTAT_INC(ips_noroute);
79
+                error = EHOSTUNREACH;
80
+                goto bad;
81
+	}
82
 
83
 	ip = mtod(m, struct ip *);
84
 
(57-57/67)