* [PATCH net-2.6.26 0/10][VLAN]: Make VLAN devices work in net namespaces.
@ 2008-04-15 11:59 Pavel Emelyanov
2008-04-15 12:01 ` [PATCH net-2.6.26 1/10][RTNL]: Relax for_each_netdev_safe in __rtnl_link_unregister Pavel Emelyanov
` (10 more replies)
0 siblings, 11 replies; 24+ messages in thread
From: Pavel Emelyanov @ 2008-04-15 11:59 UTC (permalink / raw)
To: David Miller; +Cc: Patrick McHardy, Linux Netdev List
This set does not intersect with the TUN one at all, since
they both use generic net pointers.
It also includes some changes in RTNL code to facilitate
VLAN netnsization and a bit more VLAN cleanups.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH net-2.6.26 1/10][RTNL]: Relax for_each_netdev_safe in __rtnl_link_unregister.
2008-04-15 12:01 ` [PATCH net-2.6.26 1/10][RTNL]: Relax for_each_netdev_safe in __rtnl_link_unregister Pavel Emelyanov
@ 2008-04-15 12:00 ` Patrick McHardy
0 siblings, 0 replies; 24+ messages in thread
From: Patrick McHardy @ 2008-04-15 12:00 UTC (permalink / raw)
To: Pavel Emelyanov; +Cc: David Miller, Linux Netdev List
Pavel Emelyanov wrote:
> Each potential list_del (happening from inside a ->dellink call)
> is followed by goto restart, so there's no need in _safe iteration.
>
> Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Acked-by: Patrick McHardy <kaber@trash.net>
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH net-2.6.26 2/10][RTNL]: Introduce the rtnl_kill_links helper.
2008-04-15 12:03 ` [PATCH net-2.6.26 2/10][RTNL]: Introduce the rtnl_kill_links helper Pavel Emelyanov
@ 2008-04-15 12:01 ` Patrick McHardy
0 siblings, 0 replies; 24+ messages in thread
From: Patrick McHardy @ 2008-04-15 12:01 UTC (permalink / raw)
To: Pavel Emelyanov; +Cc: David Miller, Linux Netdev List
Pavel Emelyanov wrote:
> This one is responsible for calling ->dellink on each net
> device found in net to help with vlan net_exit hook in the
> nearest future.
>
> Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Acked-by: Patrick McHardy <kaber@trash.net>
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH net-2.6.26 1/10][RTNL]: Relax for_each_netdev_safe in __rtnl_link_unregister.
2008-04-15 11:59 [PATCH net-2.6.26 0/10][VLAN]: Make VLAN devices work in net namespaces Pavel Emelyanov
@ 2008-04-15 12:01 ` Pavel Emelyanov
2008-04-15 12:00 ` Patrick McHardy
2008-04-15 12:03 ` [PATCH net-2.6.26 2/10][RTNL]: Introduce the rtnl_kill_links helper Pavel Emelyanov
` (9 subsequent siblings)
10 siblings, 1 reply; 24+ messages in thread
From: Pavel Emelyanov @ 2008-04-15 12:01 UTC (permalink / raw)
To: David Miller; +Cc: Patrick McHardy, Linux Netdev List
Each potential list_del (happening from inside a ->dellink call)
is followed by goto restart, so there's no need in _safe iteration.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
---
net/core/rtnetlink.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index da99ac0..edc6dbf 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -277,12 +277,12 @@ EXPORT_SYMBOL_GPL(rtnl_link_register);
*/
void __rtnl_link_unregister(struct rtnl_link_ops *ops)
{
- struct net_device *dev, *n;
+ struct net_device *dev;
struct net *net;
for_each_net(net) {
restart:
- for_each_netdev_safe(net, dev, n) {
+ for_each_netdev(net, dev) {
if (dev->rtnl_link_ops == ops) {
ops->dellink(dev);
goto restart;
--
1.5.3.4
^ permalink raw reply related [flat|nested] 24+ messages in thread
* Re: [PATCH net-2.6.26 3/10][VLAN]: Tag vlan_group_device with net device, not ifindex.
2008-04-15 12:05 ` [PATCH net-2.6.26 3/10][VLAN]: Tag vlan_group_device with net device, not ifindex Pavel Emelyanov
@ 2008-04-15 12:03 ` Patrick McHardy
0 siblings, 0 replies; 24+ messages in thread
From: Patrick McHardy @ 2008-04-15 12:03 UTC (permalink / raw)
To: Pavel Emelyanov; +Cc: David Miller, Linux Netdev List
Pavel Emelyanov wrote:
> Currently vlan group is searched using one key - the ifindex.
> We'll have to lookup the vlan_group by two keys - ifindex and
> net. Turning the vlan_group lookup key to struct net_device
> pointer will make this process easier.
>
> Besides, this will eliminate one more place in the networking,
> that assumes that indexes are unique in the kernel.
>
> Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Acked-by: Patrick McHardy <kaber@trash.net>
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH net-2.6.26 2/10][RTNL]: Introduce the rtnl_kill_links helper.
2008-04-15 11:59 [PATCH net-2.6.26 0/10][VLAN]: Make VLAN devices work in net namespaces Pavel Emelyanov
2008-04-15 12:01 ` [PATCH net-2.6.26 1/10][RTNL]: Relax for_each_netdev_safe in __rtnl_link_unregister Pavel Emelyanov
@ 2008-04-15 12:03 ` Pavel Emelyanov
2008-04-15 12:01 ` Patrick McHardy
2008-04-15 12:05 ` [PATCH net-2.6.26 3/10][VLAN]: Tag vlan_group_device with net device, not ifindex Pavel Emelyanov
` (8 subsequent siblings)
10 siblings, 1 reply; 24+ messages in thread
From: Pavel Emelyanov @ 2008-04-15 12:03 UTC (permalink / raw)
To: David Miller; +Cc: Patrick McHardy, Linux Netdev List
This one is responsible for calling ->dellink on each net
device found in net to help with vlan net_exit hook in the
nearest future.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
---
include/net/rtnetlink.h | 1 +
net/core/rtnetlink.c | 29 +++++++++++++++++++++--------
2 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
index 793863e..3c1895e 100644
--- a/include/net/rtnetlink.h
+++ b/include/net/rtnetlink.h
@@ -74,6 +74,7 @@ struct rtnl_link_ops {
extern int __rtnl_link_register(struct rtnl_link_ops *ops);
extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
+extern void rtnl_kill_links(struct net *net, struct rtnl_link_ops *ops);
extern int rtnl_link_register(struct rtnl_link_ops *ops);
extern void rtnl_link_unregister(struct rtnl_link_ops *ops);
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index edc6dbf..bc39e41 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -269,6 +269,26 @@ int rtnl_link_register(struct rtnl_link_ops *ops)
EXPORT_SYMBOL_GPL(rtnl_link_register);
+static void __rtnl_kill_links(struct net *net, struct rtnl_link_ops *ops)
+{
+ struct net_device *dev;
+restart:
+ for_each_netdev(net, dev) {
+ if (dev->rtnl_link_ops == ops) {
+ ops->dellink(dev);
+ goto restart;
+ }
+ }
+}
+
+void rtnl_kill_links(struct net *net, struct rtnl_link_ops *ops)
+{
+ rtnl_lock();
+ __rtnl_kill_links(net, ops);
+ rtnl_unlock();
+}
+EXPORT_SYMBOL_GPL(rtnl_kill_links);
+
/**
* __rtnl_link_unregister - Unregister rtnl_link_ops from rtnetlink.
* @ops: struct rtnl_link_ops * to unregister
@@ -277,17 +297,10 @@ EXPORT_SYMBOL_GPL(rtnl_link_register);
*/
void __rtnl_link_unregister(struct rtnl_link_ops *ops)
{
- struct net_device *dev;
struct net *net;
for_each_net(net) {
-restart:
- for_each_netdev(net, dev) {
- if (dev->rtnl_link_ops == ops) {
- ops->dellink(dev);
- goto restart;
- }
- }
+ __rtnl_kill_links(net, ops);
}
list_del(&ops->list);
}
--
1.5.3.4
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH net-2.6.26 3/10][VLAN]: Tag vlan_group_device with net device, not ifindex.
2008-04-15 11:59 [PATCH net-2.6.26 0/10][VLAN]: Make VLAN devices work in net namespaces Pavel Emelyanov
2008-04-15 12:01 ` [PATCH net-2.6.26 1/10][RTNL]: Relax for_each_netdev_safe in __rtnl_link_unregister Pavel Emelyanov
2008-04-15 12:03 ` [PATCH net-2.6.26 2/10][RTNL]: Introduce the rtnl_kill_links helper Pavel Emelyanov
@ 2008-04-15 12:05 ` Pavel Emelyanov
2008-04-15 12:03 ` Patrick McHardy
2008-04-15 12:07 ` [PATCH net-2.6.26 4/10][VLAN]: Introduce the vlan_net structure and init/exit net ops Pavel Emelyanov
` (7 subsequent siblings)
10 siblings, 1 reply; 24+ messages in thread
From: Pavel Emelyanov @ 2008-04-15 12:05 UTC (permalink / raw)
To: David Miller; +Cc: Patrick McHardy, Linux Netdev List
Currently vlan group is searched using one key - the ifindex.
We'll have to lookup the vlan_group by two keys - ifindex and
net. Turning the vlan_group lookup key to struct net_device
pointer will make this process easier.
Besides, this will eliminate one more place in the networking,
that assumes that indexes are unique in the kernel.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
---
include/linux/if_vlan.h | 4 +++-
net/8021q/vlan.c | 22 +++++++++++-----------
2 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index edd55af..15ace02 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -81,7 +81,9 @@ extern void vlan_ioctl_set(int (*hook)(struct net *, void __user *));
#define VLAN_GROUP_ARRAY_PART_LEN (VLAN_GROUP_ARRAY_LEN/VLAN_GROUP_ARRAY_SPLIT_PARTS)
struct vlan_group {
- int real_dev_ifindex; /* The ifindex of the ethernet(like) device the vlan is attached to. */
+ struct net_device *real_dev; /* The ethernet(like) device
+ * the vlan is attached to.
+ */
unsigned int nr_vlans;
struct hlist_node hlist; /* linked list */
struct net_device **vlan_devices_arrays[VLAN_GROUP_ARRAY_SPLIT_PARTS];
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 5975ec3..cf8d810 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -65,14 +65,14 @@ static inline unsigned int vlan_grp_hashfn(unsigned int idx)
}
/* Must be invoked with RCU read lock (no preempt) */
-static struct vlan_group *__vlan_find_group(int real_dev_ifindex)
+static struct vlan_group *__vlan_find_group(struct net_device *real_dev)
{
struct vlan_group *grp;
struct hlist_node *n;
- int hash = vlan_grp_hashfn(real_dev_ifindex);
+ int hash = vlan_grp_hashfn(real_dev->ifindex);
hlist_for_each_entry_rcu(grp, n, &vlan_group_hash[hash], hlist) {
- if (grp->real_dev_ifindex == real_dev_ifindex)
+ if (grp->real_dev == real_dev)
return grp;
}
@@ -86,7 +86,7 @@ static struct vlan_group *__vlan_find_group(int real_dev_ifindex)
struct net_device *__find_vlan_dev(struct net_device *real_dev,
unsigned short VID)
{
- struct vlan_group *grp = __vlan_find_group(real_dev->ifindex);
+ struct vlan_group *grp = __vlan_find_group(real_dev);
if (grp)
return vlan_group_get_device(grp, VID);
@@ -103,7 +103,7 @@ static void vlan_group_free(struct vlan_group *grp)
kfree(grp);
}
-static struct vlan_group *vlan_group_alloc(int ifindex)
+static struct vlan_group *vlan_group_alloc(struct net_device *real_dev)
{
struct vlan_group *grp;
@@ -111,9 +111,9 @@ static struct vlan_group *vlan_group_alloc(int ifindex)
if (!grp)
return NULL;
- grp->real_dev_ifindex = ifindex;
+ grp->real_dev = real_dev;
hlist_add_head_rcu(&grp->hlist,
- &vlan_group_hash[vlan_grp_hashfn(ifindex)]);
+ &vlan_group_hash[vlan_grp_hashfn(real_dev->ifindex)]);
return grp;
}
@@ -151,7 +151,7 @@ void unregister_vlan_dev(struct net_device *dev)
ASSERT_RTNL();
- grp = __vlan_find_group(real_dev->ifindex);
+ grp = __vlan_find_group(real_dev);
BUG_ON(!grp);
vlan_proc_rem_dev(dev);
@@ -246,9 +246,9 @@ int register_vlan_dev(struct net_device *dev)
struct vlan_group *grp, *ngrp = NULL;
int err;
- grp = __vlan_find_group(real_dev->ifindex);
+ grp = __vlan_find_group(real_dev);
if (!grp) {
- ngrp = grp = vlan_group_alloc(real_dev->ifindex);
+ ngrp = grp = vlan_group_alloc(real_dev);
if (!grp)
return -ENOBUFS;
}
@@ -412,7 +412,7 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
goto out;
}
- grp = __vlan_find_group(dev->ifindex);
+ grp = __vlan_find_group(dev);
if (!grp)
goto out;
--
1.5.3.4
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH net-2.6.26 4/10][VLAN]: Introduce the vlan_net structure and init/exit net ops.
2008-04-15 11:59 [PATCH net-2.6.26 0/10][VLAN]: Make VLAN devices work in net namespaces Pavel Emelyanov
` (2 preceding siblings ...)
2008-04-15 12:05 ` [PATCH net-2.6.26 3/10][VLAN]: Tag vlan_group_device with net device, not ifindex Pavel Emelyanov
@ 2008-04-15 12:07 ` Pavel Emelyanov
2008-04-15 12:09 ` Patrick McHardy
2008-04-15 12:24 ` Patrick McHardy
2008-04-15 12:09 ` [PATCH net-2.6.26 5/10][VLAN]: Add a net argument to proc init and cleanup calls Pavel Emelyanov
` (6 subsequent siblings)
10 siblings, 2 replies; 24+ messages in thread
From: Pavel Emelyanov @ 2008-04-15 12:07 UTC (permalink / raw)
To: David Miller; +Cc: Patrick McHardy, Linux Netdev List
Unlike TUN, it is empty from the very beginning, and will
be eventually populated later.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
---
net/8021q/vlan.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
net/8021q/vlan.h | 5 +++++
2 files changed, 51 insertions(+), 0 deletions(-)
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index cf8d810..9296601 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -32,6 +32,7 @@
#include <linux/rtnetlink.h>
#include <linux/notifier.h>
#include <net/net_namespace.h>
+#include <net/netns/generic.h>
#include <linux/if_vlan.h>
#include "vlan.h"
@@ -41,6 +42,8 @@
/* Global VLAN variables */
+int vlan_net_id;
+
/* Our listing of VLAN group(s) */
static struct hlist_head vlan_group_hash[VLAN_GRP_HASH_SIZE];
@@ -625,6 +628,41 @@ out:
return err;
}
+static int vlan_init_net(struct net *net)
+{
+ int err;
+ struct vlan_net *vn;
+
+ err = -ENOMEM;
+ vn = kzalloc(sizeof(struct vlan_net), GFP_KERNEL);
+ if (vn == NULL)
+ goto err_alloc;
+
+ err = net_assign_generic(net, vlan_net_id, vn);
+ if (err < 0)
+ goto err_assign;
+
+ return 0;
+
+err_assign:
+ kfree(vn);
+err_alloc:
+ return err;
+}
+
+static void vlan_exit_net(struct net *net)
+{
+ struct vlan_net *vn;
+
+ vn = net_generic(net, vlan_net_id);
+ kfree(vn);
+}
+
+static struct pernet_operations vlan_net_ops = {
+ .init = vlan_init_net,
+ .exit = vlan_exit_net,
+};
+
static int __init vlan_proto_init(void)
{
int err;
@@ -632,6 +670,10 @@ static int __init vlan_proto_init(void)
pr_info("%s v%s %s\n", vlan_fullname, vlan_version, vlan_copyright);
pr_info("All bugs added by %s\n", vlan_buggyright);
+ err = register_pernet_gen_device(&vlan_net_id, &vlan_net_ops);
+ if (err < 0)
+ goto err0;
+
err = vlan_proc_init();
if (err < 0)
goto err1;
@@ -653,6 +695,8 @@ err3:
err2:
vlan_proc_cleanup();
err1:
+ unregister_pernet_gen_device(vlan_net_id, &vlan_net_ops);
+err0:
return err;
}
@@ -673,6 +717,8 @@ static void __exit vlan_cleanup_module(void)
vlan_proc_cleanup();
+ unregister_pernet_gen_device(vlan_net_id, &vlan_net_ops);
+
synchronize_net();
}
diff --git a/net/8021q/vlan.h b/net/8021q/vlan.h
index 51271ae..f27d8d6 100644
--- a/net/8021q/vlan.h
+++ b/net/8021q/vlan.h
@@ -50,4 +50,9 @@ static inline int is_vlan_dev(struct net_device *dev)
return dev->priv_flags & IFF_802_1Q_VLAN;
}
+extern int vlan_net_id;
+
+struct vlan_net {
+};
+
#endif /* !(__BEN_VLAN_802_1Q_INC__) */
--
1.5.3.4
^ permalink raw reply related [flat|nested] 24+ messages in thread
* Re: [PATCH net-2.6.26 4/10][VLAN]: Introduce the vlan_net structure and init/exit net ops.
2008-04-15 12:07 ` [PATCH net-2.6.26 4/10][VLAN]: Introduce the vlan_net structure and init/exit net ops Pavel Emelyanov
@ 2008-04-15 12:09 ` Patrick McHardy
2008-04-15 12:50 ` Pavel Emelyanov
2008-04-15 12:24 ` Patrick McHardy
1 sibling, 1 reply; 24+ messages in thread
From: Patrick McHardy @ 2008-04-15 12:09 UTC (permalink / raw)
To: Pavel Emelyanov; +Cc: David Miller, Linux Netdev List
Pavel Emelyanov wrote:
> @@ -632,6 +670,10 @@ static int __init vlan_proto_init(void)
> pr_info("%s v%s %s\n", vlan_fullname, vlan_version, vlan_copyright);
> pr_info("All bugs added by %s\n", vlan_buggyright);
>
> + err = register_pernet_gen_device(&vlan_net_id, &vlan_net_ops);
> + if (err < 0)
> + goto err0;
I'm wondering what vlan_net_id is used for, but I can't find that
function in the current net-2.6.26.git tree. What tree are these
patches based on?
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH net-2.6.26 5/10][VLAN]: Add a net argument to proc init and cleanup calls.
2008-04-15 11:59 [PATCH net-2.6.26 0/10][VLAN]: Make VLAN devices work in net namespaces Pavel Emelyanov
` (3 preceding siblings ...)
2008-04-15 12:07 ` [PATCH net-2.6.26 4/10][VLAN]: Introduce the vlan_net structure and init/exit net ops Pavel Emelyanov
@ 2008-04-15 12:09 ` Pavel Emelyanov
2008-04-15 12:26 ` Patrick McHardy
2008-04-15 12:12 ` [PATCH net-2.6.26 6/10][VLAN]: Create proc entries in the proper net Pavel Emelyanov
` (5 subsequent siblings)
10 siblings, 1 reply; 24+ messages in thread
From: Pavel Emelyanov @ 2008-04-15 12:09 UTC (permalink / raw)
To: David Miller; +Cc: Patrick McHardy, Linux Netdev List
All proc files will be created in each net, so prepare them for
this change now, not to mess it with real creation patch.
The net != &init_net checks in them are for git-bisect sanity,
but I will drop them soon.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
---
net/8021q/vlan.c | 15 +++++++--------
net/8021q/vlanproc.c | 12 +++++++++---
net/8021q/vlanproc.h | 10 ++++++----
3 files changed, 22 insertions(+), 15 deletions(-)
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 9296601..541542e 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -642,8 +642,14 @@ static int vlan_init_net(struct net *net)
if (err < 0)
goto err_assign;
+ err = vlan_proc_init(net);
+ if (err < 0)
+ goto err_proc;
+
return 0;
+err_proc:
+ /* nothing */
err_assign:
kfree(vn);
err_alloc:
@@ -655,6 +661,7 @@ static void vlan_exit_net(struct net *net)
struct vlan_net *vn;
vn = net_generic(net, vlan_net_id);
+ vlan_proc_cleanup(net);
kfree(vn);
}
@@ -674,10 +681,6 @@ static int __init vlan_proto_init(void)
if (err < 0)
goto err0;
- err = vlan_proc_init();
- if (err < 0)
- goto err1;
-
err = register_netdevice_notifier(&vlan_notifier_block);
if (err < 0)
goto err2;
@@ -693,8 +696,6 @@ static int __init vlan_proto_init(void)
err3:
unregister_netdevice_notifier(&vlan_notifier_block);
err2:
- vlan_proc_cleanup();
-err1:
unregister_pernet_gen_device(vlan_net_id, &vlan_net_ops);
err0:
return err;
@@ -715,8 +716,6 @@ static void __exit vlan_cleanup_module(void)
for (i = 0; i < VLAN_GRP_HASH_SIZE; i++)
BUG_ON(!hlist_empty(&vlan_group_hash[i]));
- vlan_proc_cleanup();
-
unregister_pernet_gen_device(vlan_net_id, &vlan_net_ops);
synchronize_net();
diff --git a/net/8021q/vlanproc.c b/net/8021q/vlanproc.c
index 24cd96e..4d13aeb 100644
--- a/net/8021q/vlanproc.c
+++ b/net/8021q/vlanproc.c
@@ -138,8 +138,11 @@ static const char *vlan_name_type_str[VLAN_NAME_TYPE_HIGHEST] = {
* Clean up /proc/net/vlan entries
*/
-void vlan_proc_cleanup(void)
+void vlan_proc_cleanup(struct net *net)
{
+ if (net != &init_net)
+ return;
+
if (proc_vlan_conf)
remove_proc_entry(name_conf, proc_vlan_dir);
@@ -155,8 +158,11 @@ void vlan_proc_cleanup(void)
* Create /proc/net/vlan entries
*/
-int __init vlan_proc_init(void)
+int vlan_proc_init(struct net *net)
{
+ if (net != &init_net)
+ return 0;
+
proc_vlan_dir = proc_mkdir(name_root, init_net.proc_net);
if (!proc_vlan_dir)
goto err;
@@ -169,7 +175,7 @@ int __init vlan_proc_init(void)
err:
pr_err("%s: can't create entry in proc filesystem!\n", __func__);
- vlan_proc_cleanup();
+ vlan_proc_cleanup(net);
return -ENOBUFS;
}
diff --git a/net/8021q/vlanproc.h b/net/8021q/vlanproc.h
index da542ca..063f60a 100644
--- a/net/8021q/vlanproc.h
+++ b/net/8021q/vlanproc.h
@@ -2,15 +2,17 @@
#define __BEN_VLAN_PROC_INC__
#ifdef CONFIG_PROC_FS
-int vlan_proc_init(void);
+struct net;
+
+int vlan_proc_init(struct net *net);
int vlan_proc_rem_dev(struct net_device *vlandev);
int vlan_proc_add_dev(struct net_device *vlandev);
-void vlan_proc_cleanup(void);
+void vlan_proc_cleanup(struct net *net);
#else /* No CONFIG_PROC_FS */
-#define vlan_proc_init() (0)
-#define vlan_proc_cleanup() do {} while (0)
+#define vlan_proc_init(net) (0)
+#define vlan_proc_cleanup(net) do {} while (0)
#define vlan_proc_add_dev(dev) ({(void)(dev), 0; })
#define vlan_proc_rem_dev(dev) ({(void)(dev), 0; })
#endif
--
1.5.3.4
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH net-2.6.26 6/10][VLAN]: Create proc entries in the proper net.
2008-04-15 11:59 [PATCH net-2.6.26 0/10][VLAN]: Make VLAN devices work in net namespaces Pavel Emelyanov
` (4 preceding siblings ...)
2008-04-15 12:09 ` [PATCH net-2.6.26 5/10][VLAN]: Add a net argument to proc init and cleanup calls Pavel Emelyanov
@ 2008-04-15 12:12 ` Pavel Emelyanov
2008-04-15 12:28 ` Patrick McHardy
2008-04-15 12:13 ` [PATCH net-2.6.26 7/10][VLAN]: Make the /proc/net/vlan/conf file show per-net info Pavel Emelyanov
` (4 subsequent siblings)
10 siblings, 1 reply; 24+ messages in thread
From: Pavel Emelyanov @ 2008-04-15 12:12 UTC (permalink / raw)
To: David Miller; +Cc: Patrick McHardy, Linux Netdev List
The proc_vlan_dir and proc_vlan_conf migrate on the struct
vlan_net and their creation uses the struct net.
The devices' entries use the corresponding device's net.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
---
net/8021q/vlan.h | 6 ++++++
net/8021q/vlanproc.c | 44 +++++++++++++++++---------------------------
2 files changed, 23 insertions(+), 27 deletions(-)
diff --git a/net/8021q/vlan.h b/net/8021q/vlan.h
index f27d8d6..7258357 100644
--- a/net/8021q/vlan.h
+++ b/net/8021q/vlan.h
@@ -52,7 +52,13 @@ static inline int is_vlan_dev(struct net_device *dev)
extern int vlan_net_id;
+struct proc_dir_entry;
+
struct vlan_net {
+ /* /proc/net/vlan */
+ struct proc_dir_entry *proc_vlan_dir;
+ /* /proc/net/vlan/config */
+ struct proc_dir_entry *proc_vlan_conf;
};
#endif /* !(__BEN_VLAN_802_1Q_INC__) */
diff --git a/net/8021q/vlanproc.c b/net/8021q/vlanproc.c
index 4d13aeb..995544b 100644
--- a/net/8021q/vlanproc.c
+++ b/net/8021q/vlanproc.c
@@ -34,6 +34,7 @@
#include <linux/netdevice.h>
#include <linux/if_vlan.h>
#include <net/net_namespace.h>
+#include <net/netns/generic.h>
#include "vlanproc.h"
#include "vlan.h"
@@ -111,18 +112,6 @@ static const struct file_operations vlandev_fops = {
* Proc filesystem derectory entries.
*/
-/*
- * /proc/net/vlan
- */
-
-static struct proc_dir_entry *proc_vlan_dir;
-
-/*
- * /proc/net/vlan/config
- */
-
-static struct proc_dir_entry *proc_vlan_conf;
-
/* Strings */
static const char *vlan_name_type_str[VLAN_NAME_TYPE_HIGHEST] = {
[VLAN_NAME_TYPE_RAW_PLUS_VID] = "VLAN_NAME_TYPE_RAW_PLUS_VID",
@@ -140,14 +129,13 @@ static const char *vlan_name_type_str[VLAN_NAME_TYPE_HIGHEST] = {
void vlan_proc_cleanup(struct net *net)
{
- if (net != &init_net)
- return;
+ struct vlan_net *vn = net_generic(net, vlan_net_id);
- if (proc_vlan_conf)
- remove_proc_entry(name_conf, proc_vlan_dir);
+ if (vn->proc_vlan_conf)
+ remove_proc_entry(name_conf, vn->proc_vlan_dir);
- if (proc_vlan_dir)
- proc_net_remove(&init_net, name_root);
+ if (vn->proc_vlan_dir)
+ proc_net_remove(net, name_root);
/* Dynamically added entries should be cleaned up as their vlan_device
* is removed, so we should not have to take care of it here...
@@ -160,16 +148,15 @@ void vlan_proc_cleanup(struct net *net)
int vlan_proc_init(struct net *net)
{
- if (net != &init_net)
- return 0;
+ struct vlan_net *vn = net_generic(net, vlan_net_id);
- proc_vlan_dir = proc_mkdir(name_root, init_net.proc_net);
- if (!proc_vlan_dir)
+ vn->proc_vlan_dir = proc_net_mkdir(net, name_root, net->proc_net);
+ if (!vn->proc_vlan_dir)
goto err;
- proc_vlan_conf = proc_create(name_conf, S_IFREG|S_IRUSR|S_IWUSR,
- proc_vlan_dir, &vlan_fops);
- if (!proc_vlan_conf)
+ vn->proc_vlan_conf = proc_create(name_conf, S_IFREG|S_IRUSR|S_IWUSR,
+ vn->proc_vlan_dir, &vlan_fops);
+ if (!vn->proc_vlan_conf)
goto err;
return 0;
@@ -186,9 +173,10 @@ err:
int vlan_proc_add_dev(struct net_device *vlandev)
{
struct vlan_dev_info *dev_info = vlan_dev_info(vlandev);
+ struct vlan_net *vn = net_generic(dev_net(vlandev), vlan_net_id);
dev_info->dent = proc_create(vlandev->name, S_IFREG|S_IRUSR|S_IWUSR,
- proc_vlan_dir, &vlandev_fops);
+ vn->proc_vlan_dir, &vlandev_fops);
if (!dev_info->dent)
return -ENOBUFS;
@@ -201,10 +189,12 @@ int vlan_proc_add_dev(struct net_device *vlandev)
*/
int vlan_proc_rem_dev(struct net_device *vlandev)
{
+ struct vlan_net *vn = net_generic(dev_net(vlandev), vlan_net_id);
+
/** NOTE: This will consume the memory pointed to by dent, it seems. */
if (vlan_dev_info(vlandev)->dent) {
remove_proc_entry(vlan_dev_info(vlandev)->dent->name,
- proc_vlan_dir);
+ vn->proc_vlan_dir);
vlan_dev_info(vlandev)->dent = NULL;
}
return 0;
--
1.5.3.4
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH net-2.6.26 7/10][VLAN]: Make the /proc/net/vlan/conf file show per-net info.
2008-04-15 11:59 [PATCH net-2.6.26 0/10][VLAN]: Make VLAN devices work in net namespaces Pavel Emelyanov
` (5 preceding siblings ...)
2008-04-15 12:12 ` [PATCH net-2.6.26 6/10][VLAN]: Create proc entries in the proper net Pavel Emelyanov
@ 2008-04-15 12:13 ` Pavel Emelyanov
2008-04-15 12:28 ` Patrick McHardy
2008-04-15 12:15 ` [PATCH net-2.6.26 8/10][VLAN]: Make the vlan_name_type per-net Pavel Emelyanov
` (3 subsequent siblings)
10 siblings, 1 reply; 24+ messages in thread
From: Pavel Emelyanov @ 2008-04-15 12:13 UTC (permalink / raw)
To: David Miller; +Cc: Patrick McHardy, Linux Netdev List
It is created in a proper net, so make is show info, related
to this particular net.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
---
net/8021q/vlanproc.c | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/net/8021q/vlanproc.c b/net/8021q/vlanproc.c
index 995544b..cc17b72 100644
--- a/net/8021q/vlanproc.c
+++ b/net/8021q/vlanproc.c
@@ -80,7 +80,8 @@ static const struct seq_operations vlan_seq_ops = {
static int vlan_seq_open(struct inode *inode, struct file *file)
{
- return seq_open(file, &vlan_seq_ops);
+ return seq_open_net(inode, file, &vlan_seq_ops,
+ sizeof(struct seq_net_private));
}
static const struct file_operations vlan_fops = {
@@ -88,7 +89,7 @@ static const struct file_operations vlan_fops = {
.open = vlan_seq_open,
.read = seq_read,
.llseek = seq_lseek,
- .release = seq_release,
+ .release = seq_release_net,
};
/*
@@ -211,6 +212,7 @@ static void *vlan_seq_start(struct seq_file *seq, loff_t *pos)
__acquires(dev_base_lock)
{
struct net_device *dev;
+ struct net *net = seq_file_net(seq);
loff_t i = 1;
read_lock(&dev_base_lock);
@@ -218,7 +220,7 @@ static void *vlan_seq_start(struct seq_file *seq, loff_t *pos)
if (*pos == 0)
return SEQ_START_TOKEN;
- for_each_netdev(&init_net, dev) {
+ for_each_netdev(net, dev) {
if (!is_vlan_dev(dev))
continue;
@@ -232,14 +234,15 @@ static void *vlan_seq_start(struct seq_file *seq, loff_t *pos)
static void *vlan_seq_next(struct seq_file *seq, void *v, loff_t *pos)
{
struct net_device *dev;
+ struct net *net = seq_file_net(seq);
++*pos;
dev = (struct net_device *)v;
if (v == SEQ_START_TOKEN)
- dev = net_device_entry(&init_net.dev_base_head);
+ dev = net_device_entry(&net->dev_base_head);
- for_each_netdev_continue(&init_net, dev) {
+ for_each_netdev_continue(net, dev) {
if (!is_vlan_dev(dev))
continue;
--
1.5.3.4
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH net-2.6.26 8/10][VLAN]: Make the vlan_name_type per-net.
2008-04-15 11:59 [PATCH net-2.6.26 0/10][VLAN]: Make VLAN devices work in net namespaces Pavel Emelyanov
` (6 preceding siblings ...)
2008-04-15 12:13 ` [PATCH net-2.6.26 7/10][VLAN]: Make the /proc/net/vlan/conf file show per-net info Pavel Emelyanov
@ 2008-04-15 12:15 ` Pavel Emelyanov
2008-04-15 12:17 ` [PATCH net-2.6.26 9/10][VLAN]: Allow vlan devices registration in net namespaces Pavel Emelyanov
` (2 subsequent siblings)
10 siblings, 0 replies; 24+ messages in thread
From: Pavel Emelyanov @ 2008-04-15 12:15 UTC (permalink / raw)
To: David Miller; +Cc: Patrick McHardy, Linux Netdev List
This includes moving one on the struct vlan_net and
s/vlan_name_type/vn->name_type/ over the code.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
---
net/8021q/vlan.c | 14 +++++++++-----
net/8021q/vlan.h | 4 ++--
net/8021q/vlanproc.c | 7 +++++--
3 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 541542e..5cacad0 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -52,9 +52,6 @@ static char vlan_version[] = DRV_VERSION;
static char vlan_copyright[] = "Ben Greear <greearb@candelatech.com>";
static char vlan_buggyright[] = "David S. Miller <davem@redhat.com>";
-/* Determines interface naming scheme. */
-unsigned short vlan_name_type = VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD;
-
static struct packet_type vlan_packet_type = {
.type = __constant_htons(ETH_P_8021Q),
.func = vlan_skb_recv, /* VLAN receive method */
@@ -299,6 +296,8 @@ static int register_vlan_device(struct net_device *real_dev,
unsigned short VLAN_ID)
{
struct net_device *new_dev;
+ struct net *net = dev_net(real_dev);
+ struct vlan_net *vn = net_generic(net, vlan_net_id);
char name[IFNAMSIZ];
int err;
@@ -310,7 +309,7 @@ static int register_vlan_device(struct net_device *real_dev,
return err;
/* Gotta set up the fields for the device. */
- switch (vlan_name_type) {
+ switch (vn->name_type) {
case VLAN_NAME_TYPE_RAW_PLUS_VID:
/* name will look like: eth1.0005 */
snprintf(name, IFNAMSIZ, "%s.%.4i", real_dev->name, VLAN_ID);
@@ -580,7 +579,10 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
break;
if ((args.u.name_type >= 0) &&
(args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
- vlan_name_type = args.u.name_type;
+ struct vlan_net *vn;
+
+ vn = net_generic(net, vlan_net_id);
+ vn->name_type = args.u.name_type;
err = 0;
} else {
err = -EINVAL;
@@ -642,6 +644,8 @@ static int vlan_init_net(struct net *net)
if (err < 0)
goto err_assign;
+ vn->name_type = VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD;
+
err = vlan_proc_init(net);
if (err < 0)
goto err_proc;
diff --git a/net/8021q/vlan.h b/net/8021q/vlan.h
index 7258357..5229a72 100644
--- a/net/8021q/vlan.h
+++ b/net/8021q/vlan.h
@@ -3,8 +3,6 @@
#include <linux/if_vlan.h>
-extern unsigned short vlan_name_type;
-
#define VLAN_GRP_HASH_SHIFT 5
#define VLAN_GRP_HASH_SIZE (1 << VLAN_GRP_HASH_SHIFT)
#define VLAN_GRP_HASH_MASK (VLAN_GRP_HASH_SIZE - 1)
@@ -59,6 +57,8 @@ struct vlan_net {
struct proc_dir_entry *proc_vlan_dir;
/* /proc/net/vlan/config */
struct proc_dir_entry *proc_vlan_conf;
+ /* Determines interface naming scheme. */
+ unsigned short name_type;
};
#endif /* !(__BEN_VLAN_802_1Q_INC__) */
diff --git a/net/8021q/vlanproc.c b/net/8021q/vlanproc.c
index cc17b72..daad006 100644
--- a/net/8021q/vlanproc.c
+++ b/net/8021q/vlanproc.c
@@ -260,13 +260,16 @@ static void vlan_seq_stop(struct seq_file *seq, void *v)
static int vlan_seq_show(struct seq_file *seq, void *v)
{
+ struct net *net = seq_file_net(seq);
+ struct vlan_net *vn = net_generic(net, vlan_net_id);
+
if (v == SEQ_START_TOKEN) {
const char *nmtype = NULL;
seq_puts(seq, "VLAN Dev name | VLAN ID\n");
- if (vlan_name_type < ARRAY_SIZE(vlan_name_type_str))
- nmtype = vlan_name_type_str[vlan_name_type];
+ if (vn->name_type < ARRAY_SIZE(vlan_name_type_str))
+ nmtype = vlan_name_type_str[vn->name_type];
seq_printf(seq, "Name-Type: %s\n",
nmtype ? nmtype : "UNKNOWN");
--
1.5.3.4
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH net-2.6.26 9/10][VLAN]: Allow vlan devices registration in net namespaces.
2008-04-15 11:59 [PATCH net-2.6.26 0/10][VLAN]: Make VLAN devices work in net namespaces Pavel Emelyanov
` (7 preceding siblings ...)
2008-04-15 12:15 ` [PATCH net-2.6.26 8/10][VLAN]: Make the vlan_name_type per-net Pavel Emelyanov
@ 2008-04-15 12:17 ` Pavel Emelyanov
2008-04-15 12:19 ` [PATCH net-2.6.26 10/10][VLAN]: Handle vlan devices net namespace changing Pavel Emelyanov
2008-04-16 8:02 ` [PATCH net-2.6.26 0/10][VLAN]: Make VLAN devices work in net namespaces David Miller
10 siblings, 0 replies; 24+ messages in thread
From: Pavel Emelyanov @ 2008-04-15 12:17 UTC (permalink / raw)
To: David Miller; +Cc: Patrick McHardy, Linux Netdev List
This one is similar to what I've done for TUN - set the proper
net after device allocation and clean VLANs on net exit (use the
rtnl_kill_links helper finally).
Plus, drop explicit init_net usage and net != &init_net checks.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
---
net/8021q/vlan.c | 7 +++----
net/8021q/vlan_dev.c | 3 ---
net/8021q/vlan_netlink.c | 2 +-
3 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 5cacad0..7e9d22e 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -340,6 +340,7 @@ static int register_vlan_device(struct net_device *real_dev,
if (new_dev == NULL)
return -ENOBUFS;
+ dev_net_set(new_dev, net);
/* need 4 bytes for extra VLAN header info,
* hope the underlying device can handle it.
*/
@@ -406,9 +407,6 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
int i, flgs;
struct net_device *vlandev;
- if (dev_net(dev) != &init_net)
- return NOTIFY_DONE;
-
if (is_vlan_dev(dev)) {
__vlan_device_event(dev, event);
goto out;
@@ -534,7 +532,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
case GET_VLAN_REALDEV_NAME_CMD:
case GET_VLAN_VID_CMD:
err = -ENODEV;
- dev = __dev_get_by_name(&init_net, args.device1);
+ dev = __dev_get_by_name(net, args.device1);
if (!dev)
goto out;
@@ -665,6 +663,7 @@ static void vlan_exit_net(struct net *net)
struct vlan_net *vn;
vn = net_generic(net, vlan_net_id);
+ rtnl_kill_links(net, &vlan_link_ops);
vlan_proc_cleanup(net);
kfree(vn);
}
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 4ae0d7e..c961f08 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -153,9 +153,6 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
struct net_device_stats *stats;
unsigned short vlan_TCI;
- if (dev_net(dev) != &init_net)
- goto err_free;
-
skb = skb_share_check(skb, GFP_ATOMIC);
if (skb == NULL)
goto err_free;
diff --git a/net/8021q/vlan_netlink.c b/net/8021q/vlan_netlink.c
index e32eeb3..c93e69e 100644
--- a/net/8021q/vlan_netlink.c
+++ b/net/8021q/vlan_netlink.c
@@ -113,7 +113,7 @@ static int vlan_newlink(struct net_device *dev,
if (!tb[IFLA_LINK])
return -EINVAL;
- real_dev = __dev_get_by_index(&init_net, nla_get_u32(tb[IFLA_LINK]));
+ real_dev = __dev_get_by_index(dev_net(dev), nla_get_u32(tb[IFLA_LINK]));
if (!real_dev)
return -ENODEV;
--
1.5.3.4
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH net-2.6.26 10/10][VLAN]: Handle vlan devices net namespace changing.
2008-04-15 11:59 [PATCH net-2.6.26 0/10][VLAN]: Make VLAN devices work in net namespaces Pavel Emelyanov
` (8 preceding siblings ...)
2008-04-15 12:17 ` [PATCH net-2.6.26 9/10][VLAN]: Allow vlan devices registration in net namespaces Pavel Emelyanov
@ 2008-04-15 12:19 ` Pavel Emelyanov
2008-04-15 12:30 ` Patrick McHardy
2008-04-16 8:02 ` [PATCH net-2.6.26 0/10][VLAN]: Make VLAN devices work in net namespaces David Miller
10 siblings, 1 reply; 24+ messages in thread
From: Pavel Emelyanov @ 2008-04-15 12:19 UTC (permalink / raw)
To: David Miller; +Cc: Patrick McHardy, Linux Netdev List
When van device is moved to another namespace proc files,
related to this device, should also change one.
Use the netdev REGISTER and UNREGISTER event handlers for this.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
---
net/8021q/vlan.c | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 7e9d22e..2a739ad 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -154,8 +154,6 @@ void unregister_vlan_dev(struct net_device *dev)
grp = __vlan_find_group(real_dev);
BUG_ON(!grp);
- vlan_proc_rem_dev(dev);
-
/* Take it out of our own structures, but be sure to interlock with
* HW accelerating devices or SW vlan input packet processing.
*/
@@ -278,9 +276,6 @@ int register_vlan_dev(struct net_device *dev)
if (real_dev->features & NETIF_F_HW_VLAN_FILTER)
real_dev->vlan_rx_add_vid(real_dev, vlan_id);
- if (vlan_proc_add_dev(dev) < 0)
- pr_warning("8021q: failed to add proc entry for %s\n",
- dev->name);
return 0;
out_free_group:
@@ -396,6 +391,14 @@ static void __vlan_device_event(struct net_device *dev, unsigned long event)
pr_warning("8021q: failed to change proc name for %s\n",
dev->name);
break;
+ case NETDEV_REGISTER:
+ if (vlan_proc_add_dev(dev) < 0)
+ pr_warning("8021q: failed to add proc entry for %s\n",
+ dev->name);
+ break;
+ case NETDEV_UNREGISTER:
+ vlan_proc_rem_dev(dev);
+ break;
}
}
--
1.5.3.4
^ permalink raw reply related [flat|nested] 24+ messages in thread
* Re: [PATCH net-2.6.26 4/10][VLAN]: Introduce the vlan_net structure and init/exit net ops.
2008-04-15 12:07 ` [PATCH net-2.6.26 4/10][VLAN]: Introduce the vlan_net structure and init/exit net ops Pavel Emelyanov
2008-04-15 12:09 ` Patrick McHardy
@ 2008-04-15 12:24 ` Patrick McHardy
1 sibling, 0 replies; 24+ messages in thread
From: Patrick McHardy @ 2008-04-15 12:24 UTC (permalink / raw)
To: Pavel Emelyanov; +Cc: David Miller, Linux Netdev List
Pavel Emelyanov wrote:
> Unlike TUN, it is empty from the very beginning, and will
> be eventually populated later.
>
> Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Acked-by: Patrick McHardy <kaber@trash.net>
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH net-2.6.26 5/10][VLAN]: Add a net argument to proc init and cleanup calls.
2008-04-15 12:09 ` [PATCH net-2.6.26 5/10][VLAN]: Add a net argument to proc init and cleanup calls Pavel Emelyanov
@ 2008-04-15 12:26 ` Patrick McHardy
2008-04-15 13:05 ` Pavel Emelyanov
0 siblings, 1 reply; 24+ messages in thread
From: Patrick McHardy @ 2008-04-15 12:26 UTC (permalink / raw)
To: Pavel Emelyanov; +Cc: David Miller, Linux Netdev List
Pavel Emelyanov wrote:
> All proc files will be created in each net, so prepare them for
> this change now, not to mess it with real creation patch.
>
> The net != &init_net checks in them are for git-bisect sanity,
> but I will drop them soon.
>
> Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
>
> ---
> net/8021q/vlan.c | 15 +++++++--------
> net/8021q/vlanproc.c | 12 +++++++++---
> net/8021q/vlanproc.h | 10 ++++++----
> 3 files changed, 22 insertions(+), 15 deletions(-)
>
> diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
> index 9296601..541542e 100644
> --- a/net/8021q/vlan.c
> +++ b/net/8021q/vlan.c
> @@ -642,8 +642,14 @@ static int vlan_init_net(struct net *net)
> if (err < 0)
> goto err_assign;
>
> + err = vlan_proc_init(net);
> + if (err < 0)
> + goto err_proc;
> +
> return 0;
>
> +err_proc:
> + /* nothing */
What is going to clean up net_generic_assign above?
> err_assign:
> kfree(vn);
> err_alloc:
> @@ -655,6 +661,7 @@ static void vlan_exit_net(struct net *net)
> struct vlan_net *vn;
>
> vn = net_generic(net, vlan_net_id);
> + vlan_proc_cleanup(net);
> kfree(vn);
> }
>
> @@ -674,10 +681,6 @@ static int __init vlan_proto_init(void)
> if (err < 0)
> goto err0;
>
> - err = vlan_proc_init();
> - if (err < 0)
> - goto err1;
> -
> err = register_netdevice_notifier(&vlan_notifier_block);
> if (err < 0)
> goto err2;
> @@ -693,8 +696,6 @@ static int __init vlan_proto_init(void)
> err3:
> unregister_netdevice_notifier(&vlan_notifier_block);
> err2:
> - vlan_proc_cleanup();
> -err1:
> unregister_pernet_gen_device(vlan_net_id, &vlan_net_ops);
> err0:
> return err;
This could be done nicer, not leaving holes in the numbering.
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH net-2.6.26 6/10][VLAN]: Create proc entries in the proper net.
2008-04-15 12:12 ` [PATCH net-2.6.26 6/10][VLAN]: Create proc entries in the proper net Pavel Emelyanov
@ 2008-04-15 12:28 ` Patrick McHardy
0 siblings, 0 replies; 24+ messages in thread
From: Patrick McHardy @ 2008-04-15 12:28 UTC (permalink / raw)
To: Pavel Emelyanov; +Cc: David Miller, Linux Netdev List
Pavel Emelyanov wrote:
> The proc_vlan_dir and proc_vlan_conf migrate on the struct
> vlan_net and their creation uses the struct net.
>
> The devices' entries use the corresponding device's net.
>
> Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Acked-by: Patrick McHardy <kaber@trash.net>
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH net-2.6.26 7/10][VLAN]: Make the /proc/net/vlan/conf file show per-net info.
2008-04-15 12:13 ` [PATCH net-2.6.26 7/10][VLAN]: Make the /proc/net/vlan/conf file show per-net info Pavel Emelyanov
@ 2008-04-15 12:28 ` Patrick McHardy
0 siblings, 0 replies; 24+ messages in thread
From: Patrick McHardy @ 2008-04-15 12:28 UTC (permalink / raw)
To: Pavel Emelyanov; +Cc: David Miller, Linux Netdev List
Pavel Emelyanov wrote:
> It is created in a proper net, so make is show info, related
> to this particular net.
>
> Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Acked-by: Patrick McHardy <kaber@trash.net>
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH net-2.6.26 10/10][VLAN]: Handle vlan devices net namespace changing.
2008-04-15 12:19 ` [PATCH net-2.6.26 10/10][VLAN]: Handle vlan devices net namespace changing Pavel Emelyanov
@ 2008-04-15 12:30 ` Patrick McHardy
0 siblings, 0 replies; 24+ messages in thread
From: Patrick McHardy @ 2008-04-15 12:30 UTC (permalink / raw)
To: Pavel Emelyanov; +Cc: David Miller, Linux Netdev List
Pavel Emelyanov wrote:
> When van device is moved to another namespace proc files,
> related to this device, should also change one.
>
> Use the netdev REGISTER and UNREGISTER event handlers for this.
>
> Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
For patches 8-10 also:
Acked-by: Patrick McHardy <kaber@trash.net>
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH net-2.6.26 5/10][VLAN]: Add a net argument to proc init and cleanup calls.
2008-04-15 13:05 ` Pavel Emelyanov
@ 2008-04-15 12:31 ` Patrick McHardy
0 siblings, 0 replies; 24+ messages in thread
From: Patrick McHardy @ 2008-04-15 12:31 UTC (permalink / raw)
To: Pavel Emelyanov; +Cc: David Miller, Linux Netdev List
Pavel Emelyanov wrote:
>>> +++ b/net/8021q/vlan.c
>>> @@ -642,8 +642,14 @@ static int vlan_init_net(struct net *net)
>>> if (err < 0)
>>> goto err_assign;
>>>
>>> + err = vlan_proc_init(net);
>>> + if (err < 0)
>>> + goto err_proc;
>>> +
>>> return 0;
>>>
>>> +err_proc:
>>> + /* nothing */
>> What is going to clean up net_generic_assign above?
>
> This is not required. Net will be just destroyed after this
> function returns.
Thanks for the explanation, I wasn't sure about that.
>
>>> @@ -693,8 +696,6 @@ static int __init vlan_proto_init(void)
>>> err3:
>>> unregister_netdevice_notifier(&vlan_notifier_block);
>>> err2:
>>> - vlan_proc_cleanup();
>>> -err1:
>>> unregister_pernet_gen_device(vlan_net_id, &vlan_net_ops);
>>> err0:
>>> return err;
>> This could be done nicer, not leaving holes in the numbering.
>
> Well, yes. Bu this patch is large enough without it. Can I make
> this in a separate patch?
Of course, thanks.
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH net-2.6.26 4/10][VLAN]: Introduce the vlan_net structure and init/exit net ops.
2008-04-15 12:09 ` Patrick McHardy
@ 2008-04-15 12:50 ` Pavel Emelyanov
0 siblings, 0 replies; 24+ messages in thread
From: Pavel Emelyanov @ 2008-04-15 12:50 UTC (permalink / raw)
To: Patrick McHardy; +Cc: David Miller, Linux Netdev List
Patrick McHardy wrote:
> Pavel Emelyanov wrote:
>> @@ -632,6 +670,10 @@ static int __init vlan_proto_init(void)
>> pr_info("%s v%s %s\n", vlan_fullname, vlan_version, vlan_copyright);
>> pr_info("All bugs added by %s\n", vlan_buggyright);
>>
>> + err = register_pernet_gen_device(&vlan_net_id, &vlan_net_ops);
>> + if (err < 0)
>> + goto err0;
>
> I'm wondering what vlan_net_id is used for, but I can't find that
> function in the current net-2.6.26.git tree. What tree are these
> patches based on?
>
They are for net-2.6.26 with this
http://marc.info/?l=linux-netdev&m=120799367318572&w=2
and this
http://marc.info/?l=linux-netdev&m=120799357618440&w=2
patches.
David said the he accepted them both and agreed that I send
other work based on them.
Thanks,
Pavel
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH net-2.6.26 5/10][VLAN]: Add a net argument to proc init and cleanup calls.
2008-04-15 12:26 ` Patrick McHardy
@ 2008-04-15 13:05 ` Pavel Emelyanov
2008-04-15 12:31 ` Patrick McHardy
0 siblings, 1 reply; 24+ messages in thread
From: Pavel Emelyanov @ 2008-04-15 13:05 UTC (permalink / raw)
To: Patrick McHardy; +Cc: David Miller, Linux Netdev List
>> +++ b/net/8021q/vlan.c
>> @@ -642,8 +642,14 @@ static int vlan_init_net(struct net *net)
>> if (err < 0)
>> goto err_assign;
>>
>> + err = vlan_proc_init(net);
>> + if (err < 0)
>> + goto err_proc;
>> +
>> return 0;
>>
>> +err_proc:
>> + /* nothing */
>
> What is going to clean up net_generic_assign above?
This is not required. Net will be just destroyed after this
function returns.
>> @@ -693,8 +696,6 @@ static int __init vlan_proto_init(void)
>> err3:
>> unregister_netdevice_notifier(&vlan_notifier_block);
>> err2:
>> - vlan_proc_cleanup();
>> -err1:
>> unregister_pernet_gen_device(vlan_net_id, &vlan_net_ops);
>> err0:
>> return err;
>
> This could be done nicer, not leaving holes in the numbering.
Well, yes. Bu this patch is large enough without it. Can I make
this in a separate patch?
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH net-2.6.26 0/10][VLAN]: Make VLAN devices work in net namespaces.
2008-04-15 11:59 [PATCH net-2.6.26 0/10][VLAN]: Make VLAN devices work in net namespaces Pavel Emelyanov
` (9 preceding siblings ...)
2008-04-15 12:19 ` [PATCH net-2.6.26 10/10][VLAN]: Handle vlan devices net namespace changing Pavel Emelyanov
@ 2008-04-16 8:02 ` David Miller
10 siblings, 0 replies; 24+ messages in thread
From: David Miller @ 2008-04-16 8:02 UTC (permalink / raw)
To: xemul; +Cc: kaber, netdev
From: Pavel Emelyanov <xemul@openvz.org>
Date: Tue, 15 Apr 2008 15:59:27 +0400
> This set does not intersect with the TUN one at all, since
> they both use generic net pointers.
>
> It also includes some changes in RTNL code to facilitate
> VLAN netnsization and a bit more VLAN cleanups.
>
> Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
All applied and pushed out to net-2.6.26, thanks Pavel.
^ permalink raw reply [flat|nested] 24+ messages in thread
end of thread, other threads:[~2008-04-16 8:02 UTC | newest]
Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-15 11:59 [PATCH net-2.6.26 0/10][VLAN]: Make VLAN devices work in net namespaces Pavel Emelyanov
2008-04-15 12:01 ` [PATCH net-2.6.26 1/10][RTNL]: Relax for_each_netdev_safe in __rtnl_link_unregister Pavel Emelyanov
2008-04-15 12:00 ` Patrick McHardy
2008-04-15 12:03 ` [PATCH net-2.6.26 2/10][RTNL]: Introduce the rtnl_kill_links helper Pavel Emelyanov
2008-04-15 12:01 ` Patrick McHardy
2008-04-15 12:05 ` [PATCH net-2.6.26 3/10][VLAN]: Tag vlan_group_device with net device, not ifindex Pavel Emelyanov
2008-04-15 12:03 ` Patrick McHardy
2008-04-15 12:07 ` [PATCH net-2.6.26 4/10][VLAN]: Introduce the vlan_net structure and init/exit net ops Pavel Emelyanov
2008-04-15 12:09 ` Patrick McHardy
2008-04-15 12:50 ` Pavel Emelyanov
2008-04-15 12:24 ` Patrick McHardy
2008-04-15 12:09 ` [PATCH net-2.6.26 5/10][VLAN]: Add a net argument to proc init and cleanup calls Pavel Emelyanov
2008-04-15 12:26 ` Patrick McHardy
2008-04-15 13:05 ` Pavel Emelyanov
2008-04-15 12:31 ` Patrick McHardy
2008-04-15 12:12 ` [PATCH net-2.6.26 6/10][VLAN]: Create proc entries in the proper net Pavel Emelyanov
2008-04-15 12:28 ` Patrick McHardy
2008-04-15 12:13 ` [PATCH net-2.6.26 7/10][VLAN]: Make the /proc/net/vlan/conf file show per-net info Pavel Emelyanov
2008-04-15 12:28 ` Patrick McHardy
2008-04-15 12:15 ` [PATCH net-2.6.26 8/10][VLAN]: Make the vlan_name_type per-net Pavel Emelyanov
2008-04-15 12:17 ` [PATCH net-2.6.26 9/10][VLAN]: Allow vlan devices registration in net namespaces Pavel Emelyanov
2008-04-15 12:19 ` [PATCH net-2.6.26 10/10][VLAN]: Handle vlan devices net namespace changing Pavel Emelyanov
2008-04-15 12:30 ` Patrick McHardy
2008-04-16 8:02 ` [PATCH net-2.6.26 0/10][VLAN]: Make VLAN devices work in net namespaces David Miller
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).