From patchwork Sat Jun 7 07:45:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ding Tianhong X-Patchwork-Id: 31509 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qg0-f71.google.com (mail-qg0-f71.google.com [209.85.192.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8C09D2100A for ; Sat, 7 Jun 2014 07:46:36 +0000 (UTC) Received: by mail-qg0-f71.google.com with SMTP id a108sf9545443qge.2 for ; Sat, 07 Jun 2014 00:46:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=6RDh3WPVEL1kofpbZ09SsrHgP8cQZ83y2CVHjm7oh1U=; b=OAzhq1L5VDg1ckXN4Rg6AOYI/qjgcEKnnLSN2NxFdaaEuS0vPkxKfp5yn/dpFqejLp ZZ17+JRGWlT9+AFFgMIsGH0R1U+mNi48F3HBLcA4fuRBJZBgnYS/hUzfK+7lUmPGkzpX ujdNr8hEJv0GOqxJFA5rROWZGINFN4ckIlE/6nL2ebg+y9ks/lagrWHsp75217xqQuwU RCnoQyaIkUtqI/75EiWrdh0OaQRpKSCcKz6CglNakOeblLjuNozSZgnKPrSYYkSl30ik WOaoiL/2iZPBM9ga3j5RU8OJO6oIHBbMw0ky9k62/4y+lw1Fkyn6+NEs1VcEK4CNkrGu yeKg== X-Gm-Message-State: ALoCoQn2dCWgDC9TONv0Ti0pLedjbQz9sk9T316fWeePanBWoEvQcfYLq0Fu2sSckrJNNlEzEFb/ X-Received: by 10.58.225.197 with SMTP id rm5mr6743593vec.5.1402127196393; Sat, 07 Jun 2014 00:46:36 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.108.229 with SMTP id j92ls916020qgf.14.gmail; Sat, 07 Jun 2014 00:46:36 -0700 (PDT) X-Received: by 10.220.249.198 with SMTP id ml6mr9545613vcb.36.1402127196270; Sat, 07 Jun 2014 00:46:36 -0700 (PDT) Received: from mail-ve0-f178.google.com (mail-ve0-f178.google.com [209.85.128.178]) by mx.google.com with ESMTPS id yc10si8385288vec.103.2014.06.07.00.46.36 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 07 Jun 2014 00:46:36 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.178 as permitted sender) client-ip=209.85.128.178; Received: by mail-ve0-f178.google.com with SMTP id sa20so4553078veb.9 for ; Sat, 07 Jun 2014 00:46:36 -0700 (PDT) X-Received: by 10.53.10.234 with SMTP id ed10mr8637727vdd.86.1402127196191; Sat, 07 Jun 2014 00:46:36 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.54.6 with SMTP id vs6csp6583vcb; Sat, 7 Jun 2014 00:46:35 -0700 (PDT) X-Received: by 10.68.102.34 with SMTP id fl2mr9650485pbb.2.1402127195197; Sat, 07 Jun 2014 00:46:35 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bh2si23941557pbb.204.2014.06.07.00.46.34; Sat, 07 Jun 2014 00:46:34 -0700 (PDT) Received-SPF: none (google.com: netdev-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752828AbaFGHqa (ORCPT + 3 others); Sat, 7 Jun 2014 03:46:30 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:48751 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752813AbaFGHq2 (ORCPT ); Sat, 7 Jun 2014 03:46:28 -0400 Received: from 172.24.2.119 (EHLO szxeml207-edg.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id BUV13317; Sat, 07 Jun 2014 15:45:53 +0800 (CST) Received: from SZXEML454-HUB.china.huawei.com (10.82.67.197) by szxeml207-edg.china.huawei.com (172.24.2.56) with Microsoft SMTP Server (TLS) id 14.3.158.1; Sat, 7 Jun 2014 15:45:52 +0800 Received: from localhost (10.177.22.246) by SZXEML454-HUB.china.huawei.com (10.82.67.197) with Microsoft SMTP Server id 14.3.158.1; Sat, 7 Jun 2014 15:45:50 +0800 From: Ding Tianhong To: , , , , CC: Subject: [PATCH net-next v2 RESEND 4/4] net: dev: don't set the same mac address for netdev Date: Sat, 7 Jun 2014 15:45:43 +0800 Message-ID: <1402127143-6456-5-git-send-email-dingtianhong@huawei.com> X-Mailer: git-send-email 1.8.5.2.msysgit.0 In-Reply-To: <1402127143-6456-1-git-send-email-dingtianhong@huawei.com> References: <1402127143-6456-1-git-send-email-dingtianhong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.22.246] X-CFilter-Loop: Reflected Sender: netdev-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: netdev@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: dingtianhong@huawei.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.178 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Most of netdev just link bond, team, vlan will set the mac address and propagate to the upperdev or lowerdev regardless the mac address is same or not, setting a same mac address make no sense for most of the netdev, but some netdev need a flag to see whether the ndo_set_mac_address() is called and decide what to do next, so don't do anything if the address has already been set by user and it is the same as before, otherwise set the same address to the netdev. Signed-off-by: Ding Tianhong --- net/core/dev.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/net/core/dev.c b/net/core/dev.c index b0fb3dd..201d88b 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -5572,6 +5572,13 @@ int dev_set_mac_address(struct net_device *dev, struct sockaddr *sa) if (!netif_device_present(dev)) return -ENODEV; + /* If the address has already been set by user and it + * is the same as before, don't do anything. + */ + if (dev->addr_assign_type == NET_ADDR_SET && + ether_addr_equal_64bits(dev->dev_addr, sa->sa_data)) + return 0; + old_sa.sa_family = dev->type; ether_addr_copy(old_sa.sa_data, dev->dev_addr);