From: Hangbin Liu <liuhangbin@gmail.com>
To: netdev@vger.kernel.org
Cc: David Miller <davem@davemloft.net>,
Stefano Brivio <sbrivio@redhat.com>,
Cong Wang <xiyou.wangcong@gmail.com>,
Hangbin Liu <liuhangbin@gmail.com>
Subject: [PATCH net] net: mv __dev_notify_flags from void to int
Date: Wed, 4 Jul 2018 14:29:46 +0800 [thread overview]
Message-ID: <1530685786-26449-1-git-send-email-liuhangbin@gmail.com> (raw)
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
next reply other threads:[~2018-07-04 6:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-04 6:29 Hangbin Liu [this message]
2018-07-05 0:49 ` [PATCH net] net: mv __dev_notify_flags from void to int David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1530685786-26449-1-git-send-email-liuhangbin@gmail.com \
--to=liuhangbin@gmail.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=sbrivio@redhat.com \
--cc=xiyou.wangcong@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).