summaryrefslogtreecommitdiff
path: root/include/net/netns
diff options
context:
space:
mode:
authorPaolo Abeni <pabeni@redhat.com>2017-09-20 18:26:53 +0200
committerDavid S. Miller <davem@davemloft.net>2017-09-21 15:15:22 -0700
commit6e617de84e87d626d1e976fc30e1322239fd4d2d (patch)
tree1bbc7e3a49f22574422489dd654f9e3668fe6e41 /include/net/netns
parenta99855d1598be17d3da618234daab5cbc49afb07 (diff)
net: avoid a full fib lookup when rp_filter is disabled.
Since commit 1dced6a85482 ("ipv4: Restore accept_local behaviour in fib_validate_source()") a full fib lookup is needed even if the rp_filter is disabled, if accept_local is false - which is the default. What we really need in the above scenario is just checking that the source IP address is not local, and in most case we can do that is a cheaper way looking up the ifaddr hash table. This commit adds a helper for such lookup, and uses it to validate the src address when rp_filter is disabled and no 'local' routes are created by the user space in the relevant namespace. A new ipv4 netns flag is added to account for such routes. We need that to preserve the same behavior we had before this patch. It also drops the checks to bail early from __fib_validate_source, added by the commit 1dced6a85482 ("ipv4: Restore accept_local behaviour in fib_validate_source()") they do not give any measurable performance improvement: if we do the lookup with are on a slower path. This improves UDP performances for unconnected sockets when rp_filter is disabled by 5% and also gives small but measurable performance improvement for TCP flood scenarios. v1 -> v2: - use the ifaddr lookup helper in __ip_dev_find(), as suggested by Eric - fall-back to full lookup if custom local routes are present Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/netns')
-rw-r--r--include/net/netns/ipv4.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
index 20d061c805e3..20720721da4b 100644
--- a/include/net/netns/ipv4.h
+++ b/include/net/netns/ipv4.h
@@ -49,6 +49,7 @@ struct netns_ipv4 {
#ifdef CONFIG_IP_MULTIPLE_TABLES
struct fib_rules_ops *rules_ops;
bool fib_has_custom_rules;
+ bool fib_has_custom_local_routes;
struct fib_table __rcu *fib_main;
struct fib_table __rcu *fib_default;
#endif