From patchwork Sun Mar 12 23:01:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Frederic Sowa X-Patchwork-Id: 737933 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 3vhGlQ3NQtz9s78 for ; Mon, 13 Mar 2017 10:04:02 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=stressinduktion.org header.i=@stressinduktion.org header.b="LlCK7Flf"; dkim=pass (1024-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="kJ9CR4bq"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935820AbdCLXEB (ORCPT ); Sun, 12 Mar 2017 19:04:01 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:50793 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935642AbdCLXCQ (ORCPT ); Sun, 12 Mar 2017 19:02:16 -0400 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 78CDD207D1 for ; Sun, 12 Mar 2017 19:02:13 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute7.internal (MEProxy); Sun, 12 Mar 2017 19:02:13 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= stressinduktion.org; h=date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=zDjojfA1V7bB/eYARbydKaeIfT0=; b=LlCK7F lf+vZXrq/KXLNJj0P687ll53wgsI3YsVtuG+Uo95glz/1Mq25ziTc9pGKYxTNWbJ t06+fDvTGl0k3pYzaqElPtO+XEpyKqop0EGpSZDt/t3eC/W+r/hApwyDOsf6EElk Mct2DTYcun4TtvJbkN/oBanW8oQHpYqqy5CTY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc :x-sasl-enc; s=smtpout; bh=zDjojfA1V7bB/eYARbydKaeIfT0=; b=kJ9CR 4bqL89S8v8UL7vtXHcA6j81hqDBFNFmGpwKEEjKj83kVughtPOjCQ7oITALQwlT0 EiYnF9KK2XEh6KSKks/GfY0ca0++tMECOFTGox6jxqomyarujRKMxJ1OL1nkGbqH QfRaAiqpsCknvqTOINP8zFvTYXdMFLVIVYZ1H8= X-ME-Sender: X-Sasl-enc: xlGy8GLyqP/gQ10a8N90zNv2QHBRcSC8Blz+K8xy5LKd 1489359733 Received: from m.localhost.localhost (unknown [213.55.211.72]) by mail.messagingengine.com (Postfix) with ESMTPA id E3F0D240CF for ; Sun, 12 Mar 2017 19:02:12 -0400 (EDT) From: Hannes Frederic Sowa To: netdev@vger.kernel.org Subject: [PATCH net-next RFC v1 21/27] afnetns: add support for tcpv6 Date: Mon, 13 Mar 2017 00:01:45 +0100 Message-Id: <20170312230151.5185-22-hannes@stressinduktion.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170312230151.5185-1-hannes@stressinduktion.org> References: <20170312230151.5185-1-hannes@stressinduktion.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Same as the support for tcpv4, we simply add the necessary checks so we just look at our own sockets. Signed-off-by: Hannes Frederic Sowa --- net/ipv6/inet6_hashtables.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c index 8570e0e3016b65..05b71f0937e676 100644 --- a/net/ipv6/inet6_hashtables.c +++ b/net/ipv6/inet6_hashtables.c @@ -87,6 +87,7 @@ struct sock *__inet6_lookup_established(struct net *net, const u16 hnum, const int dif) { + struct afnetns *afnetns; struct sock *sk; const struct hlist_nulls_node *node; const __portpair ports = INET_COMBINED_PORTS(sport, hnum); @@ -97,11 +98,15 @@ struct sock *__inet6_lookup_established(struct net *net, unsigned int slot = hash & hashinfo->ehash_mask; struct inet_ehash_bucket *head = &hashinfo->ehash[slot]; + afnetns = ipv6_get_ifaddr_afnetns_rcu(net, daddr, + dev_get_by_index_rcu(net, dif)); begin: sk_nulls_for_each_rcu(sk, node, &head->chain) { if (sk->sk_hash != hash) continue; + if (sock_afnetns(sk) != afnetns) + continue; if (!INET6_MATCH(sk, net, saddr, daddr, ports, dif)) continue; if (unlikely(!atomic_inc_not_zero(&sk->sk_refcnt))) @@ -123,14 +128,15 @@ struct sock *__inet6_lookup_established(struct net *net, EXPORT_SYMBOL(__inet6_lookup_established); static inline int compute_score(struct sock *sk, struct net *net, + struct afnetns *afnetns, const unsigned short hnum, const struct in6_addr *daddr, const int dif, bool exact_dif) { int score = -1; - if (net_eq(sock_net(sk), net) && inet_sk(sk)->inet_num == hnum && - sk->sk_family == PF_INET6) { + if (net_eq(sock_net(sk), net) && sock_afnetns(sk) == afnetns && + inet_sk(sk)->inet_num == hnum && sk->sk_family == PF_INET6) { score = 1; if (!ipv6_addr_any(&sk->sk_v6_rcv_saddr)) { @@ -162,10 +168,14 @@ struct sock *inet6_lookup_listener(struct net *net, int score, hiscore = 0, matches = 0, reuseport = 0; bool exact_dif = inet6_exact_dif_match(net, skb); struct sock *sk, *result = NULL; + struct afnetns *afnetns; u32 phash = 0; + afnetns = ipv6_get_ifaddr_afnetns_rcu(net, daddr, skb->dev); + sk_for_each(sk, &ilb->head) { - score = compute_score(sk, net, hnum, daddr, dif, exact_dif); + score = compute_score(sk, net, afnetns, hnum, daddr, dif, + exact_dif); if (score > hiscore) { reuseport = sk->sk_reuseport; if (reuseport) {