* [PATCH net-2.6.25] [NETNS] Make arp code network namespace consistent.
@ 2008-01-14 13:48 Denis V. Lunev
2008-01-14 13:48 ` [PATCH net-2.6.25] [IPV4] fib_rules_unregister is essentially void Denis V. Lunev
0 siblings, 1 reply; 5+ messages in thread
From: Denis V. Lunev @ 2008-01-14 13:48 UTC (permalink / raw)
To: davem
Cc: netdev, devel,
den1/0006-ARP-Move-inet_addr_type-call-after-simple-error-ch.patch,
Denis V. Lunev
Some calls in the arp.c have network namespace as an argument. Getting
init_net inside these functions is simply inconsistent. Fix this.
Signed-off-by: Denis V. Lunev <den@openvz.org>
---
net/ipv4/arp.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c
index 49c24ff..0db7d49 100644
--- a/net/ipv4/arp.c
+++ b/net/ipv4/arp.c
@@ -969,13 +969,13 @@ static int arp_req_set_public(struct net *net, struct arpreq *r,
if (mask && mask != htonl(0xFFFFFFFF))
return -EINVAL;
if (!dev && (r->arp_flags & ATF_COM)) {
- dev = dev_getbyhwaddr(&init_net, r->arp_ha.sa_family,
+ dev = dev_getbyhwaddr(net, r->arp_ha.sa_family,
r->arp_ha.sa_data);
if (!dev)
return -ENODEV;
}
if (mask) {
- if (pneigh_lookup(&arp_tbl, &init_net, &ip, dev, 1) == NULL)
+ if (pneigh_lookup(&arp_tbl, net, &ip, dev, 1) == NULL)
return -ENOBUFS;
return 0;
}
@@ -1084,7 +1084,7 @@ static int arp_req_delete_public(struct net *net, struct arpreq *r,
__be32 mask = ((struct sockaddr_in *)&r->arp_netmask)->sin_addr.s_addr;
if (mask == htonl(0xFFFFFFFF))
- return pneigh_delete(&arp_tbl, &init_net, &ip, dev);
+ return pneigh_delete(&arp_tbl, net, &ip, dev);
if (mask)
return -EINVAL;
@@ -1162,7 +1162,7 @@ int arp_ioctl(struct net *net, unsigned int cmd, void __user *arg)
rtnl_lock();
if (r.arp_dev[0]) {
err = -ENODEV;
- if ((dev = __dev_get_by_name(&init_net, r.arp_dev)) == NULL)
+ if ((dev = __dev_get_by_name(net, r.arp_dev)) == NULL)
goto out;
/* Mmmm... It is wrong... ARPHRD_NETROM==0 */
--
1.5.3.rc5
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH net-2.6.25] [IPV4] fib_rules_unregister is essentially void.
2008-01-14 13:48 [PATCH net-2.6.25] [NETNS] Make arp code network namespace consistent Denis V. Lunev
@ 2008-01-14 13:48 ` Denis V. Lunev
2008-01-14 13:48 ` [PATCH net-2.6.25] [ARP] Remove overkill checks from neigh_param_alloc Denis V. Lunev
0 siblings, 1 reply; 5+ messages in thread
From: Denis V. Lunev @ 2008-01-14 13:48 UTC (permalink / raw)
To: davem
Cc: netdev, devel,
den1/0006-ARP-Move-inet_addr_type-call-after-simple-error-ch.patch,
Denis V. Lunev
fib_rules_unregister is called only after successful register and the return
code is never checked.
Signed-off-by: Denis V. Lunev <den@openvz.org>
---
include/net/fib_rules.h | 2 +-
net/core/fib_rules.c | 21 ++++-----------------
2 files changed, 5 insertions(+), 18 deletions(-)
diff --git a/include/net/fib_rules.h b/include/net/fib_rules.h
index 88f870f..34349f9 100644
--- a/include/net/fib_rules.h
+++ b/include/net/fib_rules.h
@@ -104,7 +104,7 @@ static inline u32 frh_get_table(struct fib_rule_hdr *frh, struct nlattr **nla)
}
extern int fib_rules_register(struct net *, struct fib_rules_ops *);
-extern int fib_rules_unregister(struct net *, struct fib_rules_ops *);
+extern void fib_rules_unregister(struct net *, struct fib_rules_ops *);
extern void fib_rules_cleanup_ops(struct fib_rules_ops *);
extern int fib_rules_lookup(struct fib_rules_ops *,
diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c
index 0eecf4c..42ccaf5 100644
--- a/net/core/fib_rules.c
+++ b/net/core/fib_rules.c
@@ -115,29 +115,16 @@ void fib_rules_cleanup_ops(struct fib_rules_ops *ops)
}
EXPORT_SYMBOL_GPL(fib_rules_cleanup_ops);
-int fib_rules_unregister(struct net *net, struct fib_rules_ops *ops)
+void fib_rules_unregister(struct net *net, struct fib_rules_ops *ops)
{
- int err = 0;
- struct fib_rules_ops *o;
spin_lock(&net->rules_mod_lock);
- list_for_each_entry(o, &net->rules_ops, list) {
- if (o == ops) {
- list_del_rcu(&o->list);
- fib_rules_cleanup_ops(ops);
- goto out;
- }
- }
-
- err = -ENOENT;
-out:
+ list_del_rcu(&ops->list);
+ fib_rules_cleanup_ops(ops);
spin_unlock(&net->rules_mod_lock);
synchronize_rcu();
- if (!err)
- release_net(net);
-
- return err;
+ release_net(net);
}
EXPORT_SYMBOL_GPL(fib_rules_unregister);
--
1.5.3.rc5
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH net-2.6.25] [ARP] Remove overkill checks from neigh_param_alloc.
2008-01-14 13:48 ` [PATCH net-2.6.25] [IPV4] fib_rules_unregister is essentially void Denis V. Lunev
@ 2008-01-14 13:48 ` Denis V. Lunev
2008-01-14 13:48 ` [PATCH net-2.6.25] [ARP] Remove forward declaration of neigh_changeaddr Denis V. Lunev
0 siblings, 1 reply; 5+ messages in thread
From: Denis V. Lunev @ 2008-01-14 13:48 UTC (permalink / raw)
To: davem
Cc: netdev, devel,
den1/0006-ARP-Move-inet_addr_type-call-after-simple-error-ch.patch,
Denis V. Lunev, Pavel Emelyanov
Valid network device is always passed into neigh_param_alloc, so remove
extra checking for dev == NULL. Additionally, cleanup bogus netns assignment.
Signed-off-by: Denis V. Lunev <den@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
---
net/core/neighbour.c | 18 +++++++-----------
1 files changed, 7 insertions(+), 11 deletions(-)
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index af49137..32f1a23 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -1301,10 +1301,7 @@ struct neigh_parms *neigh_parms_alloc(struct net_device *dev,
struct neigh_parms *p, *ref;
struct net *net;
- net = &init_net;
- if (dev)
- net = dev->nd_net;
-
+ net = dev->nd_net;
ref = lookup_neigh_params(tbl, net, 0);
if (!ref)
return NULL;
@@ -1316,15 +1313,14 @@ struct neigh_parms *neigh_parms_alloc(struct net_device *dev,
INIT_RCU_HEAD(&p->rcu_head);
p->reachable_time =
neigh_rand_reach_time(p->base_reachable_time);
- if (dev) {
- if (dev->neigh_setup && dev->neigh_setup(dev, p)) {
- kfree(p);
- return NULL;
- }
- dev_hold(dev);
- p->dev = dev;
+ if (dev->neigh_setup && dev->neigh_setup(dev, p)) {
+ kfree(p);
+ return NULL;
}
+
+ dev_hold(dev);
+ p->dev = dev;
p->net = hold_net(net);
p->sysctl_table = NULL;
write_lock_bh(&tbl->lock);
--
1.5.3.rc5
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH net-2.6.25] [ARP] Remove forward declaration of neigh_changeaddr.
2008-01-14 13:48 ` [PATCH net-2.6.25] [ARP] Remove overkill checks from neigh_param_alloc Denis V. Lunev
@ 2008-01-14 13:48 ` Denis V. Lunev
2008-01-14 13:48 ` [PATCH net-2.6.25] [ARP] neigh_parms_put(destroy) are essentially local to core/neighbour.c Denis V. Lunev
0 siblings, 1 reply; 5+ messages in thread
From: Denis V. Lunev @ 2008-01-14 13:48 UTC (permalink / raw)
To: davem
Cc: netdev, devel,
den1/0006-ARP-Move-inet_addr_type-call-after-simple-error-ch.patch,
Denis V. Lunev
No need for this. It is declared in the neighbour.h
Signed-off-by: Denis V. Lunev <den@openvz.org>
---
net/core/neighbour.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 2eab6a5..9b0b773 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -59,7 +59,6 @@ static void neigh_timer_handler(unsigned long arg);
static void __neigh_notify(struct neighbour *n, int type, int flags);
static void neigh_update_notify(struct neighbour *neigh);
static int pneigh_ifdown(struct neigh_table *tbl, struct net_device *dev);
-void neigh_changeaddr(struct neigh_table *tbl, struct net_device *dev);
static struct neigh_table *neigh_tables;
#ifdef CONFIG_PROC_FS
--
1.5.3.rc5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH net-2.6.25] [ARP] neigh_parms_put(destroy) are essentially local to core/neighbour.c.
2008-01-14 13:48 ` [PATCH net-2.6.25] [ARP] Remove forward declaration of neigh_changeaddr Denis V. Lunev
@ 2008-01-14 13:48 ` Denis V. Lunev
0 siblings, 0 replies; 5+ messages in thread
From: Denis V. Lunev @ 2008-01-14 13:48 UTC (permalink / raw)
To: davem
Cc: netdev, devel,
den1/0006-ARP-Move-inet_addr_type-call-after-simple-error-ch.patch,
Denis V. Lunev
Make them static.
Signed-off-by: Denis V. Lunev <den@openvz.org>
---
include/net/neighbour.h | 7 -------
net/core/neighbour.c | 11 ++++++++++-
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/include/net/neighbour.h b/include/net/neighbour.h
index a0d42a5..ebbfb50 100644
--- a/include/net/neighbour.h
+++ b/include/net/neighbour.h
@@ -213,7 +213,6 @@ extern struct neighbour *neigh_event_ns(struct neigh_table *tbl,
extern struct neigh_parms *neigh_parms_alloc(struct net_device *dev, struct neigh_table *tbl);
extern void neigh_parms_release(struct neigh_table *tbl, struct neigh_parms *parms);
-extern void neigh_parms_destroy(struct neigh_parms *parms);
extern unsigned long neigh_rand_reach_time(unsigned long base);
extern void pneigh_enqueue(struct neigh_table *tbl, struct neigh_parms *p,
@@ -254,12 +253,6 @@ static inline void __neigh_parms_put(struct neigh_parms *parms)
atomic_dec(&parms->refcnt);
}
-static inline void neigh_parms_put(struct neigh_parms *parms)
-{
- if (atomic_dec_and_test(&parms->refcnt))
- neigh_parms_destroy(parms);
-}
-
static inline struct neigh_parms *neigh_parms_clone(struct neigh_parms *parms)
{
atomic_inc(&parms->refcnt);
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 9b0b773..41394db 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -55,6 +55,8 @@
#define PNEIGH_HASHMASK 0xF
+static inline void neigh_parms_put(struct neigh_parms *parms);
+
static void neigh_timer_handler(unsigned long arg);
static void __neigh_notify(struct neighbour *n, int type, int flags);
static void neigh_update_notify(struct neighbour *neigh);
@@ -1348,7 +1350,7 @@ void neigh_parms_release(struct neigh_table *tbl, struct neigh_parms *parms)
NEIGH_PRINTK1("neigh_parms_release: not found\n");
}
-void neigh_parms_destroy(struct neigh_parms *parms)
+static void neigh_parms_destroy(struct neigh_parms *parms)
{
release_net(parms->net);
if (parms->dev)
@@ -1356,6 +1358,13 @@ void neigh_parms_destroy(struct neigh_parms *parms)
kfree(parms);
}
+static inline void neigh_parms_put(struct neigh_parms *parms)
+{
+ if (atomic_dec_and_test(&parms->refcnt))
+ neigh_parms_destroy(parms);
+}
+
+
static struct lock_class_key neigh_table_proxy_queue_class;
void neigh_table_init_no_netlink(struct neigh_table *tbl)
--
1.5.3.rc5
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-01-14 13:48 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-14 13:48 [PATCH net-2.6.25] [NETNS] Make arp code network namespace consistent Denis V. Lunev
2008-01-14 13:48 ` [PATCH net-2.6.25] [IPV4] fib_rules_unregister is essentially void Denis V. Lunev
2008-01-14 13:48 ` [PATCH net-2.6.25] [ARP] Remove overkill checks from neigh_param_alloc Denis V. Lunev
2008-01-14 13:48 ` [PATCH net-2.6.25] [ARP] Remove forward declaration of neigh_changeaddr Denis V. Lunev
2008-01-14 13:48 ` [PATCH net-2.6.25] [ARP] neigh_parms_put(destroy) are essentially local to core/neighbour.c Denis V. Lunev
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox