Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp5454366imm; Tue, 16 Oct 2018 10:27:51 -0700 (PDT) X-Google-Smtp-Source: ACcGV63ilhqvK1xFYouXrTKhOycgBYPkAQ64fE/RRcd8RmUclreFjGgr+4S1l5qBX2OdV1nTrkpw X-Received: by 2002:a62:1b45:: with SMTP id b66-v6mr23003905pfb.94.1539710870952; Tue, 16 Oct 2018 10:27:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539710870; cv=none; d=google.com; s=arc-20160816; b=bkVrdbsD6+89XmTXvweE6np/bWk+wutpRiNqKawi2O9/m41aNIjC7JNad6B565Mr2a lM4Z7bdafQbvWpa5rb18wnczhRV4sBGe2ya+5IhDBGI94gjqGiw4R/EQUTTtjSsu6Qza XtUf2McgffOHkYrSvinlfB90/bi3fLN1goUP4HD4haJb41lCu0lurZVz83on0kprVe24 UikyCXlvVzWwePpszpto3VjqpZCH4rFPssRIzRsdoMCr5dBYWCxibbEjw9JQqf4xuJ1W 4r5M4rTMMYyDpBiIrIRyjOjsAQrbeNAUsyFZOpPFxFBdqtN9DXWXcWXC7pMglMrOagxt tFDA== 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=AfQpXYxZSdF53NxmznSp/U737LRPQc9LcbugPIZAPe0=; b=YxO2lrd7ZSCR7ti1KUYF3/TuOQv0nNVp9Qkk+ihyj9y17AzE8vzyx7PYi+oV/gd+Tq k1539i1W9jbZi/XV7zyT7X7h2NA6/0i7ove0u5F/EfMBX9B3ZKKWhgkcEow6tzdSiP9n XiwvcFd9rq3krMmXClLNzrndwDWBuJKT/xbb0BijEDG81oVF50aloJdzrnVxxIoENaSW xxDMaPg4r665GogLhpie2lTnLTw2LtcDoyUgyfNu1lO1w4TUm71rO+o6y1bdDkzjCLQH L61L6BjfEH2mTaVirdIHs1Fjf9IDVIQi76zlstkn8sZPdsRnha1gQ5sH8T/9lvk4Nd21 6hxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Wp72JkEC; 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 g27-v6si13843384pfj.37.2018.10.16.10.27.35; Tue, 16 Oct 2018 10:27:50 -0700 (PDT) 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=Wp72JkEC; 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 S1732143AbeJQBRT (ORCPT + 99 others); Tue, 16 Oct 2018 21:17:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:36080 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731313AbeJQBRR (ORCPT ); Tue, 16 Oct 2018 21:17:17 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (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 E333E2098A; Tue, 16 Oct 2018 17:25:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539710751; bh=9cIGkkUlzrEU7y5UkRrz0D6OkEhjjG/ETtSY3VdAR30=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wp72JkECIsfg9ExvJJNsWtM5Bez8cMPUWr2oQnafoadGLfgdqs7qEC6C3foISpCYp bUPoMxEUSXYUwf0PORmfpjAkoJeAX7e0LUI0ZPHL225ok09Dq4ORSPROBWudxBARcH P5ncs6V5Ck9wiD1ExT2+WZfSoMx4ut3kysJ4oidM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , "David S. Miller" Subject: [PATCH 4.9 52/71] inet: frags: get rif of inet_frag_evicting() Date: Tue, 16 Oct 2018 19:09:49 +0200 Message-Id: <20181016170541.975679282@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181016170539.315587743@linuxfoundation.org> References: <20181016170539.315587743@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Dumazet 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 (cherry picked from commit 399d1404be660d355192ff4df5ccc3f4159ec1e4) 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 @@ -141,8 +141,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); @@ -156,45 +159,41 @@ static void ip_expire(unsigned long arg) ipq_kill(qp); __IP_INC_STATS(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(net, IPSTATS_MIB_REASMTIMEOUT); + __IP_INC_STATS(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(net, __in6_dev_get(dev), IPSTATS_MIB_REASMFAILS); - - if (inet_frag_evicting(&fq->q)) - goto out_rcu_unlock; - __IP6_INC_STATS(net, __in6_dev_get(dev), IPSTATS_MIB_REASMTIMEOUT); /* Don't send error if the first segment did not arrive. */