From: Simon Horman <horms@verge.net.au>
To: Pablo Neira Ayuso <pablo@netfilter.org>,
David Miller <davem@davemloft.net>
Cc: lvs-devel@vger.kernel.org, netdev@vger.kernel.org,
netfilter-devel@vger.kernel.org,
Wensong Zhang <wensong@linux-vs.org>,
Julian Anastasov <ja@ssi.bg>, Simon Horman <horms@verge.net.au>
Subject: [PATCH 06/15] ipvs: no need to reroute anymore on DNAT over loopback
Date: Thu, 28 Mar 2013 14:39:35 +0900 [thread overview]
Message-ID: <1364449184-26672-7-git-send-email-horms@verge.net.au> (raw)
In-Reply-To: <1364449184-26672-1-git-send-email-horms@verge.net.au>
From: Julian Anastasov <ja@ssi.bg>
After commit 70e7341673 (ipv4: Show that ip_send_reply()
is purely unicast routine.) we do not need to reroute DNAT-ed
traffic over loopback because reply uses iph daddr and not
rt_spec_dst.
Signed-off-by: Julian Anastasov <ja@ssi.bg>
Signed-off by: Hans Schillstrom <hans@schillstrom.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
---
net/netfilter/ipvs/ip_vs_xmit.c | 58 ++-------------------------------------
1 file changed, 2 insertions(+), 56 deletions(-)
diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
index 6448a2e..c942d36 100644
--- a/net/netfilter/ipvs/ip_vs_xmit.c
+++ b/net/netfilter/ipvs/ip_vs_xmit.c
@@ -207,44 +207,6 @@ __ip_vs_get_out_rt(struct sk_buff *skb, struct ip_vs_dest *dest,
return rt;
}
-/* Reroute packet to local IPv4 stack after DNAT */
-static int
-__ip_vs_reroute_locally(struct sk_buff *skb)
-{
- struct rtable *rt = skb_rtable(skb);
- struct net_device *dev = rt->dst.dev;
- struct net *net = dev_net(dev);
- struct iphdr *iph = ip_hdr(skb);
-
- if (rt_is_input_route(rt)) {
- unsigned long orefdst = skb->_skb_refdst;
-
- if (ip_route_input(skb, iph->daddr, iph->saddr,
- iph->tos, skb->dev))
- return 0;
- refdst_drop(orefdst);
- } else {
- struct flowi4 fl4 = {
- .daddr = iph->daddr,
- .saddr = iph->saddr,
- .flowi4_tos = RT_TOS(iph->tos),
- .flowi4_mark = skb->mark,
- };
-
- rt = ip_route_output_key(net, &fl4);
- if (IS_ERR(rt))
- return 0;
- if (!(rt->rt_flags & RTCF_LOCAL)) {
- ip_rt_put(rt);
- return 0;
- }
- /* Drop old route. */
- skb_dst_drop(skb);
- skb_dst_set(skb, &rt->dst);
- }
- return 1;
-}
-
#ifdef CONFIG_IP_VS_IPV6
static inline int __ip_vs_is_local_route6(struct rt6_info *rt)
@@ -635,16 +597,8 @@ ip_vs_nat_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
/* drop old route */
skb_dst_drop(skb);
skb_dst_set(skb, &rt->dst);
- } else {
+ } else
ip_rt_put(rt);
- /*
- * Some IPv4 replies get local address from routes,
- * not from iph, so while we DNAT after routing
- * we need this second input/output route.
- */
- if (!__ip_vs_reroute_locally(skb))
- goto tx_error;
- }
IP_VS_DBG_PKT(10, AF_INET, pp, skb, 0, "After DNAT");
@@ -1269,16 +1223,8 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
/* drop the old route when skb is not shared */
skb_dst_drop(skb);
skb_dst_set(skb, &rt->dst);
- } else {
+ } else
ip_rt_put(rt);
- /*
- * Some IPv4 replies get local address from routes,
- * not from iph, so while we DNAT after routing
- * we need this second input/output route.
- */
- if (!__ip_vs_reroute_locally(skb))
- goto tx_error;
- }
/* Another hack: avoid icmp_send in ip_fragment */
skb->local_df = 1;
--
1.7.10.4
next prev parent reply other threads:[~2013-03-28 5:39 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-28 5:39 [PATCH 00/15 v3] IPVS optimizations (repost) Simon Horman
2013-03-28 5:39 ` [PATCH 01/15] net: add skb_dst_set_noref_force Simon Horman
2013-03-28 5:39 ` [PATCH 02/15] ipvs: avoid routing by TOS for real server Simon Horman
2013-03-28 5:39 ` [PATCH 03/15] ipvs: prefer NETDEV_DOWN event to free cached dsts Simon Horman
2013-03-28 5:39 ` [PATCH 04/15] ipvs: convert the IP_VS_XMIT macros to functions Simon Horman
2013-03-28 5:39 ` [PATCH 05/15] ipvs: rename functions related to dst_cache reset Simon Horman
2013-03-28 5:39 ` Simon Horman [this message]
2013-03-28 5:39 ` [PATCH 07/15] ipvs: do not use skb_share_check Simon Horman
2013-03-28 5:39 ` [PATCH 08/15] ipvs: consolidate all dst checks on transmit in one place Simon Horman
2013-03-28 5:39 ` [PATCH 09/15] ipvs: optimize dst usage for real server Simon Horman
2013-03-28 5:39 ` [PATCH 10/15] ipvs: convert app locks Simon Horman
2013-03-28 5:39 ` [PATCH 11/15] ipvs: remove rs_lock by using RCU Simon Horman
2013-03-28 5:39 ` [PATCH 12/15] ipvs: convert locks used in persistence engines Simon Horman
2013-03-28 5:39 ` [PATCH 13/15] ipvs: convert connection locking Simon Horman
2013-03-28 5:39 ` [PATCH 14/15] ipvs: reorder keys in connection structure Simon Horman
2013-03-28 5:39 ` [PATCH 15/15] ipvs: avoid kmem_cache_zalloc in ip_vs_conn_new Simon Horman
2013-03-28 9:04 ` [PATCH 00/15 v3] IPVS optimizations (repost) Simon Horman
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=1364449184-26672-7-git-send-email-horms@verge.net.au \
--to=horms@verge.net.au \
--cc=davem@davemloft.net \
--cc=ja@ssi.bg \
--cc=lvs-devel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
--cc=wensong@linux-vs.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;
as well as URLs for NNTP newsgroup(s).