From patchwork Sat Sep 26 00:56:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 260159 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0EA9C4727D for ; Sat, 26 Sep 2020 00:56:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 88DB823119 for ; Sat, 26 Sep 2020 00:56:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601081818; bh=Cg9Si7MgCEn8QKF5o4itCLFhnHeZQZHq5qtC9sNzaas=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=A79c0/CIi6q+hXvNXv1nCkxgjWRKrpIRbZk9/2epFm9oRzz3mrhLbhiRLrinQS4PH YO4mIvZWtpF+bb1NrZySsXAS20UCvMCrF8TklVENNTIv6BvI5pyhGhoJan7WRngJ5B wiPzVuSHPapXM8WRF9luj+0OtERg4Qaaxd5AybwY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729859AbgIZA46 (ORCPT ); Fri, 25 Sep 2020 20:56:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:47346 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726316AbgIZA45 (ORCPT ); Fri, 25 Sep 2020 20:56:57 -0400 Received: from kicinski-fedora-PC1C0HJN.thefacebook.com (unknown [163.114.132.6]) (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 4F1B422211; Sat, 26 Sep 2020 00:56:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601081816; bh=Cg9Si7MgCEn8QKF5o4itCLFhnHeZQZHq5qtC9sNzaas=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jI8O+oCmQu1776AYelZm14he0bT2Y1DF17Bc8eRGg7OOqql7XAFbOg8sGaHJO/vtf mKX67ahwdTlSlzXCcZAORFjMiF7KyQic0H+rWql5f/ORpZ0mqMywSMC6Ix9ECFZLox WrSIVrZaxSF3WHpx7FilFyBjOq0g4hWG2OVfSnkk= From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, anthony.l.nguyen@intel.com, Jakub Kicinski Subject: [PATCH net-next v2 02/10] netdevsim: add warnings on unexpected UDP tunnel port errors Date: Fri, 25 Sep 2020 17:56:41 -0700 Message-Id: <20200926005649.3285089-3-kuba@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200926005649.3285089-1-kuba@kernel.org> References: <20200926005649.3285089-1-kuba@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org We should never see a removal of a port which is not in the table or adding a port to an occupied entry in the table. To make sure such errors don't escape the checks in the test script add a warning/kernel spat. Error injection will not trigger those, nor should it ever put us in a bad state. Signed-off-by: Jakub Kicinski --- drivers/net/netdevsim/udp_tunnels.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/net/netdevsim/udp_tunnels.c b/drivers/net/netdevsim/udp_tunnels.c index 22c06a76033c..ad65b860bd7b 100644 --- a/drivers/net/netdevsim/udp_tunnels.c +++ b/drivers/net/netdevsim/udp_tunnels.c @@ -22,11 +22,13 @@ nsim_udp_tunnel_set_port(struct net_device *dev, unsigned int table, msleep(ns->udp_ports.sleep); if (!ret) { - if (ns->udp_ports.ports[table][entry]) + if (ns->udp_ports.ports[table][entry]) { + WARN(1, "entry already in use\n"); ret = -EBUSY; - else + } else { ns->udp_ports.ports[table][entry] = be16_to_cpu(ti->port) << 16 | ti->type; + } } netdev_info(dev, "set [%d, %d] type %d family %d port %d - %d\n", @@ -50,10 +52,13 @@ nsim_udp_tunnel_unset_port(struct net_device *dev, unsigned int table, if (!ret) { u32 val = be16_to_cpu(ti->port) << 16 | ti->type; - if (val == ns->udp_ports.ports[table][entry]) + if (val == ns->udp_ports.ports[table][entry]) { ns->udp_ports.ports[table][entry] = 0; - else + } else { + WARN(1, "entry not installed %x vs %x\n", + val, ns->udp_ports.ports[table][entry]); ret = -ENOENT; + } } netdev_info(dev, "unset [%d, %d] type %d family %d port %d - %d\n",