[PATCH 17/26] IPVS: Add connection hashing function for IPv6 entries.

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Julius R. Volz
Date: Wednesday, June 11, 2008 - 10:12 am

Add ip_vs_conn_hashkey_v6() and call it instead of ip_vs_conn_hashkey()
when hashing IPv6 connection entries.

Signed-off-by: Julius R. Volz <juliusv@google.com>

 1 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
index 1a4040d..4ee5dac 100644
--- a/net/netfilter/ipvs/ip_vs_conn.c
+++ b/net/netfilter/ipvs/ip_vs_conn.c
@@ -37,6 +37,9 @@
 
 #include <net/net_namespace.h>
 #include <net/ip_vs.h>
+#ifdef CONFIG_IP_VS_IPV6
+#include <net/ipv6.h>
+#endif
 
 
 /*
@@ -122,6 +125,13 @@ static unsigned int ip_vs_conn_hashkey(unsigned proto, __be32 addr, __be16 port)
 		& IP_VS_CONN_TAB_MASK;
 }
 
+#ifdef CONFIG_IP_VS_IPV6
+static unsigned int ip_vs_conn_hashkey_v6(unsigned proto, const struct in6_addr *addr, __be16 port)
+{
+	return jhash_3words(jhash(addr, 16, ip_vs_conn_rnd), (__force u32)port, proto, ip_vs_conn_rnd)
+		& IP_VS_CONN_TAB_MASK;
+}
+#endif
 
 /*
  *	Hashes ip_vs_conn in ip_vs_conn_tab by proto,addr,port.
@@ -133,7 +143,12 @@ static inline int ip_vs_conn_hash(struct ip_vs_conn *cp)
 	int ret;
 
 	/* Hash by protocol, client address and port */
-	hash = ip_vs_conn_hashkey(cp->protocol, cp->caddr, cp->cport);
+#ifdef CONFIG_IP_VS_IPV6
+	if (cp->af == AF_INET6)
+		hash = ip_vs_conn_hashkey_v6(cp->protocol, &cp->caddr.v6, cp->cport);
+	else
+#endif
+		hash = ip_vs_conn_hashkey(cp->protocol, cp->caddr.v4, cp->cport);
 
 	ct_write_lock(hash);
 
@@ -164,7 +179,12 @@ static inline int ip_vs_conn_unhash(struct ip_vs_conn *cp)
 	int ret;
 
 	/* unhash it and decrease its reference counter */
-	hash = ip_vs_conn_hashkey(cp->protocol, cp->caddr, cp->cport);
+#ifdef CONFIG_IP_VS_IPV6
+	if (cp->af == AF_INET6)
+		hash = ip_vs_conn_hashkey_v6(cp->protocol, &cp->caddr.v6, cp->cport);
+	else
+#endif
+		hash = ip_vs_conn_hashkey(cp->protocol, cp->caddr.v4, cp->cport);
 
 	ct_write_lock(hash);
 
-- 
1.5.3.6

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 00/26] IPVS: Add first IPv6 support to IPVS., Julius R. Volz, (Wed Jun 11, 10:11 am)
[PATCH 11/26] IPVS: Add supports_ipv6 flag to schedulers., Julius R. Volz, (Wed Jun 11, 10:11 am)
[PATCH 15/26] IPVS: Modify IP_VS_XMIT() to support IPv6., Julius R. Volz, (Wed Jun 11, 10:11 am)
[PATCH 16/26] IPVS: Add IPv6 xmit forwarding functions., Julius R. Volz, (Wed Jun 11, 10:11 am)
[PATCH 17/26] IPVS: Add connection hashing function for IP ..., Julius R. Volz, (Wed Jun 11, 10:12 am)
[PATCH 24/26] IPVS: Add IPv6 support to userspace interface., Julius R. Volz, (Wed Jun 11, 10:12 am)
[PATCH 26/26] IPVS: Add some blame/credits for IPv6 version., Julius R. Volz, (Wed Jun 11, 10:12 am)
Re: [PATCH 10/26] IPVS: Add IPv6 handler functions to UDP ..., Patrick McHardy, (Wed Jun 11, 10:18 am)
Re: [PATCH 00/26] IPVS: Add first IPv6 support to IPVS., Patrick McHardy, (Wed Jun 11, 10:23 am)
Re: [PATCH 00/26] IPVS: Add first IPv6 support to IPVS., Julius Volz, (Wed Jun 11, 11:23 am)
Re: [PATCH 00/26] IPVS: Add first IPv6 support to IPVS., Patrick McHardy, (Wed Jun 11, 11:42 am)
Re: [PATCH 00/26] IPVS: Add first IPv6 support to IPVS., Julius Volz, (Wed Jun 11, 12:05 pm)
Re: [PATCH 00/26] IPVS: Add first IPv6 support to IPVS., Patrick McHardy, (Wed Jun 11, 12:10 pm)
Re: [PATCH 00/26] IPVS: Add first IPv6 support to IPVS., Julius Volz, (Wed Jun 11, 12:29 pm)
Re: [PATCH 00/26] IPVS: Add first IPv6 support to IPVS., Patrick McHardy, (Wed Jun 11, 12:31 pm)
Re: [PATCH 00/26] IPVS: Add first IPv6 support to IPVS., Julius Volz, (Wed Jun 11, 12:53 pm)
Re: [PATCH 00/26] IPVS: Add first IPv6 support to IPVS., Simon Horman, (Wed Jun 11, 6:45 pm)
Re: [PATCH 00/26] IPVS: Add first IPv6 support to IPVS., Patrick McHardy, (Thu Jun 12, 6:38 am)
Re: [PATCH 00/26] IPVS: Add first IPv6 support to IPVS., Patrick McHardy, (Thu Jun 12, 8:46 am)
Re: [PATCH 00/26] IPVS: Add first IPv6 support to IPVS., Julius Volz, (Thu Jun 12, 12:33 pm)
Re: [PATCH 00/26] IPVS: Add first IPv6 support to IPVS., Simon Horman, (Thu Jun 12, 11:26 pm)
Re: [PATCH 00/26] IPVS: Add first IPv6 support to IPVS., Patrick McHardy, (Fri Jun 13, 8:14 am)
Re: [PATCH 00/26] IPVS: Add first IPv6 support to IPVS., Patrick McHardy, (Mon Jun 16, 4:47 am)
Re: [PATCH 00/26] IPVS: Add first IPv6 support to IPVS., Patrick McHardy, (Tue Jun 17, 4:52 am)
Re: [PATCH 00/26] IPVS: Add first IPv6 support to IPVS., Julius Volz, (Tue Jun 17, 10:18 am)
Re: [PATCH 00/26] IPVS: Add first IPv6 support to IPVS., Patrick McHardy, (Tue Jun 17, 1:08 pm)
Re: [PATCH 00/26] IPVS: Add first IPv6 support to IPVS., Patrick McHardy, (Wed Jun 18, 1:57 am)
Re: [PATCH 00/26] IPVS: Add first IPv6 support to IPVS., Patrick McHardy, (Wed Jun 18, 7:19 am)
Re: [PATCH 00/26] IPVS: Add first IPv6 support to IPVS., Patrick McHardy, (Wed Jun 18, 7:30 am)