From: Patrick McHardy <kaber@trash.net>
To: Harald Welte <laforge@netfilter.org>
Cc: leen@wirehub.nl, netfilter-devel@lists.netfilter.org
Subject: Re: Bug (?) in ipt_reject doesn't follow policy routing (2.4.x)
Date: Tue, 15 Apr 2003 16:16:12 +0200 [thread overview]
Message-ID: <3E9C142C.5010909@trash.net> (raw)
In-Reply-To: <20030415074049.GX6866@sunbeam.de.gnumonks.org>
[-- Attachment #1: Type: text/plain, Size: 1061 bytes --]
Hi Harald,
this is an updated version, description follows below.
If davem gives his blessing i will make a patch for MIRROR as well.
Harald Welte wrote:
>We should talk to David Miller about this issue. Could you please write
>a short summary like 'old behaviour was X and we had Problem Y with it,
>now we try to fix it with this patch doing Z'? I would then put the
>patch together with this summary (as .help file) in patch-o-matic
>pending and discuss it with davem.
>
Ok here it goes:
ipt_REJECT uses saddr=0 for lookups with ip_route_output for non-local ips,
therefore routing rules like "from a.b.c.d/x" don't apply for tcp-resets
generated
by ipt_REJECT.
This patch makes reject call ip_route_output to find an interface where
the source
ip may have come from (for reverse-path filters) and then call
ip_route_input with
the source/dest address of the tcp-reset. It also fixes a bug introduced
by last fix
for asym. routing, source and dest were switched so ip_route_output
returned a
route in the wrong direction.
Best regards,
Patrick
[-- Attachment #2: ipt_REJECT-tcprst-route.diff --]
[-- Type: text/plain, Size: 1544 bytes --]
===== net/ipv4/netfilter/ipt_REJECT.c 1.10 vs edited =====
--- 1.10/net/ipv4/netfilter/ipt_REJECT.c Mon Mar 31 17:00:55 2003
+++ edited/net/ipv4/netfilter/ipt_REJECT.c Tue Apr 15 15:55:36 2003
@@ -11,7 +11,6 @@
#include <net/icmp.h>
#include <net/ip.h>
#include <net/tcp.h>
-struct in_device;
#include <net/route.h>
#include <linux/netfilter_ipv4/ip_tables.h>
#include <linux/netfilter_ipv4/ipt_REJECT.h>
@@ -64,12 +63,29 @@
csum_partial((char *)otcph, otcplen, 0)) != 0)
return;
- /* Routing: if not headed for us, route won't like source */
- if (ip_route_output(&rt, oldskb->nh.iph->daddr,
- local ? oldskb->nh.iph->saddr : 0,
- RT_TOS(oldskb->nh.iph->tos) | RTO_CONN,
- 0) != 0)
+ if (local) {
+ if (ip_route_output(&rt, oldskb->nh.iph->saddr,
+ oldskb->nh.iph->daddr,
+ RT_TOS(oldskb->nh.iph->tos), 0) != 0)
return;
+ } else {
+ /* non-local source - we use ip_route_input to respect policy
+ * routing rules. the call to ip_route_output is necessary to
+ * get a valid interface where the source may have come from.
+ */
+ if (ip_route_output(&rt, oldskb->nh.iph->daddr, 0, 0, 0) != 0)
+ return;
+ if (ip_route_input(oldskb, oldskb->nh.iph->saddr,
+ oldskb->nh.iph->daddr,
+ RT_TOS(oldskb->nh.iph->tos),
+ rt->u.dst.dev) != 0) {
+ dst_release(&rt->u.dst);
+ return;
+ }
+ dst_release(&rt->u.dst);
+ rt = (struct rtable *)oldskb->dst;
+ dst_hold(&rt->u.dst);
+ }
hh_len = (rt->u.dst.dev->hard_header_len + 15)&~15;
next prev parent reply other threads:[~2003-04-15 14:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-04-13 18:53 Bug (?) in ipt_reject doesn't follow policy routing (2.4.x) Leen Besselink
2003-04-13 20:13 ` Leen Besselink
2003-04-14 7:27 ` Leen Besselink
2003-04-14 7:59 ` Patrick Schaaf
2003-04-14 8:49 ` Patrick McHardy
2003-04-14 11:35 ` Leen Besselink
2003-04-14 21:09 ` Patrick McHardy
2003-04-15 7:40 ` Harald Welte
2003-04-15 14:16 ` Patrick McHardy [this message]
2003-04-16 0:20 ` Patrick McHardy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3E9C142C.5010909@trash.net \
--to=kaber@trash.net \
--cc=laforge@netfilter.org \
--cc=leen@wirehub.nl \
--cc=netfilter-devel@lists.netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.