* [PATCH net-next] core: Simplify logic in dev_load().
@ 2014-09-02 13:51 David Laight
2014-09-02 17:49 ` Sergei Shtylyov
2014-09-03 8:57 ` [PATCH V2 " David Laight
0 siblings, 2 replies; 4+ messages in thread
From: David Laight @ 2014-09-02 13:51 UTC (permalink / raw)
To: Linux Netdev List, David Miller
The code in dev_load() is convoluted.
Return early and remove the 'no_module' variable.
---
Note that this patch will only apply after the one that adds the
check for name[0].
net/core/dev_ioctl.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
index 84edf16..4b7ab54 100644
--- a/net/core/dev_ioctl.c
+++ b/net/core/dev_ioctl.c
@@ -356,7 +356,6 @@ static int dev_ifsioc(struct net *net, struct ifreq *ifr, unsigned int cmd)
void dev_load(struct net *net, const char *name)
{
struct net_device *dev;
- int no_module;
if (!name[0])
return;
@@ -364,15 +363,15 @@ void dev_load(struct net *net, const char *name)
rcu_read_lock();
dev = dev_get_by_name_rcu(net, name);
rcu_read_unlock();
+ if (dev)
+ return;
- no_module = !dev;
- if (no_module && capable(CAP_NET_ADMIN))
- no_module = request_module("netdev-%s", name);
- if (no_module && capable(CAP_SYS_MODULE)) {
- if (!request_module("%s", name))
- pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
- name);
- }
+ if (capable(CAP_NET_ADMIN) && !request_module("netdev-%s", name))
+ return;
+
+ if (capable(CAP_SYS_MODULE) && !request_module("%s", name))
+ pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
+ name);
}
EXPORT_SYMBOL(dev_load);
--
1.8.1.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] core: Simplify logic in dev_load().
2014-09-02 13:51 [PATCH net-next] core: Simplify logic in dev_load() David Laight
@ 2014-09-02 17:49 ` Sergei Shtylyov
2014-09-03 9:04 ` David Laight
2014-09-03 8:57 ` [PATCH V2 " David Laight
1 sibling, 1 reply; 4+ messages in thread
From: Sergei Shtylyov @ 2014-09-02 17:49 UTC (permalink / raw)
To: David Laight, Linux Netdev List, David Miller
Hello.
On 09/02/2014 05:51 PM, David Laight wrote:
> The code in dev_load() is convoluted.
> Return early and remove the 'no_module' variable.
You forgot to sign off on the patch, so it can't be applied.
WBR, Sergei
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH V2 net-next] core: Simplify logic in dev_load().
2014-09-02 13:51 [PATCH net-next] core: Simplify logic in dev_load() David Laight
2014-09-02 17:49 ` Sergei Shtylyov
@ 2014-09-03 8:57 ` David Laight
1 sibling, 0 replies; 4+ messages in thread
From: David Laight @ 2014-09-03 8:57 UTC (permalink / raw)
To: 'Linux Netdev List', 'David Miller'
The code in dev_load() is convoluted.
Return early and remove the 'no_module' variable.
Signed-off-by: David Laight <david.laight@aculab.com>
---
V2: Added signed-off
Note that this patch will only apply after the one that adds the
check for name[0].
net/core/dev_ioctl.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
index 84edf16..4b7ab54 100644
--- a/net/core/dev_ioctl.c
+++ b/net/core/dev_ioctl.c
@@ -356,7 +356,6 @@ static int dev_ifsioc(struct net *net, struct ifreq *ifr, unsigned int cmd)
void dev_load(struct net *net, const char *name)
{
struct net_device *dev;
- int no_module;
if (!name[0])
return;
@@ -364,15 +363,15 @@ void dev_load(struct net *net, const char *name)
rcu_read_lock();
dev = dev_get_by_name_rcu(net, name);
rcu_read_unlock();
+ if (dev)
+ return;
- no_module = !dev;
- if (no_module && capable(CAP_NET_ADMIN))
- no_module = request_module("netdev-%s", name);
- if (no_module && capable(CAP_SYS_MODULE)) {
- if (!request_module("%s", name))
- pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
- name);
- }
+ if (capable(CAP_NET_ADMIN) && !request_module("netdev-%s", name))
+ return;
+
+ if (capable(CAP_SYS_MODULE) && !request_module("%s", name))
+ pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
+ name);
}
EXPORT_SYMBOL(dev_load);
--
1.8.1.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [PATCH net-next] core: Simplify logic in dev_load().
2014-09-02 17:49 ` Sergei Shtylyov
@ 2014-09-03 9:04 ` David Laight
0 siblings, 0 replies; 4+ messages in thread
From: David Laight @ 2014-09-03 9:04 UTC (permalink / raw)
To: 'Sergei Shtylyov', Linux Netdev List, David Miller
> > The code in dev_load() is convoluted.
> > Return early and remove the 'no_module' variable.
>
> You forgot to sign off on the patch, so it can't be applied.
Gah, git defaults and brain-fade.
Does that mean that if I submit a patch without a sign-off then no one
else is allowed to submit the same patch?
I see a DoS attack :-)
David
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-09-03 9:06 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-02 13:51 [PATCH net-next] core: Simplify logic in dev_load() David Laight
2014-09-02 17:49 ` Sergei Shtylyov
2014-09-03 9:04 ` David Laight
2014-09-03 8:57 ` [PATCH V2 " David Laight
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).