From patchwork Wed Feb 10 00:18:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Craig Gallek X-Patchwork-Id: 581239 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 2F4C4140BAD for ; Wed, 10 Feb 2016 11:20:14 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755468AbcBJATV (ORCPT ); Tue, 9 Feb 2016 19:19:21 -0500 Received: from mail-qg0-f50.google.com ([209.85.192.50]:35166 "EHLO mail-qg0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753986AbcBJATL (ORCPT ); Tue, 9 Feb 2016 19:19:11 -0500 Received: by mail-qg0-f50.google.com with SMTP id y89so3010799qge.2 for ; Tue, 09 Feb 2016 16:19:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=WUcQY9YI2O/FUU4NemXyWIJVSjMEqYeXbjJHyvQavzg=; b=VpxLYk78uWeL4K9jnSlqNEJ30omx61GYXDC/P/klpvVCJUBRprDjwf6JIbDc5HLq+c o+uUkHh9hJNbPYBZzc56vdtuILYbCFOYcI45HcHoaZQV1VLMEWu6d7B0cx/tDddCDftT Qna80qcSXFIfq5HqHyvVt8ge2GkKr2beQbw+dHh9OnBqYqJ2UbkaEWxVg/0Ycdg7kBUD kPbSZ5i2t0e9NDMf8WfQpw322SaZ+e6Q01A74geYX4cKmp1gC2KiDNA3007Hv+am/v2o 8lgMpWtoGIaODTW448GGDWp7NEhxsckOps3OkaSCkf2Ekba64i4qNtZsZDZq3Ep5o/Mh rBwg== X-Gm-Message-State: AG10YOSxawHjK9TRD6rv7PNIvb1v6Y0slVEMf7TIecPW9J9+udFmoVTrsYQEIiCJdRQsmZqu X-Received: by 10.140.238.8 with SMTP id j8mr44039931qhc.76.1455063550719; Tue, 09 Feb 2016 16:19:10 -0800 (PST) Received: from cgallek-warp18.nyc.corp.google.com ([172.29.18.56]) by smtp.gmail.com with ESMTPSA id i136sm219319qhc.42.2016.02.09.16.19.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 Feb 2016 16:19:09 -0800 (PST) From: Craig Gallek To: netdev@vger.kernel.org, David Miller Subject: [PATCH net-next v3 2/7] inet: create IPv6-equivalent inet_hash function Date: Tue, 9 Feb 2016 19:18:57 -0500 Message-Id: <1455063542-18227-3-git-send-email-kraigatgoog@gmail.com> X-Mailer: git-send-email 2.7.0.rc3.207.g0ac5344 In-Reply-To: <1455063542-18227-1-git-send-email-kraigatgoog@gmail.com> References: <1455063542-18227-1-git-send-email-kraigatgoog@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Craig Gallek In order to support fast lookups for TCP sockets with SO_REUSEPORT, the function that adds sockets to the listening hash set needs to be able to check receive address equality. Since this equality check is different for IPv4 and IPv6, we will need two different socket hashing functions. This patch adds inet6_hash identical to the existing inet_hash function and updates the appropriate references. A following patch will differentiate the two by passing different comparison functions to __inet_hash. Signed-off-by: Craig Gallek --- include/net/inet6_hashtables.h | 2 ++ net/dccp/ipv6.c | 2 +- net/ipv6/inet6_hashtables.c | 12 ++++++++++++ net/ipv6/tcp_ipv6.c | 2 +- net/l2tp/l2tp_ip6.c | 3 ++- 5 files changed, 18 insertions(+), 3 deletions(-) diff --git a/include/net/inet6_hashtables.h b/include/net/inet6_hashtables.h index 7ff588ca6817..b3c28a9dfbf1 100644 --- a/include/net/inet6_hashtables.h +++ b/include/net/inet6_hashtables.h @@ -96,6 +96,8 @@ struct sock *inet6_lookup(struct net *net, struct inet_hashinfo *hashinfo, const struct in6_addr *saddr, const __be16 sport, const struct in6_addr *daddr, const __be16 dport, const int dif); + +int inet6_hash(struct sock *sk); #endif /* IS_ENABLED(CONFIG_IPV6) */ #define INET6_MATCH(__sk, __net, __saddr, __daddr, __ports, __dif) \ diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c index 9c6d0508e63a..90a8269b28d0 100644 --- a/net/dccp/ipv6.c +++ b/net/dccp/ipv6.c @@ -993,7 +993,7 @@ static struct proto dccp_v6_prot = { .sendmsg = dccp_sendmsg, .recvmsg = dccp_recvmsg, .backlog_rcv = dccp_v6_do_rcv, - .hash = inet_hash, + .hash = inet6_hash, .unhash = inet_unhash, .accept = inet_csk_accept, .get_port = inet_csk_get_port, diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c index 21ace5a2bf7c..3521b15b8b85 100644 --- a/net/ipv6/inet6_hashtables.c +++ b/net/ipv6/inet6_hashtables.c @@ -274,3 +274,15 @@ int inet6_hash_connect(struct inet_timewait_death_row *death_row, __inet6_check_established); } EXPORT_SYMBOL_GPL(inet6_hash_connect); + +int inet6_hash(struct sock *sk) +{ + if (sk->sk_state != TCP_CLOSE) { + local_bh_disable(); + __inet_hash(sk, NULL); + local_bh_enable(); + } + + return 0; +} +EXPORT_SYMBOL_GPL(inet6_hash); diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 006396e31cb0..d72bcfb326d8 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -1865,7 +1865,7 @@ struct proto tcpv6_prot = { .sendpage = tcp_sendpage, .backlog_rcv = tcp_v6_do_rcv, .release_cb = tcp_release_cb, - .hash = inet_hash, + .hash = inet6_hash, .unhash = inet_unhash, .get_port = inet_csk_get_port, .enter_memory_pressure = tcp_enter_memory_pressure, diff --git a/net/l2tp/l2tp_ip6.c b/net/l2tp/l2tp_ip6.c index a2c8747d2936..6b54ff3ff4cb 100644 --- a/net/l2tp/l2tp_ip6.c +++ b/net/l2tp/l2tp_ip6.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -718,7 +719,7 @@ static struct proto l2tp_ip6_prot = { .sendmsg = l2tp_ip6_sendmsg, .recvmsg = l2tp_ip6_recvmsg, .backlog_rcv = l2tp_ip6_backlog_recv, - .hash = inet_hash, + .hash = inet6_hash, .unhash = inet_unhash, .obj_size = sizeof(struct l2tp_ip6_sock), #ifdef CONFIG_COMPAT