Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp989412pxt; Fri, 6 Aug 2021 20:33:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzv5Pxs+ltxTCbbKU7GX3CVqmjq2EzB2trMzrN94ctnE3C3cUwSnMWS2YjrvDxtxZffj4gR X-Received: by 2002:a02:5bca:: with SMTP id g193mr12508877jab.129.1628307191610; Fri, 06 Aug 2021 20:33:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628307191; cv=none; d=google.com; s=arc-20160816; b=bgE1Suf7R/tmwidvtQHrF7BioDiCqJ1qpog0KybbkOZrUQr6ijgl3zfj6WdFceH74k eq/NzHDwZLErV+mfCUWqvzXUxoBMznk0PW+1+/T/nKbU7Y9HAYkYUzalAOcJedbLuaHe kZ3TukCfIoEC2KATxS2yzlEymCjK8NOFwnL06N8i7ERKtyCW609XW5SZNCZZHiS9MZcv xtI2vHWR3am496rgDmQBQwyIjQ9GrTQArrJTclG8zN5jHYPXk3HAaKWDvcxNOIhhzE7X VvAX++E7IdZxUNTldUvsTQl0rW8IP8IA9L52SpsGcb/W81wj/0Ns1Dy8lu7m7/Jsw5aH H8Kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=nHbeQb3co1qFdO5yYL3pbqWGx/3+00txeK0/F7Wbgx4=; b=ohKUT31WWxMrzBOCvbeJyAJOivnlu/P8hl3S0gwhEkWi/QEz2bqp9dh6Gd3ilVFTyJ VRMNjchnxFISVGXUnth3uvkrt7c31PVhIZRzoTm05x14UUeW/hJgmhDwH5xuSz7LzDSc F/EJJHdDfhBbJ1K8cqJ/Rg5ciXrauB57wWvp29RAAHPTRWUbJ/1VwZg7zAqRxUhCwgjq 6HxI5mnpx32+Y81lIpbW1QrfXDUOEkXNlYEdhJiv5pvQwq2nQDu60xLm2DtICCFzF+Oa 9Hzhbp/6sa7UTYeqBuVmzigBB3VBz4Rzz3OcODtJvtCWk1POm4l9gJy2W4Ybxpwmp9ui Ch1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fK1OI0xA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u10si11550437ilv.84.2021.08.06.20.33.00; Fri, 06 Aug 2021 20:33:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fK1OI0xA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230459AbhHGDbe (ORCPT + 99 others); Fri, 6 Aug 2021 23:31:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:32312 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230513AbhHGDbd (ORCPT ); Fri, 6 Aug 2021 23:31:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628307077; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nHbeQb3co1qFdO5yYL3pbqWGx/3+00txeK0/F7Wbgx4=; b=fK1OI0xAMdaS8Bt45zMI4gOhPsnpYperSnWR1gfQjLrxyEXPWdM+WGOcnZuLEY6GDqS6h3 2NxIavqtp+X3IbP0et0ohajPaw/i1e56+q2a0O8n49fXOp76ku3fWR3vVVH6lhrDTLgM3/ Xmehe1EvYYAzwxgVvmPDkzcYaJ06Fxg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-530-S_6Njpf1NQCdkRiTNnEiug-1; Fri, 06 Aug 2021 23:31:15 -0400 X-MC-Unique: S_6Njpf1NQCdkRiTNnEiug-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id ACB11871803; Sat, 7 Aug 2021 03:31:14 +0000 (UTC) Received: from jtoppins.rdu.csb (unknown [10.22.8.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7FEF627C5E; Sat, 7 Aug 2021 03:31:13 +0000 (UTC) From: Jonathan Toppins To: netdev@vger.kernel.org Cc: Jay Vosburgh , Veaceslav Falico , Andy Gospodarek , "David S. Miller" , Jakub Kicinski , linux-kernel@vger.kernel.org Subject: [PATCH net-next 2/2] bonding: combine netlink and console error messages Date: Fri, 6 Aug 2021 23:30:55 -0400 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There seems to be no reason to have different error messages between netlink and printk. It also cleans up the function slightly. Signed-off-by: Jonathan Toppins --- drivers/net/bonding/bond_main.c | 45 ++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 3ba5f4871162..46b95175690b 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -1712,6 +1712,16 @@ void bond_lower_state_changed(struct slave *slave) netdev_lower_state_changed(slave->dev, &info); } +#define BOND_NL_ERR(bond_dev, extack, errmsg) do { \ + NL_SET_ERR_MSG(extack, errmsg); \ + netdev_err(bond_dev, "Error: " errmsg "\n"); \ +} while (0) + +#define SLAVE_NL_ERR(bond_dev, slave_dev, extack, errmsg) do { \ + NL_SET_ERR_MSG(extack, errmsg); \ + slave_err(bond_dev, slave_dev, "Error: " errmsg "\n"); \ +} while (0) + /* enslave device to bond device */ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev, struct netlink_ext_ack *extack) @@ -1725,9 +1735,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev, if (slave_dev->flags & IFF_MASTER && !netif_is_bond_master(slave_dev)) { - NL_SET_ERR_MSG(extack, "Device with IFF_MASTER cannot be enslaved"); - netdev_err(bond_dev, - "Error: Device with IFF_MASTER cannot be enslaved\n"); + BOND_NL_ERR(bond_dev, extack, + "Device with IFF_MASTER cannot be enslaved"); return -EPERM; } @@ -1739,15 +1748,13 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev, /* already in-use? */ if (netdev_is_rx_handler_busy(slave_dev)) { - NL_SET_ERR_MSG(extack, "Device is in use and cannot be enslaved"); - slave_err(bond_dev, slave_dev, - "Error: Device is in use and cannot be enslaved\n"); + SLAVE_NL_ERR(bond_dev, slave_dev, extack, + "Device is in use and cannot be enslaved"); return -EBUSY; } if (bond_dev == slave_dev) { - NL_SET_ERR_MSG(extack, "Cannot enslave bond to itself."); - netdev_err(bond_dev, "cannot enslave bond to itself.\n"); + BOND_NL_ERR(bond_dev, extack, "Cannot enslave bond to itself."); return -EPERM; } @@ -1756,8 +1763,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev, if (slave_dev->features & NETIF_F_VLAN_CHALLENGED) { slave_dbg(bond_dev, slave_dev, "is NETIF_F_VLAN_CHALLENGED\n"); if (vlan_uses_dev(bond_dev)) { - NL_SET_ERR_MSG(extack, "Can not enslave VLAN challenged device to VLAN enabled bond"); - slave_err(bond_dev, slave_dev, "Error: cannot enslave VLAN challenged slave on VLAN enabled bond\n"); + SLAVE_NL_ERR(bond_dev, slave_dev, extack, + "Can not enslave VLAN challenged device to VLAN enabled bond"); return -EPERM; } else { slave_warn(bond_dev, slave_dev, "enslaved VLAN challenged slave. Adding VLANs will be blocked as long as it is part of bond.\n"); @@ -1775,8 +1782,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev, * enslaving it; the old ifenslave will not. */ if (slave_dev->flags & IFF_UP) { - NL_SET_ERR_MSG(extack, "Device can not be enslaved while up"); - slave_err(bond_dev, slave_dev, "slave is up - this may be due to an out of date ifenslave\n"); + SLAVE_NL_ERR(bond_dev, slave_dev, extack, + "Device can not be enslaved while up"); return -EPERM; } @@ -1815,17 +1822,15 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev, bond_dev); } } else if (bond_dev->type != slave_dev->type) { - NL_SET_ERR_MSG(extack, "Device type is different from other slaves"); - slave_err(bond_dev, slave_dev, "ether type (%d) is different from other slaves (%d), can not enslave it\n", - slave_dev->type, bond_dev->type); + SLAVE_NL_ERR(bond_dev, slave_dev, extack, + "Device type is different from other slaves"); return -EINVAL; } if (slave_dev->type == ARPHRD_INFINIBAND && BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP) { - NL_SET_ERR_MSG(extack, "Only active-backup mode is supported for infiniband slaves"); - slave_warn(bond_dev, slave_dev, "Type (%d) supports only active-backup mode\n", - slave_dev->type); + SLAVE_NL_ERR(bond_dev, slave_dev, extack, + "Only active-backup mode is supported for infiniband slaves"); res = -EOPNOTSUPP; goto err_undo_flags; } @@ -1839,8 +1844,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev, bond->params.fail_over_mac = BOND_FOM_ACTIVE; slave_warn(bond_dev, slave_dev, "Setting fail_over_mac to active for active-backup mode\n"); } else { - NL_SET_ERR_MSG(extack, "Slave device does not support setting the MAC address, but fail_over_mac is not set to active"); - slave_err(bond_dev, slave_dev, "The slave device specified does not support setting the MAC address, but fail_over_mac is not set to active\n"); + SLAVE_NL_ERR(bond_dev, slave_dev, extack, + "Slave device does not support setting the MAC address, but fail_over_mac is not set to active"); res = -EOPNOTSUPP; goto err_undo_flags; } -- 2.27.0