From mboxrd@z Thu Jan 1 00:00:00 1970 From: Hangbin Liu Subject: [PATCH net] net: mv __dev_notify_flags from void to int Date: Wed, 4 Jul 2018 14:29:46 +0800 Message-ID: <1530685786-26449-1-git-send-email-liuhangbin@gmail.com> Cc: David Miller , Stefano Brivio , Cong Wang , Hangbin Liu To: netdev@vger.kernel.org Return-path: Received: from mail-pg0-f67.google.com ([74.125.83.67]:34813 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933239AbeGDGaD (ORCPT ); Wed, 4 Jul 2018 02:30:03 -0400 Received: by mail-pg0-f67.google.com with SMTP id y5-v6so2056914pgv.1 for ; Tue, 03 Jul 2018 23:30:03 -0700 (PDT) Sender: netdev-owner@vger.kernel.org List-ID: As call_netdevice_notifiers() and call_netdevice_notifiers_info() have return values, we should also return the values in function __dev_notify_flags(). Signed-off-by: Hangbin Liu --- include/linux/netdevice.h | 2 +- net/core/dev.c | 30 ++++++++++++++++++++---------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 3d0cc0b..b1c145e 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -3411,7 +3411,7 @@ int dev_ethtool(struct net *net, struct ifreq *); unsigned int dev_get_flags(const struct net_device *); int __dev_change_flags(struct net_device *, unsigned int flags); int dev_change_flags(struct net_device *, unsigned int); -void __dev_notify_flags(struct net_device *, unsigned int old_flags, +int __dev_notify_flags(struct net_device *, unsigned int old_flags, unsigned int gchanges); int dev_change_name(struct net_device *, const char *); int dev_set_alias(struct net_device *, const char *, size_t); diff --git a/net/core/dev.c b/net/core/dev.c index a5aa1c7..0994533 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -6798,8 +6798,10 @@ static int __dev_set_promiscuity(struct net_device *dev, int inc, bool notify) dev_change_rx_flags(dev, IFF_PROMISC); } + if (notify) - __dev_notify_flags(dev, old_flags, IFF_PROMISC); + return __dev_notify_flags(dev, old_flags, IFF_PROMISC); + return 0; } @@ -6854,8 +6856,8 @@ static int __dev_set_allmulti(struct net_device *dev, int inc, bool notify) dev_change_rx_flags(dev, IFF_ALLMULTI); dev_set_rx_mode(dev); if (notify) - __dev_notify_flags(dev, old_flags, - dev->gflags ^ old_gflags); + return __dev_notify_flags(dev, old_flags, + dev->gflags ^ old_gflags); } return 0; } @@ -7016,21 +7018,26 @@ int __dev_change_flags(struct net_device *dev, unsigned int flags) return ret; } -void __dev_notify_flags(struct net_device *dev, unsigned int old_flags, - unsigned int gchanges) +int __dev_notify_flags(struct net_device *dev, unsigned int old_flags, + unsigned int gchanges) { unsigned int changes = dev->flags ^ old_flags; + int err = 0; if (gchanges) rtmsg_ifinfo(RTM_NEWLINK, dev, gchanges, GFP_ATOMIC); if (changes & IFF_UP) { if (dev->flags & IFF_UP) - call_netdevice_notifiers(NETDEV_UP, dev); + err = call_netdevice_notifiers(NETDEV_UP, dev); else - call_netdevice_notifiers(NETDEV_DOWN, dev); + err = call_netdevice_notifiers(NETDEV_DOWN, dev); } + err = notifier_to_errno(err); + if (err) + goto out; + if (dev->flags & IFF_UP && (changes & ~(IFF_UP | IFF_PROMISC | IFF_ALLMULTI | IFF_VOLATILE))) { struct netdev_notifier_change_info change_info = { @@ -7040,8 +7047,12 @@ void __dev_notify_flags(struct net_device *dev, unsigned int old_flags, .flags_changed = changes, }; - call_netdevice_notifiers_info(NETDEV_CHANGE, &change_info.info); + err = call_netdevice_notifiers_info(NETDEV_CHANGE, &change_info.info); + err = notifier_to_errno(err); } + +out: + return err; } /** @@ -7062,8 +7073,7 @@ int dev_change_flags(struct net_device *dev, unsigned int flags) return ret; changes = (old_flags ^ dev->flags) | (old_gflags ^ dev->gflags); - __dev_notify_flags(dev, old_flags, changes); - return ret; + return __dev_notify_flags(dev, old_flags, changes); } EXPORT_SYMBOL(dev_change_flags); -- 2.5.5