* [PATCH net] net: mv __dev_notify_flags from void to int
@ 2018-07-04 6:29 Hangbin Liu
2018-07-05 0:49 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Hangbin Liu @ 2018-07-04 6:29 UTC (permalink / raw)
To: netdev; +Cc: David Miller, Stefano Brivio, Cong Wang, Hangbin Liu
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 <liuhangbin@gmail.com>
---
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] net: mv __dev_notify_flags from void to int
2018-07-04 6:29 [PATCH net] net: mv __dev_notify_flags from void to int Hangbin Liu
@ 2018-07-05 0:49 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2018-07-05 0:49 UTC (permalink / raw)
To: liuhangbin; +Cc: netdev, sbrivio, xiyou.wangcong
From: Hangbin Liu <liuhangbin@gmail.com>
Date: Wed, 4 Jul 2018 14:29:46 +0800
> @@ -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.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-07-05 0:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-04 6:29 [PATCH net] net: mv __dev_notify_flags from void to int Hangbin Liu
2018-07-05 0:49 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.