From patchwork Tue May 22 14:00:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evgenii Smirnov X-Patchwork-Id: 10418689 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 95180600CC for ; Tue, 22 May 2018 14:01:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7891828DF8 for ; Tue, 22 May 2018 14:01:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2EE9828E78; Tue, 22 May 2018 14:01:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6832828EC3 for ; Tue, 22 May 2018 14:01:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751214AbeEVOBG (ORCPT ); Tue, 22 May 2018 10:01:06 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:41638 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751196AbeEVOBF (ORCPT ); Tue, 22 May 2018 10:01:05 -0400 Received: by mail-wr0-f196.google.com with SMTP id u12-v6so1387551wrn.8 for ; Tue, 22 May 2018 07:01:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=profitbricks-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=1H9EDNs+W6snx+WnB+fexhvBRwsVJHPGDbNqRyvmgUg=; b=ID83wa+FwWh50giHijXtFYNtwiMpZNeMiR6ZnziVAtSIF5vm0feXFAwPkOFyOnHDpc yukihPNsz4wJEX26Al5sxDOsT2pFz4OLsEvO9E007JYYDFmJtcI1ypIQbOSxdxNX74g5 8CaOQc4KYqBXMMeC+DSm12uCLROc26wPjbe1ouMZT4xbLvxrs7/Abb9/z9j/qjbP1Sh1 cJNSLhl+TboERITD37cPniGeQXplARoXvn1ZrBJ4AFPB0c22TZjXfMoN9lgplIbkx9qz 3j2TxHsMN/alFh3HFFzoZDZDyvMoYel1WEXOT1ewEk0QC2ZnSZI/EQkQVGanJMR91kl+ qleA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=1H9EDNs+W6snx+WnB+fexhvBRwsVJHPGDbNqRyvmgUg=; b=D2cz1Mu3WdZGrT9gJb+J9mr0kP62bScmLY7Cy/XDDY2yIacnl8ZMPIVnDN8oVAT1GZ hMc1kVwE6sBUAiMyi9Gy3525IAaTQiBmfe8rxV68McS4Av7gUBhlhqPcGY4fywksrMu8 ptGa4ai+06QIAS0ROt27L8vvJP9OJFw0AcJIIHrBfiLC2/5YskVjDmNCYVSW9ZPFpTqy vUOPcN+C5KD3YUFStIcUwE/GrrXy0VYpTpa599a5U+c4wdECZcIn2Hksa2I3NXtrTHQK DotTSdvE2Bb2Mfpmi6H21ikDiwrFUpcrlnSuCiIeANuI8s4qNu8Nomlbz7YXIAreM6wY uaoQ== X-Gm-Message-State: ALKqPwexHD8gSWbzKGqcqWa2Ru9ybolzfMZKgJcfPYf8lmAg+/CrmXAS bbbM1bmQQPIrCv1QCVxL7ZsLIrNx X-Google-Smtp-Source: AB8JxZrrhANhzzEbc23LeIjdu5+yU8Hg0c4VD47X2gnNYgPyHq49m86TcYyz2ctXqWpxfu3bQd4/Sw== X-Received: by 2002:adf:9441:: with SMTP id 59-v6mr9060429wrq.194.1526997664075; Tue, 22 May 2018 07:01:04 -0700 (PDT) Received: from smirnov-ws.pb.local ([62.217.45.26]) by smtp.gmail.com with ESMTPSA id f83-v6sm24526022wmh.32.2018.05.22.07.01.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 May 2018 07:01:03 -0700 (PDT) From: Evgenii Smirnov To: linux-rdma@vger.kernel.org Cc: Doug Ledford , Jason Gunthorpe , Evgenii Smirnov Subject: [PATCH] RDMA/ipoib: drop skb on path record lookup failure Date: Tue, 22 May 2018 16:00:47 +0200 Message-Id: <20180522140047.25524-1-evgenii.smirnov@profitbricks.com> X-Mailer: git-send-email 2.17.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In unicast_arp_send function there is an inconsistency in error handling of path_rec_start call. If path_rec_start is called because of an absent ah field, skb will be dropped. But if it is called on a creation of a new path, or if the path is invalid, skb will be added to the tail of path queue. In case of a new path it will be dropped on path_free, but in case of invalid path it can stay in the queue forever. This patch unifies the behavior, dropping skb in all cases of path_rec_start failure. Signed-off-by: Evgenii Smirnov --- drivers/infiniband/ulp/ipoib/ipoib_main.c | 55 +++++++++-------------- 1 file changed, 21 insertions(+), 34 deletions(-) diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c index cf291f90b58f..79e00db50bdf 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c @@ -1039,53 +1039,40 @@ static void unicast_arp_send(struct sk_buff *skb, struct net_device *dev, if (!path) { path = path_rec_create(dev, phdr->hwaddr + 4); + if (!path) + goto drop_and_unlock; new_path = 1; + } else { + /* make sure there is no changes in the existing path record */ + init_path_rec(priv, path, phdr->hwaddr + 4); } - if (path) { - if (!new_path) - /* make sure there is no changes in the existing path record */ - init_path_rec(priv, path, phdr->hwaddr + 4); - - if (skb_queue_len(&path->queue) < IPOIB_MAX_PATH_REC_QUEUE) { - push_pseudo_header(skb, phdr->hwaddr); - __skb_queue_tail(&path->queue, skb); - } else { - ++dev->stats.tx_dropped; - dev_kfree_skb_any(skb); - } - if (!path->query && path_rec_start(dev, path)) { - spin_unlock_irqrestore(&priv->lock, flags); - if (new_path) - path_free(dev, path); - return; - } else - __path_add(dev, path); - } else { + if (!path->query && path_rec_start(dev, path)) { + if (new_path) + path_free(dev, path); goto drop_and_unlock; } - spin_unlock_irqrestore(&priv->lock, flags); - return; - } + if (new_path) + __path_add(dev, path); - if (path->ah) { - ipoib_dbg(priv, "Send unicast ARP to %08x\n", - be32_to_cpu(sa_path_get_dlid(&path->pathrec))); + if (skb_queue_len(&path->queue) < IPOIB_MAX_PATH_REC_QUEUE) { + push_pseudo_header(skb, phdr->hwaddr); + __skb_queue_tail(&path->queue, skb); + } else { + goto drop_and_unlock; + } spin_unlock_irqrestore(&priv->lock, flags); - path->ah->last_send = rn->send(dev, skb, path->ah->ah, - IPOIB_QPN(phdr->hwaddr)); return; - } else if ((path->query || !path_rec_start(dev, path)) && - skb_queue_len(&path->queue) < IPOIB_MAX_PATH_REC_QUEUE) { - push_pseudo_header(skb, phdr->hwaddr); - __skb_queue_tail(&path->queue, skb); - } else { - goto drop_and_unlock; } + ipoib_dbg(priv, "Send unicast ARP to %08x\n", + be32_to_cpu(sa_path_get_dlid(&path->pathrec))); + spin_unlock_irqrestore(&priv->lock, flags); + path->ah->last_send = rn->send(dev, skb, path->ah->ah, + IPOIB_QPN(phdr->hwaddr)); return; drop_and_unlock: