Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp1297334lqh; Mon, 6 May 2024 03:32:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWBPA/VUHWD+B90yah+VzFCgnFEbIzZJdNd0AlJq+Efd6PyuYeqF2lUVDNibC8CYTOzO7ZzgzUHrUhk1KEYjcg1JQB+nbrWixev/hWAVw== X-Google-Smtp-Source: AGHT+IHqQzFN5muOKjUS3121huuXDSn5342uhpgoGHL/J1s0zKhNdYT5lBWtaX9mGJPNGg/ob35P X-Received: by 2002:a17:903:1205:b0:1e3:d4eb:a0f2 with SMTP id l5-20020a170903120500b001e3d4eba0f2mr11604848plh.51.1714991559266; Mon, 06 May 2024 03:32:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714991559; cv=pass; d=google.com; s=arc-20160816; b=z8X0gTxKP4GzQTKY75t8bIPSSZnlIuFr7kJkxNlFjJ1lmbidcHKcFfbz2hxPRFEY0V dptgncxQMBKpPF9DeyI1Pn1Z9QXhWhR6zinDISb0dALW4u/XRDj/DBaMkKeDOlPvf1Hi Te88EQ/b570oWC/tM2YmS+hiQfhbvE7iLbSu02ECj/mBqZS8LuIGYQI2PEjPuzHkD68b ETk2+R9VX66W5bbUW+543chXLhB0Mg8PxrCD8z7Mxr7H3beXPP6cVr8wH9oBsY43Bs5q ORIiVgCxFDXa8K/UmYDh/LkvVP1lSY6SVzcBya4O1erQPqGyT2lCqFy7Cf9iO3DL5zea yzNQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=b0UQxM3TonOcehuwcatxMce5YJodNsGcp9N5OnSH5oc=; fh=OcvN10eV77yK7PvKqvprtCX9G7QwTUs6GbFNSpYGs08=; b=sgNNJzWHeNlFJ8S06ydUjlHljmBy3PB3r0vKPJTzjkKfCAxmgAORpFjNsKyfoddFgi nqgxPxTNMBeMjAHtEyMwXNNZg4ogFF31CwsVZrAleF3BThbb1AB0woL8wcFpWjNOHAOK 0t3cappGoYIR0BUQQPWjhyp83q5BX0C/LA3qh4Rv2/EWa8inHaQkKLBSETDECUoJPPio C7TNOO6yiG/fl/aLdbMpClj+sTnuEMy4P/sBMMzyZZChbXqs5O+DWOQfAzi7HtFsutns ufwO5mULPUzMPmMXCoEkSJ3UbmsVWmlCJILKirY70t87/rY6l/KWq/mc+ykX4K167uRR MVWg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-169671-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169671-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id t4-20020a170902e84400b001e84ad92f52si8275627plg.486.2024.05.06.03.32.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 03:32:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-169671-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-169671-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169671-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 7D0892830BC for ; Mon, 6 May 2024 10:32:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D51AA2BAE3; Mon, 6 May 2024 10:32:33 +0000 (UTC) Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B3AE29A9 for ; Mon, 6 May 2024 10:32:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714991553; cv=none; b=Wufj2jMLcOhKDYJPvc2y0LsqOpzNEobtLw11mMlOOk92r386kqxfgiVfXPOjKkaAqd7te3Eso3kVLYwUcHdicnXcXyRDtQGBctrh2D0vq2VIAYZWQA3hMF33LYNE/IK5FKvjwf4u37j7z6agGeIHQ0MSpwhbtlhF1qHntYLkEoc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714991553; c=relaxed/simple; bh=Wym1846Bns5koUhuTopZyiuPiGa2cITbldLcrqUxUq8=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=q7EAVxuV9P/rVzY9OG9zOb+FR8bka4Xm1PHikbvAG/O5kY1YZkjt9AYZf5OmVTburiHTGW1XrTuNjTu3rmgkO2ELGrDVW4J9rBocn9+tMTZZscZFjS73W9VgDDHfDIlUunurwa1Nud47J4bFOQXrOfr9jrl/RJ8YGRcdZBg6rGc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1s3vdi-0004i4-5A; Mon, 06 May 2024 12:32:10 +0200 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s3vdf-00GFN1-TH; Mon, 06 May 2024 12:32:07 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1s3vdf-005C9u-2j; Mon, 06 May 2024 12:32:07 +0200 From: Oleksij Rempel To: Jiri Pirko , Ivan Vecera , "David S. Miller" , Andrew Lunn , Eric Dumazet , Florian Fainelli , Jakub Kicinski , Paolo Abeni , Vladimir Oltean Cc: Oleksij Rempel , Simon Horman , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net-next v4 1/1] net: bridge: switchdev: Improve error message for port_obj_add/del functions Date: Mon, 6 May 2024 12:32:05 +0200 Message-Id: <20240506103205.1238139-1-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Enhance the error reporting mechanism in the switchdev framework to provide more informative and user-friendly error messages. Following feedback from users struggling to understand the implications of error messages like "failed (err=-28) to add object (id=2)", this update aims to clarify what operation failed and how this might impact the system or network. With this change, error messages now include a description of the failed operation, the specific object involved, and a brief explanation of the potential impact on the system. This approach helps administrators and developers better understand the context and severity of errors, facilitating quicker and more effective troubleshooting. Example of the improved logging: [ 70.516446] ksz-switch spi0.0 uplink: Failed to add Port Multicast Database entry (object id=2) with error: -ENOSPC (-28). [ 70.516446] Failure in updating the port's Multicast Database could lead to multicast forwarding issues. [ 70.516446] Current HW/SW setup lacks sufficient resources. This comprehensive update includes handling for a range of switchdev object IDs, ensuring that most operations within the switchdev framework benefit from clearer error reporting. Reviewed-by: Simon Horman Signed-off-by: Oleksij Rempel --- changes v4: - reorder Reviewed-by tag - make a shorter patch title changes v3: - fix check patch warnings changes v2: - make all variables const - add Reviewed-by: Simon Horman --- net/switchdev/switchdev.c | 99 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 95 insertions(+), 4 deletions(-) diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c index c9189a970eec3..6488ead9e4645 100644 --- a/net/switchdev/switchdev.c +++ b/net/switchdev/switchdev.c @@ -244,6 +244,99 @@ static int switchdev_port_obj_notify(enum switchdev_notifier_type nt, return 0; } +static void switchdev_obj_id_to_helpful_msg(struct net_device *dev, + enum switchdev_obj_id obj_id, + int err, bool add) +{ + const char *action = add ? "add" : "del"; + const char *reason = ""; + const char *problem; + const char *obj_str; + + switch (obj_id) { + case SWITCHDEV_OBJ_ID_UNDEFINED: + obj_str = "Undefined object"; + problem = "Attempted operation is undefined, indicating a possible programming\n" + "error.\n"; + break; + case SWITCHDEV_OBJ_ID_PORT_VLAN: + obj_str = "VLAN entry"; + problem = "Failure in VLAN settings on this port might disrupt network\n" + "segmentation or traffic isolation, affecting network partitioning.\n"; + break; + case SWITCHDEV_OBJ_ID_PORT_MDB: + obj_str = "Port Multicast Database entry"; + problem = "Failure in updating the port's Multicast Database could lead to\n" + "multicast forwarding issues.\n"; + break; + case SWITCHDEV_OBJ_ID_HOST_MDB: + obj_str = "Host Multicast Database entry"; + problem = "Failure in updating the host's Multicast Database may impact multicast\n" + "group memberships or traffic delivery, affecting multicast\n" + "communication.\n"; + break; + case SWITCHDEV_OBJ_ID_MRP: + obj_str = "Media Redundancy Protocol configuration for port"; + problem = "Failure to set MRP ring ID on this port prevents communication with\n" + "the specified redundancy ring, resulting in an inability to engage\n" + "in MRP-based network operations.\n"; + break; + case SWITCHDEV_OBJ_ID_RING_TEST_MRP: + obj_str = "MRP Test Frame Operations for port"; + problem = "Failure to generate/monitor MRP test frames may lead to inability to\n" + "assess the ring's operational integrity and fault response, hindering\n" + "proactive network management.\n"; + break; + case SWITCHDEV_OBJ_ID_RING_ROLE_MRP: + obj_str = "MRP Ring Role Configuration"; + problem = "Improper MRP ring role configuration may create conflicts in the ring,\n" + "disrupting communication for all participants, or isolate the local\n" + "system from the ring, hindering its ability to communicate with other\n" + "participants.\n"; + break; + case SWITCHDEV_OBJ_ID_RING_STATE_MRP: + obj_str = "MRP Ring State Configuration"; + problem = "Failure to correctly set the MRP ring state can result in network\n" + "loops or leave segments without communication. In a Closed state,\n" + "it maintains loop prevention by blocking one MRM port, while an Open\n" + "state activates in response to failures, changing port states to\n" + "preserve network connectivity.\n"; + break; + case SWITCHDEV_OBJ_ID_IN_TEST_MRP: + obj_str = "MRP_InTest Frame Generation Configuration"; + problem = "Failure in managing MRP_InTest frame generation can misjudge the\n" + "interconnection ring's state, leading to incorrect blocking or\n" + "unblocking of the I/C port. This misconfiguration might result\n" + "in unintended network loops or isolate critical network segments,\n" + "compromising network integrity and reliability.\n"; + break; + case SWITCHDEV_OBJ_ID_IN_ROLE_MRP: + obj_str = "Interconnection Ring Role Configuration"; + problem = "Failure in incorrect assignment of interconnection ring roles\n" + "(MIM/MIC) can impair the formation of the interconnection rings.\n"; + break; + case SWITCHDEV_OBJ_ID_IN_STATE_MRP: + obj_str = "Interconnection Ring State Configuration"; + problem = "Failure in updating the interconnection ring state can lead in\n" + "case of Open state to incorrect blocking or unblocking of the\n" + "I/C port, resulting in unintended network loops or isolation\n" + "of critical network\n"; + break; + default: + obj_str = "Unknown object"; + problem = "Indicating a possible programming error.\n"; + } + + switch (err) { + case -ENOSPC: + reason = "Current HW/SW setup lacks sufficient resources.\n"; + break; + } + + netdev_err(dev, "Failed to %s %s (object id=%d) with error: %pe (%d).\n%s%s\n", + action, obj_str, obj_id, ERR_PTR(err), err, problem, reason); +} + static void switchdev_port_obj_add_deferred(struct net_device *dev, const void *data) { @@ -254,8 +347,7 @@ static void switchdev_port_obj_add_deferred(struct net_device *dev, err = switchdev_port_obj_notify(SWITCHDEV_PORT_OBJ_ADD, dev, obj, NULL); if (err && err != -EOPNOTSUPP) - netdev_err(dev, "failed (err=%d) to add object (id=%d)\n", - err, obj->id); + switchdev_obj_id_to_helpful_msg(dev, obj->id, err, true); if (obj->complete) obj->complete(dev, err, obj->complete_priv); } @@ -304,8 +396,7 @@ static void switchdev_port_obj_del_deferred(struct net_device *dev, err = switchdev_port_obj_del_now(dev, obj); if (err && err != -EOPNOTSUPP) - netdev_err(dev, "failed (err=%d) to del object (id=%d)\n", - err, obj->id); + switchdev_obj_id_to_helpful_msg(dev, obj->id, err, false); if (obj->complete) obj->complete(dev, err, obj->complete_priv); } -- 2.39.2