From patchwork Fri Sep 8 07:01:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Axtens X-Patchwork-Id: 811342 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 3xpStG2Qccz9sDB; Fri, 8 Sep 2017 17:01:58 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1dqDIZ-0001C8-IX; Fri, 08 Sep 2017 07:01:55 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1dqDIX-0001BB-J0 for kernel-team@lists.canonical.com; Fri, 08 Sep 2017 07:01:53 +0000 Received: from mail-pf0-f197.google.com ([209.85.192.197]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1dqDIX-0003DM-7K for kernel-team@lists.canonical.com; Fri, 08 Sep 2017 07:01:53 +0000 Received: by mail-pf0-f197.google.com with SMTP id g13so3517978pfm.0 for ; Fri, 08 Sep 2017 00:01:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=3h5Nslc+TJ2Gs9qsKFsqnONND8ZQDkg5jmFuRrVH2w8=; b=kiDelvb1cpOpF5oIpUJ+JMl0pIX5ArDqaEOE0j2Svq3XqPIxLNLFFL+uSOYTOtxwG9 1HihjwKZtdYXLttebG1UR8f0HFwV1LkJFnWjdTNCs4Z40fSHfg487kYrmsDHN7kMol3s ImZte08Wrvpmy2177ntcXa4A6iaJF8iBVsEM/WceV1SUj+GF8ftLUcBIcnapMa1Eu3+0 Z9GSXWo0LHglguEVP4mxlTkOPnEeuaUeeYkQqHP/dNSBSK8ihR34c6o0fApLNqQwgjV+ oriyZyVS3BIDdFi3TK/SUdV1x1le2hllYG7G8XvLcTJ7aqs1J2DA1+XYsvBQH45/cnGW 95Bg== X-Gm-Message-State: AHPjjUhY37xE273Wm9KAn0mPDSe7BdCsy1Ww59k89I4z6ltDByNHmboh +EZ/xRnnIiEvrg05gQNxDF9xpwBLGZMFbrk1cnL0VeRFpZIkVNEROREWUzFcvMsEzgnX8ec60by rqLYMbGo37Bu3A+1v/cFXiX4mEa61GH0FIHMmHRo= X-Received: by 10.98.77.70 with SMTP id a67mr2092261pfb.347.1504854111760; Fri, 08 Sep 2017 00:01:51 -0700 (PDT) X-Google-Smtp-Source: ADKCNb4LnPLoqy4GGgbtBhcFK2/ugrCKxlmbtLCHyBQnfQb8MO3zh+9qQMw3NH/kkCZ8qx0JZQpN8w== X-Received: by 10.98.77.70 with SMTP id a67mr2092247pfb.347.1504854111350; Fri, 08 Sep 2017 00:01:51 -0700 (PDT) Received: from localhost.localdomain (124-171-202-56.dyn.iinet.net.au. [124.171.202.56]) by smtp.gmail.com with ESMTPSA id h1sm2255518pfg.153.2017.09.08.00.01.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Sep 2017 00:01:50 -0700 (PDT) From: Daniel Axtens To: kernel-team@lists.canonical.com Subject: [SRU][Xenial][PATCH 1/7] sock: add sk_dst_pending_confirm flag Date: Fri, 8 Sep 2017 17:01:36 +1000 Message-Id: <20170908070142.4440-2-daniel.axtens@canonical.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170908070142.4440-1-daniel.axtens@canonical.com> References: <20170908070142.4440-1-daniel.axtens@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Julian Anastasov BugLink: https://bugs.launchpad.net/bugs/1715812 Add new sock flag to allow sockets to confirm neighbour. When same struct dst_entry can be used for many different neighbours we can not use it for pending confirmations. As not all call paths lock the socket use full word for the flag. Add sk_dst_confirm as replacement for dst_confirm when called for received packets. Signed-off-by: Julian Anastasov Acked-by: Eric Dumazet Signed-off-by: David S. Miller (backported from commit 9b8805a325591cf5b6b9df71200de25a2bd721fd) Signed-off-by: Daniel Axtens --- include/net/sock.h | 11 +++++++++++ net/core/sock.c | 2 ++ 2 files changed, 13 insertions(+) diff --git a/include/net/sock.h b/include/net/sock.h index 3d5ff7436f41..08d2bb9e66ee 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -254,6 +254,7 @@ struct cg_proto; * @sk_wq: sock wait queue and async head * @sk_rx_dst: receive input route used by early demux * @sk_dst_cache: destination cache + * @sk_dst_pending_confirm: need to confirm neighbour * @sk_policy: flow policy * @sk_receive_queue: incoming packets * @sk_wmem_alloc: transmit queue bytes committed @@ -397,6 +398,7 @@ struct sock { atomic_t sk_omem_alloc; int sk_sndbuf; struct sk_buff_head sk_write_queue; + __u32 sk_dst_pending_confirm; kmemcheck_bitfield_begin(flags); unsigned int sk_shutdown : 2, sk_no_check_tx : 1, @@ -1748,6 +1750,7 @@ static inline void dst_negative_advice(struct sock *sk) if (ndst != dst) { rcu_assign_pointer(sk->sk_dst_cache, ndst); sk_tx_queue_clear(sk); + sk->sk_dst_pending_confirm = 0; } } } @@ -1758,6 +1761,7 @@ __sk_dst_set(struct sock *sk, struct dst_entry *dst) struct dst_entry *old_dst; sk_tx_queue_clear(sk); + sk->sk_dst_pending_confirm = 0; /* * This can be called while sk is owned by the caller only, * with no state that can be checked in a rcu_dereference_check() cond @@ -1773,6 +1777,7 @@ sk_dst_set(struct sock *sk, struct dst_entry *dst) struct dst_entry *old_dst; sk_tx_queue_clear(sk); + sk->sk_dst_pending_confirm = 0; old_dst = xchg((__force struct dst_entry **)&sk->sk_dst_cache, dst); dst_release(old_dst); } @@ -1793,6 +1798,12 @@ struct dst_entry *__sk_dst_check(struct sock *sk, u32 cookie); struct dst_entry *sk_dst_check(struct sock *sk, u32 cookie); +static inline void sk_dst_confirm(struct sock *sk) +{ + if (!sk->sk_dst_pending_confirm) + sk->sk_dst_pending_confirm = 1; +} + bool sk_mc_loop(struct sock *sk); static inline bool sk_can_gso(const struct sock *sk) diff --git a/net/core/sock.c b/net/core/sock.c index bd2fad27891e..6c890806868d 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -532,6 +532,7 @@ struct dst_entry *__sk_dst_check(struct sock *sk, u32 cookie) if (dst && dst->obsolete && dst->ops->check(dst, cookie) == NULL) { sk_tx_queue_clear(sk); + sk->sk_dst_pending_confirm = 0; RCU_INIT_POINTER(sk->sk_dst_cache, NULL); dst_release(dst); return NULL; @@ -1540,6 +1541,7 @@ struct sock *sk_clone_lock(const struct sock *sk, const gfp_t priority) af_family_clock_key_strings[newsk->sk_family]); newsk->sk_dst_cache = NULL; + newsk->sk_dst_pending_confirm = 0; newsk->sk_wmem_queued = 0; newsk->sk_forward_alloc = 0; newsk->sk_send_head = NULL;