Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp246668imj; Thu, 7 Feb 2019 03:45:30 -0800 (PST) X-Google-Smtp-Source: AHgI3IY/DIOCZGcdqrSSHPsLFENDv1+ZxBRLf+0A3AE7zMeYCm/X82o9vQGun3Z2CWUEIWZLY7Ru X-Received: by 2002:a62:1d8f:: with SMTP id d137mr15609972pfd.11.1549539930711; Thu, 07 Feb 2019 03:45:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549539930; cv=none; d=google.com; s=arc-20160816; b=IzdKPC1KVGC4DbQbsEFddYWkH1i4GfseRp9ft3XMjifsOkZgfP+MtM9Y2jX2iIXgBo tsKCSr3427kuFmyoYlgbPQEBK5JcEId/UjXtmnXuUdglf4XEOWlknKED6jGnmhTu95oH 4KX6St/xHfNLmMBp+RwHFOTovaNxrTeS+hMbTi/3LovPBN/BiqJ+m0DGRZHUZ2LBnLOu tTP7ZrgNnvjs1SJ/kE/aSwkDmy4h3r+Y888plSR1TePhdcAIXrQihN7I6M5hrRz74q3v K+jQ1Ieu5/+s5qsWcOyk1Ojqt5yGGASdOaLKCOadengzSSuORW2WUSagRfeUjvfSxYZf +U3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vyEdh8cCs5Esn3O/dt/8S1/QsrpD4Pp8mOHJ0yhrgxQ=; b=wgYq76We+kkEC4pdRHBZ/mFMyiKDAFjX5xNg/ebHryXH6Jd0xJL0HYe42sCaiygXLR fswkrm9AFhmcdaNN7Ajv2lJcVDPFDCsrF1QDpKoDNjlD71UVJhLq9KKeepH1xafLjGSx 5wucPj3Fh53F8DzeMRfyWm30bghlzk4Pi12rh/wfMoIhbt/O84e/GTBKRb9tflID6Zzx ELnF0VvEKMXCOsYiIyEpamb4TGSmTjoHtGhEzMz+nK57HUm+o4CpHxjxjG5hZROwBMfl Z3TN6ImR6gWqN3JyQ8mtEbETBHeZJLxMnjlGS6dhP4xI2qTqoV8wd33zMrLQ7dunhMok Yuzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=b+hbFPfe; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f7si2614103plr.96.2019.02.07.03.45.15; Thu, 07 Feb 2019 03:45:30 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=b+hbFPfe; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727435AbfBGLnX (ORCPT + 99 others); Thu, 7 Feb 2019 06:43:23 -0500 Received: from mail.kernel.org ([198.145.29.99]:33600 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727423AbfBGLnW (ORCPT ); Thu, 7 Feb 2019 06:43:22 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C33E32190A; Thu, 7 Feb 2019 11:43:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549539802; bh=kumJb13zqZB4efZMCLaf8NKGpFOWCQhlWfjfV6UMt5Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b+hbFPfeqxNOkYgZGk+rxOmgjXWMktZZ4L0BWH8lkZ1/SVnj7p6TtbJzQVVwh4bfE 0gFre+wi41HIFrTe0RQpdJE/oHRekCPejxm7qeRnNSkbbXLyLW0BQaJ25eCm6cET6y qW9UawfJLIEBy/t2gzCh080ckWRoDCghuFvg0QwQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , "David S. Miller" , Mao Wenan , Ben Hutchings Subject: [PATCH 4.4 13/34] inet: frags: get rif of inet_frag_evicting() Date: Thu, 7 Feb 2019 12:41:55 +0100 Message-Id: <20190207113026.099380300@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190207113025.552605181@linuxfoundation.org> References: <20190207113025.552605181@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Dumazet commit 399d1404be660d355192ff4df5ccc3f4159ec1e4 upstream. This refactors ip_expire() since one indentation level is removed. Note: in the future, we should try hard to avoid the skb_clone() since this is a serious performance cost. Under DDOS, the ICMP message wont be sent because of rate limits. Fact that ip6_expire_frag_queue() does not use skb_clone() is disturbing too. Presumably IPv6 should have the same issue than the one we fixed in commit ec4fbd64751d ("inet: frag: release spinlock before calling icmp_send()") Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller Signed-off-by: Mao Wenan [bwh: Backported to 4.4: adjust context] Signed-off-by: Ben Hutchings Signed-off-by: Greg Kroah-Hartman --- include/net/inet_frag.h | 5 --- net/ipv4/ip_fragment.c | 65 +++++++++++++++++++++++------------------------- net/ipv6/reassembly.c | 4 -- 3 files changed, 32 insertions(+), 42 deletions(-) --- a/include/net/inet_frag.h +++ b/include/net/inet_frag.h @@ -118,11 +118,6 @@ static inline void inet_frag_put(struct inet_frag_destroy(q); } -static inline bool inet_frag_evicting(struct inet_frag_queue *q) -{ - return false; -} - /* Memory Tracking Functions. */ static inline int frag_mem_limit(struct netns_frags *nf) --- a/net/ipv4/ip_fragment.c +++ b/net/ipv4/ip_fragment.c @@ -143,8 +143,11 @@ static bool frag_expire_skip_icmp(u32 us */ static void ip_expire(unsigned long arg) { - struct ipq *qp; + struct sk_buff *clone, *head; + const struct iphdr *iph; struct net *net; + struct ipq *qp; + int err; qp = container_of((struct inet_frag_queue *) arg, struct ipq, q); net = container_of(qp->q.net, struct net, ipv4.frags); @@ -158,45 +161,41 @@ static void ip_expire(unsigned long arg) ipq_kill(qp); IP_INC_STATS_BH(net, IPSTATS_MIB_REASMFAILS); - if (!inet_frag_evicting(&qp->q)) { - struct sk_buff *clone, *head = qp->q.fragments; - const struct iphdr *iph; - int err; + head = qp->q.fragments; - IP_INC_STATS_BH(net, IPSTATS_MIB_REASMTIMEOUT); + IP_INC_STATS_BH(net, IPSTATS_MIB_REASMTIMEOUT); - if (!(qp->q.flags & INET_FRAG_FIRST_IN) || !qp->q.fragments) - goto out; + if (!(qp->q.flags & INET_FRAG_FIRST_IN) || !head) + goto out; - head->dev = dev_get_by_index_rcu(net, qp->iif); - if (!head->dev) - goto out; + head->dev = dev_get_by_index_rcu(net, qp->iif); + if (!head->dev) + goto out; - /* skb has no dst, perform route lookup again */ - iph = ip_hdr(head); - err = ip_route_input_noref(head, iph->daddr, iph->saddr, + /* skb has no dst, perform route lookup again */ + iph = ip_hdr(head); + err = ip_route_input_noref(head, iph->daddr, iph->saddr, iph->tos, head->dev); - if (err) - goto out; + if (err) + goto out; + + /* Only an end host needs to send an ICMP + * "Fragment Reassembly Timeout" message, per RFC792. + */ + if (frag_expire_skip_icmp(qp->q.key.v4.user) && + (skb_rtable(head)->rt_type != RTN_LOCAL)) + goto out; + + clone = skb_clone(head, GFP_ATOMIC); - /* Only an end host needs to send an ICMP - * "Fragment Reassembly Timeout" message, per RFC792. - */ - if (frag_expire_skip_icmp(qp->q.key.v4.user) && - (skb_rtable(head)->rt_type != RTN_LOCAL)) - goto out; - - clone = skb_clone(head, GFP_ATOMIC); - - /* Send an ICMP "Fragment Reassembly Timeout" message. */ - if (clone) { - spin_unlock(&qp->q.lock); - icmp_send(clone, ICMP_TIME_EXCEEDED, - ICMP_EXC_FRAGTIME, 0); - consume_skb(clone); - goto out_rcu_unlock; - } + /* Send an ICMP "Fragment Reassembly Timeout" message. */ + if (clone) { + spin_unlock(&qp->q.lock); + icmp_send(clone, ICMP_TIME_EXCEEDED, + ICMP_EXC_FRAGTIME, 0); + consume_skb(clone); + goto out_rcu_unlock; } out: spin_unlock(&qp->q.lock); --- a/net/ipv6/reassembly.c +++ b/net/ipv6/reassembly.c @@ -106,10 +106,6 @@ void ip6_expire_frag_queue(struct net *n goto out_rcu_unlock; IP6_INC_STATS_BH(net, __in6_dev_get(dev), IPSTATS_MIB_REASMFAILS); - - if (inet_frag_evicting(&fq->q)) - goto out_rcu_unlock; - IP6_INC_STATS_BH(net, __in6_dev_get(dev), IPSTATS_MIB_REASMTIMEOUT); /* Don't send error if the first segment did not arrive. */