net: mv __dev_notify_flags from void to int
Subsystems (2)
PATCH 1/1 net: mv __dev_notify_flags from void to int
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 <[email protected]>
--- include/linux/netdevice.h | 2 +- net/core/dev.c | 30 ++++++++++++++++++++---------- 2 files changed, 21 insertions(+), 11 deletions(-)
include/linux/netdevice.h +1 -1
@@ -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 );
net/core/dev.c +20 -10
@@ -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);
Signature · 1 line
2.5.5
David Miller
maintainerFrom: Hangbin Liu <[email protected]>
Date: Wed, 4 Jul 2018 14:29:46 +0800
net/core/dev.c int dev_change_flags(struct net_device *dev, unsigned int flags) · line 7076
Quoted 7 lines
net/core/dev.c +1
-2@@ -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);
By doing this, you will lose any error code returned from dev_open(). That is why we return 'ret' instead of plain '0' here.