From patchwork Tue Jun 13 12:24:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Piotr Gardocki X-Patchwork-Id: 13278682 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 65F293C25 for ; Tue, 13 Jun 2023 12:24:33 +0000 (UTC) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33EA3CE for ; Tue, 13 Jun 2023 05:24:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686659072; x=1718195072; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=E5mmwH2fSHfoDdpc2kQEZSS8TlOLkOc7UCmxYue/2Bc=; b=Qxdd9G06CYI+6zoO6TDneIbc8Agi8iKmuQCsQHLa6X5OQVi1Bx2uoQpD AFRCxgCZqj/wlNqOZ5GcN3gFdhR8Qn0hCechgtnr0oc+eaUGagnKDpQhS Du4yj1tk3ps3O2KshevCQmgPrZ4obN3ABErfYrpKJVfdeYKGNo7MALrhL CS5tfVHpMAsHwMQrsofKZYMco1SqqnwhBuYg5g8njHkrioVqUUb8tNSZj 6+Ie65WcjHXXwyqw3h4Xvx111o0ptFrFgNdvyE+pEkUWXzB+to0QCx3Sw v0itR0gQS0WYsQ96jwAFoblRdZqHEe6BERQNUlSMxJOCYRo1NIxFxdQlV Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10739"; a="337951213" X-IronPort-AV: E=Sophos;i="6.00,239,1681196400"; d="scan'208";a="337951213" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jun 2023 05:24:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10739"; a="835871998" X-IronPort-AV: E=Sophos;i="6.00,239,1681196400"; d="scan'208";a="835871998" Received: from pgardocx-mobl1.igk.intel.com ([10.237.95.41]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jun 2023 05:24:29 -0700 From: Piotr Gardocki To: netdev@vger.kernel.org Cc: piotrx.gardocki@intel.com, intel-wired-lan@lists.osuosl.org, przemyslaw.kitszel@intel.com, michal.swiatkowski@linux.intel.com, pmenzel@molgen.mpg.de, kuba@kernel.org, maciej.fijalkowski@intel.com, anthony.l.nguyen@intel.com, simon.horman@corigine.com, aleksander.lobakin@intel.com Subject: [PATCH net-next v2 1/3] net: add check for current MAC address in dev_set_mac_address Date: Tue, 13 Jun 2023 14:24:18 +0200 Message-Id: <20230613122420.855486-2-piotrx.gardocki@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230613122420.855486-1-piotrx.gardocki@intel.com> References: <20230613122420.855486-1-piotrx.gardocki@intel.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org In some cases it is possible for kernel to come with request to change primary MAC address to the address that is already set on the given interface. This patch adds proper check to return fast from the function in these cases. An example of such case is adding an interface to bonding channel in balance-alb mode: modprobe bonding mode=balance-alb miimon=100 max_bonds=1 ip link set bond0 up ifenslave bond0 Signed-off-by: Piotr Gardocki --- net/core/dev.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/core/dev.c b/net/core/dev.c index c2456b3667fe..8f1c49ab17df 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -8754,6 +8754,8 @@ int dev_set_mac_address(struct net_device *dev, struct sockaddr *sa, return -EINVAL; if (!netif_device_present(dev)) return -ENODEV; + if (!memcmp(dev->dev_addr, sa->sa_data, dev->addr_len)) + return 0; err = dev_pre_changeaddr_notify(dev, sa->sa_data, extack); if (err) return err;