From patchwork Thu May 23 09:58:28 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Timo Teras X-Patchwork-Id: 245863 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id B2AF42C016A for ; Thu, 23 May 2013 19:57:06 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757935Ab3EWJ5B (ORCPT ); Thu, 23 May 2013 05:57:01 -0400 Received: from mail-ea0-f170.google.com ([209.85.215.170]:58791 "EHLO mail-ea0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757819Ab3EWJ5A (ORCPT ); Thu, 23 May 2013 05:57:00 -0400 Received: by mail-ea0-f170.google.com with SMTP id f15so1707873eak.15 for ; Thu, 23 May 2013 02:56:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:mime-version :content-type:content-transfer-encoding; bh=ucXKKrJGAjtoFDDoaFAZYGnT9/dbhZ9IOEdBhn6JxBA=; b=LRDbpmmiz2W31QeJwhJk55pMnTnzSGkqsO6syfQu2+mWky/jqg36nKIhgFfOW/+R9D 4GwvPb09gAq3GZ32ps6d6cnM612Woj/Gjly5Z7U7wLntLYiKGS5WWjtECbRyNgaMqbQq BDSNhM/Bfq8dusOqpzz339MglMvldG3EsTCqm8hXgxYbzEkfeOWrwTzxMuX6JhhbHGur nwf+V2sDTYi4WvOYH/qDkzLyhLks9o+KyKbLDU0m2pKPXaQ8yhrDYSxbOoxS6Fb1UQKV Dr4zbaqfIMSI+T5G74m57W8+odWgpojqzQ/RaiKA+AMb8u9Tcln11TZIAFsaLmX9BQqK XQEg== X-Received: by 10.14.5.5 with SMTP id 5mr29583667eek.21.1369303019189; Thu, 23 May 2013 02:56:59 -0700 (PDT) Received: from vostro.util.wtbts.net ([83.145.235.199]) by mx.google.com with ESMTPSA id a5sm15665184ees.6.2013.05.23.02.56.57 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 23 May 2013 02:56:58 -0700 (PDT) From: =?UTF-8?q?Timo=20Ter=C3=A4s?= To: netdev@vger.kernel.org Cc: =?UTF-8?q?Timo=20Ter=C3=A4s?= , Ben Hutchings Subject: [PATCH net-next 1/2] net: inform NETDEV_CHANGE callbacks which flags were changed Date: Thu, 23 May 2013 12:58:28 +0300 Message-Id: <1369303109-12003-1-git-send-email-timo.teras@iki.fi> X-Mailer: git-send-email 1.8.2.3 MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In certain cases (like the follow up commit to arp.c) will need to check which flags actually changed to avoid excessive work. Ben Hutchings nicely worded why to put these transient flags to struct net_device for the time being: > It's inelegant to put transient data associated with an event in a > persistent data structure. On the other hand, having every user cache > the old state is pretty awful as well. > > Really, netdev notifiers should be changed to accept a structure that > encapsulates the changes rather than just a pointer to the net_device. > But making such a change would be an enormous pain and error-prone > because notifier functions aren't type-safe. > > As an interim solution, I think either the general priv_flags_changed or > old_priv_flags would be preferable to defining extra transient flags. Signed-off-by: Timo Teräs Cc: Ben Hutchings --- include/linux/netdevice.h | 4 +++- net/core/dev.c | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 7dd535d..86c155a 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -1112,7 +1112,9 @@ struct net_device { /* Hardware header description */ const struct header_ops *header_ops; - unsigned int flags; /* interface flags (a la BSD) */ + unsigned int flags; /* interface flags (a la BSD) */ + unsigned int flags_changed; /* flags that are being changed + * valid during NETDEV_CHANGE notifier */ unsigned int priv_flags; /* Like 'flags' but invisible to userspace. * See if.h for definitions. */ unsigned short gflags; diff --git a/net/core/dev.c b/net/core/dev.c index 7229bc3..221634f 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -4741,8 +4741,11 @@ void __dev_notify_flags(struct net_device *dev, unsigned int old_flags) } if (dev->flags & IFF_UP && - (changes & ~(IFF_UP | IFF_PROMISC | IFF_ALLMULTI | IFF_VOLATILE))) + (changes & ~(IFF_UP | IFF_PROMISC | IFF_ALLMULTI | IFF_VOLATILE))) { + dev->flags_changed = changes; call_netdevice_notifiers(NETDEV_CHANGE, dev); + dev->flags_changed = 0; + } } /**