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: Wed, 16 Apr 2003 02:20:00 +0200 [thread overview]
Message-ID: <3E9CA1B0.4010507@trash.net> (raw)
In-Reply-To: <3E9C142C.5010909@trash.net>
[-- Attachment #1: Type: text/plain, Size: 173 bytes --]
This is a once-again-updated patch, i discovered two memory leaks,
one introduced by my patch and one from asym. routing fix. Both
are fixed in this version.
Bye,
Patrick
[-- Attachment #2: ipt_REJECT-route.diff --]
[-- Type: text/plain, Size: 2078 bytes --]
diff -Nru a/net/ipv4/netfilter/ipt_REJECT.c b/net/ipv4/netfilter/ipt_REJECT.c
--- a/net/ipv4/netfilter/ipt_REJECT.c Wed Apr 16 02:14:52 2003
+++ b/net/ipv4/netfilter/ipt_REJECT.c Wed Apr 16 02:14:52 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>
@@ -40,6 +39,7 @@
struct sk_buff *nskb;
struct tcphdr *otcph, *tcph;
struct rtable *rt;
+ struct dst_entry *odst;
unsigned int otcplen;
u_int16_t tmp_port;
u_int32_t tmp_addr;
@@ -64,12 +64,30 @@
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)
- return;
+ 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 ip may have come from.
+ */
+ if (ip_route_output(&rt, oldskb->nh.iph->daddr, 0, 0, 0) != 0)
+ return;
+ odst = oldskb->dst;
+ 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;
+ oldskb->dst = odst;
+ }
hh_len = (rt->u.dst.dev->hard_header_len + 15)&~15;
@@ -80,8 +98,10 @@
hh_len of incoming interface < hh_len of outgoing interface */
nskb = skb_copy_expand(oldskb, hh_len, skb_tailroom(oldskb),
GFP_ATOMIC);
- if (!nskb)
+ if (!nskb) {
+ dst_release(&rt->u.dst);
return;
+ }
dst_release(nskb->dst);
nskb->dst = &rt->u.dst;
prev parent reply other threads:[~2003-04-16 0:20 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
2003-04-16 0:20 ` Patrick McHardy [this message]
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=3E9CA1B0.4010507@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.