summaryrefslogtreecommitdiffstats
path: root/sys/netinet/in_rmx.c
diff options
context:
space:
mode:
authormelifaro <melifaro@FreeBSD.org>2012-10-10 19:06:11 +0000
committermelifaro <melifaro@FreeBSD.org>2012-10-10 19:06:11 +0000
commit02e40e1b73cf03bfc9521cfc48e93e132d2e9596 (patch)
treeeadfb79e4a7a03342694f5708e28ff1340981a5c /sys/netinet/in_rmx.c
parent9e15eadd181311f674215ea14e508faa724685b0 (diff)
downloadFreeBSD-src-02e40e1b73cf03bfc9521cfc48e93e132d2e9596.zip
FreeBSD-src-02e40e1b73cf03bfc9521cfc48e93e132d2e9596.tar.gz
Do not check if found IPv4 rte is dynamic if net.inet.icmp.drop_redirect is
enabled. This eliminates one mtx_lock() per each routing lookup thus improving performance in several cases (routing to directly connected interface or routing to default gateway). Icmp redirects should not be used to provide routing direction nowadays, even for end hosts. Routers should not use them too (and this is explicitly restricted in IPv6, see RFC 4861, clause 8.2). Current commit changes rnh_machaddr function to 'stock' rn_match (and back) for every AF_INET routing table in given VNET instance on drop_redirect sysctl change. This change is part of bigger patch eliminating rte locking. Sponsored by: Yandex LLC MFC after: 2 weeks
Diffstat (limited to 'sys/netinet/in_rmx.c')
-rw-r--r--sys/netinet/in_rmx.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/sys/netinet/in_rmx.c b/sys/netinet/in_rmx.c
index 1389873..80ec096 100644
--- a/sys/netinet/in_rmx.c
+++ b/sys/netinet/in_rmx.c
@@ -58,6 +58,8 @@ __FBSDID("$FreeBSD$");
#include <netinet/in.h>
#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_icmp.h>
#include <netinet/ip_var.h>
extern int in_inithead(void **head, int off);
@@ -340,6 +342,13 @@ in_rtqdrain(void)
VNET_LIST_RUNLOCK_NOSLEEP();
}
+void
+in_setmatchfunc(struct radix_node_head *rnh, int val)
+{
+
+ rnh->rnh_matchaddr = (val != 0) ? rn_match : in_matroute;
+}
+
static int _in_rt_was_here;
/*
* Initialize our routing tree.
@@ -365,7 +374,7 @@ in_inithead(void **head, int off)
rnh = *head;
rnh->rnh_addaddr = in_addroute;
- rnh->rnh_matchaddr = in_matroute;
+ in_setmatchfunc(rnh, V_drop_redirect);
rnh->rnh_close = in_clsroute;
if (_in_rt_was_here == 0 ) {
callout_init(&V_rtq_timer, CALLOUT_MPSAFE);
OpenPOWER on IntegriCloud