From: KOVACS Krisztian <hidden@balabit.hu>
To: netdev@vger.kernel.org
Subject: [PATCH/RFC 05/13] Loosen source address check on IPv4 output
Date: Mon, 05 Mar 2007 16:45:41 +0100 [thread overview]
Message-ID: <20070305154541.3471.36004.stgit@nienna.balabit> (raw)
In-Reply-To: <20070305154451.3471.18396.stgit@nienna.balabit>
ip_route_output() contains a check to make sure that no flows with
non-local source IP addresses are routed. This obviously makes using
such addresses impossible.
This patch introduces a flowi flag which makes omitting this check
possible. The new flag provides a way of handling transparent and
non-transparent connections differently.
Signed-off-by: KOVACS Krisztian <hidden@balabit.hu>
---
include/net/flow.h | 1 +
net/ipv4/route.c | 8 ++++++--
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/include/net/flow.h b/include/net/flow.h
index ce4b10d..9eb91f2 100644
--- a/include/net/flow.h
+++ b/include/net/flow.h
@@ -49,6 +49,7 @@ struct flowi {
__u8 proto;
__u8 flags;
#define FLOWI_FLAG_MULTIPATHOLDROUTE 0x01
+#define FLOWI_FLAG_TRANSPARENT 0x02
union {
struct {
__be16 sport;
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index c526fb2..8091a96 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -572,7 +572,8 @@ static inline int compare_keys(struct flowi *fl1, struct flowi *fl2)
(*(u16 *)&fl1->nl_u.ip4_u.tos ^
*(u16 *)&fl2->nl_u.ip4_u.tos) |
(fl1->oif ^ fl2->oif) |
- (fl1->iif ^ fl2->iif)) == 0;
+ (fl1->iif ^ fl2->iif) |
+ ((fl1->flags ^ fl2->flags) & FLOWI_FLAG_TRANSPARENT)) == 0;
}
#ifdef CONFIG_IP_ROUTE_MULTIPATH_CACHED
@@ -2338,6 +2339,7 @@ static inline int __mkroute_output(struct rtable **result,
rth->fl.fl4_src = oldflp->fl4_src;
rth->fl.oif = oldflp->oif;
rth->fl.mark = oldflp->mark;
+ rth->fl.flags = oldflp->flags;
rth->rt_dst = fl->fl4_dst;
rth->rt_src = fl->fl4_src;
rth->rt_iif = oldflp->oif ? : dev_out->ifindex;
@@ -2482,6 +2484,7 @@ static int ip_route_output_slow(struct rtable **rp, const struct flowi *oldflp)
RT_SCOPE_LINK :
RT_SCOPE_UNIVERSE),
} },
+ .flags = oldflp->flags,
.mark = oldflp->mark,
.iif = loopback_dev.ifindex,
.oif = oldflp->oif };
@@ -2506,7 +2509,7 @@ static int ip_route_output_slow(struct rtable **rp, const struct flowi *oldflp)
/* It is equivalent to inet_addr_type(saddr) == RTN_LOCAL */
dev_out = ip_dev_find(oldflp->fl4_src);
- if (dev_out == NULL)
+ if (dev_out == NULL && !(oldflp->flags & FLOWI_FLAG_TRANSPARENT))
goto out;
/* I removed check for oif == dev_out->oif here.
@@ -2678,6 +2681,7 @@ int __ip_route_output_key(struct rtable **rp, const struct flowi *flp)
rth->fl.iif == 0 &&
rth->fl.oif == flp->oif &&
rth->fl.mark == flp->mark &&
+ !((rth->fl.flags ^ flp->flags) & FLOWI_FLAG_TRANSPARENT) &&
!((rth->fl.fl4_tos ^ flp->fl4_tos) &
(IPTOS_RT_MASK | RTO_ONLINK))) {
next prev parent reply other threads:[~2007-03-05 15:45 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-05 15:44 [PATCH/RFC 00/13] Transparent proxying patches, take two KOVACS Krisztian
2007-03-05 15:45 ` [PATCH/RFC 01/13] Implement local diversion of IPv4 skbs KOVACS Krisztian
2007-03-05 15:45 ` [PATCH/RFC 02/13] Port redirection support for TCP KOVACS Krisztian
2007-03-05 15:45 ` [PATCH/RFC 03/13] Don't do the TCP socket lookup if we already have one attached KOVACS Krisztian
2007-03-05 15:45 ` [PATCH/RFC 04/13] Don't do the UDP " KOVACS Krisztian
2007-03-05 15:45 ` KOVACS Krisztian [this message]
2007-03-05 15:45 ` [PATCH/RFC 06/13] Implement IP_TRANSPARENT socket option KOVACS Krisztian
2007-03-05 15:46 ` [PATCH/RFC 07/13] Conditionally enable transparent flow flag when connecting KOVACS Krisztian
2007-03-05 15:46 ` [PATCH/RFC 08/13] Handle TCP SYN+ACK/ACK/RST transparency KOVACS Krisztian
2007-03-05 15:46 ` [PATCH/RFC 09/13] Create a tproxy flag in struct sk_buff KOVACS Krisztian
2007-03-05 15:46 ` [PATCH/RFC 10/13] Export UDP socket lookup function KOVACS Krisztian
2007-03-05 15:46 ` [PATCH/RFC 11/13] iptables tproxy table KOVACS Krisztian
2007-03-05 15:46 ` [PATCH/RFC 12/13] iptables TPROXY target KOVACS Krisztian
2007-03-05 15:47 ` [PATCH/RFC 13/13] iptables tproxy match KOVACS Krisztian
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=20070305154541.3471.36004.stgit@nienna.balabit \
--to=hidden@balabit.hu \
--cc=netdev@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox