netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [NETFILTER] Apply IPsec to ipt_REJECT packets
@ 2004-11-23  8:42 Herbert Xu
  2004-11-23  9:22 ` Harald Welte
  2004-11-23 18:17 ` [netfilter-core] " Patrick McHardy
  0 siblings, 2 replies; 10+ messages in thread
From: Herbert Xu @ 2004-11-23  8:42 UTC (permalink / raw)
  To: David S. Miller, coreteam, netdev

[-- Attachment #1: Type: text/plain, Size: 579 bytes --]

Hi:

I found out today that packets generated by ipt_REJECT weren't protected
by IPsec.  This is because the proto field isn't set at all in the flow
supplied to ip_route_output_key.

The following patch sets that as well as protocol-specific fields so
that the appropriate IPsec policy can be applied.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Cheers,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

[-- Attachment #2: p --]
[-- Type: text/plain, Size: 1592 bytes --]

===== net/ipv4/netfilter/ipt_REJECT.c 1.32 vs edited =====
--- 1.32/net/ipv4/netfilter/ipt_REJECT.c	2004-11-14 00:41:07 +11:00
+++ edited/net/ipv4/netfilter/ipt_REJECT.c	2004-11-23 19:35:22 +11:00
@@ -38,7 +38,8 @@
 #define DEBUGP(format, args...)
 #endif
 
-static inline struct rtable *route_reverse(struct sk_buff *skb, int hook)
+static inline struct rtable *route_reverse(struct sk_buff *skb, 
+					   struct tcphdr *tcph, int hook)
 {
 	struct iphdr *iph = skb->nh.iph;
 	struct dst_entry *odst;
@@ -56,6 +57,9 @@
 		if (hook == NF_IP_LOCAL_IN)
 			fl.nl_u.ip4_u.saddr = iph->daddr;
 		fl.nl_u.ip4_u.tos = RT_TOS(iph->tos);
+		fl.proto = IPPROTO_TCP;
+		fl.fl_ip_sport = tcph->dest;
+		fl.fl_ip_dport = tcph->source;
 
 		if (ip_route_output_key(&rt, &fl) != 0)
 			return NULL;
@@ -110,7 +114,7 @@
 		return;
 
 	/* FIXME: Check checksum --RR */
-	if ((rt = route_reverse(oldskb, hook)) == NULL)
+	if ((rt = route_reverse(oldskb, oth, hook)) == NULL)
 		return;
 
 	hh_len = LL_RESERVED_SPACE(rt->u.dst.dev);
@@ -282,10 +286,23 @@
 	tos = (iph->tos & IPTOS_TOS_MASK) | IPTOS_PREC_INTERNETCONTROL;
 
 	{
-		struct flowi fl = { .nl_u = { .ip4_u =
-					      { .daddr = skb_in->nh.iph->saddr,
-						.saddr = saddr,
-						.tos = RT_TOS(tos) } } };
+		struct flowi fl = {
+			.nl_u = {
+				.ip4_u = {
+					.daddr = skb_in->nh.iph->saddr,
+					.saddr = saddr,
+					.tos = RT_TOS(tos)
+				}
+			},
+			.proto = IPPROTO_ICMP,
+			.uli_u = {
+				.icmpt = {
+					.type = ICMP_DEST_UNREACH,
+					.code = code
+				}
+			}
+		};
+
 		if (ip_route_output_key(&rt, &fl))
 			return;
 	}

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2004-11-24  8:32 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-23  8:42 [NETFILTER] Apply IPsec to ipt_REJECT packets Herbert Xu
2004-11-23  9:22 ` Harald Welte
2004-11-23 18:17 ` [netfilter-core] " Patrick McHardy
2004-11-23 21:16   ` Herbert Xu
2004-11-23 21:17     ` Herbert Xu
2004-11-23 21:44     ` Patrick McHardy
2004-11-23 22:19       ` Herbert Xu
     [not found]         ` <41A3E9D6.9060904@trash.net>
2004-11-24  6:27           ` Herbert Xu
2004-11-24  8:32             ` David S. Miller
     [not found]         ` <41A3CD45.4080802@trash.net>
2004-11-24  7:29           ` Harald Welte

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).